Changeset 806c18 in git for factory/cf_resultant.cc
 Timestamp:
 Nov 15, 2010, 4:34:57 PM (13 years ago)
 Branches:
 (u'spielwiese', '91fdef05f09f54b8d58d92a472e9c4a43aa4656f')
 Children:
 7c3bca08c96331a56864c1d35b8c2e8ff2e0be89
 Parents:
 c840d97af622b4e4da8761738b540e21144f716b
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

factory/cf_resultant.cc
rc840d9 r806c18 48 48 // some checks on triviality 49 49 if ( f.isZero()  g.isZero() ) { 50 51 50 trivialResult[0] = 0; 51 return trivialResult; 52 52 } 53 53 54 54 // make x main variable 55 55 if ( f.mvar() > x  g.mvar() > x ) { 56 57 58 59 60 61 56 if ( f.mvar() > g.mvar() ) 57 X = f.mvar(); 58 else 59 X = g.mvar(); 60 F = swapvar( f, X, x ); 61 G = swapvar( g, X, x ); 62 62 } 63 63 else { 64 65 66 64 X = x; 65 F = f; 66 G = g; 67 67 } 68 68 // at this point, we have to calculate the sequence of F and … … 83 83 // make sure that S[j+1] is regular and j < n 84 84 if ( m == n && j > 0 ) { 85 86 85 S[j1] = LC( S[j], X ) * psr( S[j+1], S[j], X ); 86 j; 87 87 } else if ( m < n ) { 88 89 88 S[j1] = LC( S[j], X ) * LC( S[j], X ) * S[j+1]; 89 j; 90 90 } else if ( m > n && j > 0 ) { 91 92 93 94 95 96 97 98 99 100 101 102 103 91 // calculate first step 92 r = degree( S[j], X ); 93 R = LC( S[j+1], X ); 94 95 // if there was a gap calculate similar polynomial 96 if ( j > r && r >= 0 ) 97 S[r] = power( LC( S[j], X ), j  r ) * S[j] * power( R, j  r ); 98 99 if ( r > 0 ) { 100 // calculate remainder 101 S[r1] = psr( S[j+1], S[j], X ) * power( R, j  r ); 102 j = r1; 103 } 104 104 } 105 105 106 106 while ( j > 0 ) { 107 108 109 110 111 112 113 114 115 116 117 118 119 120 107 // at this point, 0 < j < n and S[j+1] is regular 108 r = degree( S[j], X ); 109 R = LC( S[j+1], X ); 110 111 // if there was a gap calculate similar polynomial 112 if ( j > r && r >= 0 ) 113 S[r] = (power( LC( S[j], X ), j  r ) * S[j]) / power( R, j  r ); 114 115 if ( r <= 0 ) break; 116 // calculate remainder 117 S[r1] = psr( S[j+1], S[j], X ) / power( R, j  r + 2 ); 118 119 j = r1; 120 // again 0 <= j < r <= jOld and S[j+1] is regular 121 121 } 122 122 123 123 for ( j = 0; j <= S.max(); j++ ) { 124 125 126 127 124 // reswap variables if necessary 125 if ( X != x ) { 126 S[j] = swapvar( S[j], X, x ); 127 } 128 128 } 129 129 … … 148 148 // f or g in R 149 149 if ( degree( f, x ) == 0 ) 150 150 return power( f, degree( g, x ) ); 151 151 if ( degree( g, x ) == 0 ) 152 152 return power( g, degree( f, x ) ); 153 153 154 154 // f and g are linear polynomials … … 180 180 // here because this may involve variable swapping. 181 181 if ( f.isZero()  g.isZero() ) 182 182 return 0; 183 183 if ( f.mvar() < x ) 184 184 return power( f, g.degree( x ) ); 185 185 if ( g.mvar() < x ) 186 186 return power( g, f.degree( x ) ); 187 187 188 188 // make x main variale … … 190 190 Variable X; 191 191 if ( f.mvar() > x  g.mvar() > x ) { 192 193 194 195 196 197 192 if ( f.mvar() > g.mvar() ) 193 X = f.mvar(); 194 else 195 X = g.mvar(); 196 F = swapvar( f, X, x ); 197 G = swapvar( g, X, x ); 198 198 } 199 199 else { 200 201 202 200 X = x; 201 F = f; 202 G = g; 203 203 } 204 204 // at this point, we have to calculate resultant( F, G, X ) … … 210 210 // catch trivial cases 211 211 if ( m+n <= 2  m == 0  n == 0 ) 212 212 return swapvar( trivialResultant( F, G, X ), X, x ); 213 213 214 214 // exchange F and G if necessary 215 215 int flipFactor; 216 216 if ( m < n ) { 217 218 219 220 221 222 223 224 217 CanonicalForm swap = F; 218 F = G; G = swap; 219 int degswap = m; 220 m = n; n = degswap; 221 if ( m & 1 && n & 1 ) 222 flipFactor = 1; 223 else 224 flipFactor = 1; 225 225 } else 226 226 flipFactor = 1; 227 227 228 228 // this is not an effective way to calculate the resultant! 229 229 CanonicalForm extFactor; 230 230 if ( m == n ) { 231 232 233 234 231 if ( n & 1 ) 232 extFactor = LC( G, X ); 233 else 234 extFactor = LC( G, X ); 235 235 } else 236 236 extFactor = power( LC( F, X ), mn1 ); 237 237 238 238 CanonicalForm result;
Note: See TracChangeset
for help on using the changeset viewer.