Changeset a64b0e in git for factory/algext.cc
- Timestamp:
- Nov 15, 2012, 2:17:37 PM (11 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '00e2e9c41af3fde1273eb3633f4c0c7c3db2579d')
- Children:
- e2e4be38ca2210479e037e6d8c68c82be5b92ff1
- Parents:
- 780b5285f9d867d03d9da5298c36e8bedf88eaf4
- git-author:
- Martin Lee <martinlee84@web.de>2012-11-15 14:17:37+01:00
- git-committer:
- Martin Lee <martinlee84@web.de>2012-11-16 13:13:23+01:00
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
factory/algext.cc
r780b52 ra64b0e 365 365 static CanonicalForm tryvcontent ( const CanonicalForm & f, const Variable & x, const CanonicalForm & M, bool & fail ); 366 366 static CanonicalForm trycf_content ( const CanonicalForm & f, const CanonicalForm & g, const CanonicalForm & M, bool & fail ); 367 static void tryDivide( const CanonicalForm & f, const CanonicalForm & g, const CanonicalForm & M, CanonicalForm & result, bool & divides, bool & fail );368 367 369 368 static inline CanonicalForm … … 1019 1018 } 1020 1019 1021 1022 static void tryDivide( const CanonicalForm & f, const CanonicalForm & g, const CanonicalForm & M, CanonicalForm & result, bool & divides, bool & fail )1023 { // M "univariate" monic polynomial1024 // f, g polynomials with coeffs modulo M.1025 // if f is divisible by g, 'divides' is set to 1 and 'result' == f/g mod M coefficientwise.1026 // 'fail' is set to 1, iff a zero divisor is encountered.1027 // divides==1 implies fail==01028 // required: getReduce(M.mvar())==01029 if(g.inBaseDomain())1030 {1031 result = f/g;1032 divides = true;1033 return;1034 }1035 if(g.inCoeffDomain())1036 {1037 tryInvert(g,M,result,fail);1038 if(fail)1039 return;1040 result = reduce(f*result, M);1041 divides = true;1042 return;1043 }1044 // here: g NOT inCoeffDomain1045 Variable x = g.mvar();1046 if(f.degree(x) < g.degree(x))1047 {1048 divides = false;1049 return;1050 }1051 // here: f.degree(x) > 0 and f.degree(x) >= g.degree(x)1052 CanonicalForm F = f;1053 CanonicalForm q, leadG = LC(g);1054 result = 0;1055 while(!F.isZero())1056 {1057 tryDivide(F.LC(x),leadG,M,q,divides,fail);1058 if(fail || !divides)1059 return;1060 if(F.degree(x)<g.degree(x))1061 {1062 divides = false;1063 return;1064 }1065 q *= power(x,F.degree(x)-g.degree(x));1066 result += q;1067 F = reduce(F-q*g, M);1068 }1069 result = reduce(result, M);1070 divides = true;1071 }1072 1073 1020 void tryExtgcd( const CanonicalForm & F, const CanonicalForm & G, CanonicalForm & result, CanonicalForm & s, CanonicalForm & t, bool & fail ) 1074 1021 {
Note: See TracChangeset
for help on using the changeset viewer.