Changeset e4eea0e in git
- Timestamp:
- Jul 19, 1997, 10:09:28 AM (27 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- 66e0d201fa56526ea7c5fe49c469ed956b42d2db
- Parents:
- fb8518fe473cb4484cb222f067d3ccdaf909d892
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
factory/cf_ops.cc
rfb8518f re4eea0e 1 1 /* emacs edit mode for this file is -*- C++ -*- */ 2 /* $Id: cf_ops.cc,v 1. 2 1997-06-19 12:24:13schmidt Exp $ */2 /* $Id: cf_ops.cc,v 1.3 1997-07-19 08:09:28 schmidt Exp $ */ 3 3 4 4 #include <config.h> … … 203 203 } 204 204 205 CanonicalForm 206 resultant( const CanonicalForm & f, const CanonicalForm& g, const Variable & x ) 205 //{{{ CanonicalForm resultant( const CanonicalForm & f, const CanonicalForm & g, const Variable & x ) 206 //{{{ docu 207 // 208 // resultant() - return resultant of f and g with respect to x. 209 // 210 // We calculate the resultant using a subresultant PSR. 211 // 212 // flipFactor: Res(f, g) = flipFactor * Res(g, f) 213 // F, G: f and g with x as main variable 214 // pi, pi1, pi2: used to compute PSR 215 // delta: 216 // bi, Hi: 217 // 218 //}}} 219 CanonicalForm 220 resultant( const CanonicalForm & f, const CanonicalForm & g, const Variable & x ) 207 221 { 208 222 CanonicalForm Hi, bi, pi, pi1, pi2, F, G; 209 int delta; 210 Variable v = f.mvar(); 211 212 if ( f.mvar() < x || g.mvar() < x ) 213 return 1; 214 223 int delta, flipFactor; 224 Variable v; 225 226 ASSERT( x.level() > 0, "cannot calculate resultant in respect to algebraic variables" ); 227 228 // some checks on triviality. We will not use degree( v ) 229 // here because this may involve variable swapping. 230 if ( f.isZero() || g.isZero() ) 231 return 0; 232 if ( f.mvar() < x ) 233 return power( f, g.degree( x ) ); 234 if ( g.mvar() < x ) 235 return power( g, f.degree( x ) ); 236 237 // make x main variale 215 238 if ( f.mvar() > x || g.mvar() > x ) { 216 239 if ( f.mvar() > g.mvar() ) … … 226 249 G = g; 227 250 } 228 if ( F.degree( v ) < 1 || G.degree( v ) < 1 ) 229 return 1; 230 231 if ( f.degree( v ) >= g.degree( v ) ) { 251 // at this point, we have to calculate resultant( F, G, v ) 252 // where v is equal to or greater than the main variables 253 // of F and G 254 255 // trivial case: F or G in R. Swapping will not occur 256 // when calling degree( v ). 257 if ( F.degree( v ) < 1 ) 258 return power( f, G.degree( v ) ); 259 if ( G.degree( v ) < 1 ) 260 return power( g, F.degree( v ) ); 261 262 // start the pseudo remainder sequence 263 if ( F.degree( v ) >= G.degree( v ) ) { 232 264 pi = F; pi1 = G; 233 } 234 else { 265 flipFactor = 1; 266 } 267 else { 268 if ( (F.degree( v ) * G.degree( v )) % 2 ) 269 flipFactor = -1; 270 else 271 flipFactor = 1; 235 272 pi = G; pi1 = F; 236 273 } 274 237 275 delta = degree( pi, v ) - degree( pi1, v ); 238 276 Hi = power( LC( pi1, v ), delta ); 277 278 // Ist hier nicht if und else zweig vertauscht ??? 239 279 if ( (delta+1) % 2 ) 240 280 bi = 1; 241 281 else 242 282 bi = -1; 283 284 // Ist pi1.isZero vielleich schneller ??? 243 285 while ( degree( pi1, v ) >= 0 ) { 244 286 pi2 = psr( pi, pi1, v ); … … 247 289 if ( degree( pi1, v ) >= 0 ) { 248 290 delta = degree( pi, v ) - degree( pi1, v ); 291 292 // Ist hier nicht if und else zweig vertauscht ??? 249 293 if ( (delta+1) % 2 ) 250 294 bi = LC( pi, v ) * power( Hi, delta ); 251 295 else 252 296 bi = -LC( pi, v ) * power( Hi, delta ); 297 298 // Was ist f"ur delta == 0 ??? 253 299 Hi = power( LC( pi1, v ), delta ) / power( Hi, delta-1 ); 254 300 } 255 301 } 302 303 // f and g have non-trivial common divisor 304 // if ( degree( pi, v ) > 0 ) 305 // return 0; 306 307 // undo variable swap 256 308 if ( v == x ) 257 return Hi; 258 else 259 return swapvar( Hi, v, x ); 260 } 261 309 // Gibt man hier nicht den letzten Rest der PSR zur"uck 310 // und nicht den Korrekturterm Hi ??? 311 return Hi * flipFactor; 312 else 313 return swapvar( Hi, v, x ) * flipFactor; 314 } 315 //}}} 262 316 263 317 static CanonicalForm
Note: See TracChangeset
for help on using the changeset viewer.