Changeset 186df6 in git
- Timestamp:
- Oct 26, 2012, 11:30:17 AM (11 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '0604212ebb110535022efecad887940825b97c3f')
- Children:
- 18ccf2907a4a103e379cecf364131e83e3aebab55c890683760ed725b5c0bb38871a3459d5f5ff2b
- Parents:
- 1130ffcea9f0651b2cb15d5f7ea1758fc8cf75aa7061c1e376e43786ea799c82620a0bbed1dc5dd3
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
Tst/Manual/extgcd.res.gz.uu
r1130ffc r186df6 1 begin 64 0extgcd.res.gz2 M'XL(" &4I<DX``V5X=&=C9"YR97,`34\]"\(P%-SS*Q[%H;%I:=+$P6`&<2F(1 begin 644 extgcd.res.gz 2 M'XL(")Y5BE```V5X=&=C9"YR97,`34\]"\(P%-SS*Q[%H;%I:=+$P6`&<2F( 3 3 M2]V*B!^E!$J1-F+\]R:MA"[O#N[N'5>=#^4)`*B"8[F'R(PFZ_0]DN#85??: 4 4 MQ%@BCZ`4--:TCV?6-Y]L-#>#JG^:*7=F,6:<T-QE:GK9(J^AFLTL=;28J0C1 -
Tst/Manual/extgcd.stat
r1130ffc r186df6 1 1 >> tst_memory_0 :: 13 16104113:3132- exportiert :3-1-3:ix86-Linux:mamawutz:1734602 1 >> tst_memory_1 :: 13 16104113:3132- exportiert :3-1-3:ix86-Linux:mamawutz:6673603 1 >> tst_memory_2 :: 13 16104113:3132- exportiert :3-1-3:ix86-Linux:mamawutz:7001444 1 >> tst_timer_1 :: 13 16104113:3132- exportiert :3-1-3:ix86-Linux:mamawutz:121 1 >> tst_memory_0 :: 1351243166:3150:3-1-5:ix86-Linux:mamawutz:172148 2 1 >> tst_memory_1 :: 1351243166:3150:3-1-5:ix86-Linux:mamawutz:2239256 3 1 >> tst_memory_2 :: 1351243166:3150:3-1-5:ix86-Linux:mamawutz:2272040 4 1 >> tst_timer_1 :: 1351243166:3150:3-1-5:ix86-Linux:mamawutz:3 -
Tst/Old/m61si.res.gz.uu
r1130ffc r186df6 1 begin 64 0m61si.res.gz2 M'XL(" (T/CDP``VTV,7-I+G)E<P`+#G'Q]%-04#"T`Q*I%27IR2D:1CK&FM9<1 begin 644 m61si.res.gz 2 M'XL("!026U```VTV,7-I+G)E<P`+#G'Q]%-04#"T`Q*I%27IR2D:1CK&FM9< 3 3 MT8:Q5EP@&:YH(PA+%\@TA@D&0S4:@3069>:E*Q39&NAH5.A4:NKD%%C#Y8V1 4 M#-:H,-*N,-;4`M*Z0%H'S#<%\T'B2) 8:59AJ&U68P*T&*=#&9KV)G8*/IY."5 B4DEQB5Y.9I*2-9`17UR26%):K&&H::W"!0`(VD/WX0``````4 M#-:H,-*N,-;4`M*Z0%H'S#<%\T'B2)96F&I7F,`M-M0W`JH`D2`"X0@@&V:- 5 IB9V"CZ>3@E))<8E>3F:2DC60$5]<DEA26JQAJ&FMP@4`.W-4^>D````` 6 6 ` 7 7 end -
Tst/Old/m61si.stat
r1130ffc r186df6 1 1 >> tst_memory_0 :: 1 284378480:3115- 13145 :3-1-1:ix86-Linux:mamawutz:170784 1292524760:3120- 13145 :3-1-2:ix86-Linux:mamawutz:1710482 1 >> tst_memory_1 :: 1 284378480:3115- 13145 :3-1-1:ix86-Linux:mamawutz:667288 1292524760:3120- 13145 :3-1-2:ix86-Linux:mamawutz:6673363 1 >> tst_memory_2 :: 1 284378480:3115- 13145 :3-1-1:ix86-Linux:mamawutz:700072 1292524760:3120- 13145 :3-1-2:ix86-Linux:mamawutz:7001204 1 >> tst_timer_1 :: 1 284378480:3115- 13145 :3-1-1:ix86-Linux:mamawutz:3 1292524760:3120- 13145 :3-1-2:ix86-Linux:mamawutz:41 1 >> tst_memory_0 :: 1348145684:3150:3-1-5:ix86-Linux:mamawutz:171000 2 1 >> tst_memory_1 :: 1348145684:3150:3-1-5:ix86-Linux:mamawutz:2239256 3 1 >> tst_memory_2 :: 1348145684:3150:3-1-5:ix86-Linux:mamawutz:2272040 4 1 >> tst_timer_1 :: 1348145684:3150:3-1-5:ix86-Linux:mamawutz:2 -
factory/FLINTconvert.cc
r1130ffc r186df6 36 36 #define __GMP_BITS_PER_MP_LIMB GMP_LIMB_BITS 37 37 #endif 38 #include <fmpz.h> 39 #include <fmpq.h> 40 #include <fmpz_poly.h> 41 #include <fmpz_mod_poly.h> 42 #include <nmod_poly.h> 43 #include <fmpq_poly.h> 38 #include <flint/fmpz.h> 39 #include <flint/fmpq.h> 40 #include <flint/fmpz_poly.h> 41 #include <flint/fmpz_mod_poly.h> 42 #include <flint/nmod_poly.h> 43 #include <flint/fmpq_poly.h> 44 #include <flint/nmod_mat.h> 45 #include <flint/fmpz_mat.h> 44 46 #ifdef __cplusplus 45 47 } … … 270 272 long i; 271 273 272 for (i = 0; i < fac->num _factors; i++)273 result.append (CFFactor (convertnmod_poly_t2FacCF ((nmod_poly_t &)fac-> factors[i],x),274 fac->exp onents[i]));274 for (i = 0; i < fac->num; i++) 275 result.append (CFFactor (convertnmod_poly_t2FacCF ((nmod_poly_t &)fac->p[i],x), 276 fac->exp[i])); 275 277 return result; 276 278 } … … 299 301 } 300 302 301 #endif 302 303 303 void convertFacCFMatrix2Fmpz_mat_t (fmpz_mat_t M, CFMatrix &m) 304 { 305 fmpz_mat_init (M, (long) m.rows(), (long) m.columns()); 306 307 int i,j; 308 for(i=m.rows();i>0;i--) 309 { 310 for(j=m.columns();j>0;j--) 311 { 312 convertCF2Fmpz (fmpz_mat_entry (M,i-1,j-1), m(i,j)); 313 } 314 } 315 } 316 CFMatrix* convertFmpz_mat_t2FacCFMatrix(fmpz_mat_t m) 317 { 318 CFMatrix *res=new CFMatrix(fmpz_mat_nrows (m),fmpz_mat_ncols (m)); 319 int i,j; 320 for(i=res->rows();i>0;i--) 321 { 322 for(j=res->columns();j>0;j--) 323 { 324 (*res)(i,j)=convertFmpz2CF(fmpz_mat_entry (m,i-1,j-1)); 325 } 326 } 327 return res; 328 } 329 330 void convertFacCFMatrix2nmod_mat_t (nmod_mat_t M, CFMatrix &m) 331 { 332 nmod_mat_init (M, (long) m.rows(), (long) m.columns(), getCharacteristic()); 333 334 bool save_sym_ff= isOn (SW_SYMMETRIC_FF); 335 if (save_sym_ff) Off (SW_SYMMETRIC_FF); 336 int i,j; 337 for(i=m.rows();i>0;i--) 338 { 339 for(j=m.columns();j>0;j--) 340 { 341 if(!(m(i,j)).isImm()) printf("convertFacCFMatrix2FLINTmat_zz_p: not imm.\n"); 342 nmod_mat_entry (M,i-1,j-1)= (m(i,j)).intval(); 343 } 344 } 345 if (save_sym_ff) On (SW_SYMMETRIC_FF); 346 } 347 348 CFMatrix* convertNmod_mat_t2FacCFMatrix(nmod_mat_t m) 349 { 350 CFMatrix *res=new CFMatrix(nmod_mat_nrows (m), nmod_mat_ncols (m)); 351 int i,j; 352 for(i=res->rows();i>0;i--) 353 { 354 for(j=res->columns();j>0;j--) 355 { 356 (*res)(i,j)=CanonicalForm((long) nmod_mat_entry (m, i-1, j-1)); 357 } 358 } 359 return res; 360 } 361 362 #endif 363 364 -
factory/FLINTconvert.h
r1130ffc r186df6 27 27 #define __GMP_BITS_PER_MP_LIMB GMP_LIMB_BITS 28 28 #endif 29 #include <fmpz.h> 30 #include <fmpq.h> 31 #include <fmpz_poly.h> 32 #include <fmpz_mod_poly.h> 33 #include <fmpq_poly.h> 34 #include <nmod_poly.h> 29 #include <flint/fmpz.h> 30 #include <flint/fmpq.h> 31 #include <flint/fmpz_poly.h> 32 #include <flint/fmpz_mod_poly.h> 33 #include <flint/fmpq_poly.h> 34 #include <flint/nmod_poly.h> 35 #include <flint/nmod_mat.h> 36 #include <flint/fmpz_mat.h> 35 37 #ifdef __cplusplus 36 38 } … … 132 134 ); 133 135 136 /// conversion of a factory matrix over Z to a fmpz_mat_t 137 void convertFacCFMatrix2Fmpz_mat_t (fmpz_mat_t M, ///<[in,out] fmpz_mat_t 138 CFMatrix &m ///<[in] matrix over Z 139 ); 140 141 /// conversion of a FLINT matrix over Z to a factory matrix 142 CFMatrix* convertFmpz_mat_t2FacCFMatrix(fmpz_mat_t m ///<[in] fmpz_mat_t 143 ); 144 145 /// conversion of a factory matrix over Z/p to a nmod_mat_t 146 void convertFacCFMatrix2nmod_mat_t (nmod_mat_t M, ///<[in,out] nmod_mat_t 147 CFMatrix &m ///<[in] matrix over Z/p 148 ); 149 150 /// conversion of a FLINT matrix over Z/p to a factory matrix 151 CFMatrix* convertNmod_mat_t2FacCFMatrix(nmod_mat_t m ///<[in] nmod_mat_t 152 ); 153 134 154 #endif 135 155 #endif -
factory/algext.cc
r1130ffc r186df6 29 29 #ifdef HAVE_NTL 30 30 #include "NTLconvert.h" 31 #endif 32 33 #ifdef HAVE_FLINT 34 #include "FLINTconvert.h" 31 35 #endif 32 36 … … 637 641 { 638 642 if (c.isZero()) return abs (f); 643 #ifdef HAVE_FLINT 644 fmpz_poly_t FLINTf, FLINTc; 645 convertFacCF2Fmpz_poly_t (FLINTf, f); 646 convertFacCF2Fmpz_poly_t (FLINTc, c); 647 fmpz_poly_gcd (FLINTc, FLINTc, FLINTf); 648 CanonicalForm result; 649 if (f.inCoeffDomain()) 650 result= convertFmpz_poly_t2FacCF (FLINTc, f.mvar()); 651 else 652 result= convertFmpz_poly_t2FacCF (FLINTc, c.mvar()); 653 fmpz_poly_clear (FLINTc); 654 fmpz_poly_clear (FLINTf); 655 return result; 656 #else 639 657 ZZX NTLf= convertFacCF2NTLZZX (f); 640 658 ZZX NTLc= convertFacCF2NTLZZX (c); … … 644 662 else 645 663 return convertNTLZZX2CF(NTLc,c.mvar()); 664 #endif 646 665 } 647 666 else -
factory/cfModResultant.cc
r1130ffc r186df6 26 26 #endif 27 27 28 #ifdef HAVE_FLINT 29 #include "FLINTconvert.h" 30 #endif 31 28 32 //TODO arrange by bound= deg (F,xlevel)*deg (G,i)+deg (G,xlevel)*deg (F, i) 29 33 static inline … … 242 246 return 0; 243 247 248 #ifdef HAVE_FLINT 249 nmod_poly_t FLINTF, FLINTG; 250 convertFacCF2nmod_poly_t (FLINTF, F); 251 convertFacCF2nmod_poly_t (FLINTG, G); 252 mp_limb_t FLINTresult= nmod_poly_resultant (FLINTF, FLINTG); 253 nmod_poly_clear (FLINTF); 254 nmod_poly_clear (FLINTG); 255 return CanonicalForm ((long) FLINTresult); 256 #else 244 257 zz_pBak bak; 245 258 bak.save(); … … 252 265 bak.restore(); 253 266 return CanonicalForm (to_long (rep (NTLResult))); 267 #endif 254 268 #else 255 269 return resultant (F, G, F.mvar()); -
factory/cf_gcd.cc
r1130ffc r186df6 26 26 #include "NTLconvert.h" 27 27 bool isPurePoly(const CanonicalForm & ); 28 #ifndef HAVE_FLINT 28 29 static CanonicalForm gcd_univar_ntl0( const CanonicalForm &, const CanonicalForm & ); 29 30 static CanonicalForm gcd_univar_ntlp( const CanonicalForm &, const CanonicalForm & ); 31 #endif 30 32 #endif 31 33 … … 307 309 } 308 310 #ifdef HAVE_NTL 311 #ifdef HAVE_FLINT 312 if (( getCharacteristic() > 0 ) && (CFFactory::gettype() != GaloisFieldDomain) 313 && (f.level()==g.level()) && isPurePoly(f) && isPurePoly(g)) 314 { 315 nmod_poly_t F1, G1, A, B, R; 316 convertFacCF2nmod_poly_t (F1, f); 317 convertFacCF2nmod_poly_t (G1, g); 318 nmod_poly_init (R, getCharacteristic()); 319 nmod_poly_init (A, getCharacteristic()); 320 nmod_poly_init (B, getCharacteristic()); 321 nmod_poly_xgcd (R, A, B, F1, G1); 322 a= convertnmod_poly_t2FacCF (A, f.mvar()); 323 b= convertnmod_poly_t2FacCF (B, f.mvar()); 324 CanonicalForm r= convertnmod_poly_t2FacCF (R, f.mvar()); 325 nmod_poly_clear (F1); 326 nmod_poly_clear (G1); 327 nmod_poly_clear (A); 328 nmod_poly_clear (B); 329 nmod_poly_clear (R); 330 return r; 331 } 332 #else 309 333 if (isOn(SW_USE_NTL_GCD_P) && ( getCharacteristic() > 0 ) && (CFFactory::gettype() != GaloisFieldDomain) 310 334 && (f.level()==g.level()) && isPurePoly(f) && isPurePoly(g)) … … 347 371 #endif 348 372 } 373 #endif 374 #ifdef HAVE_FLINT 375 if (( getCharacteristic() ==0) && (f.level()==g.level()) 376 && isPurePoly(f) && isPurePoly(g)) 377 { 378 fmpq_poly_t F1, G1; 379 convertFacCF2Fmpq_poly_t (F1, f); 380 convertFacCF2Fmpq_poly_t (G1, g); 381 fmpq_poly_t R, A, B; 382 fmpq_poly_init (R); 383 fmpq_poly_init (A); 384 fmpq_poly_init (B); 385 fmpq_poly_xgcd (R, A, B, F1, G1); 386 a= convertFmpq_poly_t2FacCF (A, f.mvar()); 387 b= convertFmpq_poly_t2FacCF (B, f.mvar()); 388 CanonicalForm r= convertFmpq_poly_t2FacCF (R, f.mvar()); 389 fmpq_poly_clear (F1); 390 fmpq_poly_clear (G1); 391 fmpq_poly_clear (A); 392 fmpq_poly_clear (B); 393 fmpq_poly_clear (R); 394 return r; 395 } 396 #else 349 397 if (isOn(SW_USE_NTL_GCD_0) && ( getCharacteristic() ==0) 350 398 && (f.level()==g.level()) && isPurePoly(f) && isPurePoly(g)) … … 378 426 CanonicalForm rr=convertZZ2CF(RR); 379 427 ASSERT (!rr.isZero(), "NTL:XGCD failed"); 380 r*=rr;381 if ( r.sign() < 0 ) { r= -r; a= -a; b= -b; }428 a /= rr; 429 b /= rr; 382 430 return r; 383 431 } 384 432 } 433 #endif 385 434 #endif 386 435 // may contain bug in the co-factors, see track 107 … … 669 718 if ( pi.isUnivariate() && pi1.isUnivariate() ) 670 719 { 671 /*#ifdef HAVE_FLINT720 #ifdef HAVE_FLINT 672 721 if (isPurePoly(pi) && isPurePoly(pi1) ) 673 722 return gcd_univar_flint0(pi, pi1 ) * C; 674 #else */723 #else 675 724 #ifdef HAVE_NTL 676 725 if ( isOn(SW_USE_NTL_GCD_0) && isPurePoly(pi) && isPurePoly(pi1) ) 677 726 return gcd_univar_ntl0(pi, pi1 ) * C; 678 727 #endif 679 //#endif728 #endif 680 729 return gcd_poly_univar0( pi, pi1, true ) * C; 681 730 } … … 993 1042 994 1043 #ifdef HAVE_NTL 995 1044 #ifndef HAVE_FLINT 996 1045 static CanonicalForm 997 1046 gcd_univar_ntl0( const CanonicalForm & F, const CanonicalForm & G ) … … 1035 1084 #endif 1036 1085 } 1037 1086 #endif 1038 1087 #endif 1039 1088 -
factory/cf_gcd_smallp.cc
r1130ffc r186df6 39 39 #ifdef HAVE_NTL 40 40 #include <NTLconvert.h> 41 #endif 42 43 #ifdef HAVE_FLINT 44 #include "FLINTconvert.h" 41 45 #endif 42 46 … … 1981 1985 for (int i= 0; i < L.size(); i++, j++) 1982 1986 (*N) (j, M.columns() + 1)= L[i]; 1987 #ifdef HAVE_FLINT 1988 nmod_mat_t FLINTN; 1989 convertFacCFMatrix2nmod_mat_t (FLINTN, *N); 1990 long* dummy= new long [M.rows()]; 1991 for (int i= 0; i < M.rows(); i++) 1992 dummy[i]= 0; 1993 long rk= nmod_mat_rref (dummy, FLINTN); 1994 1995 N= convertNmod_mat_t2FacCFMatrix (FLINTN); 1996 nmod_mat_clear (FLINTN); 1997 delete dummy; 1998 #else 1983 1999 int p= getCharacteristic (); 1984 2000 zz_p::init (p); … … 1987 2003 1988 2004 N= convertNTLmat_zz_p2FacCFMatrix (*NTLN); 2005 #endif 1989 2006 1990 2007 L= CFArray (M.rows()); … … 2042 2059 for (int i= 0; i < L.size(); i++, j++) 2043 2060 (*N) (j, M.columns() + 1)= L[i]; 2061 2062 #ifdef HAVE_FLINT 2063 nmod_mat_t FLINTN; 2064 convertFacCFMatrix2nmod_mat_t (FLINTN, *N); 2065 long* dummy= new long [M.rows()]; 2066 for (int i= 0; i < M.rows(); i++) 2067 dummy[i]= 0; 2068 long rk= nmod_mat_rref (dummy, FLINTN); 2069 #else 2044 2070 int p= getCharacteristic (); 2045 2071 zz_p::init (p); 2046 2072 mat_zz_p *NTLN= convertFacCFMatrix2NTLmat_zz_p(*N); 2047 2073 long rk= gauss (*NTLN); 2074 #endif 2048 2075 if (rk != M.columns()) 2049 2076 { 2077 #ifdef HAVE_FLINT 2078 nmod_mat_clear (FLINTN); 2079 delete dummy; 2080 #endif 2050 2081 delete N; 2051 2082 return CFArray(); 2052 2083 } 2084 #ifdef HAVE_FLINT 2085 N= convertNmod_mat_t2FacCFMatrix (FLINTN); 2086 nmod_mat_clear (FLINTN); 2087 delete dummy; 2088 #else 2053 2089 N= convertNTLmat_zz_p2FacCFMatrix (*NTLN); 2054 2090 #endif 2055 2091 CFArray A= readOffSolution (*N, rk); 2056 2092 -
factory/facFqBivar.cc
r1130ffc r186df6 1280 1280 } 1281 1281 1282 #ifdef HAVE_FLINT 1283 long isReduced (const nmod_mat_t M) 1284 { 1285 long i, j, nonZero; 1286 for (i = 1; i <= nmod_mat_nrows(M); i++) 1287 { 1288 nonZero= 0; 1289 for (j = 1; j <= nmod_mat_ncols (M); j++) 1290 { 1291 if (!(nmod_mat_entry (M, i-1, j-1)==0)) 1292 nonZero++; 1293 } 1294 if (nonZero != 1) 1295 return 0; 1296 } 1297 return 1; 1298 } 1299 #endif 1300 1282 1301 long isReduced (const mat_zz_pE& M) 1283 1302 { … … 1320 1339 return result; 1321 1340 } 1341 1342 #ifdef HAVE_FLINT 1343 int * extractZeroOneVecs (const nmod_mat_t M) 1344 { 1345 long i, j; 1346 bool nonZeroOne= false; 1347 int * result= new int [nmod_mat_ncols (M)]; 1348 for (i = 0; i < nmod_mat_ncols (M); i++) 1349 { 1350 for (j = 0; j < nmod_mat_nrows (M); j++) 1351 { 1352 if (!((nmod_mat_entry (M, j, i) == 1) || (nmod_mat_entry (M, j,i) == 0))) 1353 { 1354 nonZeroOne= true; 1355 break; 1356 } 1357 } 1358 if (!nonZeroOne) 1359 result [i]= 1; 1360 else 1361 result [i]= 0; 1362 nonZeroOne= false; 1363 } 1364 return result; 1365 } 1366 #endif 1322 1367 1323 1368 int * extractZeroOneVecs (const mat_zz_pE& M) … … 1498 1543 } 1499 1544 } 1545 1546 #ifdef HAVE_FLINT 1547 void 1548 reconstructionTry (CFList& reconstructedFactors, CanonicalForm& F, const CFList& 1549 factors, const int liftBound, int& factorsFound, int*& 1550 factorsFoundIndex, nmod_mat_t N, bool beenInThres 1551 ) 1552 { 1553 Variable y= Variable (2); 1554 Variable x= Variable (1); 1555 CanonicalForm yToL= power (y, liftBound); 1556 if (factors.length() == 2) 1557 { 1558 CanonicalForm tmp1, tmp2, tmp3; 1559 tmp1= factors.getFirst(); 1560 tmp2= factors.getLast(); 1561 tmp1 *= LC (F, x); 1562 tmp1= mod (tmp1, yToL); 1563 tmp1 /= content (tmp1, x); 1564 tmp2 *= LC (F, x); 1565 tmp2= mod (tmp2, yToL); 1566 tmp2 /= content (tmp2, x); 1567 tmp3 = tmp1*tmp2; 1568 if (tmp3/Lc (tmp3) == F/Lc (F)) 1569 { 1570 factorsFound++; 1571 F= 1; 1572 reconstructedFactors.append (tmp1); 1573 reconstructedFactors.append (tmp2); 1574 return; 1575 } 1576 } 1577 CanonicalForm quot, buf; 1578 CFListIterator iter; 1579 for (long i= 0; i < nmod_mat_ncols (N); i++) 1580 { 1581 if (factorsFoundIndex [i] == 1) 1582 continue; 1583 iter= factors; 1584 if (beenInThres) 1585 { 1586 int count= 0; 1587 while (count < i) 1588 { 1589 count++; 1590 iter++; 1591 } 1592 buf= iter.getItem(); 1593 } 1594 else 1595 { 1596 buf= 1; 1597 for (long j= 0; j < nmod_mat_nrows (N); j++, iter++) 1598 { 1599 if (!(nmod_mat_entry (N, j, i) == 0)) 1600 buf= mulMod2 (buf, iter.getItem(), yToL); 1601 } 1602 } 1603 buf *= LC (F, x); 1604 buf= mod (buf, yToL); 1605 buf /= content (buf, x); 1606 if (fdivides (buf, F, quot)) 1607 { 1608 factorsFoundIndex[i]= 1; 1609 factorsFound++; 1610 F= quot; 1611 F /= Lc (F); 1612 reconstructedFactors.append (buf); 1613 } 1614 if (degree (F) <= 0) 1615 return; 1616 if (factorsFound + 1 == nmod_mat_ncols (N)) 1617 { 1618 reconstructedFactors.append (F); 1619 return; 1620 } 1621 } 1622 } 1623 #endif 1500 1624 1501 1625 CFList … … 1680 1804 } 1681 1805 1806 #ifdef HAVE_FLINT 1807 CFList 1808 extReconstruction (CanonicalForm& G, CFList& factors, int* zeroOneVecs, int 1809 precision, const nmod_mat_t N, const ExtensionInfo& info, 1810 const CanonicalForm& evaluation 1811 ) 1812 { 1813 Variable y= Variable (2); 1814 Variable x= Variable (1); 1815 Variable alpha= info.getAlpha(); 1816 Variable beta= info.getBeta(); 1817 int k= info.getGFDegree(); 1818 CanonicalForm gamma= info.getGamma(); 1819 CanonicalForm delta= info.getDelta(); 1820 CanonicalForm F= G; 1821 CanonicalForm yToL= power (y, precision); 1822 CFList result; 1823 CFList bufFactors= factors; 1824 CFList factorsConsidered; 1825 CanonicalForm buf2, quot, buf; 1826 CFListIterator iter; 1827 for (long i= 0; i < nmod_mat_ncols(N); i++) 1828 { 1829 if (zeroOneVecs [i] == 0) 1830 continue; 1831 iter= factors; 1832 buf= 1; 1833 factorsConsidered= CFList(); 1834 for (long j= 0; j < nmod_mat_ncols(N); j++, iter++) 1835 { 1836 if (!(nmod_mat_entry (N, j, i) == 0)) 1837 { 1838 factorsConsidered.append (iter.getItem()); 1839 buf= mulMod2 (buf, iter.getItem(), yToL); 1840 } 1841 } 1842 buf *= LC (F, x); 1843 buf= mod (buf, yToL); 1844 buf /= content (buf, x); 1845 buf2= buf (y-evaluation, y); 1846 if (!k && beta == x) 1847 { 1848 if (degree (buf2, alpha) < 1) 1849 { 1850 if (fdivides (buf, F, quot)) 1851 { 1852 F= quot; 1853 F /= Lc (F); 1854 result.append (buf2); 1855 bufFactors= Difference (bufFactors, factorsConsidered); 1856 } 1857 } 1858 } 1859 else 1860 { 1861 CFList source, dest; 1862 1863 if (!isInExtension (buf2, gamma, k, delta, source, dest)) 1864 { 1865 if (fdivides (buf, F, quot)) 1866 { 1867 F= quot; 1868 F /= Lc (F); 1869 result.append (buf2); 1870 bufFactors= Difference (bufFactors, factorsConsidered); 1871 } 1872 } 1873 } 1874 if (degree (F) <= 0) 1875 { 1876 G= F; 1877 factors= bufFactors; 1878 return result; 1879 } 1880 } 1881 G= F; 1882 factors= bufFactors; 1883 return result; 1884 } 1885 #endif 1886 1682 1887 CFList 1683 1888 reconstruction (CanonicalForm& G, CFList& factors, int* zeroOneVecs, … … 1729 1934 return result; 1730 1935 } 1936 1937 #ifdef HAVE_FLINT 1938 CFList 1939 reconstruction (CanonicalForm& G, CFList& factors, int* zeroOneVecs, 1940 int precision, const nmod_mat_t N) 1941 { 1942 Variable y= Variable (2); 1943 Variable x= Variable (1); 1944 CanonicalForm F= G; 1945 CanonicalForm yToL= power (y, precision); 1946 CanonicalForm quot, buf; 1947 CFList result; 1948 CFList bufFactors= factors; 1949 CFList factorsConsidered; 1950 CFListIterator iter; 1951 for (long i= 0; i < nmod_mat_ncols (N); i++) 1952 { 1953 if (zeroOneVecs [i] == 0) 1954 continue; 1955 iter= factors; 1956 buf= 1; 1957 factorsConsidered= CFList(); 1958 for (long j= 0; j < nmod_mat_nrows (N); j++, iter++) 1959 { 1960 if (!(nmod_mat_entry (N, j, i) == 0)) 1961 { 1962 factorsConsidered.append (iter.getItem()); 1963 buf= mulMod2 (buf, iter.getItem(), yToL); 1964 } 1965 } 1966 buf *= LC (F, x); 1967 buf= mod (buf, yToL); 1968 buf /= content (buf, x); 1969 if (fdivides (buf, F, quot)) 1970 { 1971 F= quot; 1972 F /= Lc (F); 1973 result.append (buf); 1974 bufFactors= Difference (bufFactors, factorsConsidered); 1975 } 1976 if (degree (F) <= 0) 1977 { 1978 G= F; 1979 factors= bufFactors; 1980 return result; 1981 } 1982 } 1983 G= F; 1984 factors= bufFactors; 1985 return result; 1986 } 1987 #endif 1731 1988 1732 1989 void … … 1857 2114 } 1858 2115 } 2116 2117 #ifdef HAVE_FLINT 2118 void 2119 extReconstructionTry (CFList& reconstructedFactors, CanonicalForm& F, const 2120 CFList& factors, const int liftBound, int& factorsFound, 2121 int*& factorsFoundIndex, nmod_mat_t N, bool beenInThres, 2122 const ExtensionInfo& info, const CanonicalForm& evaluation 2123 ) 2124 { 2125 Variable y= Variable (2); 2126 Variable x= Variable (1); 2127 Variable alpha= info.getAlpha(); 2128 Variable beta= info.getBeta(); 2129 int k= info.getGFDegree(); 2130 CanonicalForm gamma= info.getGamma(); 2131 CanonicalForm delta= info.getDelta(); 2132 CanonicalForm yToL= power (y, liftBound); 2133 CFList source, dest; 2134 if (factors.length() == 2) 2135 { 2136 CanonicalForm tmp1, tmp2, tmp3; 2137 tmp1= factors.getFirst(); 2138 tmp2= factors.getLast(); 2139 tmp1 *= LC (F, x); 2140 tmp1= mod (tmp1, yToL); 2141 tmp1 /= content (tmp1, x); 2142 tmp2 *= LC (F, x); 2143 tmp2= mod (tmp2, yToL); 2144 tmp2 /= content (tmp2, x); 2145 tmp3 = tmp1*tmp2; 2146 if (tmp3/Lc (tmp3) == F/Lc (F)) 2147 { 2148 tmp1= tmp1 (y - evaluation, y); 2149 tmp2= tmp2 (y - evaluation, y); 2150 if (!k && beta == x && degree (tmp2, alpha) < 1 && 2151 degree (tmp1, alpha) < 1) 2152 { 2153 factorsFound++; 2154 F= 1; 2155 tmp1= mapDown (tmp1, info, source, dest); 2156 tmp2= mapDown (tmp2, info, source, dest); 2157 reconstructedFactors.append (tmp1); 2158 reconstructedFactors.append (tmp2); 2159 return; 2160 } 2161 else if (!isInExtension (tmp2, gamma, k, delta, source, dest) && 2162 !isInExtension (tmp1, gamma, k, delta, source, dest)) 2163 { 2164 factorsFound++; 2165 F= 1; 2166 tmp1= mapDown (tmp1, info, source, dest); 2167 tmp2= mapDown (tmp2, info, source, dest); 2168 reconstructedFactors.append (tmp1); 2169 reconstructedFactors.append (tmp2); 2170 return; 2171 } 2172 } 2173 } 2174 CanonicalForm quot, buf, buf2; 2175 CFListIterator iter; 2176 for (long i= 0; i < nmod_mat_ncols (N); i++) 2177 { 2178 if (factorsFoundIndex [i] == 1) 2179 continue; 2180 iter= factors; 2181 if (beenInThres) 2182 { 2183 int count= 0; 2184 while (count < i) 2185 { 2186 count++; 2187 iter++; 2188 } 2189 buf= iter.getItem(); 2190 } 2191 else 2192 { 2193 buf= 1; 2194 for (long j= 0; j < nmod_mat_nrows (N); j++, iter++) 2195 { 2196 if (!(nmod_mat_entry (N, j, i) == 0)) 2197 buf= mulMod2 (buf, iter.getItem(), yToL); 2198 } 2199 } 2200 buf *= LC (F, x); 2201 buf= mod (buf, yToL); 2202 buf /= content (buf, x); 2203 buf2= buf (y - evaluation, y); 2204 if (!k && beta == x) 2205 { 2206 if (degree (buf2, alpha) < 1) 2207 { 2208 if (fdivides (buf, F, quot)) 2209 { 2210 factorsFoundIndex[i]= 1; 2211 factorsFound++; 2212 F= quot; 2213 F /= Lc (F); 2214 buf2= mapDown (buf2, info, source, dest); 2215 reconstructedFactors.append (buf2); 2216 } 2217 } 2218 } 2219 else 2220 { 2221 if (!isInExtension (buf2, gamma, k, delta, source, dest)) 2222 { 2223 if (fdivides (buf, F, quot)) 2224 { 2225 factorsFoundIndex[i]= 1; 2226 factorsFound++; 2227 F= quot; 2228 F /= Lc (F); 2229 buf2= mapDown (buf2, info, source, dest); 2230 reconstructedFactors.append (buf2); 2231 } 2232 } 2233 } 2234 if (degree (F) <= 0) 2235 return; 2236 if (factorsFound + 1 == nmod_mat_nrows (N)) 2237 { 2238 CanonicalForm tmp= F (y - evaluation, y); 2239 tmp= mapDown (tmp, info, source, dest); 2240 reconstructedFactors.append (tmp); 2241 return; 2242 } 2243 } 2244 } 2245 #endif 1859 2246 1860 2247 //over Fp … … 1965 2352 return l; 1966 2353 } 2354 2355 #ifdef HAVE_FLINT 2356 int 2357 liftAndComputeLattice (const CanonicalForm& F, int* bounds, int sizeBounds, int 2358 start, int liftBound, int minBound, CFList& factors, 2359 nmod_mat_t FLINTN, CFList& diophant, CFMatrix& M,CFArray& 2360 Pi, CFArray& bufQ, bool& irreducible 2361 ) 2362 { 2363 CanonicalForm LCF= LC (F, 1); 2364 CFArray *A= new CFArray [factors.length() - 1]; 2365 bool wasInBounds= false; 2366 bool hitBound= false; 2367 int l= (minBound+1)*2; 2368 int stepSize= 2; 2369 int oldL= l/2; 2370 bool reduced= false; 2371 long rank; 2372 nmod_mat_t FLINTK, FLINTC, null; 2373 CFMatrix C; 2374 CFArray buf; 2375 CFListIterator j; 2376 CanonicalForm truncF; 2377 Variable y= F.mvar(); 2378 while (l <= liftBound) 2379 { 2380 if (start) 2381 { 2382 henselLiftResume12 (F, factors, start, l, Pi, diophant, M); 2383 start= 0; 2384 } 2385 else 2386 { 2387 if (wasInBounds) 2388 henselLiftResume12 (F, factors, oldL, l, Pi, diophant, M); 2389 else 2390 henselLift12 (F, factors, l, Pi, diophant, M); 2391 } 2392 2393 factors.insert (LCF); 2394 j= factors; 2395 j++; 2396 2397 truncF= mod (F, power (y, l)); 2398 for (int i= 0; i < factors.length() - 1; i++, j++) 2399 { 2400 if (!wasInBounds) 2401 A[i]= logarithmicDerivative (truncF, j.getItem(), l, bufQ[i]); 2402 else 2403 A[i]= logarithmicDerivative (truncF, j.getItem(), l, oldL, bufQ[i], 2404 bufQ[i]); 2405 } 2406 2407 for (int i= 0; i < sizeBounds; i++) 2408 { 2409 if (bounds [i] + 1 <= l/2) 2410 { 2411 wasInBounds= true; 2412 int k= tmin (bounds [i] + 1, l/2); 2413 C= CFMatrix (l - k, factors.length() - 1); 2414 for (int ii= 0; ii < factors.length() - 1; ii++) 2415 { 2416 if (A[ii].size() - 1 >= i) 2417 { 2418 buf= getCoeffs (A[ii] [i], k); 2419 writeInMatrix (C, buf, ii + 1, 0); 2420 } 2421 } 2422 2423 convertFacCFMatrix2nmod_mat_t (FLINTC, C); 2424 nmod_mat_init (FLINTK, nmod_mat_nrows (FLINTC), nmod_mat_ncols (FLINTN), 2425 getCharacteristic()); 2426 nmod_mat_mul (FLINTK, FLINTC, FLINTN); 2427 nmod_mat_init (null, nmod_mat_ncols (FLINTK), nmod_mat_ncols (FLINTK), 2428 getCharacteristic()); 2429 rank= nmod_mat_nullspace (null, FLINTK); 2430 nmod_mat_clear (FLINTK); 2431 nmod_mat_window_init (FLINTK, null, 0, 0, nmod_mat_nrows(null), rank); 2432 nmod_mat_clear (FLINTC); 2433 nmod_mat_init_set (FLINTC, FLINTN); 2434 nmod_mat_clear (FLINTN); 2435 nmod_mat_init (FLINTN, nmod_mat_nrows (FLINTC), nmod_mat_ncols (FLINTK), 2436 getCharacteristic()); 2437 nmod_mat_mul (FLINTN, FLINTC, FLINTK); //no aliasing allowed!! 2438 2439 nmod_mat_clear (FLINTC); 2440 nmod_mat_window_clear (FLINTK); 2441 nmod_mat_clear (null); 2442 if (nmod_mat_ncols (FLINTN) == 1) 2443 { 2444 irreducible= true; 2445 break; 2446 } 2447 if (isReduced (FLINTN) && l > (minBound+1)*2) 2448 { 2449 reduced= true; 2450 break; 2451 } 2452 } 2453 } 2454 2455 if (irreducible) 2456 break; 2457 if (reduced) 2458 break; 2459 oldL= l; 2460 l += stepSize; 2461 stepSize *= 2; 2462 if (l > liftBound) 2463 { 2464 if (!hitBound) 2465 { 2466 l= liftBound; 2467 hitBound= true; 2468 } 2469 else 2470 break; 2471 } 2472 } 2473 delete [] A; 2474 return l; 2475 } 2476 #endif 1967 2477 1968 2478 //over field extension … … 2145 2655 } 2146 2656 2657 /*#ifdef HAVE_FLINT 2658 //over field extension 2659 int 2660 extLiftAndComputeLattice (const CanonicalForm& F, int* bounds, int sizeBounds, 2661 int liftBound, int minBound, int start, CFList& 2662 factors, nmod_mat_t FLINTN, CFList& diophant, 2663 CFMatrix& M, CFArray& Pi, CFArray& bufQ, bool& 2664 irreducible, const CanonicalForm& evaluation, const 2665 ExtensionInfo& info, CFList& source, CFList& dest 2666 ) 2667 { 2668 bool GF= (CFFactory::gettype()==GaloisFieldDomain); 2669 CanonicalForm LCF= LC (F, 1); 2670 CFArray *A= new CFArray [factors.length() - 1]; 2671 bool wasInBounds= false; 2672 bool hitBound= false; 2673 int degMipo; 2674 Variable alpha; 2675 alpha= info.getAlpha(); 2676 degMipo= degree (getMipo (alpha)); 2677 2678 Variable gamma= info.getBeta(); 2679 CanonicalForm primElemAlpha= info.getGamma(); 2680 CanonicalForm imPrimElemAlpha= info.getDelta(); 2681 2682 int stepSize= 2; 2683 int l= ((minBound+1)/degMipo+1)*2; 2684 l= tmax (l, 2); 2685 if (start > l) 2686 l= start; 2687 int oldL= l/2; 2688 bool reduced= false; 2689 Variable y= F.mvar(); 2690 Variable x= Variable (1); 2691 CanonicalForm powX, imBasis, truncF; 2692 CFMatrix Mat, C; 2693 CFArray buf; 2694 CFIterator iter; 2695 long rank; 2696 nmod_mat_t FLINTMat, FLINTMatInv, FLINTC, FLINTK, null; 2697 CFListIterator j; 2698 while (l <= liftBound) 2699 { 2700 if (start) 2701 { 2702 henselLiftResume12 (F, factors, start, l, Pi, diophant, M); 2703 start= 0; 2704 } 2705 else 2706 { 2707 if (wasInBounds) 2708 henselLiftResume12 (F, factors, oldL, l, Pi, diophant, M); 2709 else 2710 henselLift12 (F, factors, l, Pi, diophant, M); 2711 } 2712 2713 factors.insert (LCF); 2714 2715 if (GF) 2716 setCharacteristic (getCharacteristic()); 2717 2718 powX= power (y-gamma, l); 2719 Mat= CFMatrix (l*degMipo, l*degMipo); 2720 for (int i= 0; i < l*degMipo; i++) 2721 { 2722 imBasis= mod (power (y, i), powX); 2723 imBasis= imBasis (power (y, degMipo), y); 2724 imBasis= imBasis (y, gamma); 2725 iter= imBasis; 2726 for (; iter.hasTerms(); iter++) 2727 Mat (iter.exp()+ 1, i+1)= iter.coeff(); 2728 } 2729 2730 convertFacCFMatrix2nmod_mat_t (FLINTMat, Mat); 2731 nmod_mat_init (FLINTMatInv, nmod_mat_nrows (FLINTMat), 2732 nmod_mat_nrows (FLINTMat), getCharacteristic()); 2733 nmod_mat_inv (FLINTMatInv, FLINTMat); 2734 2735 if (GF) 2736 setCharacteristic (getCharacteristic(), degMipo, info.getGFName()); 2737 2738 j= factors; 2739 j++; 2740 2741 truncF= mod (F, power (y, l)); 2742 for (int i= 0; i < factors.length() - 1; i++, j++) 2743 { 2744 if (!wasInBounds) 2745 A[i]= logarithmicDerivative (truncF, j.getItem(), l, bufQ[i]); 2746 else 2747 A[i]= logarithmicDerivative (truncF, j.getItem(), l, oldL, bufQ[i], 2748 bufQ[i]); 2749 } 2750 2751 for (int i= 0; i < sizeBounds; i++) 2752 { 2753 if (bounds [i] + 1 <= (l/2)*degMipo) 2754 { 2755 wasInBounds= true; 2756 int k= tmin (bounds [i] + 1, (l/2)*degMipo); 2757 C= CFMatrix (l*degMipo - k, factors.length() - 1); 2758 2759 for (int ii= 0; ii < factors.length() - 1; ii++) 2760 { 2761 if (A[ii].size() - 1 >= i) 2762 { 2763 if (GF) 2764 { 2765 A [ii] [i]= A [ii] [i] (y-evaluation, y); 2766 setCharacteristic (getCharacteristic()); 2767 A[ii] [i]= GF2FalphaRep (A[ii] [i], alpha); 2768 if (alpha != gamma) 2769 A [ii] [i]= mapDown (A[ii] [i], imPrimElemAlpha, primElemAlpha, 2770 gamma, source, dest 2771 ); 2772 buf= getCoeffs (A[ii] [i], k, l, degMipo, gamma, 0, FLINTMatInv); //TODO 2773 } 2774 else 2775 { 2776 A [ii] [i]= A [ii] [i] (y-evaluation, y); 2777 if (alpha != gamma) 2778 A[ii] [i]= mapDown (A[ii] [i], imPrimElemAlpha, primElemAlpha, 2779 gamma, source, dest 2780 ); 2781 buf= getCoeffs (A[ii] [i], k, l, degMipo, gamma, 0, FLINTMatInv); //TODO 2782 } 2783 writeInMatrix (C, buf, ii + 1, 0); 2784 } 2785 if (GF) 2786 setCharacteristic (getCharacteristic(), degMipo, info.getGFName()); 2787 } 2788 2789 if (GF) 2790 setCharacteristic(getCharacteristic()); 2791 2792 convertFacCFMatrix2nmod_mat_t (FLINTC, C); 2793 nmod_mat_init (FLINTK, nmod_mat_nrows (FLINTC), nmod_mat_ncols (FLINTN), 2794 getCharacteristic()); 2795 nmod_mat_mul (FLINTK, FLINTC, FLINTN); 2796 nmod_mat_init (null, nmod_mat_ncols (FLINTK), nmod_mat_ncols (FLINTK), 2797 getCharacteristic()); 2798 rank= nmod_mat_nullspace (null, FLINTK); 2799 nmod_mat_clear (FLINTK); 2800 nmod_mat_window_init (FLINTK, null, 0, 0, nmod_mat_nrows(null), rank); 2801 nmod_mat_clear (FLINTC); 2802 nmod_mat_init_set (FLINTC, FLINTN); 2803 nmod_mat_clear (FLINTN); 2804 nmod_mat_init (FLINTN, nmod_mat_nrows (FLINTC), nmod_mat_ncols (FLINTK), 2805 getCharacteristic()); 2806 nmod_mat_mul (FLINTN, FLINTC, FLINTK); //no aliasing allowed!! 2807 2808 nmod_mat_clear (FLINTC); 2809 nmod_mat_window_clear (FLINTK); 2810 nmod_mat_clear (null); 2811 2812 if (GF) 2813 setCharacteristic (getCharacteristic(), degMipo, info.getGFName()); 2814 2815 if (nmod_mat_ncols (FLINTN) == 1) 2816 { 2817 irreducible= true; 2818 break; 2819 } 2820 if (isReduced (FLINTN)) 2821 { 2822 reduced= true; 2823 break; 2824 } 2825 } 2826 } 2827 2828 nmod_mat_clear (FLINTMat); 2829 nmod_mat_clear (FLINTMatInv); 2830 2831 if (nmod_mat_ncols (FLINTN) == 1) 2832 { 2833 irreducible= true; 2834 break; 2835 } 2836 if (reduced) 2837 break; 2838 oldL= l; 2839 l += stepSize; 2840 stepSize *= 2; 2841 if (l > liftBound) 2842 { 2843 if (!hitBound) 2844 { 2845 l= liftBound; 2846 hitBound= true; 2847 } 2848 else 2849 break; 2850 } 2851 } 2852 delete [] A; 2853 return l; 2854 } 2855 #endif*/ 2856 2147 2857 // over Fq 2148 2858 int … … 2263 2973 } 2264 2974 2975 #ifdef HAVE_FLINT 2976 int 2977 liftAndComputeLatticeFq2Fp (const CanonicalForm& F, int* bounds, int sizeBounds, 2978 int start, int liftBound, int minBound, CFList& 2979 factors, nmod_mat_t FLINTN, CFList& diophant, 2980 CFMatrix& M, CFArray& Pi, CFArray& bufQ, bool& 2981 irreducible, const Variable& alpha 2982 ) 2983 #else 2265 2984 int 2266 2985 liftAndComputeLatticeFq2Fp (const CanonicalForm& F, int* bounds, int sizeBounds, … … 2270 2989 const Variable& alpha 2271 2990 ) 2991 #endif 2272 2992 { 2273 2993 CanonicalForm LCF= LC (F, 1); … … 2283 3003 CFMatrix C; 2284 3004 CFArray buf; 3005 #ifdef HAVE_FLINT 3006 long rank; 3007 nmod_mat_t FLINTC, FLINTK, null; 3008 #else 2285 3009 mat_zz_p* NTLC, NTLK; 3010 #endif 2286 3011 Variable y= F.mvar(); 2287 3012 CanonicalForm truncF; … … 2336 3061 } 2337 3062 3063 #ifdef HAVE_FLINT 3064 convertFacCFMatrix2nmod_mat_t (FLINTC, C); 3065 nmod_mat_init (FLINTK, nmod_mat_nrows (FLINTC), nmod_mat_ncols (FLINTN), 3066 getCharacteristic()); 3067 nmod_mat_mul (FLINTK, FLINTC, FLINTN); 3068 nmod_mat_init (null, nmod_mat_ncols (FLINTK), nmod_mat_ncols (FLINTK), 3069 getCharacteristic()); 3070 rank= nmod_mat_nullspace (null, FLINTK); 3071 nmod_mat_clear (FLINTK); 3072 nmod_mat_window_init (FLINTK, null, 0, 0, nmod_mat_nrows(null), rank); 3073 nmod_mat_clear (FLINTC); 3074 nmod_mat_init_set (FLINTC, FLINTN); 3075 nmod_mat_clear (FLINTN); 3076 nmod_mat_init (FLINTN, nmod_mat_nrows (FLINTC), nmod_mat_ncols (FLINTK), 3077 getCharacteristic()); 3078 nmod_mat_mul (FLINTN, FLINTC, FLINTK); //no aliasing allowed!! 3079 3080 nmod_mat_clear (FLINTC); 3081 nmod_mat_window_clear (FLINTK); 3082 nmod_mat_clear (null); 3083 #else 2338 3084 NTLC= convertFacCFMatrix2NTLmat_zz_p(C); 2339 3085 NTLK= (*NTLC)*NTLN; … … 2342 3088 transpose (NTLK, NTLK); 2343 3089 NTLN *= NTLK; 2344 3090 #endif 3091 3092 #ifdef HAVE_FLINT 3093 if (nmod_mat_nrows (FLINTN) == 1) 3094 #else 2345 3095 if (NTLN.NumCols() == 1) 3096 #endif 2346 3097 { 2347 3098 irreducible= true; 2348 3099 break; 2349 3100 } 3101 #ifdef HAVE_FLINT 3102 if (isReduced (FLINTN) && l > (minBound+1)*2) 3103 #else 2350 3104 if (isReduced (NTLN) && l > (minBound+1)*2) 3105 #endif 2351 3106 { 2352 3107 reduced= true; … … 2356 3111 } 2357 3112 3113 #ifdef HAVE_FLINT 3114 if (nmod_mat_ncols (FLINTN) == 1) 3115 #else 2358 3116 if (NTLN.NumCols() == 1) 3117 #endif 2359 3118 { 2360 3119 irreducible= true; … … 2398 3157 CFArray * A= new CFArray [factors.length()]; 2399 3158 CFArray bufQ= CFArray (factors.length()); 3159 #ifdef HAVE_FLINT 3160 nmod_mat_t FLINTN; 3161 nmod_mat_init (FLINTN,factors.length(),factors.length(), getCharacteristic()); 3162 for (long i=factors.length()-1; i >= 0; i--) 3163 nmod_mat_entry (FLINTN, i, i)= 1; 3164 #else 2400 3165 mat_zz_p NTLN; 2401 3166 ident (NTLN, factors.length()); 3167 #endif 2402 3168 int minBound= bounds[0]; 2403 3169 for (int i= 1; i < d; i++) … … 2414 3180 CFMatrix C; 2415 3181 CFArray buf; 3182 #ifdef HAVE_FLINT 3183 long rank; 3184 nmod_mat_t FLINTC, FLINTK, null; 3185 #else 2416 3186 mat_zz_p* NTLC, NTLK; 3187 #endif 2417 3188 Variable y= F.mvar(); 2418 3189 CanonicalForm truncF; … … 2448 3219 } 2449 3220 } 3221 #ifdef HAVE_FLINT 3222 convertFacCFMatrix2nmod_mat_t (FLINTC, C); 3223 nmod_mat_init (FLINTK, nmod_mat_nrows (FLINTC), nmod_mat_ncols (FLINTN), 3224 getCharacteristic()); 3225 nmod_mat_mul (FLINTK, FLINTC, FLINTN); 3226 nmod_mat_init (null, nmod_mat_ncols (FLINTK), nmod_mat_ncols (FLINTK), 3227 getCharacteristic()); 3228 rank= nmod_mat_nullspace (null, FLINTK); 3229 nmod_mat_clear (FLINTK); 3230 nmod_mat_window_init (FLINTK, null, 0, 0, nmod_mat_nrows(null), rank); 3231 nmod_mat_clear (FLINTC); 3232 nmod_mat_init_set (FLINTC, FLINTN); 3233 nmod_mat_clear (FLINTN); 3234 nmod_mat_init (FLINTN, nmod_mat_nrows (FLINTC), nmod_mat_ncols (FLINTK), 3235 getCharacteristic()); 3236 nmod_mat_mul (FLINTN, FLINTC, FLINTK); //no aliasing allowed!! 3237 3238 nmod_mat_clear (FLINTC); 3239 nmod_mat_window_clear (FLINTK); 3240 nmod_mat_clear (null); 3241 #else 2450 3242 NTLC= convertFacCFMatrix2NTLmat_zz_p(C); 2451 3243 NTLK= (*NTLC)*NTLN; … … 2454 3246 transpose (NTLK, NTLK); 2455 3247 NTLN *= NTLK; 3248 #endif 3249 #ifdef HAVE_FLINT 3250 if (nmod_mat_ncols (FLINTN) == 1) 3251 { 3252 nmod_mat_clear (FLINTN); 3253 #else 2456 3254 if (NTLN.NumCols() == 1) 2457 3255 { 3256 #endif 2458 3257 delete [] A; 2459 3258 delete [] bounds; … … 2465 3264 } 2466 3265 3266 #ifdef HAVE_FLINT 3267 if (nmod_mat_ncols (FLINTN) < oldNumCols - factorsFound) 3268 { 3269 if (isReduced (FLINTN)) 3270 { 3271 int * factorsFoundIndex= new int [nmod_mat_ncols (FLINTN)]; 3272 for (long i= 0; i < nmod_mat_ncols (FLINTN); i++) 3273 #else 2467 3274 if (NTLN.NumCols() < oldNumCols - factorsFound) 2468 3275 { … … 2471 3278 int * factorsFoundIndex= new int [NTLN.NumCols()]; 2472 3279 for (long i= 0; i < NTLN.NumCols(); i++) 3280 #endif 2473 3281 factorsFoundIndex[i]= 0; 2474 3282 int factorsFound2= 0; 2475 3283 CFList result; 2476 3284 CanonicalForm bufF= F; 3285 #ifdef HAVE_FLINT 3286 reconstructionTry (result, bufF, factors, degree (F) + 1, factorsFound2, 3287 factorsFoundIndex, FLINTN, false 3288 ); 3289 if (result.length() == nmod_mat_ncols (FLINTN)) 3290 { 3291 nmod_mat_clear (FLINTN); 3292 #else 2477 3293 reconstructionTry (result, bufF, factors, degree (F) + 1, factorsFound2, 2478 3294 factorsFoundIndex, NTLN, false … … 2480 3296 if (result.length() == NTLN.NumCols()) 2481 3297 { 3298 #endif 2482 3299 delete [] factorsFoundIndex; 2483 3300 delete [] A; … … 2491 3308 { 2492 3309 CanonicalForm bufF= F; 3310 #ifdef HAVE_FLINT 3311 int * zeroOne= extractZeroOneVecs (FLINTN); 3312 CFList result= reconstruction (bufF,factors,zeroOne,precision,FLINTN); 3313 nmod_mat_clear (FLINTN); 3314 #else 2493 3315 int * zeroOne= extractZeroOneVecs (NTLN); 2494 3316 CFList result= reconstruction (bufF, factors, zeroOne, precision, NTLN); 3317 #endif 2495 3318 F= bufF; 2496 3319 delete [] zeroOne; … … 2514 3337 } 2515 3338 } 3339 #ifdef HAVE_FLINT 3340 nmod_mat_clear (FLINTN); 3341 #endif 2516 3342 delete [] bounds; 2517 3343 delete [] A; … … 3003 3829 CFArray * A= new CFArray [factors.length()]; 3004 3830 CFArray bufQ= CFArray (factors.length()); 3831 #ifdef HAVE_FLINT 3832 nmod_mat_t FLINTN; 3833 nmod_mat_init (FLINTN,factors.length(),factors.length(), getCharacteristic()); 3834 for (long i=factors.length()-1; i >= 0; i--) 3835 nmod_mat_entry (FLINTN, i, i)= 1; 3836 #else 3005 3837 mat_zz_p NTLN; 3006 3838 ident (NTLN, factors.length()); 3839 #endif 3007 3840 int minBound= bounds[0]; 3008 3841 for (int i= 1; i < d; i++) … … 3018 3851 CFListIterator j; 3019 3852 CFMatrix C; 3853 #ifdef HAVE_FLINT 3854 long rank; 3855 nmod_mat_t FLINTC, FLINTK, null; 3856 #else 3020 3857 mat_zz_p* NTLC, NTLK; 3858 #endif 3021 3859 CFArray buf; 3022 3860 Variable y= F.mvar(); … … 3053 3891 } 3054 3892 } 3893 #ifdef HAVE_FLINT 3894 convertFacCFMatrix2nmod_mat_t (FLINTC, C); 3895 nmod_mat_init (FLINTK, nmod_mat_nrows (FLINTC), nmod_mat_ncols (FLINTN), 3896 getCharacteristic()); 3897 nmod_mat_mul (FLINTK, FLINTC, FLINTN); 3898 nmod_mat_init (null, nmod_mat_ncols (FLINTK), nmod_mat_ncols (FLINTK), 3899 getCharacteristic()); 3900 rank= nmod_mat_nullspace (null, FLINTK); 3901 nmod_mat_clear (FLINTK); 3902 nmod_mat_window_init (FLINTK, null, 0, 0, nmod_mat_nrows(null), rank); 3903 nmod_mat_clear (FLINTC); 3904 nmod_mat_init_set (FLINTC, FLINTN); 3905 nmod_mat_clear (FLINTN); 3906 nmod_mat_init (FLINTN, nmod_mat_nrows (FLINTC), nmod_mat_ncols (FLINTK), 3907 getCharacteristic()); 3908 nmod_mat_mul (FLINTN, FLINTC, FLINTK); //no aliasing allowed!! 3909 3910 nmod_mat_clear (FLINTC); 3911 nmod_mat_window_clear (FLINTK); 3912 nmod_mat_clear (null); 3913 #else 3055 3914 NTLC= convertFacCFMatrix2NTLmat_zz_p(C); 3056 3915 NTLK= (*NTLC)*NTLN; … … 3059 3918 transpose (NTLK, NTLK); 3060 3919 NTLN *= NTLK; 3920 #endif 3921 #ifdef HAVE_FLINT 3922 if (nmod_mat_ncols (FLINTN) == 1) 3923 { 3924 nmod_mat_clear (FLINTN); 3925 #else 3061 3926 if (NTLN.NumCols() == 1) 3062 3927 { 3928 #endif 3063 3929 delete [] A; 3064 3930 delete [] bounds; … … 3070 3936 } 3071 3937 3938 #ifdef HAVE_FLINT 3939 if (nmod_mat_ncols (FLINTN) < oldNumCols - factorsFound) 3940 { 3941 if (isReduced (FLINTN)) 3942 { 3943 int * factorsFoundIndex= new int [nmod_mat_ncols (FLINTN)]; 3944 for (long i= 0; i < nmod_mat_ncols (FLINTN); i++) 3945 #else 3072 3946 if (NTLN.NumCols() < oldNumCols - factorsFound) 3073 3947 { … … 3076 3950 int * factorsFoundIndex= new int [NTLN.NumCols()]; 3077 3951 for (long i= 0; i < NTLN.NumCols(); i++) 3952 #endif 3078 3953 factorsFoundIndex[i]= 0; 3079 3954 int factorsFound2= 0; 3080 3955 CFList result; 3081 3956 CanonicalForm bufF= F; 3957 #ifdef HAVE_FLINT 3958 reconstructionTry (result, bufF, factors, degree (F) + 1, factorsFound2, 3959 factorsFoundIndex, FLINTN, false 3960 ); 3961 if (result.length() == nmod_mat_ncols (FLINTN)) 3962 { 3963 nmod_mat_clear (FLINTN); 3964 #else 3082 3965 reconstructionTry (result, bufF, factors, degree (F) + 1, factorsFound2, 3083 3966 factorsFoundIndex, NTLN, false … … 3085 3968 if (result.length() == NTLN.NumCols()) 3086 3969 { 3970 #endif 3087 3971 delete [] factorsFoundIndex; 3088 3972 delete [] A; … … 3096 3980 { 3097 3981 CanonicalForm bufF= F; 3982 #ifdef HAVE_FLINT 3983 int * zeroOne= extractZeroOneVecs (FLINTN); 3984 CFList result= reconstruction (bufF,factors,zeroOne,precision,FLINTN); 3985 nmod_mat_clear (FLINTN); 3986 #else 3098 3987 int * zeroOne= extractZeroOneVecs (NTLN); 3099 3988 CFList result= reconstruction (bufF, factors, zeroOne, precision, NTLN); 3989 #endif 3100 3990 F= bufF; 3101 3991 delete [] zeroOne; … … 3119 4009 } 3120 4010 } 4011 #ifdef HAVE_FLINT 4012 nmod_mat_clear (FLINTN); 4013 #endif 3121 4014 delete [] bounds; 3122 4015 delete [] A; … … 3124 4017 } 3125 4018 4019 #ifdef HAVE_FLINT 4020 CFList 4021 increasePrecision (CanonicalForm& F, CFList& factors, int oldL, int 4022 l, int d, int* bounds, CFArray& bufQ, nmod_mat_t FLINTN 4023 ) 4024 #else 3126 4025 CFList 3127 4026 increasePrecision (CanonicalForm& F, CFList& factors, int oldL, int 3128 4027 l, int d, int* bounds, CFArray& bufQ, mat_zz_p& NTLN 3129 4028 ) 4029 #endif 3130 4030 { 3131 4031 CFList result= CFList(); … … 3133 4033 int oldL2= oldL/2; 3134 4034 bool hitBound= false; 4035 #ifdef HAVE_FLINT 4036 if (nmod_mat_nrows (FLINTN) != factors.length()) //refined factors 4037 { 4038 nmod_mat_clear (FLINTN); 4039 nmod_mat_init(FLINTN,factors.length(),factors.length(),getCharacteristic()); 4040 for (long i=factors.length()-1; i >= 0; i--) 4041 nmod_mat_entry (FLINTN, i, i)= 1; 4042 bufQ= CFArray (factors.length()); 4043 } 4044 #else 3135 4045 if (NTLN.NumRows() != factors.length()) //refined factors 3136 4046 { … … 3138 4048 bufQ= CFArray (factors.length()); 3139 4049 } 4050 #endif 3140 4051 bool useOldQs= false; 3141 4052 CFListIterator j; 3142 4053 CFMatrix C; 3143 4054 CFArray buf; 4055 #ifdef HAVE_FLINT 4056 long rank; 4057 nmod_mat_t FLINTC, FLINTK, null; 4058 #else 3144 4059 mat_zz_p* NTLC, NTLK; 4060 #endif 3145 4061 CanonicalForm bufF, truncF; 3146 4062 CFList bufUniFactors; … … 3178 4094 } 3179 4095 } 4096 #ifdef HAVE_FLINT 4097 convertFacCFMatrix2nmod_mat_t (FLINTC, C); 4098 nmod_mat_init (FLINTK, nmod_mat_nrows (FLINTC), nmod_mat_ncols (FLINTN), 4099 getCharacteristic()); 4100 nmod_mat_mul (FLINTK, FLINTC, FLINTN); 4101 nmod_mat_init (null, nmod_mat_ncols (FLINTK), nmod_mat_ncols (FLINTK), 4102 getCharacteristic()); 4103 rank= nmod_mat_nullspace (null, FLINTK); 4104 nmod_mat_clear (FLINTK); 4105 nmod_mat_window_init (FLINTK, null, 0, 0, nmod_mat_nrows(null), rank); 4106 nmod_mat_clear (FLINTC); 4107 nmod_mat_init_set (FLINTC, FLINTN); 4108 nmod_mat_clear (FLINTN); 4109 nmod_mat_init (FLINTN, nmod_mat_nrows (FLINTC), nmod_mat_ncols (FLINTK), 4110 getCharacteristic()); 4111 nmod_mat_mul (FLINTN, FLINTC, FLINTK); //no aliasing allowed!! 4112 4113 nmod_mat_clear (FLINTC); 4114 nmod_mat_window_clear (FLINTK); 4115 nmod_mat_clear (null); 4116 #else 3180 4117 NTLC= convertFacCFMatrix2NTLmat_zz_p(C); 3181 4118 NTLK= (*NTLC)*NTLN; … … 3184 4121 transpose (NTLK, NTLK); 3185 4122 NTLN *= NTLK; 4123 #endif 4124 #ifdef HAVE_FLINT 4125 if (nmod_mat_ncols (FLINTN) == 1) 4126 #else 3186 4127 if (NTLN.NumCols() == 1) 4128 #endif 3187 4129 { 3188 4130 delete [] A; … … 3191 4133 } 3192 4134 } 4135 #ifdef HAVE_FLINT 4136 if (nmod_mat_ncols (FLINTN) == 1) 4137 #else 3193 4138 if (NTLN.NumCols() == 1) 4139 #endif 3194 4140 { 3195 4141 delete [] A; … … 3197 4143 } 3198 4144 int * zeroOneVecs; 4145 #ifdef HAVE_FLINT 4146 zeroOneVecs= extractZeroOneVecs (FLINTN); 4147 #else 3199 4148 zeroOneVecs= extractZeroOneVecs (NTLN); 4149 #endif 3200 4150 bufF= F; 3201 4151 bufUniFactors= factors; 4152 #ifdef HAVE_FLINT 4153 result= reconstruction (bufF, bufUniFactors, zeroOneVecs, oldL, FLINTN); 4154 #else 3202 4155 result= reconstruction (bufF, bufUniFactors, zeroOneVecs, oldL, NTLN); 4156 #endif 3203 4157 delete [] zeroOneVecs; 3204 4158 if (degree (bufF) + 1 + degree (LC (bufF, 1)) < oldL && result.length() > 0) … … 3501 4455 } 3502 4456 4457 #ifdef HAVE_FLINT 4458 CFList 4459 increasePrecisionFq2Fp (CanonicalForm& F, CFList& factors, int oldL, int l, 4460 int d, int* bounds, CFArray& bufQ, nmod_mat_t FLINTN, 4461 const Variable& alpha 4462 ) 4463 #else 3503 4464 CFList 3504 4465 increasePrecisionFq2Fp (CanonicalForm& F, CFList& factors, int oldL, int l, … … 3506 4467 const Variable& alpha 3507 4468 ) 4469 #endif 3508 4470 { 3509 4471 CFList result= CFList(); … … 3513 4475 bool hitBound= false; 3514 4476 bool useOldQs= false; 4477 #ifdef HAVE_FLINT 4478 if (nmod_mat_nrows (FLINTN) != factors.length()) //refined factors 4479 { 4480 nmod_mat_clear (FLINTN); 4481 nmod_mat_init(FLINTN,factors.length(),factors.length(),getCharacteristic()); 4482 for (long i=factors.length()-1; i >= 0; i--) 4483 nmod_mat_entry (FLINTN, i, i)= 1; 4484 } 4485 #else 3515 4486 if (NTLN.NumRows() != factors.length()) //refined factors 3516 4487 ident (NTLN, factors.length()); 4488 #endif 3517 4489 CFListIterator j; 3518 4490 CFMatrix C; 3519 4491 CFArray buf; 4492 #ifdef HAVE_FLINT 4493 long rank; 4494 nmod_mat_t FLINTC, FLINTK, null; 4495 #else 3520 4496 mat_zz_p* NTLC, NTLK; 4497 #endif 3521 4498 CanonicalForm bufF, truncF; 3522 4499 CFList bufUniFactors; … … 3554 4531 } 3555 4532 } 4533 #ifdef HAVE_FLINT 4534 convertFacCFMatrix2nmod_mat_t (FLINTC, C); 4535 nmod_mat_init (FLINTK, nmod_mat_nrows (FLINTC), nmod_mat_ncols (FLINTN), 4536 getCharacteristic()); 4537 nmod_mat_mul (FLINTK, FLINTC, FLINTN); 4538 nmod_mat_init (null, nmod_mat_ncols (FLINTK), nmod_mat_ncols (FLINTK), 4539 getCharacteristic()); 4540 rank= nmod_mat_nullspace (null, FLINTK); 4541 nmod_mat_clear (FLINTK); 4542 nmod_mat_window_init (FLINTK, null, 0, 0, nmod_mat_nrows(null), rank); 4543 nmod_mat_clear (FLINTC); 4544 nmod_mat_init_set (FLINTC, FLINTN); 4545 nmod_mat_clear (FLINTN); 4546 nmod_mat_init (FLINTN, nmod_mat_nrows (FLINTC), nmod_mat_ncols (FLINTK), 4547 getCharacteristic()); 4548 nmod_mat_mul (FLINTN, FLINTC, FLINTK); //no aliasing allowed!! 4549 4550 nmod_mat_clear (FLINTC); 4551 nmod_mat_window_clear (FLINTK); 4552 nmod_mat_clear (null); 4553 #else 3556 4554 NTLC= convertFacCFMatrix2NTLmat_zz_p(C); 3557 4555 NTLK= (*NTLC)*NTLN; … … 3560 4558 transpose (NTLK, NTLK); 3561 4559 NTLN *= NTLK; 4560 #endif 4561 #ifdef HAVE_FLINT 4562 if (nmod_mat_ncols (FLINTN) == 1) 4563 #else 3562 4564 if (NTLN.NumCols() == 1) 4565 #endif 3563 4566 { 3564 4567 delete [] A; … … 3569 4572 3570 4573 int * zeroOneVecs; 4574 #ifdef HAVE_FLINT 4575 zeroOneVecs= extractZeroOneVecs (FLINTN); 4576 #else 3571 4577 zeroOneVecs= extractZeroOneVecs (NTLN); 4578 #endif 3572 4579 3573 4580 bufF= F; 3574 4581 bufUniFactors= factors; 4582 #ifdef HAVE_FLINT 4583 result= reconstruction (bufF, bufUniFactors, zeroOneVecs, oldL, FLINTN); 4584 #else 3575 4585 result= reconstruction (bufF, bufUniFactors, zeroOneVecs, oldL, NTLN); 4586 #endif 3576 4587 delete [] zeroOneVecs; 3577 4588 if (degree (bufF) + 1 + degree (LC (bufF, 1)) < l && result.length() > 0) … … 3601 4612 } 3602 4613 4614 #ifdef HAVE_FLINT 4615 CFList 4616 furtherLiftingAndIncreasePrecision (CanonicalForm& F, CFList& 4617 factors, int l, int liftBound, int d, int* 4618 bounds, nmod_mat_t FLINTN, CFList& diophant, 4619 CFMatrix& M, CFArray& Pi, CFArray& bufQ 4620 ) 4621 #else 3603 4622 CFList 3604 4623 furtherLiftingAndIncreasePrecision (CanonicalForm& F, CFList& … … 3607 4626 CFMatrix& M, CFArray& Pi, CFArray& bufQ 3608 4627 ) 4628 #endif 3609 4629 { 3610 4630 CanonicalForm LCF= LC (F, 1); … … 3618 4638 int stepSize= 8; //TODO choose better step size? 3619 4639 l += tmax (tmin (8, degree (F) + 1 + degree (LC (F, 1))-l), 2); 4640 #ifdef HAVE_FLINT 4641 if (nmod_mat_nrows (FLINTN) != factors.length()) //refined factors 4642 { 4643 nmod_mat_clear (FLINTN); 4644 nmod_mat_init(FLINTN,factors.length(),factors.length(),getCharacteristic()); 4645 for (long i=factors.length()-1; i >= 0; i--) 4646 nmod_mat_entry (FLINTN, i, i)= 1; 4647 } 4648 #else 3620 4649 if (NTLN.NumRows() != factors.length()) //refined factors 3621 4650 ident (NTLN, factors.length()); 4651 #endif 3622 4652 CFListIterator j; 3623 4653 CFMatrix C; 3624 4654 CFArray buf; 4655 #ifdef HAVE_FLINT 4656 long rank; 4657 nmod_mat_t FLINTC, FLINTK, null; 4658 #else 3625 4659 mat_zz_p* NTLC, NTLK; 4660 #endif 3626 4661 CanonicalForm bufF, truncF; 3627 4662 Variable y= F.mvar(); … … 3659 4694 } 3660 4695 } 4696 #ifdef HAVE_FLINT 4697 convertFacCFMatrix2nmod_mat_t (FLINTC, C); 4698 nmod_mat_init (FLINTK, nmod_mat_nrows (FLINTC), nmod_mat_ncols (FLINTN), 4699 getCharacteristic()); 4700 nmod_mat_mul (FLINTK, FLINTC, FLINTN); 4701 nmod_mat_init (null, nmod_mat_ncols (FLINTK), nmod_mat_ncols (FLINTK), 4702 getCharacteristic()); 4703 rank= nmod_mat_nullspace (null, FLINTK); 4704 nmod_mat_clear (FLINTK); 4705 nmod_mat_window_init (FLINTK, null, 0, 0, nmod_mat_nrows(null), rank); 4706 nmod_mat_clear (FLINTC); 4707 nmod_mat_init_set (FLINTC, FLINTN); 4708 nmod_mat_clear (FLINTN); 4709 nmod_mat_init (FLINTN, nmod_mat_nrows (FLINTC), nmod_mat_ncols (FLINTK), 4710 getCharacteristic()); 4711 nmod_mat_mul (FLINTN, FLINTC, FLINTK); //no aliasing allowed!! 4712 4713 nmod_mat_clear (FLINTC); 4714 nmod_mat_window_clear (FLINTK); 4715 nmod_mat_clear (null); 4716 #else 3661 4717 NTLC= convertFacCFMatrix2NTLmat_zz_p(C); 3662 4718 NTLK= (*NTLC)*NTLN; … … 3665 4721 transpose (NTLK, NTLK); 3666 4722 NTLN *= NTLK; 4723 #endif 4724 #ifdef HAVE_FLINT 4725 if (nmod_mat_ncols (FLINTN) == 1) 4726 #else 3667 4727 if (NTLN.NumCols() == 1) 4728 #endif 3668 4729 { 3669 4730 irreducible= true; … … 3673 4734 } 3674 4735 4736 #ifdef HAVE_FLINT 4737 if (nmod_mat_ncols (FLINTN) == 1) 4738 #else 3675 4739 if (NTLN.NumCols() == 1) 4740 #endif 3676 4741 { 3677 4742 irreducible= true; … … 3679 4744 } 3680 4745 4746 #ifdef HAVE_FLINT 4747 int * zeroOneVecs= extractZeroOneVecs (FLINTN); 4748 #else 3681 4749 int * zeroOneVecs= extractZeroOneVecs (NTLN); 4750 #endif 3682 4751 bufF= F; 4752 #ifdef HAVE_FLINT 4753 result= reconstruction (bufF, bufFactors, zeroOneVecs, l, FLINTN); 4754 #else 3683 4755 result= reconstruction (bufF, bufFactors, zeroOneVecs, l, NTLN); 4756 #endif 3684 4757 delete [] zeroOneVecs; 3685 4758 if (result.length() > 0 && degree (bufF) + 1 + degree (LC (bufF, 1)) <= l) … … 3691 4764 } 3692 4765 4766 #ifdef HAVE_FLINT 4767 if (isReduced (FLINTN)) 4768 #else 3693 4769 if (isReduced (NTLN)) 4770 #endif 3694 4771 { 3695 4772 int factorsFound= 0; 3696 4773 bufF= F; 4774 #ifdef HAVE_FLINT 4775 int* factorsFoundIndex= new int [nmod_mat_ncols (FLINTN)]; 4776 for (long i= 0; i < nmod_mat_ncols (FLINTN); i++) 4777 #else 3697 4778 int* factorsFoundIndex= new int [NTLN.NumCols()]; 3698 4779 for (long i= 0; i < NTLN.NumCols(); i++) 4780 #endif 3699 4781 factorsFoundIndex[i]= 0; 4782 #ifdef HAVE_FLINT 4783 if (l < liftBound) 4784 reconstructionTry (result, bufF, bufFactors, l, factorsFound, 4785 factorsFoundIndex, FLINTN, false 4786 ); 4787 else 4788 reconstructionTry (result, bufF, bufFactors, degree (bufF) + 1 + 4789 degree (LCF), factorsFound, factorsFoundIndex, 4790 FLINTN, false 4791 ); 4792 4793 if (nmod_mat_ncols (FLINTN) == result.length()) 4794 #else 3700 4795 if (l < liftBound) 3701 4796 reconstructionTry (result, bufF, bufFactors, l, factorsFound, … … 3709 4804 3710 4805 if (NTLN.NumCols() == result.length()) 4806 #endif 3711 4807 { 3712 4808 delete [] A; … … 4080 5176 } 4081 5177 5178 #ifdef HAVE_FLINT 5179 CFList 5180 furtherLiftingAndIncreasePrecisionFq2Fp (CanonicalForm& F, CFList& factors, int 5181 l, int liftBound, int d, int* bounds, 5182 nmod_mat_t FLINTN, CFList& diophant, 5183 CFMatrix& M, CFArray& Pi, CFArray& bufQ, 5184 const Variable& alpha 5185 ) 5186 #else 4082 5187 CFList 4083 5188 furtherLiftingAndIncreasePrecisionFq2Fp (CanonicalForm& F, CFList& factors, int … … 4087 5192 const Variable& alpha 4088 5193 ) 5194 #endif 4089 5195 { 4090 5196 CanonicalForm LCF= LC (F, 1); … … 4099 5205 int stepSize= 8; //TODO choose better step size? 4100 5206 l += tmax (tmin (8, degree (F) + 1 + degree (LC (F, 1))-l), 2); 5207 #ifdef HAVE_FLINT 5208 if (nmod_mat_nrows (FLINTN) != factors.length()) //refined factors 5209 { 5210 nmod_mat_clear (FLINTN); 5211 nmod_mat_init(FLINTN,factors.length(),factors.length(),getCharacteristic()); 5212 for (long i=factors.length()-1; i >= 0; i--) 5213 nmod_mat_entry (FLINTN, i, i)= 1; 5214 } 5215 #else 4101 5216 if (NTLN.NumRows() != factors.length()) //refined factors 4102 5217 ident (NTLN, factors.length()); 5218 #endif 4103 5219 CFListIterator j; 4104 5220 CFMatrix C; 5221 #ifdef HAVE_FLINT 5222 long rank; 5223 nmod_mat_t FLINTC, FLINTK, null; 5224 #else 4105 5225 mat_zz_p* NTLC, NTLK; 5226 #endif 4106 5227 CanonicalForm bufF, truncF; 4107 5228 Variable y= F.mvar(); … … 4138 5259 } 4139 5260 } 5261 #ifdef HAVE_FLINT 5262 convertFacCFMatrix2nmod_mat_t (FLINTC, C); 5263 nmod_mat_init (FLINTK, nmod_mat_nrows (FLINTC), nmod_mat_ncols (FLINTN), 5264 getCharacteristic()); 5265 nmod_mat_mul (FLINTK, FLINTC, FLINTN); 5266 nmod_mat_init (null, nmod_mat_ncols (FLINTK), nmod_mat_ncols (FLINTK), 5267 getCharacteristic()); 5268 rank= nmod_mat_nullspace (null, FLINTK); 5269 nmod_mat_clear (FLINTK); 5270 nmod_mat_window_init (FLINTK, null, 0, 0, nmod_mat_nrows(null), rank); 5271 nmod_mat_clear (FLINTC); 5272 nmod_mat_init_set (FLINTC, FLINTN); 5273 nmod_mat_clear (FLINTN); 5274 nmod_mat_init (FLINTN, nmod_mat_nrows (FLINTC), nmod_mat_ncols (FLINTK), 5275 getCharacteristic()); 5276 nmod_mat_mul (FLINTN, FLINTC, FLINTK); //no aliasing allowed!! 5277 5278 nmod_mat_clear (FLINTC); 5279 nmod_mat_window_clear (FLINTK); 5280 nmod_mat_clear (null); 5281 #else 4140 5282 NTLC= convertFacCFMatrix2NTLmat_zz_p(C); 4141 5283 NTLK= (*NTLC)*NTLN; … … 4144 5286 transpose (NTLK, NTLK); 4145 5287 NTLN *= NTLK; 5288 #endif 5289 #ifdef HAVE_FLINT 5290 if (nmod_mat_ncols (FLINTN) == 1) 5291 #else 4146 5292 if (NTLN.NumCols() == 1) 5293 #endif 4147 5294 { 4148 5295 irreducible= true; … … 4151 5298 } 4152 5299 } 5300 #ifdef HAVE_FLINT 5301 if (nmod_mat_ncols (FLINTN) == 1) 5302 #else 4153 5303 if (NTLN.NumCols() == 1) 5304 #endif 4154 5305 { 4155 5306 irreducible= true; … … 4157 5308 } 4158 5309 5310 #ifdef HAVE_FLINT 5311 int * zeroOneVecs= extractZeroOneVecs (FLINTN); 5312 #else 4159 5313 int * zeroOneVecs= extractZeroOneVecs (NTLN); 5314 #endif 4160 5315 CanonicalForm bufF= F; 5316 #ifdef HAVE_FLINT 5317 result= reconstruction (bufF, bufFactors, zeroOneVecs, l, FLINTN); 5318 #else 4161 5319 result= reconstruction (bufF, bufFactors, zeroOneVecs, l, NTLN); 5320 #endif 4162 5321 delete [] zeroOneVecs; 4163 5322 if (result.length() > 0 && degree (bufF) + 1 + degree (LC (bufF, 1)) <= l) … … 4169 5328 } 4170 5329 5330 #ifdef HAVE_FLINT 5331 if (isReduced (FLINTN)) 5332 #else 4171 5333 if (isReduced (NTLN)) 5334 #endif 4172 5335 { 4173 5336 int factorsFound= 0; 4174 5337 bufF= F; 5338 #ifdef HAVE_FLINT 5339 int* factorsFoundIndex= new int [nmod_mat_ncols (FLINTN)]; 5340 for (long i= 0; i < nmod_mat_ncols (FLINTN); i++) 5341 #else 4175 5342 int* factorsFoundIndex= new int [NTLN.NumCols()]; 4176 5343 for (long i= 0; i < NTLN.NumCols(); i++) 5344 #endif 4177 5345 factorsFoundIndex[i]= 0; 5346 #ifdef HAVE_FLINT 5347 if (l < degree (bufF) + 1 + degree (LCF)) 5348 reconstructionTry (result, bufF, bufFactors, l, factorsFound, 5349 factorsFoundIndex, FLINTN, false 5350 ); 5351 else 5352 reconstructionTry (result, bufF, bufFactors, degree (bufF) + 1 + 5353 degree (LCF), factorsFound, factorsFoundIndex, 5354 FLINTN, false 5355 ); 5356 if (nmod_mat_ncols (FLINTN) == result.length()) 5357 #else 4178 5358 if (l < degree (bufF) + 1 + degree (LCF)) 4179 5359 reconstructionTry (result, bufF, bufFactors, l, factorsFound, … … 4186 5366 ); 4187 5367 if (NTLN.NumCols() == result.length()) 5368 #endif 4188 5369 { 4189 5370 delete [] A; … … 4248 5429 } 4249 5430 5431 #ifdef HAVE_FLINT 5432 void 5433 refineAndRestartLift (const CanonicalForm& F, const nmod_mat_t FLINTN, int 5434 liftBound, int l, CFList& factors, CFMatrix& M, CFArray& 5435 Pi, CFList& diophant 5436 ) 5437 { 5438 CFList bufFactors; 5439 Variable y= Variable (2); 5440 CanonicalForm LCF= LC (F, 1); 5441 CFListIterator iter; 5442 CanonicalForm buf; 5443 for (long i= 0; i < nmod_mat_ncols (FLINTN); i++) 5444 { 5445 iter= factors; 5446 buf= 1; 5447 for (long j= 0; j < nmod_mat_nrows (FLINTN); j++, iter++) 5448 { 5449 if (!(nmod_mat_entry (FLINTN,j,i) == 0)) 5450 buf= mulNTL (buf, mod (iter.getItem(), y)); 5451 } 5452 bufFactors.append (buf); 5453 } 5454 factors= bufFactors; 5455 M= CFMatrix (liftBound, factors.length()); 5456 Pi= CFArray(); 5457 diophant= CFList(); 5458 factors.insert (LCF); 5459 henselLift12 (F, factors, l, Pi, diophant, M); 5460 } 5461 #endif 5462 4250 5463 void 4251 5464 refineAndRestartLift (const CanonicalForm& F, const mat_zz_pE& NTLN, int … … 4278 5491 } 4279 5492 5493 #ifdef HAVE_FLINT 5494 CFList 5495 earlyReconstructionAndLifting (const CanonicalForm& F, const nmod_mat_t N, 5496 CanonicalForm& bufF, CFList& factors, int& l, 5497 int& factorsFound, bool beenInThres, CFMatrix& M, 5498 CFArray& Pi, CFList& diophant, bool symmetric, 5499 const CanonicalForm& evaluation 5500 ) 5501 #else 4280 5502 CFList 4281 5503 earlyReconstructionAndLifting (const CanonicalForm& F, const mat_zz_p& N, 5504 CanonicalForm& bufF, CFList& factors, int& l, 5505 int& factorsFound, bool beenInThres, CFMatrix& M, 5506 CFArray& Pi, CFList& diophant, bool symmetric, 5507 const CanonicalForm& evaluation 5508 ) 5509 #endif 5510 { 5511 int sizeOfLiftPre; 5512 int * liftPre= getLiftPrecisions (F, sizeOfLiftPre, degree (LC (F, 1), 2)); 5513 5514 Variable y= F.mvar(); 5515 factorsFound= 0; 5516 CanonicalForm LCF= LC (F, 1); 5517 CFList result; 5518 int smallFactorDeg= tmin (11, liftPre [sizeOfLiftPre- 1] + 1); 5519 #ifdef HAVE_FLINT 5520 nmod_mat_t FLINTN; 5521 nmod_mat_init_set (FLINTN, N); 5522 int * factorsFoundIndex= new int [nmod_mat_ncols (FLINTN)]; 5523 for (long i= 0; i < nmod_mat_ncols (FLINTN); i++) 5524 #else 5525 mat_zz_p NTLN= N; 5526 int * factorsFoundIndex= new int [NTLN.NumCols()]; 5527 for (long i= 0; i < NTLN.NumCols(); i++) 5528 #endif 5529 factorsFoundIndex [i]= 0; 5530 5531 if (degree (F) + 1 > smallFactorDeg) 5532 { 5533 if (l < smallFactorDeg) 5534 { 5535 factors.insert (LCF); 5536 henselLiftResume12 (F, factors, l, smallFactorDeg, Pi, diophant, M); 5537 l= smallFactorDeg; 5538 } 5539 #ifdef HAVE_FLINT 5540 reconstructionTry (result, bufF, factors, smallFactorDeg, factorsFound, 5541 factorsFoundIndex, FLINTN, beenInThres 5542 ); 5543 if (result.length() == nmod_mat_ncols (FLINTN)) 5544 { 5545 nmod_mat_clear (FLINTN); 5546 #else 5547 reconstructionTry (result, bufF, factors, smallFactorDeg, factorsFound, 5548 factorsFoundIndex, NTLN, beenInThres 5549 ); 5550 if (result.length() == NTLN.NumCols()) 5551 { 5552 #endif 5553 delete [] liftPre; 5554 delete [] factorsFoundIndex; 5555 return result; 5556 } 5557 } 5558 5559 int i= sizeOfLiftPre - 1; 5560 int dummy= 1; 5561 if (sizeOfLiftPre > 1 && sizeOfLiftPre < 30) 5562 { 5563 while (i > 0) 5564 { 5565 if (l < liftPre[i-1] + 1) 5566 { 5567 factors.insert (LCF); 5568 henselLiftResume12 (F, factors, l, liftPre[i-1] + 1, Pi, diophant, M); 5569 l= liftPre[i-1] + 1; 5570 } 5571 else 5572 { 5573 i--; 5574 if (i != 0) 5575 continue; 5576 } 5577 #ifdef HAVE_FLINT 5578 reconstructionTry (result, bufF, factors, l, factorsFound, 5579 factorsFoundIndex, FLINTN, beenInThres 5580 ); 5581 if (result.length() == nmod_mat_ncols (FLINTN)) 5582 { 5583 nmod_mat_clear (FLINTN); 5584 #else 5585 reconstructionTry (result, bufF, factors, l, factorsFound, 5586 factorsFoundIndex, NTLN, beenInThres 5587 ); 5588 if (result.length() == NTLN.NumCols()) 5589 { 5590 #endif 5591 delete [] liftPre; 5592 delete [] factorsFoundIndex; 5593 return result; 5594 } 5595 i--; 5596 } 5597 } 5598 else 5599 { 5600 i= 1; 5601 while ((degree (F,y)/4)*i + 4 <= smallFactorDeg) 5602 i++; 5603 while (i < 5) 5604 { 5605 dummy= tmin (degree (F,y)+1, (degree (F,y)/4)*i+4); 5606 if (l < dummy) 5607 { 5608 factors.insert (LCF); 5609 henselLiftResume12 (F, factors, l, dummy, Pi, diophant, M); 5610 l= dummy; 5611 if (i == 1 && degree (F)%4==0 && symmetric && factors.length() == 2 && 5612 LC (F,1).inCoeffDomain() && 5613 (degree (factors.getFirst(), 1) == degree (factors.getLast(),1))) 5614 { 5615 Variable x= Variable (1); 5616 CanonicalForm g, h, gg, hh, multiplier1, multiplier2, check1, check2; 5617 int m= degree (F)/4+1; 5618 g= factors.getFirst(); 5619 h= factors.getLast(); 5620 g= mod (g, power (y,m)); 5621 h= mod (h, power (y,m)); 5622 g= g (y-evaluation, y); 5623 h= h (y-evaluation, y); 5624 gg= mod (swapvar (g,x,y),power (x,m)); 5625 gg= gg (y + evaluation, y); 5626 multiplier1= factors.getLast()[m-1][0]/gg[m-1][0]; 5627 gg= div (gg, power (y,m)); 5628 gg= gg*power (y,m); 5629 hh= mod (swapvar (h,x,y),power (x,m)); 5630 hh= hh (y + evaluation, y); 5631 multiplier2= factors.getFirst()[m-1][0]/hh[m-1][0]; 5632 hh= div (hh, power (y,m)); 5633 hh= hh*power (y,m); 5634 gg= multiplier1*gg+mod (factors.getLast(), power (y,m)); 5635 hh= multiplier2*hh+mod (factors.getFirst(), power (y,m)); 5636 check1= gg (y-evaluation,y); 5637 check2= hh (y-evaluation,y); 5638 check1= swapvar (check1, x, y); 5639 if (check1/Lc (check1) == check2/Lc (check2)) 5640 { 5641 #ifdef HAVE_FLINT 5642 nmod_mat_clear (FLINTN); 5643 #endif 5644 result.append (gg); 5645 result.append (hh); 5646 delete [] liftPre; 5647 delete [] factorsFoundIndex; 5648 return result; 5649 } 5650 } 5651 } 5652 else 5653 { 5654 i++; 5655 if (i < 5) 5656 continue; 5657 } 5658 #ifdef HAVE_FLINT 5659 reconstructionTry (result, bufF, factors, l, factorsFound, 5660 factorsFoundIndex, FLINTN, beenInThres 5661 ); 5662 if (result.length() == nmod_mat_ncols (FLINTN)) 5663 { 5664 nmod_mat_clear (FLINTN); 5665 #else 5666 reconstructionTry (result, bufF, factors, l, factorsFound, 5667 factorsFoundIndex, NTLN, beenInThres 5668 ); 5669 if (result.length() == NTLN.NumCols()) 5670 { 5671 #endif 5672 delete [] liftPre; 5673 delete [] factorsFoundIndex; 5674 return result; 5675 } 5676 i++; 5677 } 5678 } 5679 5680 #ifdef HAVE_FLINT 5681 nmod_mat_clear (FLINTN); 5682 #endif 5683 delete [] liftPre; 5684 delete [] factorsFoundIndex; 5685 return result; 5686 } 5687 5688 CFList 5689 earlyReconstructionAndLifting (const CanonicalForm& F, const mat_zz_pE& N, 4282 5690 CanonicalForm& bufF, CFList& factors, int& l, 4283 5691 int& factorsFound, bool beenInThres, CFMatrix& M, … … 4288 5696 int sizeOfLiftPre; 4289 5697 int * liftPre= getLiftPrecisions (F, sizeOfLiftPre, degree (LC (F, 1), 2)); 4290 4291 5698 Variable y= F.mvar(); 4292 5699 factorsFound= 0; 4293 5700 CanonicalForm LCF= LC (F, 1); 4294 5701 CFList result; 4295 int smallFactorDeg= tmin (11, liftPre [sizeOfLiftPre- 1] + 1);4296 mat_zz_p NTLN= N;5702 int smallFactorDeg= 11; 5703 mat_zz_pE NTLN= N; 4297 5704 int * factorsFoundIndex= new int [NTLN.NumCols()]; 4298 5705 for (long i= 0; i < NTLN.NumCols(); i++) … … 4423 5830 } 4424 5831 4425 CFList4426 earlyReconstructionAndLifting (const CanonicalForm& F, const mat_zz_pE& N,4427 CanonicalForm& bufF, CFList& factors, int& l,4428 int& factorsFound, bool beenInThres, CFMatrix& M,4429 CFArray& Pi, CFList& diophant, bool symmetric,4430 const CanonicalForm& evaluation4431 )4432 {4433 int sizeOfLiftPre;4434 int * liftPre= getLiftPrecisions (F, sizeOfLiftPre, degree (LC (F, 1), 2));4435 Variable y= F.mvar();4436 factorsFound= 0;4437 CanonicalForm LCF= LC (F, 1);4438 CFList result;4439 int smallFactorDeg= 11;4440 mat_zz_pE NTLN= N;4441 int * factorsFoundIndex= new int [NTLN.NumCols()];4442 for (long i= 0; i < NTLN.NumCols(); i++)4443 factorsFoundIndex [i]= 0;4444 4445 if (degree (F) + 1 > smallFactorDeg)4446 {4447 if (l < smallFactorDeg)4448 {4449 factors.insert (LCF);4450 henselLiftResume12 (F, factors, l, smallFactorDeg, Pi, diophant, M);4451 l= smallFactorDeg;4452 }4453 reconstructionTry (result, bufF, factors, smallFactorDeg, factorsFound,4454 factorsFoundIndex, NTLN, beenInThres4455 );4456 if (result.length() == NTLN.NumCols())4457 {4458 delete [] liftPre;4459 delete [] factorsFoundIndex;4460 return result;4461 }4462 }4463 4464 int i= sizeOfLiftPre - 1;4465 int dummy= 1;4466 if (sizeOfLiftPre > 1 && sizeOfLiftPre < 30)4467 {4468 while (i > 0)4469 {4470 if (l < liftPre[i-1] + 1)4471 {4472 factors.insert (LCF);4473 henselLiftResume12 (F, factors, l, liftPre[i-1] + 1, Pi, diophant, M);4474 l= liftPre[i-1] + 1;4475 }4476 else4477 {4478 i--;4479 if (i != 0)4480 continue;4481 }4482 reconstructionTry (result, bufF, factors, l, factorsFound,4483 factorsFoundIndex, NTLN, beenInThres4484 );4485 if (result.length() == NTLN.NumCols())4486 {4487 delete [] liftPre;4488 delete [] factorsFoundIndex;4489 return result;4490 }4491 i--;4492 }4493 }4494 else4495 {4496 i= 1;4497 while ((degree (F,y)/4)*i + 4 <= smallFactorDeg)4498 i++;4499 while (i < 5)4500 {4501 dummy= tmin (degree (F,y)+1, (degree (F,y)/4)*i+4);4502 if (l < dummy)4503 {4504 factors.insert (LCF);4505 henselLiftResume12 (F, factors, l, dummy, Pi, diophant, M);4506 l= dummy;4507 if (i == 1 && degree (F)%4==0 && symmetric && factors.length() == 2 &&4508 LC (F,1).inCoeffDomain() &&4509 (degree (factors.getFirst(), 1) == degree (factors.getLast(),1)))4510 {4511 Variable x= Variable (1);4512 CanonicalForm g, h, gg, hh, multiplier1, multiplier2, check1, check2;4513 int m= degree (F)/4+1;4514 g= factors.getFirst();4515 h= factors.getLast();4516 g= mod (g, power (y,m));4517 h= mod (h, power (y,m));4518 g= g (y-evaluation, y);4519 h= h (y-evaluation, y);4520 gg= mod (swapvar (g,x,y),power (x,m));4521 gg= gg (y + evaluation, y);4522 multiplier1= factors.getLast()[m-1][0]/gg[m-1][0];4523 gg= div (gg, power (y,m));4524 gg= gg*power (y,m);4525 hh= mod (swapvar (h,x,y),power (x,m));4526 hh= hh (y + evaluation, y);4527 multiplier2= factors.getFirst()[m-1][0]/hh[m-1][0];4528 hh= div (hh, power (y,m));4529 hh= hh*power (y,m);4530 gg= multiplier1*gg+mod (factors.getLast(), power (y,m));4531 hh= multiplier2*hh+mod (factors.getFirst(), power (y,m));4532 check1= gg (y-evaluation,y);4533 check2= hh (y-evaluation,y);4534 check1= swapvar (check1, x, y);4535 if (check1/Lc (check1) == check2/Lc (check2))4536 {4537 result.append (gg);4538 result.append (hh);4539 delete [] liftPre;4540 delete [] factorsFoundIndex;4541 return result;4542 }4543 }4544 }4545 else4546 {4547 i++;4548 if (i < 5)4549 continue;4550 }4551 reconstructionTry (result, bufF, factors, l, factorsFound,4552 factorsFoundIndex, NTLN, beenInThres4553 );4554 if (result.length() == NTLN.NumCols())4555 {4556 delete [] liftPre;4557 delete [] factorsFoundIndex;4558 return result;4559 }4560 i++;4561 }4562 }4563 4564 delete [] liftPre;4565 delete [] factorsFoundIndex;4566 return result;4567 }4568 4569 5832 //over field extension 4570 5833 CFList … … 4892 6155 int l= 1; 4893 6156 6157 #ifdef HAVE_FLINT 6158 nmod_mat_t FLINTN; 6159 #else 4894 6160 zz_p::init (getCharacteristic()); 4895 6161 mat_zz_p NTLN; 6162 #endif 6163 4896 6164 if (alpha.level() != 1) 4897 6165 { … … 4901 6169 mat_zz_pE NTLNe; 4902 6170 if (alpha.level() == 1) 6171 { 6172 #ifdef HAVE_FLINT 6173 nmod_mat_init (FLINTN, bufUniFactors.length()-1, bufUniFactors.length()-1, getCharacteristic()); 6174 for (long i= bufUniFactors.length()-2; i >= 0; i--) 6175 nmod_mat_entry (FLINTN, i, i)= 1; 6176 #else 4903 6177 ident (NTLN, bufUniFactors.length() - 1); 6178 #endif 6179 } 4904 6180 else 4905 6181 { 4906 6182 if (reduceFq2Fp) 6183 #ifdef HAVE_FLINT 6184 { 6185 nmod_mat_init (FLINTN, bufUniFactors.length()-1, bufUniFactors.length()-1, getCharacteristic()); 6186 for (long i= bufUniFactors.length()-2; i >= 0; i--) 6187 nmod_mat_entry (FLINTN, i, i)= 1; 6188 } 6189 #else 4907 6190 ident (NTLN, bufUniFactors.length() - 1); 6191 #endif 4908 6192 else 4909 6193 ident (NTLNe, bufUniFactors.length() - 1); … … 4918 6202 if (alpha.level() == 1) 4919 6203 oldL= liftAndComputeLattice (F, bounds, d, start, liftBound, minBound, 6204 #ifdef HAVE_FLINT 6205 bufUniFactors, FLINTN, diophant, M, Pi, bufQ, 6206 #else 4920 6207 bufUniFactors, NTLN, diophant, M, Pi, bufQ, 6208 #endif 4921 6209 irreducible 4922 6210 ); … … 4925 6213 if (reduceFq2Fp) 4926 6214 oldL= liftAndComputeLatticeFq2Fp (F, bounds, d, start, liftBound, 6215 #ifdef HAVE_FLINT 6216 minBound, bufUniFactors, FLINTN, 6217 #else 4927 6218 minBound, bufUniFactors, NTLN, 6219 #endif 4928 6220 diophant, M, Pi, bufQ, irreducible, 4929 6221 alpha … … 4939 6231 { 4940 6232 if (alpha.level() == 1) 6233 { 4941 6234 oldL= liftAndComputeLattice (F, bounds, d, minBound + 1, liftBound, 6235 #ifdef HAVE_FLINT 6236 minBound, bufUniFactors, FLINTN, diophant, M, 6237 #else 4942 6238 minBound, bufUniFactors, NTLN, diophant, M, 6239 #endif 4943 6240 Pi, bufQ, irreducible 4944 6241 ); 6242 } 4945 6243 else 4946 6244 { … … 4948 6246 oldL= liftAndComputeLatticeFq2Fp (F, bounds, d, minBound + 1, 4949 6247 liftBound, minBound, bufUniFactors, 6248 #ifdef HAVE_FLINT 6249 FLINTN, diophant, M, Pi, bufQ, 6250 #else 4950 6251 NTLN, diophant, M, Pi, bufQ, 6252 #endif 4951 6253 irreducible, alpha 4952 6254 ); … … 4962 6264 if (oldL > liftBound) 4963 6265 { 6266 #ifdef HAVE_FLINT 6267 nmod_mat_clear (FLINTN); 6268 #endif 4964 6269 delete [] bounds; 4965 6270 return Union (smallFactors, … … 4974 6279 if (irreducible) 4975 6280 { 6281 #ifdef HAVE_FLINT 6282 nmod_mat_clear (FLINTN); 6283 #endif 4976 6284 delete [] bounds; 4977 6285 return Union (CFList (F), smallFactors); … … 4986 6294 if (alpha.level() == 1 || (alpha.level() != 1 && reduceFq2Fp)) 4987 6295 { 6296 #ifdef HAVE_FLINT 6297 factorsFoundIndex= new int [nmod_mat_ncols (FLINTN)]; 6298 for (long i= 0; i < nmod_mat_ncols (FLINTN); i++) 6299 #else 4988 6300 factorsFoundIndex= new int [NTLN.NumCols()]; 4989 6301 for (long i= 0; i < NTLN.NumCols(); i++) 6302 #endif 4990 6303 factorsFoundIndex[i]= 0; 4991 6304 } … … 5000 6313 if (alpha.level() == 1 || (alpha.level() != 1 && reduceFq2Fp)) 5001 6314 reconstructionTry (result, bufF, bufUniFactors, degree (F) + 1, 6315 #ifdef HAVE_FLINT 6316 factorsFound, factorsFoundIndex, FLINTN, false 6317 #else 5002 6318 factorsFound, factorsFoundIndex, NTLN, false 6319 #endif 5003 6320 ); 5004 6321 else … … 5008 6325 if (alpha.level() == 1 || (alpha.level() != 1 && reduceFq2Fp)) 5009 6326 { 6327 #ifdef HAVE_FLINT 6328 if (result.length() == nmod_mat_ncols (FLINTN)) 6329 { 6330 nmod_mat_clear (FLINTN); 6331 #else 5010 6332 if (result.length() == NTLN.NumCols()) 5011 6333 { 6334 #endif 5012 6335 delete [] factorsFoundIndex; 5013 6336 delete [] bounds; … … 5019 6342 if (result.length() == NTLNe.NumCols()) 5020 6343 { 6344 #ifdef HAVE_FLINT 6345 nmod_mat_clear (FLINTN); 6346 #endif 5021 6347 delete [] factorsFoundIndex; 5022 6348 delete [] bounds; … … 5031 6357 if (alpha.level() == 1 || (alpha.level() != 1 && reduceFq2Fp)) 5032 6358 { 6359 #ifdef HAVE_FLINT 6360 factorsFoundIndex= new int [nmod_mat_ncols (FLINTN)]; 6361 for (long i= 0; i < nmod_mat_ncols (FLINTN); i++) 6362 #else 5033 6363 factorsFoundIndex= new int [NTLN.NumCols()]; 5034 6364 for (long i= 0; i < NTLN.NumCols(); i++) 6365 #endif 5035 6366 factorsFoundIndex[i]= 0; 5036 6367 } … … 5045 6376 if (alpha.level() == 1 || (alpha.level() != 1 && reduceFq2Fp)) 5046 6377 reconstructionTry (result, bufF, bufUniFactors, degree (F) + 1 + degree 6378 #ifdef HAVE_FLINT 6379 (LCF), factorsFound, factorsFoundIndex, FLINTN, false 6380 #else 5047 6381 (LCF), factorsFound, factorsFoundIndex, NTLN, false 6382 #endif 5048 6383 ); 5049 6384 else … … 5053 6388 if (alpha.level() == 1 || (alpha.level() != 1 && reduceFq2Fp)) 5054 6389 { 6390 #ifdef HAVE_FLINT 6391 if (result.length() == nmod_mat_ncols(FLINTN)) 6392 { 6393 nmod_mat_clear (FLINTN); 6394 #else 5055 6395 if (result.length() == NTLN.NumCols()) 5056 6396 { 6397 #endif 5057 6398 delete [] factorsFoundIndex; 5058 6399 delete [] bounds; … … 5064 6405 if (result.length() == NTLNe.NumCols()) 5065 6406 { 6407 #ifdef HAVE_FLINT 6408 nmod_mat_clear (FLINTN); 6409 #endif 5066 6410 delete [] factorsFoundIndex; 5067 6411 delete [] bounds; … … 5079 6423 if (alpha.level() == 1 || (alpha.level() != 1 && reduceFq2Fp)) 5080 6424 { 6425 #ifdef HAVE_FLINT 6426 if (nmod_mat_ncols (FLINTN) < bufUniFactors.length()) 6427 { 6428 refineAndRestartLift (F, FLINTN, liftBound, l, bufUniFactors, M, Pi, 6429 #else 5081 6430 if (NTLN.NumCols() < bufUniFactors.length()) 5082 6431 { 5083 6432 refineAndRestartLift (F, NTLN, liftBound, l, bufUniFactors, M, Pi, 6433 #endif 5084 6434 diophant 5085 6435 ); … … 5103 6453 if (alpha.level() == 1 || (alpha.level() != 1 && reduceFq2Fp)) 5104 6454 { 6455 #ifdef HAVE_FLINT 6456 result= earlyReconstructionAndLifting (F, FLINTN, bufF, bufUniFactors, l, 6457 #else 5105 6458 result= earlyReconstructionAndLifting (F, NTLN, bufF, bufUniFactors, l, 6459 #endif 5106 6460 factorsFound, beenInThres, M, Pi, 5107 6461 diophant, symmetric, evaluation 5108 6462 ); 5109 6463 6464 #ifdef HAVE_FLINT 6465 if (result.length() == nmod_mat_ncols (FLINTN)) 6466 { 6467 nmod_mat_clear (FLINTN); 6468 #else 5110 6469 if (result.length() == NTLN.NumCols()) 5111 6470 { 6471 #endif 5112 6472 delete [] bounds; 5113 6473 return Union (result, smallFactors); … … 5123 6483 if (result.length() == NTLNe.NumCols()) 5124 6484 { 6485 #ifdef HAVE_FLINT 6486 nmod_mat_clear (FLINTN); 6487 #endif 5125 6488 delete [] bounds; 5126 6489 return Union (result, smallFactors); … … 5157 6520 if (alpha.level() == 1 || (alpha.level() != 1 && reduceFq2Fp)) 5158 6521 { 6522 #ifdef HAVE_FLINT 6523 numCols= nmod_mat_ncols (FLINTN); 6524 numRows= nmod_mat_nrows (FLINTN); 6525 zeroOne= extractZeroOneVecs (FLINTN); 6526 #else 5159 6527 numCols= NTLN.NumCols(); 5160 6528 numRows= NTLN.NumRows(); 5161 6529 zeroOne= extractZeroOneVecs (NTLN); 6530 #endif 5162 6531 } 5163 6532 else … … 5183 6552 if (alpha.level() == 1 || (alpha.level() != 1 && reduceFq2Fp)) 5184 6553 { 6554 #ifdef HAVE_FLINT 6555 if (!(nmod_mat_entry (FLINTN, j,i) == 0)) 6556 #else 5185 6557 if (!IsZero (NTLN (j + 1,i + 1))) 6558 #endif 5186 6559 { 5187 6560 factorsConsidered.append (iter.getItem()); … … 5220 6593 if (alpha.level() == 1) 5221 6594 { 6595 #ifdef HAVE_FLINT 6596 oldNumCols= nmod_mat_ncols (FLINTN); 6597 #else 5222 6598 oldNumCols= NTLN.NumCols(); 6599 #endif 5223 6600 resultBufF= increasePrecision (bufF, bufUniFactors, factorsFound, 5224 6601 oldNumCols, oldL, l … … 5229 6606 if (reduceFq2Fp) 5230 6607 { 6608 #ifdef HAVE_FLINT 6609 oldNumCols= nmod_mat_ncols (FLINTN); 6610 #else 5231 6611 oldNumCols= NTLN.NumCols(); 6612 #endif 5232 6613 5233 6614 resultBufF= increasePrecisionFq2Fp (bufF, bufUniFactors, factorsFound, … … 5247 6628 if (bufUniFactors.isEmpty() || degree (bufF) <= 0) 5248 6629 { 6630 #ifdef HAVE_FLINT 6631 nmod_mat_clear (FLINTN); 6632 #endif 5249 6633 delete [] bounds; 5250 6634 result= Union (resultBufF, result); … … 5263 6647 if (degs.getLength() == 1 || bufUniFactors.length() == 1) 5264 6648 { 6649 #ifdef HAVE_FLINT 6650 nmod_mat_clear (FLINTN); 6651 #endif 5265 6652 result.append (bufF); 5266 6653 return result; 5267 6654 } 6655 #ifdef HAVE_FLINT 6656 nmod_mat_clear (FLINTN); 6657 #endif 5268 6658 return Union (result, henselLiftAndLatticeRecombi (bufF, bufUniFactors, 5269 6659 alpha, degs, symmetric, … … 5278 6668 { 5279 6669 result=increasePrecision (F, bufUniFactors, oldL, l, d, bounds, bufQ, 6670 #ifdef HAVE_FLINT 6671 FLINTN 6672 #else 5280 6673 NTLN 6674 #endif 5281 6675 ); 5282 6676 } … … 5286 6680 { 5287 6681 result=increasePrecisionFq2Fp (F, bufUniFactors, oldL, l, d, bounds, 6682 #ifdef HAVE_FLINT 6683 bufQ, FLINTN, alpha 6684 #else 5288 6685 bufQ, NTLN, alpha 6686 #endif 5289 6687 ); 5290 6688 } … … 5298 6696 if (alpha.level() == 1 || (alpha.level() != 1 && reduceFq2Fp)) 5299 6697 { 6698 #ifdef HAVE_FLINT 6699 if (result.length()== nmod_mat_ncols (FLINTN)) 6700 { 6701 nmod_mat_clear (FLINTN); 6702 #else 5300 6703 if (result.length()== NTLN.NumCols()) 5301 6704 { 6705 #endif 5302 6706 delete [] bounds; 5303 6707 result= Union (result, smallFactors); … … 5309 6713 if (result.length()== NTLNe.NumCols()) 5310 6714 { 6715 #ifdef HAVE_FLINT 6716 nmod_mat_clear (FLINTN); 6717 #endif 5311 6718 delete [] bounds; 5312 6719 result= Union (result, smallFactors); … … 5319 6726 if (alpha.level() == 1) 5320 6727 result= furtherLiftingAndIncreasePrecision (F,bufUniFactors, l, 6728 #ifdef HAVE_FLINT 6729 liftBound,d,bounds,FLINTN, 6730 #else 5321 6731 liftBound, d, bounds, NTLN, 6732 #endif 5322 6733 diophant, M, Pi, bufQ 5323 6734 ); … … 5327 6738 result= furtherLiftingAndIncreasePrecisionFq2Fp (F,bufUniFactors, l, 5328 6739 liftBound, d, bounds, 6740 #ifdef HAVE_FLINT 6741 FLINTN, diophant, M, 6742 #else 5329 6743 NTLN, diophant, M, 6744 #endif 5330 6745 Pi, bufQ, alpha 5331 6746 ); … … 5340 6755 if (alpha.level() == 1 || (alpha.level() != 1 && reduceFq2Fp)) 5341 6756 { 6757 #ifdef HAVE_FLINT 6758 if (result.length() == nmod_mat_ncols (FLINTN)) 6759 { 6760 nmod_mat_clear (FLINTN); 6761 #else 5342 6762 if (result.length() == NTLN.NumCols()) 5343 6763 { 6764 #endif 5344 6765 delete [] bounds; 5345 6766 result= Union (result, smallFactors); … … 5351 6772 if (result.length() == NTLNe.NumCols()) 5352 6773 { 6774 #ifdef HAVE_FLINT 6775 nmod_mat_clear (FLINTN); 6776 #endif 5353 6777 delete [] bounds; 5354 6778 result= Union (result, smallFactors); … … 5367 6791 delete [] bounds; 5368 6792 bounds= computeBounds (F, d, isIrreducible); 6793 #ifdef HAVE_FLINT 6794 nmod_mat_clear (FLINTN); 6795 #endif 5369 6796 if (isIrreducible) 5370 6797 { -
m4/flint-check.m4
r1130ffc r186df6 48 48 for FLINT_HOME in ${FLINT_HOME_PATH} 49 49 do 50 if test -r "$FLINT_HOME/include/f mpz.h"; then50 if test -r "$FLINT_HOME/include/flint/fmpz.h"; then 51 51 52 52 if test "x$FLINT_HOME" != "x/usr"; then 53 FLINT_CFLAGS="-I${FLINT_HOME}/include "53 FLINT_CFLAGS="-I${FLINT_HOME}/include/flint" 54 54 FLINT_LIBS="-L${FLINT_HOME}/lib -lflint -lmpfr -lmpir" 55 55 else
Note: See TracChangeset
for help on using the changeset viewer.