Changeset fbea8d in git
- Timestamp:
- Oct 23, 2020, 2:44:10 PM (4 years ago)
- Branches:
- (u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'c5facdfddea2addfd91babd8b9019161dea4b695')
- Children:
- 882ae62b212bc502c8321c242be959710e5781a6
- Parents:
- 9ade119ff312b238c0c9914260660919505e0254
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
factory/cf_factor.cc
r9ade11 rfbea8d 44 44 #ifdef HAVE_FLINT 45 45 #include "FLINTconvert.h" 46 #if (__FLINT_RELEASE >= 20700) 47 #include <flint/nmod_mpoly_factor.h> 48 #include <flint/fmpq_mpoly_factor.h> 49 #endif 46 50 #endif 47 51 … … 144 148 } 145 149 else 146 printf("+%ld",f.intval()); 150 { 151 long l=f.intval(); 152 if (l<0) printf("%ld",l); 153 else printf("+%ld",l); 154 } 147 155 } 148 156 else … … 508 516 #endif 509 517 #if !defined(HAVE_NTL) && !defined(HAVE_FLINT) 510 // Use Factory without NTL : char p, univariate518 // Use Factory without NTL and without FLINT: char p, univariate 511 519 { 512 520 if ( isOn( SW_BERLEKAMP ) ) … … 520 528 else // char p, multivariate 521 529 { 530 On (SW_RATIONAL); 522 531 #if defined(HAVE_NTL) 523 532 if (issqrfree) 524 533 { 525 534 CFList factors; 526 Variable alpha;527 535 if (CFFactory::gettype() == GaloisFieldDomain) 528 536 factors= GFSqrfFactorize (f); … … 534 542 else 535 543 { 536 Variable alpha;537 544 if (CFFactory::gettype() == GaloisFieldDomain) 538 545 F= GFFactorize (f); … … 540 547 F= FpFactorize (f); 541 548 } 549 #elif defined(HAVE_FLINT) && (__FLINT_RELEASE >= 20700) 550 nmod_mpoly_ctx_t ctx; 551 nmod_mpoly_ctx_init(ctx,f.level(),ORD_LEX,getCharacteristic()); 552 nmod_mpoly_t Flint_f; 553 nmod_mpoly_init(Flint_f,ctx); 554 convFactoryPFlintMP(f,Flint_f,ctx,f.level()); 555 nmod_mpoly_factor_t factors; 556 nmod_mpoly_factor_init(factors,ctx); 557 if (issqrfree) nmod_mpoly_factor_squarefree(factors,Flint_f,ctx); 558 else nmod_mpoly_factor(factors,Flint_f,ctx); 559 nmod_mpoly_t fac; 560 nmod_mpoly_init(fac,ctx); 561 CanonicalForm cf_fac; 562 int cf_exp; 563 cf_fac=nmod_mpoly_factor_get_constant_ui(factors,ctx); 564 F.append(CFFactor(cf_fac,1)); 565 for(int i=nmod_mpoly_factor_length(factors,ctx)-1; i>=0; i--) 566 { 567 nmod_mpoly_factor_get_base(fac,factors,i,ctx); 568 cf_fac=convFlintMPFactoryP(fac,ctx,f.level()); 569 cf_exp=nmod_mpoly_factor_get_exp_si(factors,i,ctx); 570 F.append(CFFactor(cf_fac,cf_exp)); 571 } 572 nmod_mpoly_factor_clear(factors,ctx); 573 nmod_mpoly_clear(Flint_f,ctx); 574 nmod_mpoly_ctx_clear(ctx); 542 575 #else 543 factoryError ("multivariate factorization depends on NTL (missing)");576 factoryError ("multivariate factorization depends on NTL/FLINT(missing)"); 544 577 return CFFList (CFFactor (f, 1)); 545 578 #endif … … 616 649 else // multivariate, char 0 617 650 { 618 #if def HAVE_NTL651 #if 0 //defined(HAVE_FLINT) && (__FLINT_RELEASE >= 20700) 619 652 On (SW_RATIONAL); 653 fmpq_mpoly_ctx_t ctx; 654 fmpq_mpoly_ctx_init(ctx,f.level(),ORD_LEX); 655 fmpq_mpoly_t Flint_f; 656 fmpq_mpoly_init(Flint_f,ctx); 657 convFactoryPFlintMP(fz,Flint_f,ctx,fz.level()); 658 fmpq_mpoly_factor_t factors; 659 fmpq_mpoly_factor_init(factors,ctx); 660 int rr; 661 if (issqrfree) rr=fmpq_mpoly_factor_squarefree(factors,Flint_f,ctx); 662 else rr=fmpq_mpoly_factor(factors,Flint_f,ctx); 663 if (rr==0) printf("fail\n"); 664 fmpq_mpoly_t fac; 665 fmpq_mpoly_init(fac,ctx); 666 CanonicalForm cf_fac; 667 int cf_exp; 668 fmpq_t c; 669 fmpq_init(c); 670 fmpq_mpoly_factor_get_constant_fmpq(c,factors,ctx); 671 cf_fac=convertFmpq2CF(c); 672 fmpq_clear(c); 673 if (!cf_fac.isOne()) F.append(CFFactor(cf_fac,1)); 674 for(int i=fmpq_mpoly_factor_length(factors,ctx)-1; i>=0; i--) 675 { 676 fmpq_mpoly_factor_get_base(fac,factors,i,ctx); 677 cf_fac=convFlintMPFactoryP(fac,ctx,f.level()); 678 cf_exp=fmpq_mpoly_factor_get_exp_si(factors,i,ctx); 679 F.append(CFFactor(cf_fac,cf_exp)); 680 } 681 fmpq_mpoly_factor_clear(factors,ctx); 682 fmpq_mpoly_clear(Flint_f,ctx); 683 fmpq_mpoly_ctx_clear(ctx); 684 #elif defined(HAVE_NTL) 620 685 if (issqrfree) 621 686 { 687 On (SW_RATIONAL); 622 688 CFList factors= ratSqrfFactorize (fz); 623 689 for (CFListIterator i= factors; i.hasItem(); i++)
Note: See TracChangeset
for help on using the changeset viewer.