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

Function fdivides

factory/cf_algorithm.cc:339–386  ·  view source on GitHub ↗

bool fdivides ( const CanonicalForm & f, const CanonicalForm & g ) * * * fdivides() - check whether `f' divides `g'. * * Returns true iff `f' divides `g'. Uses some extra heuristic * to avoid polynomial division. Without the heuristic, the test * essentialy looks like `divremt(g, f, q, r) && r.isZero()'. * * Type info: * ---------- * f, g: Current * * Elements from prime power domai

Source from the content-addressed store, hash-verified

337 *
338**/
339bool
340fdivides ( const CanonicalForm & f, const CanonicalForm & g )
341{
342 // trivial cases
343 if ( g.isZero() )
344 return true;
345 else if ( f.isZero() )
346 return false;
347
348 if ( (f.inCoeffDomain() || g.inCoeffDomain())
349 && ((getCharacteristic() == 0 && isOn( SW_RATIONAL ))
350 || (getCharacteristic() > 0) ))
351 {
352 // if we are in a field all elements not equal to zero are units
353 if ( f.inCoeffDomain() )
354 return true;
355 else
356 // g.inCoeffDomain()
357 return false;
358 }
359
360 // we may assume now that both levels either equal LEVELBASE
361 // or are greater zero
362 int fLevel = f.level();
363 int gLevel = g.level();
364 if ( (gLevel > 0) && (fLevel == gLevel) )
365 // f and g are polynomials in the same main variable
366 if ( degree( f ) <= degree( g )
367 && fdivides( f.tailcoeff(), g.tailcoeff() )
368 && fdivides( f.LC(), g.LC() ) )
369 {
370 CanonicalForm q, r;
371 return divremt( g, f, q, r ) && r.isZero();
372 }
373 else
374 return false;
375 else if ( gLevel < fLevel )
376 // g is a coefficient w.r.t. f
377 return false;
378 else
379 {
380 // either f is a coefficient w.r.t. polynomial g or both
381 // f and g are from a base domain (should be Z or Z/p^n,
382 // then)
383 CanonicalForm q, r;
384 return divremt( g, f, q, r ) && r.isZero();
385 }
386}
387
388/// same as fdivides if true returns quotient quot of g by f otherwise quot == 0
389bool

Callers 15

recoverFactorsFunction · 0.85
simplifyFunction · 0.85
modGCDFqFunction · 0.85
modGCDGFFunction · 0.85
modGCDFpFunction · 0.85
monicSparseInterpolFunction · 0.85
nonMonicSparseInterpolFunction · 0.85
sparseGCDFqFunction · 0.85
sparseGCDFpFunction · 0.85
modGCDZFunction · 0.85
HenselFunction · 0.85
ezgcdFunction · 0.85

Calls 9

getCharacteristicFunction · 0.85
isOnFunction · 0.85
degreeFunction · 0.85
divremtFunction · 0.85
isZeroMethod · 0.45
inCoeffDomainMethod · 0.45
levelMethod · 0.45
tailcoeffMethod · 0.45
LCMethod · 0.45

Tested by

no test coverage detected