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

Function mulMod2

factory/facMul.cc:2991–3071  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2989}
2990
2991CanonicalForm mulMod2 (const CanonicalForm& A, const CanonicalForm& B,
2992 const CanonicalForm& M)
2993{
2994 if (A.isZero() || B.isZero())
2995 return 0;
2996
2997 ASSERT (M.isUnivariate(), "M must be univariate");
2998
2999 CanonicalForm F= mod (A, M);
3000 CanonicalForm G= mod (B, M);
3001 if (F.inCoeffDomain())
3002 return G*F;
3003 if (G.inCoeffDomain())
3004 return F*G;
3005
3006 Variable y= M.mvar();
3007 int degF= degree (F, y);
3008 int degG= degree (G, y);
3009
3010 if ((degF < 1 && degG < 1) && (F.isUnivariate() && G.isUnivariate()) &&
3011 (F.level() == G.level()))
3012 {
3013 CanonicalForm result= mulNTL (F, G);
3014 return mod (result, M);
3015 }
3016 else if (degF <= 1 && degG <= 1)
3017 {
3018 CanonicalForm result= F*G;
3019 return mod (result, M);
3020 }
3021
3022 int sizeF= size (F);
3023 int sizeG= size (G);
3024
3025 int fallBackToNaive= 50;
3026 if (sizeF < fallBackToNaive || sizeG < fallBackToNaive)
3027 {
3028 if (sizeF < sizeG)
3029 return mod (G*F, M);
3030 else
3031 return mod (F*G, M);
3032 }
3033
3034#ifdef HAVE_FLINT
3035 if (getCharacteristic() == 0)
3036 return mulMod2FLINTQa (F, G, M);
3037#endif
3038
3039 if (getCharacteristic() > 0 && CFFactory::gettype() != GaloisFieldDomain &&
3040 (((degF-degG) < 50 && degF > degG) || ((degG-degF) < 50 && degF <= degG)))
3041 return mulMod2NTLFq (F, G, M);
3042
3043 int m= (int) ceil (degree (M)/2.0);
3044 if (degF >= m || degG >= m)
3045 {
3046 CanonicalForm MLo= power (y, m);
3047 CanonicalForm MHi= power (y, degree (M) - m);
3048 CanonicalForm F0= mod (F, MLo);

Callers 15

mulModFunction · 0.85
prodModFunction · 0.85
newtonInverseFunction · 0.85
newtonDivFunction · 0.85
newtonDivremFunction · 0.85
logarithmicDerivativeFunction · 0.85
biDiophantineFunction · 0.85
nonMonicHenselLift23Function · 0.85
earlyFactorDetectionFunction · 0.85
extEarlyFactorDetectionFunction · 0.85
reconstructionTryFunction · 0.85
reconstructionFunction · 0.85

Calls 15

degreeFunction · 0.85
mulNTLFunction · 0.85
sizeFunction · 0.85
getCharacteristicFunction · 0.85
mulMod2FLINTQaFunction · 0.85
mulMod2NTLFqFunction · 0.85
powerFunction · 0.85
tmaxFunction · 0.85
mvarMethod · 0.80
modFunction · 0.70
ceilFunction · 0.50
isZeroMethod · 0.45

Tested by

no test coverage detected