Changeset ae99c8 in git
- Timestamp:
- Jun 3, 2016, 3:35:33 PM (8 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- 52a8a94bdb5c861b9dfc195e1caeac28976f4cb6
- Parents:
- c7afbd34f1aae46fbf47925ff2246e5f42f4ca08f5430b3a3eb5a73492e701be4b7eb64eb8d10513
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/ffmodstd.lib
rc7afbd3 rae99c8 1 1 /////////////////////////////////////////////////////////////////////////////// 2 version="version poly.lib 4.0.3.0 Mar_2016"; // $Id$2 version="version ffmodstd.lib 4.0.3.0 May_2016"; // $Id$ 3 3 category="Commutative Algebra"; 4 4 info=" … … 20 20 b:=(b_1,...,b_m) (usually the b_i's are distinct primes), so that K is an ideal in 21 21 Q(z)[X]. For such a rational point b, we compute a Groebner basis G_b of K using 22 modular algorithms [1] and univariate rational interpolation [2,7]. The23 procedure is repeated for many rational points b until their is sufficiently large24 to recover the correct coeffcients in Q(T). Once we have these points, we obtain a25 set of polynomials G by applying the sparse multivariate rational interpolation22 modular algorithms [1] and univariate rational interpolation [2,7]. The 23 procedure is repeated for many rational points b until their number is sufficiently 24 large to recover the correct coeffcients in Q(T). Once we have these points, we 25 obtain a set of polynomials G by applying the sparse multivariate rational interpolation 26 26 algorithm from [4] coefficient-wise to the list of Groebner bases G_b in Q(z)[X], 27 27 where this algorithm makes use of the following algorithms: univariate polynomial … … 209 209 static proc NewtonInterpolationNormal(list d, list e,int vr) 210 210 { 211 /* 212 * 211 /* compute a polynomial from given numerical data 212 * size of d and e must be equal 213 213 * d is list of distinct elements 214 214 * number of points here are sufficiently large … … 300 300 static proc choose_a_prime(int p) 301 301 { 302 int i; 302 // p must be a prime number and the procedure returns the next prime 303 if(p==2){return(3);} 304 int i=p; 303 305 while(1) 304 306 { 305 i++; 306 if((p+i)%2 !=0) 307 { 308 if(prime(p+i)==p+i) 309 { 310 return(p+i); 311 break; 312 } 307 i = i+2; 308 if(prime(i)==i) 309 { 310 return(i); 313 311 } 314 312 } … … 319 317 static proc list_of_primes(int pa, list #) 320 318 { 321 // find distinct pa prime(s) 319 // find distinct pa prime(s) up to permutations 322 320 int p=3; 323 321 int j,k; … … 529 527 } 530 528 } 531 return(list(0,B));532 529 } 533 530 … … 622 619 { "EXAMPLE:"; echo = 2; 623 620 ring rr=0,(x,y),dp; 624 list lpr = 2,3; // assign 2 for y and 3 for z621 list lpr = 2,3; // assign 2 for x and 3 for y 625 622 list La = 150,3204,79272,2245968,70411680, 2352815424, 81496927872; 626 623 // La[i] = number(subst(f,y,lpr[1]^i,z,lpr[2]^i)); for f = x2y2+2x2y+5xy2 and i=1,...,7 627 624 poly Br = BerlekampMassey(La,1)[1]; 628 625 Br; 629 sparseInterpolation(Br,La,lpr,0,1); // reconstruct f 630 sparseInterpolation(Br,La,lpr,0); // default 626 sparseInterpolation(Br,La,lpr,0); // reconstruct f default 631 627 La = 97,275,793,2315,6817; 632 628 // La[i] = number(subst(g,y,lpr[1]^i,z,lpr[2]^i)); for g = x+y and i=4,...,8 … … 664 660 poly r1,r2,r3,t1,t2,q_m,r_m,t_m,q1; 665 661 q_m = 1; 666 667 662 if(g==0) 668 663 { 669 664 return(list(poly(0),poly(1))); 670 665 } 671 672 666 if(2*deg(g)<deg(f)) 673 667 { 668 // the degree of f is large enough 674 669 return(list(g,poly(1))); 675 670 } … … 680 675 t2=h; 681 676 list ls,l1,l,T; 682 683 677 int i=0; 684 678 // a modified while loop in the Extended Euclidean algorithm 685 679 while(r2!=0) 686 680 { … … 688 682 ls=division(r1,r2); 689 683 r3=r2; 690 q1=ls[1][1,1]; 684 q1=ls[1][1,1]; // quotient 691 685 h=number(1)/lu(ls[2][1]); 692 r2=ls[2][1]*h; 686 r2=ls[2][1]*h; // remainder times h 693 687 r1=r3; 694 688 r3=t2; 695 689 t2=(t1-q1*t2)*h; 696 690 t1=r3; 697 691 /***** find a quotient q_m whose degree is maximal and polynomials r_m & t_m 692 correspond to q_m *********************************************************/ 698 693 if( deg(q1) > deg(q_m)) 699 694 { … … 717 712 if(normalize_constant_term) 718 713 { 714 // here we normalize only for internal use 719 715 number ut=number(1)/lu(t_m[size(t_m)]); 720 716 return(list(ut*r_m,ut*t_m)); … … 727 723 if(normalize_constant_term) 728 724 { 725 // here we normalize only for internal use 729 726 number ut=number(1)/lu(t_m[size(t_m)]); 730 727 return(list(ut*r_m,ut*t_m)); … … 811 808 /////////////////////////////////////////////////////////////////////////////// 812 809 813 static proc e xpandf_wrt_vaRnvaRkplusShift(poly f,list shft,int n)810 static proc evaluate_f_at_given_points(poly f,list shft,int n) 814 811 { 815 812 // evaluate f at var(n+k) = bigint(shft[k])**j for each j … … 925 922 list m2 = list(list(poly(-7/6),21/2y+1)); 926 923 list L = list(l1,l2),list(m1,m2); 927 L;928 924 Add_the_list_farey(L); 929 925 } … … 933 929 static proc Add_list_of_list(list l1,list l2, int m) 934 930 { 931 // the procedure returns a list containing list of polynomials w.r.t. m 935 932 list lst,lyt,Yt,lm; 936 937 933 if(size(l1)!=size(l2)) 938 934 { … … 953 949 return(l1); 954 950 } 955 951 example 952 { 953 "EXAMPLE:"; echo = 2; 954 ring rr=0,y,dp; 955 list l2,m2; 956 l2[1] = list(list(-2y-5/6,y+1)); 957 m2[1] = list(list(-4y-5/6,y-5)); 958 l2[2] = list(list(-2y-5/6,2y+3)); 959 m2[2] = list(list(-4y-5/6,3y-7)); 960 Add_list_of_list(l2,m2,1); 961 } 956 962 /////////////////////////////////////////////////////////////////////////////// 957 963 958 964 static proc Add_two_lists(list l1, list l2) 959 965 { 966 // the procedure returns a list containing list of polynomials 960 967 int im=size(l1); 961 968 int k,i; … … 986 993 l2[2] = list(list(-2y-5/6,poly(1))); 987 994 m2[2] = list(list(-4y-5/6,poly(1))); 988 list L = l2,m2;989 L;990 Add_the_list_farey(L);991 995 Add_two_lists(l2[2],m2[2]); 992 996 } … … 1014 1018 { "EXAMPLE:"; echo = 2; 1015 1019 ring rr=0,y,dp; 1016 list l1,l2,l3,l4; 1017 l1 = 1,2,3; 1018 l2 = 1,4,9; 1019 l3 = 1,8,27; 1020 l4 = 1,16,81; 1020 list l1 = 1,2,3; 1021 list l2 = 1,4,9; 1022 list l3 = 1,8,27; 1023 list l4 = 1,16,81; 1021 1024 list L = l1,l2,l3,l4; 1022 L;1023 1025 arrange_list_first(L); 1024 1026 } … … 1054 1056 static proc arrangeListofIdeals(list L, list #) 1055 1057 { 1058 /* the procedure returns list of coeffcients in the given list of ideals. The 1059 * coeffcients are correspond to polynomials whose leading monomials are the same. 1060 * Moreover, if optional parameter # is given, then it also returns a list 1061 * of monomials in one of these ideals 1062 */ 1056 1063 ideal Tr = L[1]; 1057 1064 L = arrange_list_first(L); … … 1089 1096 return(Ld); 1090 1097 } 1091 1092 /////////////////////////////////////////////////////////////////////////////// 1093 // return list(Jc, us) if us is a good point 1098 example 1099 { 1100 "EXAMPLE:"; echo = 2; 1101 ring rr=(0,a),y,dp; 1102 ideal I1 = y2+(3a2+6a+5)/(a+2)*y+1, y-6a; 1103 ideal I2 = y2+(3a2+5a+7)/(a+4)*y+1, 7y-17a; 1104 list L = I1,I2; 1105 arrangeListofIdeals(L); 1106 arrangeListofIdeals(L,1); 1107 } 1108 1109 /////////////////////////////////////////////////////////////////////////////// 1094 1110 1095 1111 static proc Add_the_shift_and_evaluate_new(ideal J,list pr, list shft, int i) 1096 1112 { 1097 // n number of variables1113 // evaluate J at a given point 1098 1114 int k; 1099 1115 number Nm; … … 1108 1124 } 1109 1125 1110 // =============== a procedure for one parameter ends here ==========1111 1112 1126 /////////////////////////////////////////////////////////////////////////////// 1113 1127 … … 1115 1129 int fn, string Command, list JL,list #) 1116 1130 { 1131 // generate a set of ideals whose coefficients are univariate rational functions 1117 1132 def Gt = basering; 1118 1133 int i,i1; … … 1131 1146 list optL = imap(Gt,JL); 1132 1147 list T; 1148 int tmp; 1133 1149 int c_z = size(L); 1134 1150 for(i1=1;i1<=c_z;i1++) … … 1136 1152 if(Command == "slimgb") 1137 1153 { 1138 task t (i1) = "slimgb", list(L[i1]);1154 task tk(i1) = "slimgb", list(L[i1]); 1139 1155 } 1140 1156 else 1141 1157 { 1142 task t (i1) = "Ffmodstd::ffmodStdOne",list(L[i1],list(optL,1));1143 } 1144 } 1145 startTasks(t (1..c_z));1146 waitAllTasks(t (1..c_z));1158 task tk(i1) = "Ffmodstd::ffmodStdOne",list(L[i1],list(optL,1)); 1159 } 1160 } 1161 startTasks(tk(1..c_z)); 1162 waitAllTasks(tk(1..c_z)); 1147 1163 for(i1 = 1;i1 <= c_z; i1++) 1148 1164 { 1149 T[i1] = getResult(t (i1));1150 killTask(t (i1));1151 kill t (i1);1165 T[i1] = getResult(tk(i1)); 1166 killTask(tk(i1)); 1167 kill tk(i1); 1152 1168 } 1153 1169 if(tp) … … 1166 1182 static proc normalize_LiftofIdeal(list L) 1167 1183 { 1184 // normalize each ideal L[j] 1168 1185 for(int j=1;j<=size(L);j++) 1169 1186 { … … 1177 1194 static proc normalize_constTerm(poly g, poly f) 1178 1195 { 1196 /* Assumption: f has a non-zero constant. Then the procedure 1197 returns a pair (g/N, f/N) where N is the constant term of f */ 1179 1198 number N = leadcoef(f[size(f)]); 1180 1199 g = g/N; … … 1187 1206 static proc normalize_constTermAll(list M2, int kk) 1188 1207 { 1208 /* 1209 Assumption: each polynomial in the list has a non-zero constant term. Then 1210 the procedure normalize_constTermAll normalizes the constatnt term of 1211 each polynomial in this list starting from M2[kk] where kk is a 1212 positive integer less than or equal to the size of M2 1213 */ 1189 1214 int i,j,k; 1190 1215 list l,l1,l2,l3,l4; … … 1216 1241 /////////////////////////////////////////////////////////////////////////////// 1217 1242 1218 static proc stdoverFF(ideal I, list pr, list shft, 1219 { 1220 // return std of I with high probability 1243 static proc stdoverFF(ideal I, list pr, list shft,string Command,list Zr, list JL) 1244 { 1245 // return std of I with high probability using sparse rational interpolation 1221 1246 int fn=13; 1222 1247 def R_1=basering; … … 1236 1261 setring R_1; 1237 1262 int in = 2; 1263 // with respect to given bounds, generate univariate rational functions 1238 1264 list M2 = generate_uniRationalFunctions(I, pr, shft, in,fn, Command,JL[1],JL[2]); 1239 1265 M2 = arrangeListofIdeals(M2); … … 1244 1270 list M2 = imap(R_1,M2); 1245 1271 M2 = normalize_constTermAll(M2,1); // starts from 1 1246 list Zr = imap(R_1, Zr); 1272 list Zr = imap(R_1, Zr); // list of monomials in the std of I 1247 1273 int u_w,i1,i2,i3; 1248 1274 poly Gn,pn,pl,plm; … … 1258 1284 Gn = Zr[u_w][1]; 1259 1285 setring R_2; 1286 /******** start lifting elements from Q to Q(var(1),.., var(pa)) *****/ 1260 1287 l1 = M2[u_w]; 1261 1288 for(i1=1;i1<=size(l1);i1++) … … 1263 1290 for(i2=1;i2<=2;i2++) 1264 1291 { 1292 // the procedure first lifts the numerator and then the denominator 1265 1293 for(i3=1;i3<=size(l1[i1][i2][1]);i3++) 1266 1294 { 1267 1295 l3 = return_coef_indx(l1[i1][i2],i3); 1268 1296 l3 = l3,lk1; 1269 l3 = SubList(l3); 1297 l3 = SubList(l3); // adjust the coefficients 1298 // early termination for BerlekampMassey algorithm(BMA) 1270 1299 bp = BerlekampMassey(l3,n); 1271 1300 if(size(bp)==2) 1272 1301 { 1302 // at this step BerlekampMassey algorithm terminated early 1273 1303 if(bp[1]==1) 1274 1304 { … … 1280 1310 pn = sparseInterpolation(bp[1],l3,pr,n); 1281 1311 pl = pn+pl; 1282 lup = e xpandf_wrt_vaRnvaRkplusShift(pn, shft, n);1312 lup = evaluate_f_at_given_points(pn, shft, n); 1283 1313 lup = lup,lk3; 1284 1314 } … … 1286 1316 else 1287 1317 { 1318 /* elements in the sequence l3[i] are not large enough. 1319 * We thus add more elements to l3 and continue with the 1320 * early termination strategy until size(bp)=2 where bp[2] 1321 * is the length of the sequence that the early temination 1322 * of BMA requires 1323 */ 1288 1324 l3n = bp[6]; 1289 1325 while(1) … … 1292 1328 fn = 2*in; 1293 1329 setring R_1; 1330 /* add more points to l3 by generating rational 1331 functions*/ 1294 1332 uM1 = generate_uniRationalFunctions(I, pr, shft, in, 1295 1333 fn, Command,JL[1]); … … 1312 1350 if(size(bp)==2) 1313 1351 { 1352 // at this step BerlekampMassey algorithm terminated early 1314 1353 l3n = l3n[1..bp[2]]; 1315 1354 pn = sparseInterpolation(bp[1],l3n,pr,n); 1316 1355 pl = pn+pl; 1317 lup = e xpandf_wrt_vaRnvaRkplusShift(pn,shft,n);1356 lup = evaluate_f_at_given_points(pn,shft,n); 1318 1357 lup = lup,lk3; 1319 1358 break; … … 1324 1363 if(i3 < size(l1[i1][i2][1])) 1325 1364 { 1365 // unshift the shifted parameters see also SubList 1326 1366 lk3 = Add_poly_list(lup); 1327 1367 plm = lk3[1]; … … 1338 1378 setring R_1; 1339 1379 list H = imap(R_2,py); 1380 // numerator H[1] & denominator H[2] are recovered for each i1=1,2,... 1340 1381 Gn = Gn + (H[1]/H[2])*Zr[u_w][i1+1]; 1341 1382 kill H; … … 1358 1399 } 1359 1400 1401 1360 1402 /////////////////////////////////////////////////////////////////////////////// 1361 1403 // +++++++++++++++++ std for one parameter begins here +++++++++++++++++++ … … 1375 1417 /////////////////////////////////////////////////////////////////////////////// 1376 1418 1377 static proc ChooseprimeIdealsIAnd_ImodgJ(ideal gJ, ideal I,int n1,int nt, 1378 int i_s) 1419 static proc choose_evaluation_points(ideal I, ideal cI,int n1,int nt, int i_s) 1379 1420 { 1380 1421 /* 1381 * gJ is given ideal 1382 * f is linear polynomial with leadcoef 1 1383 * I is an output from Testlist_all 1384 * n is number of variables 1422 * I is given ideal 1423 * cI is an output from Testlist_all 1424 * n1 is number of variables 1385 1425 * nt number of prime ideals 1386 1426 * i_s is an integer … … 1398 1438 } 1399 1439 f=var(n1)-i_s; 1400 if(test_fmodI(f, I)==1)1440 if(test_fmodI(f,cI)==1) 1401 1441 { 1402 1442 j=j+1; 1403 n=n+list(subst(gJ,var(n1),i_s)); 1443 // specialize var(n1) with i_s 1444 n=n+list(subst(I,var(n1),i_s)); 1404 1445 m[j]=i_s; 1405 1446 } … … 1409 1450 n=n,m; 1410 1451 return(n); 1411 break; 1412 } 1413 } 1414 } 1415 1416 /////////////////////////////////////////////////////////////////////////////// 1417 1418 static proc firststdmodp(ideal I,ideal cI, int in_value) 1419 { 1420 /* return a list of univariate rational functions, where each function is the 1421 coefficient for each of monomials appear in the output ideal */ 1452 } 1453 } 1454 } 1455 1456 /////////////////////////////////////////////////////////////////////////////// 1457 1458 static proc firststdmodp(ideal I,ideal cI,int in_value) 1459 { 1460 /* return std FJ of I together with the coefficients, as a list of univariate 1461 rational functions, of FJ */ 1422 1462 def St=basering; 1463 // define a new ring 1423 1464 int nx=nvars(St); 1424 1465 int nr=nx-1; … … 1442 1483 int i,k1,k2; 1443 1484 list T,T1,L1,L2,L3,m_l; 1444 int r_d = char(basering)-10000000; 1445 list l_1 = ChooseprimeIdealsIAnd_ImodgJ(I,cI, nx,in_value,r_d); 1485 int r_d = char(basering)-10000000; // choose an integer r_d which is d/t from 1486 // char(basering) 1487 list l_1 = choose_evaluation_points(I,cI, nx,in_value,r_d); 1446 1488 list lus = l_1[2]; 1447 1489 l_1 = l_1[1]; 1448 m_l[1] = normalize(std(l_1[1]));1490 m_l[1] = std(l_1[1]); 1449 1491 if(size(m_l[1])==1 and deg(m_l[1][1])==0) 1450 1492 { 1451 1493 return(list(ideal(1))); 1452 1494 } 1453 1495 // compute std in parallel w.r.t. distinct r_d 1454 1496 for(k1 = 2; k1<= in_value; k1++) 1455 1497 { 1456 task t (k1-1) = "std", list(l_1[k1]);1457 } 1458 startTasks(t (1..in_value-1));1459 waitAllTasks(t (1..in_value-1));1498 task tk(k1-1) = "std", list(l_1[k1]); 1499 } 1500 startTasks(tk(1..in_value-1)); 1501 waitAllTasks(tk(1..in_value-1)); 1460 1502 for(k1 = 1;k1<=in_value-1;k1++) 1461 1503 { 1462 m_l = m_l + list(getResult(t (k1)));1463 killTask(t (k1));1464 kill t (k1);1504 m_l = m_l + list(getResult(tk(k1))); 1505 killTask(tk(k1)); 1506 kill tk(k1); 1465 1507 } 1466 1508 r_d = lus[in_value]-1; 1467 1468 1509 // DeleteUnluckyEvaluationPoints 1469 1470 list indices = delete_unlucky_primes(m_l); 1510 list indices = Modstd::deleteUnluckyPrimes_std(m_l); 1471 1511 for(i = size(indices); i > 0; i--) 1472 1512 { … … 1474 1514 lus = delete(lus, indices[i]); 1475 1515 } 1516 m_l = normalize_LiftofIdeal(m_l); 1476 1517 in_value = size(lus); 1477 1518 int ug; 1478 1479 1519 for(int cZ =1;cZ<=ncols(m_l[1]);cZ++) 1480 1520 { … … 1489 1529 return(list(m_l[1])); 1490 1530 } 1531 // dense univariate rational interpolation 1491 1532 list lev = list_coef_index(m_l,ug,2,in_value-1); 1492 1533 list L = polyInterpolation(list(lus[1..in_value-1]),lev,nx); … … 1528 1569 } 1529 1570 T1 = fareypolyEarlyTermination(I,cI,M,nx,lus,lev, k1, k2, r_d,#); 1571 // save maximum number of data m_x that are used in each lifting 1530 1572 if(m_x < T1[3][2]){ m_x = T1[3][2];} 1531 1573 L1[k2-1] = T1[3]; … … 1533 1575 setring Gt; 1534 1576 list Fr = imap(St,Fr); 1577 // add the coeffcients to g_t which are already lifted 1535 1578 g_t = g_t + (Fr[1]/Fr[2])*Zr[k1][k2]; 1536 1579 kill Fr; … … 1585 1628 /* the early termination version of the farey rational funtion map for 1586 1629 polynomials */ 1587 1588 1630 ideal Id; 1589 1631 list Tr,fr,L,l_1,m_l; … … 1595 1637 if(size(#)==1) 1596 1638 { 1639 // dense univariate rational interpolation 1597 1640 sz = size(lus); 1598 1641 L = polyInterpolation(list(lus[1..sz-1]),list(lev[1..sz-1]),#); … … 1606 1649 else 1607 1650 { 1608 // update 1651 // update by adding more evaluation points 1609 1652 NR = #[1]; 1610 1653 DR = #[2]; … … 1617 1660 while(fr[1]!=NR or fr[2]!=DR) 1618 1661 { 1619 l_1 = ChooseprimeIdealsIAnd_ImodgJ(I, cI, nx, in_value, us);1662 l_1 = choose_evaluation_points(I, cI, nx, in_value, us); 1620 1663 lus = l_1[2]; 1621 1664 l_1 = l_1[1]; 1665 // compute std in parallel w.r.t. lus 1622 1666 for(k11 = 1; k11 <= in_value; k11++) 1623 1667 { 1624 task t (k11) = "std", list(l_1[k11]);1625 } 1626 startTasks(t (1..in_value));1627 waitAllTasks(t (1..in_value));1668 task tk(k11) = "std", list(l_1[k11]); 1669 } 1670 startTasks(tk(1..in_value)); 1671 waitAllTasks(tk(1..in_value)); 1628 1672 for(k11 = 1;k11<=in_value;k11++) 1629 1673 { 1630 m_l[k11] = getResult(t (k11));1631 killTask(t (k11));1632 kill t (k11);1674 m_l[k11] = getResult(tk(k11)); 1675 killTask(tk(k11)); 1676 kill tk(k11); 1633 1677 } 1634 1678 us = lus[size(lus)]-1; 1635 1679 // DeleteUnluckyEvaluationPoints 1636 indices = delete_unlucky_primes(m_l);1680 indices = Modstd::deleteUnluckyPrimes_std(m_l); 1637 1681 for(i = size(indices); i > 0; i--) 1638 1682 { … … 1641 1685 } 1642 1686 sz = size(m_l); 1687 m_l = normalize_LiftofIdeal(m_l); 1643 1688 lev = list_coef_index(m_l,k1,k2,sz); 1644 1689 # = L; 1690 // dense univariate rational interpolation 1645 1691 L = polyInterpolation(list(lus[1..sz-1]),list(lev[1..sz-1]),nx,#); 1646 1692 fr = fareypoly(L[1],L[2]); … … 1666 1712 /////////////////////////////////////////////////////////////////////////////// 1667 1713 1668 static proc RecoverCoeffsForAFixedData(list stdResults, list distElmnt,1669 list maxData,list Zr)1714 static proc RecoverCoeffsForAFixedData(list stdResults,list distElmnt,list maxData, 1715 list Zr) 1670 1716 { 1671 1717 /* here a bound on the number of interpolation points is known and, hence, … … 1674 1720 * of std over F_p*/ 1675 1721 def St=basering; 1722 // define a new ring 1676 1723 int nx=nvars(St); 1677 1724 int nr=nx-1; … … 1726 1773 if(n_z>1) 1727 1774 { 1775 // dense univariate rational interpolation in parallel 1728 1776 list TL = interpolation_farey_lift_parallel(maxData, M, distElmnt, n_z, 1729 1777 nx, k1); … … 1749 1797 /////////////////////////////////////////////////////////////////////////////// 1750 1798 1751 static proc interpolation_farey_lift_parallel(list maxData, list M, list distElmnt, int m_sz,1752 int nx, int k1)1753 { 1754 // return list of uni .rational functions1799 static proc interpolation_farey_lift_parallel(list maxData, list M, list distElmnt, 1800 int m_sz,int nx, int k1) 1801 { 1802 // return list of univariate rational functions 1755 1803 list L; 1756 1804 int k2; 1757 1805 for(k2=2;k2<=m_sz;k2++) 1758 1806 { 1759 task t (k2) = "Ffmodstd::lift_interp_farey", list(maxData, M, distElmnt,1807 task tk(k2) = "Ffmodstd::lift_interp_farey", list(maxData, M, distElmnt, 1760 1808 nx, k1, k2); 1761 1809 } 1762 startTasks(t (2..m_sz));1763 waitAllTasks(t (2..m_sz));1810 startTasks(tk(2..m_sz)); 1811 waitAllTasks(tk(2..m_sz)); 1764 1812 for(k2 = 2;k2 <= m_sz; k2++) 1765 1813 { 1766 L[k2] = getResult(t (k2));1767 killTask(t (k2));1768 kill t (k2);1814 L[k2] = getResult(tk(k2)); 1815 killTask(tk(k2)); 1816 kill tk(k2); 1769 1817 } 1770 1818 return(L); … … 1806 1854 if(2*deg(g)<deg(f)) 1807 1855 { 1856 // here the degree of f is large enough 1808 1857 return(list(g,poly(1))); 1809 1858 } … … 1815 1864 list ls,l1,l,T; 1816 1865 int i=0; 1866 // a modified while loop in the Extended Euclidean algorithm 1817 1867 while(r2!=0) 1818 1868 { … … 1850 1900 list m_l,l_1,R_d, indices,G,Fd; 1851 1901 int k11,v_r,i; 1852 int r_d = char(basering)-10000000; 1902 int r_d = char(basering)-10000000; // choose an integer r_d d/f from char(basering) 1853 1903 while(size(G) < ma_x) 1854 1904 { 1855 l_1 = ChooseprimeIdealsIAnd_ImodgJ(I, cI,nva,ma_x,r_d);1905 l_1 = choose_evaluation_points(I, cI,nva,ma_x,r_d); 1856 1906 R_d = l_1[2]; 1857 1907 l_1 = l_1[1]; 1908 // compute std in parallel 1858 1909 for(k11 = 1; k11 <= ma_x; k11++) 1859 1910 { 1860 task t (k11) = "std", list(l_1[k11]);1861 } 1862 startTasks(t (1..ma_x));1863 waitAllTasks(t (1..ma_x));1911 task tk(k11) = "std", list(l_1[k11]); 1912 } 1913 startTasks(tk(1..ma_x)); 1914 waitAllTasks(tk(1..ma_x)); 1864 1915 for(k11 = 1;k11 <= ma_x; k11++) 1865 1916 { 1866 m_l[k11] = getResult(t (k11));1867 killTask(t (k11));1868 kill t (k11);1869 } 1870 indices = delete_unlucky_primes(m_l);1917 m_l[k11] = getResult(tk(k11)); 1918 killTask(tk(k11)); 1919 kill tk(k11); 1920 } 1921 indices = Modstd::deleteUnluckyPrimes_std(m_l); 1871 1922 r_d = R_d[size(R_d)]-1; 1872 1923 for(i = size(indices); i > 0; i--) … … 1875 1926 R_d = delete(R_d, indices[i]); 1876 1927 } 1928 m_l = normalize_LiftofIdeal(m_l); 1877 1929 G = G + m_l; 1878 1930 Fd = Fd + R_d; 1879 1931 } 1880 1932 return(list(G,Fd)); 1881 }1882 1883 /////////////// copied from modstd.lib /////////////////////////////////1884 1885 static proc delete_unlucky_primes(list modresults)1886 {1887 int size_modresults = size(modresults);1888 // the command delete_unlucky_primes is the same as delete_unlucky_evaluation points1889 /* sort results into categories.1890 * each category is represented by three entries:1891 * - the corresponding leading ideal1892 * - the number of elements1893 * - the indices of the elements1894 */1895 1896 list cat;1897 ideal L;1898 int i, j, size_cat;1899 for (i = 1; i <= size_modresults; i++) {1900 L = lead(modresults[i]);1901 attrib(L, "isSB", 1);1902 for (j = 1; j <= size_cat; j++) {1903 if (size(L) == size(cat[j][1])1904 && size(reduce(L, cat[j][1])) == 01905 && size(reduce(cat[j][1], L)) == 0) {1906 cat[j][2] = cat[j][2]+1;1907 cat[j][3][cat[j][2]] = i;1908 break;1909 }1910 }1911 if (j > size_cat) {1912 size_cat++;1913 cat[size_cat] = list();1914 cat[size_cat][1] = L;1915 cat[size_cat][2] = 1;1916 cat[size_cat][3] = list(i);1917 }1918 }1919 1920 /* find the biggest categories */1921 int cat_max = 1;1922 int max = cat[1][2];1923 for (i = 2; i <= size_cat; i++) {1924 if (cat[i][2] > max) {1925 cat_max = i;1926 max = cat[i][2];1927 }1928 }1929 1930 /* return all other indices */1931 list unluckyIndices;1932 for (i = 1; i <= size_cat; i++) {1933 if (i != cat_max) {1934 unluckyIndices = unluckyIndices + cat[i][3];1935 }1936 }1937 return(unluckyIndices);1938 1933 } 1939 1934 … … 2009 2004 static proc select_the_command(ideal I) 2010 2005 { 2006 /* the procedure select_the_command selects a command which finishes the 2007 computation first but if this command applied in a machine with a single 2008 core it returns (by default) the command ffmodStdOne 2009 */ 2011 2010 if(getcores() == 1) 2012 2011 { … … 2044 2043 list stdResults = tedY[1]; 2045 2044 list distElmnt = tedY[2]; 2046 ideal F = RecoverCoeffsForAFixedData(stdResults, distElmnt, L[1], L[2]);2045 ideal F = RecoverCoeffsForAFixedData(stdResults, distElmnt, L[1], L[2]); 2047 2046 return(F); 2048 2047 } … … 2052 2051 static proc ffmodStdOne(ideal I,list #) 2053 2052 { 2054 /* 2055 * note that the number of parameter(s) and variable(s) 2056 * in I must be equal to those in the current 2057 * base ring 2058 */ 2053 // compute std of I using dense univariate rationa interpolation 2059 2054 int tmp2 = 0; 2060 2055 int tmp = 0; … … 2064 2059 option(redSB); 2065 2060 list pL; 2061 // optional parameters 2066 2062 if(size(#)>0) 2067 2063 { … … 2080 2076 n=nvars(G_t); 2081 2077 pa=1; 2082 I = normalize(I); 2078 I = normalize(I); // make each element of I monic 2083 2079 I=scalIdeal(I); 2084 2080 list L=collect_coeffs(I); 2081 // define a new ring 2085 2082 list rl=ringlist(G_t); 2086 2083 list la=rl[1][2]; … … 2101 2098 cI = 1; 2102 2099 } 2103 2104 2100 int pr = 536870909; 2105 int paSS = prime_pass(pr, cI); // I2101 int paSS = prime_pass(pr, cI); // test whether pr is a suitable for cI 2106 2102 pr = paSS; 2107 2103 if(!tmp) … … 2112 2108 def rp = ring(lbr); 2113 2109 setring(rp); 2110 // initial std computation using dense rational interpolation 2114 2111 list rL = firststdmodp(imap(S_t,I),imap(S_t,cI), in_value); 2115 2112 setring S_t; … … 2121 2118 return(EI[1]); 2122 2119 } 2120 /* 2121 * from the initial std we obtain bounds on the number of interpolation points 2122 * and degree of each numerator and denominator which we use for later 2123 * interpolation 2124 */ 2123 2125 rL= rL[2..size(rL)]; 2124 2126 } 2125 2126 2127 list newL,optionL; 2127 2128 ideal J; … … 2129 2130 { 2130 2131 newL = I, cI, opL; 2132 // apply modular command from the Singular library parallel.lib 2131 2133 if(tmp2) 2132 2134 { 2135 // with final test 2133 2136 J = modular("Ffmodstd::modp_tran", list(newL), primeTest_tran, 2134 2137 Modstd::deleteUnluckyPrimes_std, pTest_tran, finalTest_tran, pr); … … 2136 2139 else 2137 2140 { 2141 // without final test 2138 2142 J = modular("Ffmodstd::modp_tran", list(newL), primeTest_tran, 2139 2143 Modstd::deleteUnluckyPrimes_std, pTest_tran, pr); … … 2142 2146 else 2143 2147 { 2148 // apply modular command from the Singular library parallel.lib with final test 2144 2149 newL = I, cI, rL; 2145 2150 J = modular("Ffmodstd::modp_tran", list(newL), primeTest_tran, 2146 2151 Modstd::deleteUnluckyPrimes_std, pTest_tran, finalTest_tran, pr); 2147 2152 } 2148 2149 2153 setring G_t; 2150 2154 ideal J = imap(S_t, J); … … 2204 2208 /////////////////////////////////////////////////////////////////////////////// 2205 2209 2206 static proc Is_belongs(ideal I, ideal fareyresult)2210 static proc ideal_Inclusion(ideal I, ideal fareyresult) 2207 2211 { 2208 2212 //return 1 if I is in fareyresult otherwise 0 … … 2245 2249 attrib(fry,"isSB",1); 2246 2250 attrib(Jp,"isSB",1); 2247 if( Is_belongs(Jp,fry))2251 if(ideal_Inclusion(Jp,fry)) 2248 2252 { 2249 2253 // test if fry is in Jp … … 2280 2284 return(1); 2281 2285 } 2286 2287 // =============== a procedure for one parameter ends here ========== 2282 2288 2283 2289 /////////////////////////////////////////////////////////////////////////////// … … 2329 2335 " 2330 2336 { 2331 /*2332 * note that the number of parameter(s) and variable(s)2333 * in the given ideal must be equal to those in the current2334 * basering2335 */2336 2337 intvec opt = option(get); 2337 option(redSB); 2338 option(redSB); // to obtain the reduced standard basis 2338 2339 def G_t=basering; 2339 2340 int n,pa,kr; … … 2359 2360 if(pa==1) 2360 2361 { 2362 // if the current ring has one parameter 2361 2363 def GF = ffmodStdOne(I); 2362 2364 if(size(GF)==1) … … 2369 2371 I=scalIdeal(I); 2370 2372 list L=collect_coeffs(I); 2373 // define a new ring 2371 2374 list rl=ringlist(G_t); 2372 2375 list la=rl[1][2]; … … 2387 2390 } 2388 2391 list shft = test_the_shift(cI,n,pa); 2389 //intvec vshft = shft[1..pa]; vshft;2390 2392 int j; 2391 2393 // shift the parameters … … 2394 2396 cI = subst(cI, var(n+j), var(n+j) + shft[j]); 2395 2397 } 2396 2397 list pr=list_of_primes(pa); 2398 //intvec vpr = pr[1..pa]; 2399 //vpr; 2398 list pr=list_of_primes(pa); // list distinct primes 2399 // define a new ring 2400 2400 setring G_t; 2401 2401 rl = ringlist(G_t); … … 2410 2410 setring StA; 2411 2411 ideal Jc = imap(St,Jc); 2412 // make selection to use relitively fast command 2412 2413 list Lcom = select_the_command(Jc); 2413 2414 string Command = Lcom[1]; … … 2426 2427 Lcom = poly(0); 2427 2428 } 2428 2429 2429 Lcom = Lcom,Jc; 2430 2430 if(ncols(Jc)==1 and Jc[1]==1) … … 2451 2451 list Zr = imap(StA,Zr); 2452 2452 list FG = imap(StA, Lcom); 2453 // compute std using sparse multivariate rational interpolation 2453 2454 ideal J = stdoverFF(I,pr,shft, Command, Zr, FG); 2454 2455 setring G_t; … … 2473 2474 ideal J = x^2*y+y*z^2, x*z^2+x^2-y^2; 2474 2475 ffmodStd(J); 2475 ring R =(0,a,b),(x,y,z),dp;2476 ring R1=(0,a,b),(x,y,z),dp; 2476 2477 ideal I = x^2*y^3*z+2*a*x*y*z^2+7*y^3, 2477 2478 x^2*y^4*z+(a-7b)*x^2*y*z^2-x*y^2*z^2+2*x^2*y*z-12*x+by,
Note: See TracChangeset
for help on using the changeset viewer.