Changeset 48e0bcb in git
- Timestamp:
- Jun 17, 2020, 3:34:43 PM (3 years ago)
- Branches:
- (u'spielwiese', '8d54773d6c9e2f1d2593a28bc68b7eeab54ed529')
- Children:
- e4514d3151a5c53437b9fa2f30bda8febfd87539ed6f2bb0876535189130e32d71be46f776012a36
- Parents:
- 95e373294f19817a4516238a9d8dd18b1a626ab9
- Location:
- factory
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
factory/cf_factor.cc
r95e3732 r48e0bcb 434 434 if (f.isUnivariate()) 435 435 { 436 #ifdef HAVE_FLINT 436 437 #ifdef HAVE_NTL 437 #ifdef HAVE_FLINT438 438 if (degree (f) < 300) 439 { 439 #endif 440 { 441 // use FLINT 440 442 nmod_poly_t f1; 441 443 convertFacCF2nmod_poly_t (f1, f); … … 446 448 nmod_poly_factor_clear (result); 447 449 nmod_poly_clear (f1); 448 } 449 else 450 #endif 451 { 452 // USE NTL 453 if (getCharacteristic()!=2) 454 { 455 if (fac_NTL_char != getCharacteristic()) 456 { 457 fac_NTL_char = getCharacteristic(); 458 zz_p::init(getCharacteristic()); 459 } 460 461 // convert to NTL 462 zz_pX f1=convertFacCF2NTLzzpX(f); 463 zz_p leadcoeff = LeadCoeff(f1); 464 465 //make monic 466 f1=f1 / LeadCoeff(f1); 467 // factorize 468 vec_pair_zz_pX_long factors; 469 CanZass(factors,f1); 470 471 F=convertNTLvec_pair_zzpX_long2FacCFFList(factors,leadcoeff,f.mvar()); 472 //test_cff(F,f); 473 } 474 else /*getCharacteristic()==2*/ 450 if(isOn(SW_USE_NTL_SORT)) F.sort(cmpCF); 451 return F; 452 } 453 #endif 454 #ifdef HAVE_NTL 455 { 456 if (getCharacteristic()==2) 475 457 { 476 458 // Specialcase characteristic==2 … … 489 471 // convert back to factory again using the faster conversion routine for vectors over GF2X 490 472 F=convertNTLvec_pair_GF2X_long2FacCFFList(factors,LeadCoeff(f1),f.mvar()); 473 if(isOn(SW_USE_NTL_SORT)) F.sort(cmpCF); 474 return F; 491 475 } 492 476 } 493 #else 477 #endif 478 #ifdef HAVE_NTL 479 { 480 // USE NTL 481 if (fac_NTL_char != getCharacteristic()) 482 { 483 fac_NTL_char = getCharacteristic(); 484 zz_p::init(getCharacteristic()); 485 } 486 487 // convert to NTL 488 zz_pX f1=convertFacCF2NTLzzpX(f); 489 zz_p leadcoeff = LeadCoeff(f1); 490 491 //make monic 492 f1=f1 / LeadCoeff(f1); 493 // factorize 494 vec_pair_zz_pX_long factors; 495 CanZass(factors,f1); 496 497 F=convertNTLvec_pair_zzpX_long2FacCFFList(factors,leadcoeff,f.mvar()); 498 //test_cff(F,f); 499 if(isOn(SW_USE_NTL_SORT)) F.sort(cmpCF); 500 return F; 501 } 502 #endif 503 #if !defined(HAVE_NTL) && !defined(HAVE_FLINT) 494 504 // Use Factory without NTL 495 factoryError ("univariate factorization depends on NTL(missing)");505 factoryError ("univariate factorization depends on FLINT/NTL(missing)"); 496 506 return CFFList (CFFactor (f, 1)); 497 #endif //HAVE_NTL498 } 499 else 500 { 501 #if def HAVE_NTL507 #endif 508 } 509 else 510 { 511 #if defined(HAVE_NTL) || defined(HAVE_FLINT) 502 512 if (issqrfree) 503 513 { … … 520 530 } 521 531 #else 522 ASSERT( f.isUnivariate(), "multivariate factorization depends on NTL(missing)" );523 factoryError ("multivariate factorization depends on NTL(missing)");532 ASSERT( f.isUnivariate(), "multivariate factorization depends on FLINT/NTL(missing)" ); 533 factoryError ("multivariate factorization depends on FLINT/NTL(missing)"); 524 534 return CFFList (CFFactor (f, 1)); 525 535 #endif … … 572 582 else 573 583 { 574 #ifdef HAVE_NTL575 584 On (SW_RATIONAL); 576 585 if (issqrfree) … … 584 593 F = ratFactorize (fz); 585 594 Off (SW_RATIONAL); 586 #else587 factoryError ("multivariate factorization depends on NTL(missing)");588 return CFFList (CFFactor (f, 1));589 #endif590 595 } 591 596 … … 607 612 } 608 613 609 //out_cff(F);610 614 if(isOn(SW_USE_NTL_SORT)) F.sort(cmpCF); 611 615 return F; … … 633 637 if (ch>0) 634 638 { 635 if (f.isUnivariate() && (ch>0))639 if (f.isUnivariate()) 636 640 { 637 641 #ifdef HAVE_NTL 638 //USE NTL 639 if (ch>2) 640 { 641 #if (HAVE_FLINT && __FLINT_RELEASE >= 20400) 642 nmod_poly_t FLINTmipo, leadingCoeff; 643 fq_nmod_ctx_t fq_con; 644 645 nmod_poly_init (FLINTmipo, getCharacteristic()); 646 nmod_poly_init (leadingCoeff, getCharacteristic()); 647 convertFacCF2nmod_poly_t (FLINTmipo, getMipo (alpha)); 648 649 fq_nmod_ctx_init_modulus (fq_con, FLINTmipo, "Z"); 650 fq_nmod_poly_t FLINTF; 651 convertFacCF2Fq_nmod_poly_t (FLINTF, f, fq_con); 652 fq_nmod_poly_factor_t res; 653 fq_nmod_poly_factor_init (res, fq_con); 654 fq_nmod_poly_factor (res, leadingCoeff, FLINTF, fq_con); 655 F= convertFLINTFq_nmod_poly_factor2FacCFFList (res, f.mvar(), alpha, fq_con); 656 F.insert (CFFactor (Lc (f), 1)); 657 658 fq_nmod_poly_factor_clear (res, fq_con); 659 fq_nmod_poly_clear (FLINTF, fq_con); 660 nmod_poly_clear (FLINTmipo); 661 nmod_poly_clear (leadingCoeff); 662 fq_nmod_ctx_clear (fq_con); 663 #else 664 // First all cases with characteristic !=2 665 // set remainder 666 if (fac_NTL_char != getCharacteristic()) 667 { 668 fac_NTL_char = getCharacteristic(); 669 zz_p::init(getCharacteristic()); 670 } 671 672 // set minimal polynomial in NTL 673 zz_pX minPo=convertFacCF2NTLzzpX(getMipo(alpha)); 674 zz_pE::init (minPo); 675 676 // convert to NTL 677 zz_pEX f1=convertFacCF2NTLzz_pEX(f,minPo); 678 zz_pE leadcoeff= LeadCoeff(f1); 679 680 //make monic 681 f1=f1 / leadcoeff; 682 683 // factorize using NTL 684 vec_pair_zz_pEX_long factors; 685 CanZass(factors,f1); 686 687 // return converted result 688 F=convertNTLvec_pair_zzpEX_long2FacCFFList(factors,leadcoeff,f.mvar(),alpha); 689 #endif 690 } 691 else if (/*getCharacteristic()*/ch==2) 642 if (/*getCharacteristic()*/ch==2) 692 643 { 693 644 // special case : GF2 … … 719 670 // return converted result 720 671 F=convertNTLvec_pair_GF2EX_long2FacCFFList(factors,f1_coef,f.mvar(),alpha); 721 } 722 #else 672 if(isOn(SW_USE_NTL_SORT)) F.sort(cmpCF); 673 return F; 674 } 675 #endif 676 #if (HAVE_FLINT && __FLINT_RELEASE >= 20400) 677 { 678 // use FLINT 679 nmod_poly_t FLINTmipo, leadingCoeff; 680 fq_nmod_ctx_t fq_con; 681 682 nmod_poly_init (FLINTmipo, getCharacteristic()); 683 nmod_poly_init (leadingCoeff, getCharacteristic()); 684 convertFacCF2nmod_poly_t (FLINTmipo, getMipo (alpha)); 685 686 fq_nmod_ctx_init_modulus (fq_con, FLINTmipo, "Z"); 687 fq_nmod_poly_t FLINTF; 688 convertFacCF2Fq_nmod_poly_t (FLINTF, f, fq_con); 689 fq_nmod_poly_factor_t res; 690 fq_nmod_poly_factor_init (res, fq_con); 691 fq_nmod_poly_factor (res, leadingCoeff, FLINTF, fq_con); 692 F= convertFLINTFq_nmod_poly_factor2FacCFFList (res, f.mvar(), alpha, fq_con); 693 F.insert (CFFactor (Lc (f), 1)); 694 695 fq_nmod_poly_factor_clear (res, fq_con); 696 fq_nmod_poly_clear (FLINTF, fq_con); 697 nmod_poly_clear (FLINTmipo); 698 nmod_poly_clear (leadingCoeff); 699 fq_nmod_ctx_clear (fq_con); 700 if(isOn(SW_USE_NTL_SORT)) F.sort(cmpCF); 701 return F; 702 } 703 #endif 704 #ifdef HAVE_NTL 705 { 706 // use NTL 707 if (fac_NTL_char != getCharacteristic()) 708 { 709 fac_NTL_char = getCharacteristic(); 710 zz_p::init(getCharacteristic()); 711 } 712 713 // convert to NTL 714 zz_pX f1=convertFacCF2NTLzzpX(f); 715 zz_p leadcoeff = LeadCoeff(f1); 716 717 //make monic 718 f1=f1 / LeadCoeff(f1); 719 // factorize 720 vec_pair_zz_pX_long factors; 721 CanZass(factors,f1); 722 723 F=convertNTLvec_pair_zzpX_long2FacCFFList(factors,leadcoeff,f.mvar()); 724 //test_cff(F,f); 725 if(isOn(SW_USE_NTL_SORT)) F.sort(cmpCF); 726 return F; 727 } 728 #endif 729 #if !defined(HAVE_NTL) && !defined(HAVEFLINT) 723 730 factoryError ("univariate factorization depends on NTL(missing)"); 724 731 return CFFList (CFFactor (f, 1)); … … 727 734 else 728 735 { 729 #ifdef HAVE_NTL730 736 F= FqFactorize (f, alpha); 731 #else732 ASSERT( f.isUnivariate(), "multivariate factorization depends on NTL(missing)" );733 factoryError ("multivariate factorization depends on NTL(missing)");734 return CFFList (CFFactor (f, 1));735 #endif736 737 } 737 738 } … … 744 745 else //Q(a)[x1,...,xn] 745 746 { 746 #ifdef HAVE_NTL747 747 F= ratFactorize (f, alpha); 748 #else749 ASSERT( f.isUnivariate(), "multivariate factorization depends on NTL(missing)" );750 factoryError ("multivariate factorization depends on NTL(missing)");751 return CFFList (CFFactor (f, 1));752 #endif753 748 } 754 749 } -
factory/facMul.cc
r95e3732 r48e0bcb 32 32 #include <NTL/lzz_pEX.h> 33 33 #include "NTLconvert.h" 34 #endif 34 35 35 36 #ifdef HAVE_FLINT … … 452 453 fq_ctx_clear (fq_con); 453 454 return b (result); 454 #else 455 #endif 456 #ifdef HAVE_NTL 455 457 ZZ_p::init (convertFacCF2NTLZZ (b.getpk())); 456 458 ZZ_pX NTLmipo= to_ZZ_pX (convertFacCF2NTLZZX (mipo)); … … 489 491 } 490 492 return mulFLINTQ (F, G); 491 #else 493 #endif 494 #ifdef HAVE_NTL 492 495 if (b.getp() != 0) 493 496 { … … 569 572 570 573 return b (result); 571 #else 574 #endif 575 #ifdef HAVE_NTL 572 576 ZZ_p::init (convertFacCF2NTLZZ (b.getpk())); 573 577 ZZ_pX NTLmipo= to_ZZ_pX (convertFacCF2NTLZZX (getMipo (alpha))); … … 607 611 ASSERT (F.isUnivariate() && G.isUnivariate(), "expected univariate polys"); 608 612 ASSERT (F.level() == G.level(), "expected polys of same level"); 613 #ifdef HAVE_NTL 609 614 #if (!defined(HAVE_FLINT) || __FLINT_RELEASE < 20400) 610 615 if (fac_NTL_char != getCharacteristic()) … … 613 618 zz_p::init (getCharacteristic()); 614 619 } 620 #endif 615 621 #endif 616 622 Variable alpha; … … 646 652 nmod_poly_clear (FLINTmipo); 647 653 fq_nmod_ctx_clear (fq_con); 648 #else 654 return result; 655 #elif defined(AHVE_NTL) 649 656 zz_pX NTLMipo= convertFacCF2NTLzzpX (getMipo (alpha)); 650 657 zz_pE::init (NTLMipo); … … 653 660 mul (NTLF, NTLF, NTLG); 654 661 result= convertNTLzz_pEX2CF(NTLF, F.mvar(), alpha); 662 return result; 655 663 #endif 656 664 } … … 665 673 nmod_poly_clear (FLINTF); 666 674 nmod_poly_clear (FLINTG); 667 #else 675 return result; 676 #endif 677 #ifdef HAVE_NTL 668 678 zz_pX NTLF= convertFacCF2NTLzzpX (F); 669 679 zz_pX NTLG= convertFacCF2NTLzzpX (G); 670 680 mul (NTLF, NTLF, NTLG); 671 re sult=convertNTLzzpX2CF(NTLF, F.mvar());672 #endif 673 } 674 return result;681 return convertNTLzzpX2CF(NTLF, F.mvar()); 682 #endif 683 } 684 return F*G; 675 685 } 676 686 … … 3735 3745 // end division 3736 3746 3737 #endif
Note: See TracChangeset
for help on using the changeset viewer.