Changeset 287cc8 in git for ntl/src/GF2EXFactoring.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/GF2EXFactoring.c
r1d43d18 r287cc8 29 29 c = res; 30 30 } 31 31 32 32 33 33 … … 79 79 d = deg(r)/2; 80 80 f.rep.SetLength(d+1); 81 for (k = 0; k <= d; k++) 81 for (k = 0; k <= d; k++) 82 82 IterSqr(f.rep[k], r.rep[k*2], GF2E::degree()-1); 83 83 m = m*2; … … 85 85 } while (!finished); 86 86 } 87 87 88 88 89 89 … … 216 216 SetX(res); 217 217 long i; 218 for (i = 0; i < GF2E::degree(); i++) 218 for (i = 0; i < GF2E::degree(); i++) 219 219 SqrMod(res, res, F); 220 220 … … 241 241 long m1 = 2*m; 242 242 if (i & d) m1++; 243 243 244 244 if (m1 >= NTL_BITS_PER_LONG-1 || (1L << m1) >= n) break; 245 245 246 246 m = m1; 247 247 i = i >> 1; … … 290 290 long m1 = 2*m; 291 291 if (i & d) m1++; 292 292 293 293 if (m1 >= NTL_BITS_PER_LONG-1 || (1L << m1) >= n) break; 294 294 295 295 m = m1; 296 296 i = i >> 1; … … 344 344 345 345 346 346 347 347 348 348 … … 359 359 return; 360 360 } 361 361 362 362 GF2EX h; 363 363 364 364 GF2E r; 365 365 366 366 367 367 { 368 368 GF2EXModulus F; … … 379 379 380 380 RecFindRoots(x, h); 381 div(h, f, h); 381 div(h, f, h); 382 382 RecFindRoots(x, h); 383 383 } … … 435 435 static 436 436 void split(GF2EX& f1, GF2EX& g1, GF2EX& f2, GF2EX& g2, 437 const GF2EX& f, const GF2EX& g, 437 const GF2EX& f, const GF2EX& g, 438 438 const vec_GF2E& roots, long lo, long mid) 439 439 { … … 456 456 457 457 GCD(f1, a, f); 458 458 459 459 div(f2, f, f1); 460 460 … … 520 520 521 521 522 522 523 523 524 524 void SFBerlekamp(vec_GF2EX& factors, const GF2EX& ff, long verbose) … … 619 619 Error("berlekamp: bad args"); 620 620 621 621 622 622 SquareFreeDecomp(sfd, f); 623 623 … … 644 644 645 645 static 646 void ProcessTable(GF2EX& f, vec_pair_GF2EX_long& factors, 646 void ProcessTable(GF2EX& f, vec_pair_GF2EX_long& factors, 647 647 const GF2EXModulus& F, long limit, const vec_GF2EX& tbl, 648 648 long d, long verbose) … … 681 681 682 682 while (2*d <= deg(t1)) { 683 GCD(t2, tbl[i], t1); 683 GCD(t2, tbl[i], t1); 684 684 if (deg(t2) > 0) { 685 685 AddFactor(factors, t2, d, verbose); … … 696 696 697 697 698 void TraceMap(GF2EX& w, const GF2EX& a, long d, const GF2EXModulus& F, 698 void TraceMap(GF2EX& w, const GF2EX& a, long d, const GF2EXModulus& F, 699 699 const GF2EX& b) 700 700 … … 710 710 while (d) { 711 711 if (d == 1) { 712 if (IsZero(w)) 712 if (IsZero(w)) 713 713 w = y; 714 714 else { … … 817 817 long GF2EX_BlockingFactor = 10; 818 818 819 void DDF(vec_pair_GF2EX_long& factors, const GF2EX& ff, const GF2EX& hh, 819 void DDF(vec_pair_GF2EX_long& factors, const GF2EX& ff, const GF2EX& hh, 820 820 long verbose) 821 821 { … … 836 836 } 837 837 838 long CompTableSize = 2*SqrRoot(deg(f)); 838 long CompTableSize = 2*SqrRoot(deg(f)); 839 839 840 840 long GCDTableSize = GF2EX_BlockingFactor; … … 876 876 877 877 if (deg(f) < old_n) { 878 // f has changed 878 // f has changed 879 879 880 880 build(F, f); … … 916 916 GF2EXModulus F; 917 917 vec_GF2E roots; 918 918 919 919 build(F, f); 920 920 long n = F.n; … … 947 947 } 948 948 } 949 949 950 950 951 951 void EDF(vec_GF2EX& factors, const GF2EX& ff, const GF2EX& bb, … … 978 978 } 979 979 980 980 981 981 factors.SetLength(0); 982 982 … … 1008 1008 double t; 1009 1009 1010 1010 1011 1011 GF2EXModulus F; 1012 1012 build(F, f); … … 1050 1050 } 1051 1051 } 1052 1052 1053 1053 void CanZass(vec_pair_GF2EX_long& factors, const GF2EX& f, long verbose) 1054 1054 { … … 1060 1060 vec_GF2EX x; 1061 1061 1062 1062 1063 1063 SquareFreeDecomp(sfd, f); 1064 1064 … … 1121 1121 1122 1122 static 1123 void TandemPowerCompose(GF2EX& y1, GF2EX& y2, const GF2EX& h, 1123 void TandemPowerCompose(GF2EX& y1, GF2EX& y2, const GF2EX& h, 1124 1124 long q1, long q2, const GF2EXModulus& F) 1125 1125 { … … 1201 1201 long q1, q2, r1, r2; 1202 1202 1203 q1 = fvec[fvec[u].link].val; 1203 q1 = fvec[fvec[u].link].val; 1204 1204 q2 = fvec[fvec[u].link+1].val; 1205 1205 … … 1210 1210 } 1211 1211 1212 1212 1213 1213 1214 1214 … … 1218 1218 // the common degree of the irreducible factors of f is computed 1219 1219 { 1220 if (F.n == 1 || IsX(h)) 1220 if (F.n == 1 || IsX(h)) 1221 1221 return 1; 1222 1222 … … 1239 1239 1240 1240 f = ff; 1241 1241 1242 1242 if (!IsOne(LeadCoeff(f))) 1243 1243 Error("FindRoot: bad args"); … … 1261 1261 } 1262 1262 } 1263 1263 1264 1264 root = ConstTerm(f); 1265 1265 } … … 1308 1308 1309 1309 1310 q1 = fvec[fvec[u].link].val; 1310 q1 = fvec[fvec[u].link].val; 1311 1311 q2 = fvec[fvec[u].link+1].val; 1312 1312 1313 1313 TandemPowerCompose(h1, h2, h, q1, q2, F); 1314 return RecIrredTest(fvec[u].link, h2, F, fvec) 1314 return RecIrredTest(fvec[u].link, h2, F, fvec) 1315 1315 && RecIrredTest(fvec[u].link+1, h1, F, fvec); 1316 1316 } … … 1324 1324 1325 1325 build(F, f); 1326 1326 1327 1327 GF2EX h; 1328 1328 … … 1350 1350 1351 1351 build(F, f); 1352 1352 1353 1353 GF2EX h; 1354 1354 … … 1672 1672 long i; 1673 1673 1674 long HexOutput = GF2X::HexOutput; 1674 long HexOutput = GF2X::HexOutput; 1675 1675 GF2X::HexOutput = 1; 1676 1676 … … 1708 1708 } 1709 1709 1710 1710 1711 1711 1712 1712 … … 1778 1778 } 1779 1779 } 1780 1780 1781 1781 1782 1782 … … 1838 1838 1839 1839 long i; 1840 for (i = 1; i <= k-1; i++) 1840 for (i = 1; i <= k-1; i++) 1841 1841 rem(BabyStep[i], BabyStep[i], F); 1842 1842 } … … 1847 1847 } 1848 1848 1849 if (deg(f) > 0) 1849 if (deg(f) > 0) 1850 1850 NewAddFactor(u, f, 0, verbose); 1851 1851 … … 1902 1902 NewProcessTable(factors, f, F, buf, size, first_d, 1, verbose); 1903 1903 1904 if (deg(f) > 0) 1904 if (deg(f) > 0) 1905 1905 NewAddFactor(factors, f, deg(f), verbose); 1906 1906 } 1907 1907 1908 1908 1909 1909 … … 1935 1935 } 1936 1936 1937 1938 1939 1940 1937 1938 1939 1940 1941 1941 1942 1942 void NewDDF(vec_pair_GF2EX_long& factors, … … 1962 1962 if (!GF2EX_stem[0]) 1963 1963 sprintf(GF2EX_stem, "ddf-%ld", RandomBnd(10000)); 1964 1964 1965 1965 long B = deg(f)/2; 1966 1966 long k = SqrRoot(B);
Note: See TracChangeset
for help on using the changeset viewer.