Changeset 686ce3 in git
- Timestamp:
- Jan 17, 2011, 4:35:50 PM (13 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- da2bd09796fb2e16163e9e0cdb0c34e541a200de
- Parents:
- 54667770cf90dd8ee3b56fbe6b4116e50118c921
- Location:
- factory
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
factory/facFqBivar.cc
r546677 r686ce3 1007 1007 } 1008 1008 1009 if (i == 0) 1010 { 1011 int subCheck= substituteCheck (bufUniFactors); 1012 1013 if (subCheck > 1) 1014 { 1015 CanonicalForm bufA= A; 1016 subst (bufA, bufA, subCheck, x); 1017 factors= biFactorize (bufA, info); 1018 reverseSubst (factors, subCheck, x); 1019 appendSwapDecompress (factors, contentAxFactors, contentAyFactors, 1020 swap, swap2, N); 1021 normalize (factors); 1022 return factors; 1023 } 1024 1025 if (!derivXZero && !fail2) 1026 { 1027 subCheck= substituteCheck (bufUniFactors2); 1028 if (subCheck > 1) 1029 { 1030 CanonicalForm bufA= A; 1031 subst (bufA, bufA, subCheck, y); 1032 factors= biFactorize (bufA, info); 1033 reverseSubst (factors, subCheck, x); 1034 appendSwapDecompress (factors, contentAxFactors, contentAyFactors, 1035 swap, swap2, N); 1036 normalize (factors); 1037 return factors; 1038 } 1039 } 1040 } 1041 1009 1042 // degree analysis 1010 1043 bufDegs = DegreePattern (bufUniFactors); -
factory/facFqBivarUtil.cc
r546677 r686ce3 389 389 } 390 390 391 static int 392 substituteCheck (const CanonicalForm& F, const CanonicalForm& G) 393 { 394 if (F.inCoeffDomain() || G.inCoeffDomain()) 395 return 0; 396 Variable x= Variable (1); 397 if (degree (F, x) <= 1 || degree (G, x) <= 1) 398 return 0; 399 CanonicalForm f= swapvar (F, F.mvar(), x); 400 CanonicalForm g= swapvar (G, G.mvar(), x); 401 int sizef= 0; 402 int sizeg= 0; 403 for (CFIterator i= f; i.hasTerms(); i++, sizef++) 404 { 405 if (i.exp() == 1) 406 return 0; 407 } 408 for (CFIterator i= g; i.hasTerms(); i++, sizeg++) 409 { 410 if (i.exp() == 1) 411 return 0; 412 } 413 int * expf= new int [sizef]; 414 int * expg= new int [sizeg]; 415 int j= 0; 416 for (CFIterator i= f; i.hasTerms(); i++, j++) 417 { 418 expf [j]= i.exp(); 419 } 420 j= 0; 421 for (CFIterator i= g; i.hasTerms(); i++, j++) 422 { 423 expg [j]= i.exp(); 424 } 425 426 int indf= sizef - 1; 427 int indg= sizeg - 1; 428 if (expf[indf] == 0) 429 indf--; 430 if (expg[indg] == 0) 431 indg--; 432 433 if ((expg[indg]%expf [indf] != 0 && expf[indf]%expg[indg] != 0) || 434 (expg[indg] == 1 && expf[indf] == 1)) 435 { 436 delete [] expg; 437 delete [] expf; 438 return 0; 439 } 440 441 int result; 442 if (expg [indg]%expf [indf] == 0) 443 result= expf[indf]; 444 else 445 result= expg[indg]; 446 for (int i= indf - 1; i >= 0; i--) 447 { 448 if (expf [i]%result != 0) 449 { 450 delete [] expf; 451 delete [] expg; 452 return 0; 453 } 454 } 455 456 for (int i= indg - 1; i >= 0; i--) 457 { 458 if (expg [i]%result != 0) 459 { 460 delete [] expf; 461 delete [] expg; 462 return 0; 463 } 464 } 465 466 delete [] expg; 467 delete [] expf; 468 return result; 469 } 470 471 int recSubstituteCheck (const CanonicalForm& F, const int d) 472 { 473 if (F.inCoeffDomain()) 474 return 0; 475 Variable x= Variable (1); 476 if (degree (F, x) <= 1) 477 return 0; 478 CanonicalForm f= swapvar (F, F.mvar(), x); 479 int sizef= 0; 480 for (CFIterator i= f; i.hasTerms(); i++, sizef++) 481 { 482 if (i.exp() == 1) 483 return 0; 484 } 485 int * expf= new int [sizef]; 486 int j= 0; 487 for (CFIterator i= f; i.hasTerms(); i++, j++) 488 { 489 expf [j]= i.exp(); 490 } 491 492 int indf= sizef - 1; 493 if (expf[indf] == 0) 494 indf--; 495 496 if ((d%expf [indf] != 0 && expf[indf]%d != 0) || (expf[indf] == 1)) 497 { 498 delete [] expf; 499 return 0; 500 } 501 502 int result; 503 if (d%expf [indf] == 0) 504 result= expf[indf]; 505 else 506 result= d; 507 for (int i= indf - 1; i >= 0; i--) 508 { 509 if (expf [i]%result != 0) 510 { 511 delete [] expf; 512 return 0; 513 } 514 } 515 516 delete [] expf; 517 return result; 518 } 519 520 int substituteCheck (const CFList& L) 521 { 522 ASSERT (L.length() > 1, "expected a list of at least two elements"); 523 if (L.length() < 2) 524 return 0; 525 CFListIterator i= L; 526 i++; 527 int result= substituteCheck (L.getFirst(), i.getItem()); 528 if (result <= 1) 529 return result; 530 i++; 531 for (;i.hasItem(); i++) 532 { 533 result= recSubstituteCheck (i.getItem(), result); 534 if (result <= 1) 535 return result; 536 } 537 return result; 538 } 539 540 void 541 subst (const CanonicalForm& F, CanonicalForm& A, const int d, const Variable& x) 542 { 543 if (d <= 1) 544 { 545 A= F; 546 return; 547 } 548 if (degree (F, x) <= 0) 549 { 550 A= F; 551 return; 552 } 553 CanonicalForm C= 0; 554 CanonicalForm f= swapvar (F, x, F.mvar()); 555 for (CFIterator i= f; i.hasTerms(); i++) 556 C += i.coeff()*power (f.mvar(), i.exp()/ d); 557 A= swapvar (C, x, F.mvar()); 558 } 559 560 CanonicalForm 561 reverseSubst (const CanonicalForm& F, const int d, const Variable& x) 562 { 563 if (d <= 1) 564 return F; 565 if (degree (F, x) <= 0) 566 return F; 567 CanonicalForm f= swapvar (F, x, F.mvar()); 568 CanonicalForm result= 0; 569 for (CFIterator i= f; i.hasTerms(); i++) 570 result += i.coeff()*power (f.mvar(), d*i.exp()); 571 return swapvar (result, x, F.mvar()); 572 } 573 574 void 575 reverseSubst (CFList& L, const int d, const Variable& x) 576 { 577 for (CFListIterator i= L; i.hasItem(); i++) 578 i.getItem()= reverseSubst (i.getItem(), d, x); 579 } 580 -
factory/facFqBivarUtil.h
r546677 r686ce3 158 158 ); 159 159 160 /// checks if a substitution x^n->x is possible 161 /// 162 /// @return an integer n > 1, if a substitution described as above is possible 163 /// else n <= 1 164 int substituteCheck (const CFList& L ///< [in] a list of univariate polys 165 ); 166 167 /// substitute x^d by x in F 168 void 169 subst (const CanonicalForm& F, ///< [in] a polynomial 170 CanonicalForm& A, ///< [in,out] returns F with x^d replaced by x 171 const int d, ///< d > 1 such that a substitution x^d -> x 172 ///< [in] is possible 173 const Variable& x ///< [in] a Variable 174 ); 175 176 /// reverse a substitution x^d->x 177 /// 178 /// @return a poly with x replaced by x^d 179 CanonicalForm 180 reverseSubst (const CanonicalForm& F, ///< [in] a poly 181 const int d, ///< [in] an integer > 0 182 const Variable& x ///< [in] a Variable 183 ); 184 185 /// reverse a substitution x^d->x 186 void 187 reverseSubst (CFList& L, ///< [in,out] a list of polys, returns the 188 ///< given list with x replaced by x^d 189 const int d, ///< [in] an integer > 0 190 const Variable& x ///< [in] a Variable 191 ); 192 160 193 #endif 161 194 /* FAC_FQ_BIVAR_UTIL_H */
Note: See TracChangeset
for help on using the changeset viewer.