Changeset 287cc8 in git for ntl/src/lzz_pXFactoring.c
- Timestamp:
- Jan 5, 2010, 5:51:13 PM (14 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- 3c38b3810fd61108b01f123f5a91e13ccff52b20
- Parents:
- 1d43d184dd871d77c1ba8e095d768f22a0fbe92f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ntl/src/lzz_pXFactoring.c
r1d43d18 r287cc8 58 58 d = deg(r)/p; 59 59 f.rep.SetLength(d+1); 60 for (k = 0; k <= d; k++) 60 for (k = 0; k <= d; k++) 61 61 f.rep[k] = r.rep[k*p]; 62 62 m = m*p; … … 64 64 } while (!finished); 65 65 } 66 66 67 67 68 68 … … 143 143 144 144 static 145 void BuildMatrix(vec_vec_zz_p& M, 145 void BuildMatrix(vec_vec_zz_p& M, 146 146 long n, const zz_pX& g, const zz_pXModulus& F, long verbose) 147 147 { … … 189 189 return; 190 190 } 191 191 192 192 zz_pX h; 193 193 … … 209 209 210 210 RecFindRoots(x, h); 211 div(h, f, h); 211 div(h, f, h); 212 212 RecFindRoots(x, h); 213 213 } … … 224 224 225 225 static 226 void RandomBasisElt(zz_pX& g, const vec_long& D, 226 void RandomBasisElt(zz_pX& g, const vec_long& D, 227 227 const vec_vec_zz_p& M) 228 228 { … … 263 263 static 264 264 void split(zz_pX& f1, zz_pX& g1, zz_pX& f2, zz_pX& g2, 265 const zz_pX& f, const zz_pX& g, 265 const zz_pX& f, const zz_pX& g, 266 266 const vec_zz_p& roots, long lo, long mid) 267 267 { … … 284 284 285 285 GCD(f1, a, f); 286 286 287 287 div(f2, f, f1); 288 288 … … 347 347 #endif 348 348 349 349 350 350 351 351 void SFBerlekamp(vec_zz_pX& factors, const zz_pX& ff, long verbose) … … 474 474 475 475 static 476 void ProcessTable(zz_pX& f, vec_pair_zz_pX_long& factors, 476 void ProcessTable(zz_pX& f, vec_pair_zz_pX_long& factors, 477 477 const zz_pXModulus& F, long limit, const vec_zz_pX& tbl, 478 478 long d, long verbose) … … 511 511 512 512 while (2*d <= deg(t1)) { 513 GCD(t2, tbl[i], t1); 513 GCD(t2, tbl[i], t1); 514 514 if (deg(t2) > 0) { 515 515 AddFactor(factors, t2, d, verbose); … … 526 526 527 527 528 void TraceMap(zz_pX& w, const zz_pX& a, long d, const zz_pXModulus& F, 528 void TraceMap(zz_pX& w, const zz_pX& a, long d, const zz_pXModulus& F, 529 529 const zz_pX& b) 530 530 … … 540 540 while (d) { 541 541 if (d == 1) { 542 if (IsZero(w)) 542 if (IsZero(w)) 543 543 w = y; 544 544 else { … … 647 647 long zz_pX_BlockingFactor = 10; 648 648 649 void DDF(vec_pair_zz_pX_long& factors, const zz_pX& ff, const zz_pX& hh, 649 void DDF(vec_pair_zz_pX_long& factors, const zz_pX& ff, const zz_pX& hh, 650 650 long verbose) 651 651 { … … 659 659 660 660 if (deg(f) == 0) 661 return; 661 return; 662 662 663 663 if (deg(f) == 1) { … … 666 666 } 667 667 668 long CompTableSize = 2*SqrRoot(deg(f)); 668 long CompTableSize = 2*SqrRoot(deg(f)); 669 669 670 670 long GCDTableSize = zz_pX_BlockingFactor; … … 706 706 707 707 if (deg(f) < old_n) { 708 // f has changed 708 // f has changed 709 709 710 710 build(F, f); … … 746 746 zz_pXModulus F; 747 747 vec_zz_p roots; 748 748 749 749 build(F, f); 750 750 long n = F.n; … … 777 777 } 778 778 } 779 779 780 780 781 781 void EDF(vec_zz_pX& factors, const zz_pX& ff, const zz_pX& bb, … … 808 808 } 809 809 810 810 811 811 double t; 812 812 … … 827 827 long p = zz_p::modulus(); 828 828 829 829 830 830 zz_pXModulus F; 831 831 build(F, f); … … 899 899 long p = zz_p::modulus(); 900 900 901 901 902 902 zz_pXModulus F; 903 903 build(F, f); … … 941 941 } 942 942 } 943 943 944 944 void CanZass(vec_pair_zz_pX_long& factors, const zz_pX& f, long verbose) 945 945 { … … 1010 1010 1011 1011 1012 void TandemPowerCompose(zz_pX& y1, zz_pX& y2, const zz_pX& h, 1012 void TandemPowerCompose(zz_pX& y1, zz_pX& y2, const zz_pX& h, 1013 1013 long q1, long q2, const zz_pXModulus& F) 1014 1014 { … … 1089 1089 long q1, q2, r1, r2; 1090 1090 1091 q1 = fvec[fvec[u].link].val; 1091 q1 = fvec[fvec[u].link].val; 1092 1092 q2 = fvec[fvec[u].link+1].val; 1093 1093 … … 1098 1098 } 1099 1099 1100 1100 1101 1101 1102 1102 … … 1106 1106 // the common degree of the irreducible factors of f is computed 1107 1107 { 1108 if (F.n == 1 || IsX(h)) 1108 if (F.n == 1 || IsX(h)) 1109 1109 return 1; 1110 1110 … … 1221 1221 1222 1222 1223 q1 = fvec[fvec[u].link].val; 1223 q1 = fvec[fvec[u].link].val; 1224 1224 q2 = fvec[fvec[u].link+1].val; 1225 1225 1226 1226 TandemPowerCompose(h1, h2, h, q1, q2, F); 1227 return RecIrredTest(fvec[u].link, h2, F, fvec) 1227 return RecIrredTest(fvec[u].link, h2, F, fvec) 1228 1228 && RecIrredTest(fvec[u].link+1, h1, F, fvec); 1229 1229 } … … 1237 1237 1238 1238 build(F, f); 1239 1239 1240 1240 zz_pX h; 1241 1241 … … 1263 1263 1264 1264 build(F, f); 1265 1265 1266 1266 zz_pX h; 1267 1267 … … 1510 1510 zz_pXArgument H; 1511 1511 build(H, h, F, 2*rootn); 1512 1513 1512 1513 1514 1514 for (i = 1; i <= k-1; i++) { 1515 (*BabyStepFile)(i) = h1; 1516 1515 (*BabyStepFile)(i) = h1; 1516 1517 1517 CompMod(h1, h1, H, F); 1518 1518 } 1519 1519 } 1520 1520 1521 1521 } 1522 1522 … … 1561 1561 } 1562 1562 1563 1563 1564 1564 1565 1565 … … 1651 1651 } 1652 1652 } 1653 1653 1654 1654 1655 1655 … … 1713 1713 1714 1714 long i; 1715 for (i = 1; i <= k-1; i++) 1715 for (i = 1; i <= k-1; i++) 1716 1716 rem(BabyStep[i], BabyStep[i], F); 1717 1717 } … … 1722 1722 } 1723 1723 1724 if (deg(f) > 0) 1724 if (deg(f) > 0) 1725 1725 NewAddFactor(u, f, 0, verbose); 1726 1726 … … 1777 1777 NewProcessTable(factors, f, F, buf, size, first_d, 1, verbose); 1778 1778 1779 if (deg(f) > 0) 1779 if (deg(f) > 0) 1780 1780 NewAddFactor(factors, f, deg(f), verbose); 1781 1781 } 1782 1782 1783 1783 1784 1784 … … 1812 1812 } 1813 1813 1814 1815 1816 1814 1815 1816 1817 1817 1818 1818 void NewDDF(vec_pair_zz_pX_long& factors,
Note: See TracChangeset
for help on using the changeset viewer.