MCPcopy Create free account
hub / github.com/Singular/Singular / tryDivrem

Function tryDivrem

factory/cfGcdAlgExt.cc:244–287  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

242
243#ifndef HAVE_NTL
244void tryDivrem (const CanonicalForm& F, const CanonicalForm& G, CanonicalForm& Q,
245 CanonicalForm& R, CanonicalForm& inv, const CanonicalForm& mipo,
246 bool& fail)
247{
248 if (F.inCoeffDomain())
249 {
250 Q= 0;
251 R= F;
252 return;
253 }
254
255 CanonicalForm A, B;
256 Variable x= F.mvar();
257 A= F;
258 B= G;
259 int degA= degree (A, x);
260 int degB= degree (B, x);
261
262 if (degA < degB)
263 {
264 R= A;
265 Q= 0;
266 return;
267 }
268
269 tryInvert (Lc (B), mipo, inv, fail);
270 if (fail)
271 return;
272
273 R= A;
274 Q= 0;
275 CanonicalForm Qi;
276 for (int i= degA -degB; i >= 0; i--)
277 {
278 if (degree (R, x) == i + degB)
279 {
280 Qi= Lc (R)*inv*power (x, i);
281 Qi= reduce (Qi, mipo);
282 R -= Qi*B;
283 R= reduce (R, mipo);
284 Q += Qi;
285 }
286 }
287}
288
289void tryEuclid( const CanonicalForm & A, const CanonicalForm & B, const CanonicalForm & M, CanonicalForm & result, bool & fail )
290{

Callers 2

tryEuclidFunction · 0.85
tryExtgcdFunction · 0.85

Calls 7

degreeFunction · 0.85
tryInvertFunction · 0.85
LcFunction · 0.85
powerFunction · 0.85
reduceFunction · 0.85
mvarMethod · 0.80
inCoeffDomainMethod · 0.45

Tested by

no test coverage detected