Changeset 935e83 in git
- Timestamp:
- Feb 2, 2012, 11:38:50 AM (11 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
- Children:
- 3ef2d61ea9f830707a76fcbf852b171be8716d84
- Parents:
- c53fdcb0540662085a9f0550fb16457042f01035
- git-author:
- Martin Lee <martinlee84@web.de>2012-02-02 11:38:50+01:00
- git-committer:
- Martin Lee <martinlee84@web.de>2012-04-04 14:42:25+02:00
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
factory/facHensel.cc
rc53fdc r935e83 52 52 convertCF2Fmpz (fmpz_poly_get_coeff_ptr (result, i.exp()*d), i.coeff()); 53 53 else 54 for (j=i.coeff(); j.hasTerms(); j++) 55 convertCF2Fmpz (fmpz_poly_get_coeff_ptr (result,i.exp()*d+j.exp()), j.coeff()); 54 for (j= i.coeff(); j.hasTerms(); j++) 55 convertCF2Fmpz (fmpz_poly_get_coeff_ptr (result, i.exp()*d+j.exp()), 56 j.coeff()); 56 57 } 57 58 _fmpz_poly_normalise(result); 58 59 60 /*fmpz_t coeff; 61 for (CFIterator i= A; i.hasTerms(); i++) 62 { 63 if (i.coeff().inBaseDomain()) 64 { 65 convertCF2Fmpz (coeff, i.coeff()); 66 fmpz_poly_set_coeff_fmpz (result, i.exp()*d, coeff); 67 } 68 else 69 { 70 for (CFIterator j= i.coeff();j.hasTerms(); j++) 71 { 72 convertCF2Fmpz (coeff, j.coeff()); 73 fmpz_poly_set_coeff_fmpz (result, i.exp()*d+j.exp(), coeff); 74 } 75 } 76 } 77 fmpz_clear (coeff); 78 _fmpz_poly_normalise (result);*/ 79 } 80 81 82 CanonicalForm reverseSubst (const fmpz_poly_t F, int d, const Variable& alpha, const CanonicalForm& den) 59 } 60 61 62 CanonicalForm 63 reverseSubst (const fmpz_poly_t F, int d, const Variable& alpha, 64 const CanonicalForm& den) 83 65 { 84 66 Variable x= Variable (1); … … 89 71 int k= 0; 90 72 int degfSubK; 91 int repLength ;73 int repLength, j; 92 74 CanonicalForm coeff; 93 75 fmpz* tmp; … … 101 83 repLength= degfSubK + 1; 102 84 103 for ( intj= 0; j < repLength; j++)85 for (j= 0; j < repLength; j++) 104 86 { 105 87 tmp= fmpz_poly_get_coeff_ptr (F, j+k); … … 117 99 } 118 100 119 CanonicalForm mulFLINTQa (const CanonicalForm& F, const CanonicalForm& G, const Variable& alpha) 101 CanonicalForm 102 mulFLINTQa (const CanonicalForm& F, const CanonicalForm& G, 103 const Variable& alpha) 120 104 { 121 105 CanonicalForm A= F; … … 171 155 } 172 156 173 CanonicalForm157 /*CanonicalForm 174 158 mulFLINTQ2 (const CanonicalForm& F, const CanonicalForm& G) 175 159 { … … 186 170 fmpq_poly_clear (FLINTB); 187 171 return A; 188 } 172 }*/ 189 173 190 174 CanonicalForm … … 225 209 226 210 CanonicalForm 227 mulFLINTQaTrunc (const CanonicalForm& F, const CanonicalForm& G, const Variable& alpha, int m) 211 mulFLINTQaTrunc (const CanonicalForm& F, const CanonicalForm& G, 212 const Variable& alpha, int m) 228 213 { 229 214 CanonicalForm A= F; … … 561 546 Variable alpha; 562 547 #ifdef HAVE_FLINT 563 if ((!F.inCoeffDomain() && !G.inCoeffDomain()) && (hasFirstAlgVar (F, alpha) || hasFirstAlgVar (G, alpha))) 548 if ((!F.inCoeffDomain() && !G.inCoeffDomain()) && 549 (hasFirstAlgVar (F, alpha) || hasFirstAlgVar (G, alpha))) 564 550 { 565 551 CanonicalForm result= mulFLINTQa (F, G, alpha); … … 624 610 return modFLINTQ (F, G); 625 611 else 612 //TODO newtonDivrem 626 613 return mod (F, G); 627 614 #else … … 683 670 return divFLINTQ (F,G); 684 671 else 672 //TODO newtonDivrem 685 673 return div (F, G); 686 674 #else … … 798 786 nmod_poly_t buf; 799 787 788 int j, k, bufRepLength; 800 789 for (CFIterator i= A; i.hasTerms(); i++) 801 790 { 802 791 convertFacCF2nmod_poly_t (buf, i.coeff()); 803 792 804 intk= i.exp()*d;805 intbufRepLength= (int) nmod_poly_length (buf);806 for ( intj= 0; j < bufRepLength; j++)793 k= i.exp()*d; 794 bufRepLength= (int) nmod_poly_length (buf); 795 for (j= 0; j < bufRepLength; j++) 807 796 nmod_poly_set_coeff_ui (result, j + k, nmod_poly_get_coeff_ui (buf, j)); 808 797 nmod_poly_clear (buf); … … 895 884 zz_pX buf; 896 885 zz_p *bufp; 886 int j, k, bufRepLength; 897 887 898 888 for (CFIterator i= A; i.hasTerms(); i++) … … 903 893 buf= convertFacCF2NTLzzpX (i.coeff()); 904 894 905 intk= i.exp()*d;895 k= i.exp()*d; 906 896 bufp= buf.rep.elts(); 907 intbufRepLength= (int) buf.rep.length();908 for ( intj= 0; j < bufRepLength; j++)897 bufRepLength= (int) buf.rep.length(); 898 for (j= 0; j < bufRepLength; j++) 909 899 resultp [j + k]= bufp [j]; 910 900 } … … 927 917 zz_pX buf2; 928 918 zz_pX NTLMipo= convertFacCF2NTLzzpX (getMipo (alpha)); 919 int j, k, buf1RepLength; 929 920 930 921 for (CFIterator i= A; i.hasTerms(); i++) … … 938 929 buf1= convertFacCF2NTLzz_pEX (i.coeff(), NTLMipo); 939 930 940 intk= i.exp()*d;931 k= i.exp()*d; 941 932 buf1p= buf1.rep.elts(); 942 intbuf1RepLength= (int) buf1.rep.length();943 for ( intj= 0; j < buf1RepLength; j++)933 buf1RepLength= (int) buf1.rep.length(); 934 for (j= 0; j < buf1RepLength; j++) 944 935 resultp [j + k]= buf1p [j]; 945 936 } … … 966 957 zz_pX buf2; 967 958 zz_pX NTLMipo= convertFacCF2NTLzzpX (getMipo (alpha)); 959 int j, k, kk, bufRepLength; 968 960 969 961 for (CFIterator i= A; i.hasTerms(); i++) … … 977 969 buf= convertFacCF2NTLzz_pEX (i.coeff(), NTLMipo); 978 970 979 intk= i.exp()*d;980 intkk= (degAy - i.exp())*d;971 k= i.exp()*d; 972 kk= (degAy - i.exp())*d; 981 973 bufp= buf.rep.elts(); 982 intbufRepLength= (int) buf.rep.length();983 for ( intj= 0; j < bufRepLength; j++)974 bufRepLength= (int) buf.rep.length(); 975 for (j= 0; j < bufRepLength; j++) 984 976 { 985 977 subA1p [j + k] += bufp [j]; … … 1004 996 zz_pX buf; 1005 997 zz_p *bufp; 998 int j, k, kk, bufRepLength; 1006 999 1007 1000 for (CFIterator i= A; i.hasTerms(); i++) … … 1009 1002 buf= convertFacCF2NTLzzpX (i.coeff()); 1010 1003 1011 intk= i.exp()*d;1012 intkk= (degAy - i.exp())*d;1004 k= i.exp()*d; 1005 kk= (degAy - i.exp())*d; 1013 1006 bufp= buf.rep.elts(); 1014 intbufRepLength= (int) buf.rep.length();1015 for ( intj= 0; j < bufRepLength; j++)1007 bufRepLength= (int) buf.rep.length(); 1008 for (j= 0; j < bufRepLength; j++) 1016 1009 { 1017 1010 subA1p [j + k] += bufp [j]; … … 1053 1046 int degfSubLf= degf; 1054 1047 int deggSubLg= degg-lg; 1055 int repLengthBuf2; 1056 int repLengthBuf1; 1048 int repLengthBuf2, repLengthBuf1, ind, tmp; 1057 1049 zz_pE zzpEZero= zz_pE(); 1058 1050 … … 1068 1060 1069 1061 buf1p= buf1.rep.elts(); 1070 for (in t ind= 0; ind < repLengthBuf1; ind++)1062 for (ind= 0; ind < repLengthBuf1; ind++) 1071 1063 buf1p [ind]= fp [ind + lf]; 1072 1064 buf1.normalize(); … … 1083 1075 buf2.rep.SetLength ((long) repLengthBuf2); 1084 1076 buf2p= buf2.rep.elts(); 1085 for (int ind= 0; ind < repLengthBuf2; ind++) 1086 { 1077 for (ind= 0; ind < repLengthBuf2; ind++) 1087 1078 buf2p [ind]= gp [ind + lg]; 1088 }1089 1079 buf2.normalize(); 1090 1080 … … 1095 1085 buf2p= buf2.rep.elts(); 1096 1086 buf1p= buf1.rep.elts(); 1097 for (in t ind= 0; ind < repLengthBuf1; ind++)1087 for (ind= 0; ind < repLengthBuf1; ind++) 1098 1088 buf3p [ind]= buf1p [ind]; 1099 for (in t ind= repLengthBuf1; ind < d; ind++)1089 for (ind= repLengthBuf1; ind < d; ind++) 1100 1090 buf3p [ind]= zzpEZero; 1101 for (in t ind= 0; ind < repLengthBuf2; ind++)1091 for (ind= 0; ind < repLengthBuf2; ind++) 1102 1092 buf3p [ind + d]= buf2p [ind]; 1103 1093 buf3.normalize(); … … 1119 1109 if (repLengthBuf2 > degfSubLf + 1) 1120 1110 degfSubLf= repLengthBuf2 - 1; 1121 inttmp= tmin (repLengthBuf1, deggSubLg + 1);1122 for (in t ind= 0; ind < tmp; ind++)1111 tmp= tmin (repLengthBuf1, deggSubLg + 1); 1112 for (ind= 0; ind < tmp; ind++) 1123 1113 gp [ind + lg] -= buf1p [ind]; 1124 1114 } … … 1130 1120 if (degfSubLf >= 0) 1131 1121 { 1132 for (in t ind= 0; ind < repLengthBuf2; ind++)1122 for (ind= 0; ind < repLengthBuf2; ind++) 1133 1123 fp [ind + lf] -= buf2p [ind]; 1134 1124 } … … 1168 1158 int degfSubLf= degf; 1169 1159 int deggSubLg= degg-lg; 1170 int repLengthBuf2; 1171 int repLengthBuf1; 1160 int repLengthBuf2, repLengthBuf1, ind, tmp; 1172 1161 zz_p zzpZero= zz_p(); 1173 1162 while (degf >= lf || lg >= 0) … … 1182 1171 1183 1172 buf1p= buf1.rep.elts(); 1184 for (in t ind= 0; ind < repLengthBuf1; ind++)1173 for (ind= 0; ind < repLengthBuf1; ind++) 1185 1174 buf1p [ind]= fp [ind + lf]; 1186 1175 buf1.normalize(); … … 1197 1186 buf2.rep.SetLength ((long) repLengthBuf2); 1198 1187 buf2p= buf2.rep.elts(); 1199 for (in t ind= 0; ind < repLengthBuf2; ind++)1188 for (ind= 0; ind < repLengthBuf2; ind++) 1200 1189 buf2p [ind]= gp [ind + lg]; 1201 1190 … … 1209 1198 buf2p= buf2.rep.elts(); 1210 1199 buf1p= buf1.rep.elts(); 1211 for (in t ind= 0; ind < repLengthBuf1; ind++)1200 for (ind= 0; ind < repLengthBuf1; ind++) 1212 1201 buf3p [ind]= buf1p [ind]; 1213 for (in t ind= repLengthBuf1; ind < d; ind++)1202 for (ind= repLengthBuf1; ind < d; ind++) 1214 1203 buf3p [ind]= zzpZero; 1215 for (in t ind= 0; ind < repLengthBuf2; ind++)1204 for (ind= 0; ind < repLengthBuf2; ind++) 1216 1205 buf3p [ind + d]= buf2p [ind]; 1217 1206 buf3.normalize(); … … 1233 1222 if (repLengthBuf2 > degfSubLf + 1) 1234 1223 degfSubLf= repLengthBuf2 - 1; 1235 inttmp= tmin (repLengthBuf1, deggSubLg + 1);1236 for (in t ind= 0; ind < tmp; ind++)1224 tmp= tmin (repLengthBuf1, deggSubLg + 1); 1225 for (ind= 0; ind < tmp; ind++) 1237 1226 gp [ind + lg] -= buf1p [ind]; 1238 1227 } … … 1243 1232 if (degfSubLf >= 0) 1244 1233 { 1245 for (in t ind= 0; ind < repLengthBuf2; ind++)1234 for (ind= 0; ind < repLengthBuf2; ind++) 1246 1235 fp [ind + lf] -= buf2p [ind]; 1247 1236 } … … 1265 1254 int degf= deg(f); 1266 1255 int k= 0; 1267 int degfSubK; 1268 int repLength; 1256 int degfSubK, repLength, j; 1269 1257 while (degf >= k) 1270 1258 { … … 1277 1265 buf.rep.SetLength ((long) repLength); 1278 1266 bufp= buf.rep.elts(); 1279 for ( intj= 0; j < repLength; j++)1267 for (j= 0; j < repLength; j++) 1280 1268 bufp [j]= fp [j + k]; 1281 1269 buf.normalize(); … … 1303 1291 int degf= deg(f); 1304 1292 int k= 0; 1305 int degfSubK; 1306 int repLength; 1293 int degfSubK, repLength, j; 1307 1294 while (degf >= k) 1308 1295 { … … 1315 1302 buf.rep.SetLength ((long) repLength); 1316 1303 bufp= buf.rep.elts(); 1317 for ( intj= 0; j < repLength; j++)1304 for (j= 0; j < repLength; j++) 1318 1305 bufp [j]= fp [j + k]; 1319 1306 buf.normalize(); … … 1472 1459 #ifdef HAVE_FLINT 1473 1460 void 1474 kronSubRecipro (nmod_poly_t subA1, nmod_poly_t subA2, const CanonicalForm& A, int d) 1461 kronSubRecipro (nmod_poly_t subA1, nmod_poly_t subA2, const CanonicalForm& A, 1462 int d) 1475 1463 { 1476 1464 int degAy= degree (A); … … 1481 1469 nmod_poly_t buf; 1482 1470 1471 int k, kk, j, bufRepLength; 1483 1472 for (CFIterator i= A; i.hasTerms(); i++) 1484 1473 { 1485 1474 convertFacCF2nmod_poly_t (buf, i.coeff()); 1486 1475 1487 int k= i.exp()*d; 1488 int kk= (degAy - i.exp())*d; 1489 int bufRepLength= (int) nmod_poly_length (buf); 1490 for (int j= 0; j < bufRepLength; j++) 1491 { 1492 nmod_poly_set_coeff_ui (subA1, j + k, n_addmod (nmod_poly_get_coeff_ui (subA1, j+k), nmod_poly_get_coeff_ui (buf, j), getCharacteristic())); //TODO muà man subA1 coeffs von subA1 vorher auf null setzen?? 1493 nmod_poly_set_coeff_ui (subA2, j + kk, n_addmod (nmod_poly_get_coeff_ui (subA2, j + kk),nmod_poly_get_coeff_ui (buf, j), getCharacteristic())); 1476 k= i.exp()*d; 1477 kk= (degAy - i.exp())*d; 1478 bufRepLength= (int) nmod_poly_length (buf); 1479 for (j= 0; j < bufRepLength; j++) 1480 { 1481 nmod_poly_set_coeff_ui (subA1, j + k, 1482 n_addmod (nmod_poly_get_coeff_ui (subA1, j+k), 1483 nmod_poly_get_coeff_ui (buf, j), 1484 getCharacteristic() 1485 ) 1486 ); 1487 nmod_poly_set_coeff_ui (subA2, j + kk, 1488 n_addmod (nmod_poly_get_coeff_ui (subA2, j + kk), 1489 nmod_poly_get_coeff_ui (buf, j), 1490 getCharacteristic() 1491 ) 1492 ); 1494 1493 } 1495 1494 nmod_poly_clear (buf); … … 1500 1499 1501 1500 void 1502 kronSubRecipro (fmpz_poly_t subA1, fmpz_poly_t subA2, const CanonicalForm& A, int d) 1501 kronSubRecipro (fmpz_poly_t subA1, fmpz_poly_t subA2, const CanonicalForm& A, 1502 int d) 1503 1503 { 1504 1504 int degAy= degree (A); … … 1509 1509 fmpz_t coeff1, coeff2; 1510 1510 1511 int k, kk, j, bufRepLength; 1511 1512 for (CFIterator i= A; i.hasTerms(); i++) 1512 1513 { 1513 1514 convertFacCF2Fmpz_poly_t (buf, i.coeff()); 1514 1515 1515 int k= i.exp()*d; 1516 int kk= (degAy - i.exp())*d; 1517 int bufRepLength= (int) fmpz_poly_length (buf); 1518 for (int j= 0; j < bufRepLength; j++) 1519 { 1520 fmpz_poly_get_coeff_fmpz (coeff1, subA1, j+k); //TODO muà man subA1 coeffs von subA1 vorher auf null setzen?? 1521 // vielleicht ist es schneller fmpz_poly_get_ptr zu nehmen 1516 k= i.exp()*d; 1517 kk= (degAy - i.exp())*d; 1518 bufRepLength= (int) fmpz_poly_length (buf); 1519 for (j= 0; j < bufRepLength; j++) 1520 { 1521 fmpz_poly_get_coeff_fmpz (coeff1, subA1, j+k); 1522 1522 fmpz_poly_get_coeff_fmpz (coeff2, buf, j); 1523 1523 fmpz_add (coeff1, coeff1, coeff2); … … 1549 1549 int degf= fmpz_poly_degree(f); 1550 1550 int k= 0; 1551 int degfSubK; 1552 int repLength; 1551 int degfSubK, repLength, j; 1553 1552 fmpz_t coeff; 1554 1553 while (degf >= k) … … 1562 1561 fmpz_poly_init2 (buf, repLength); 1563 1562 fmpz_init (coeff); 1564 for ( intj= 0; j < repLength; j++)1563 for (j= 0; j < repLength; j++) 1565 1564 { 1566 1565 fmpz_poly_get_coeff_fmpz (coeff, f, j + k); … … 1597 1596 1598 1597 nmod_poly_t buf1,buf2, buf3; 1599 /*nmod_poly_init_preinv (buf1, getCharacteristic(), ninv);1600 nmod_poly_init_preinv (buf2, getCharacteristic(), ninv);1601 nmod_poly_init_preinv (buf3, getCharacteristic(), ninv);*/1602 1598 1603 1599 if (nmod_poly_length (f) < (long) d*(k+1)) //zero padding … … 1610 1606 int degfSubLf= degf; 1611 1607 int deggSubLg= degg-lg; 1612 int repLengthBuf2; 1613 int repLengthBuf1; 1614 //zz_p zzpZero= zz_p(); 1608 int repLengthBuf2, repLengthBuf1, ind, tmp; 1615 1609 while (degf >= lf || lg >= 0) 1616 1610 { … … 1621 1615 else 1622 1616 repLengthBuf1= degfSubLf + 1; 1623 //cout << "repLengthBuf1= " << repLengthBuf1 << "\n";1624 //cout << "nmod_poly_length (buf1)= " << nmod_poly_length (buf1) << "\n";1625 1617 nmod_poly_init2_preinv (buf1, getCharacteristic(), ninv, repLengthBuf1); 1626 //cout << "nmod_poly_length (buf1)= " << nmod_poly_length (buf1) << "\n"; 1627 1628 for (int ind= 0; ind < repLengthBuf1; ind++) 1618 1619 for (ind= 0; ind < repLengthBuf1; ind++) 1629 1620 nmod_poly_set_coeff_ui (buf1, ind, nmod_poly_get_coeff_ui (f, ind+lf)); 1630 1621 _nmod_poly_normalise (buf1); 1631 //cout << "nmod_poly_length (buf1)= " << nmod_poly_length (buf1) << "\n";1632 1622 1633 1623 repLengthBuf1= nmod_poly_length (buf1); … … 1640 1630 repLengthBuf2= deggSubLg + 1; 1641 1631 1642 //cout << "repLengthBuf2= " << repLengthBuf2 << "\n";1643 //cout << "nmod_poly_length (buf2)= " << nmod_poly_length (buf2) << "\n";1644 1632 nmod_poly_init2_preinv (buf2, getCharacteristic(), ninv, repLengthBuf2); 1645 //cout << "nmod_poly_length (buf2)= " << nmod_poly_length (buf2) << "\n"; 1646 for (int ind= 0; ind < repLengthBuf2; ind++) 1633 for (ind= 0; ind < repLengthBuf2; ind++) 1647 1634 nmod_poly_set_coeff_ui (buf2, ind, nmod_poly_get_coeff_ui (g, ind + lg)); 1648 1635 1649 1636 _nmod_poly_normalise (buf2); 1650 //cout << "nmod_poly_length (buf2)= " << nmod_poly_length (buf2) << "\n";1651 1637 repLengthBuf2= nmod_poly_length (buf2); 1652 1638 1653 1639 nmod_poly_init2_preinv (buf3, getCharacteristic(), ninv, repLengthBuf2 + d); 1654 for (in t ind= 0; ind < repLengthBuf1; ind++)1640 for (ind= 0; ind < repLengthBuf1; ind++) 1655 1641 nmod_poly_set_coeff_ui (buf3, ind, nmod_poly_get_coeff_ui (buf1, ind)); 1656 for (in t ind= repLengthBuf1; ind < d; ind++)1642 for (ind= repLengthBuf1; ind < d; ind++) 1657 1643 nmod_poly_set_coeff_ui (buf3, ind, 0); 1658 for (in t ind= 0; ind < repLengthBuf2; ind++)1659 nmod_poly_set_coeff_ui (buf3, ind +d, nmod_poly_get_coeff_ui (buf2, ind));1644 for (ind= 0; ind < repLengthBuf2; ind++) 1645 nmod_poly_set_coeff_ui (buf3, ind+d, nmod_poly_get_coeff_ui (buf2, ind)); 1660 1646 _nmod_poly_normalise (buf3); 1661 1647 … … 1674 1660 if (repLengthBuf2 > degfSubLf + 1) 1675 1661 degfSubLf= repLengthBuf2 - 1; 1676 int tmp= tmin (repLengthBuf1, deggSubLg + 1); 1677 for (int ind= 0; ind < tmp; ind++) 1678 //{ 1679 nmod_poly_set_coeff_ui (g, ind + lg, n_submod (nmod_poly_get_coeff_ui (g, ind + lg), nmod_poly_get_coeff_ui (buf1, ind), getCharacteristic())); 1680 //cout << "nmod_poly_get_coeff_ui (g, ind + lg)= " << nmod_poly_get_coeff_ui (g, ind + lg) << "\n"; 1681 //} 1662 tmp= tmin (repLengthBuf1, deggSubLg + 1); 1663 for (ind= 0; ind < tmp; ind++) 1664 nmod_poly_set_coeff_ui (g, ind + lg, 1665 n_submod (nmod_poly_get_coeff_ui (g, ind + lg), 1666 nmod_poly_get_coeff_ui (buf1, ind), 1667 getCharacteristic() 1668 ) 1669 ); 1682 1670 } 1683 1671 if (lg < 0) … … 1690 1678 if (degfSubLf >= 0) 1691 1679 { 1692 for (int ind= 0; ind < repLengthBuf2; ind++) 1693 nmod_poly_set_coeff_ui (f, ind + lf, n_submod (nmod_poly_get_coeff_ui (f, ind + lf), nmod_poly_get_coeff_ui (buf2, ind), getCharacteristic())); 1680 for (ind= 0; ind < repLengthBuf2; ind++) 1681 nmod_poly_set_coeff_ui (f, ind + lf, 1682 n_submod (nmod_poly_get_coeff_ui (f, ind + lf), 1683 nmod_poly_get_coeff_ui (buf2, ind), 1684 getCharacteristic() 1685 ) 1686 ); 1694 1687 } 1695 1688 nmod_poly_clear (buf1); 1696 1689 nmod_poly_clear (buf2); 1697 1690 nmod_poly_clear (buf3); 1698 /*nmod_poly_init_preinv (buf1, getCharacteristic(), ninv); 1699 nmod_poly_init_preinv (buf2, getCharacteristic(), ninv); 1700 nmod_poly_init_preinv (buf3, getCharacteristic(), ninv);*/ 1701 } 1702 1703 /*nmod_poly_clear (buf1); 1704 nmod_poly_clear (buf2); 1705 nmod_poly_clear (buf3);*/ 1691 } 1692 1706 1693 nmod_poly_clear (f); 1707 1694 nmod_poly_clear (g); … … 1726 1713 1727 1714 fmpz_poly_t buf1,buf2, buf3; 1728 /*nmod_poly_init_preinv (buf1, getCharacteristic(), ninv);1729 nmod_poly_init_preinv (buf2, getCharacteristic(), ninv);1730 nmod_poly_init_preinv (buf3, getCharacteristic(), ninv);*/1731 1715 1732 1716 if (fmpz_poly_length (f) < (long) d*(k+1)) //zero padding … … 1739 1723 int degfSubLf= degf; 1740 1724 int deggSubLg= degg-lg; 1741 int repLengthBuf2; 1742 int repLengthBuf1; 1743 //zz_p zzpZero= zz_p(); 1725 int repLengthBuf2, repLengthBuf1, ind, tmp; 1744 1726 fmpz_t tmp1, tmp2; 1745 1727 while (degf >= lf || lg >= 0) … … 1751 1733 else 1752 1734 repLengthBuf1= degfSubLf + 1; 1753 //cout << "repLengthBuf1= " << repLengthBuf1 << "\n"; 1754 //cout << "nmod_poly_length (buf1)= " << nmod_poly_length (buf1) << "\n"; 1735 1755 1736 fmpz_poly_init2 (buf1, repLengthBuf1); 1756 //cout << "nmod_poly_length (buf1)= " << nmod_poly_length (buf1) << "\n"; 1757 1758 for (int ind= 0; ind < repLengthBuf1; ind++) 1737 1738 for (ind= 0; ind < repLengthBuf1; ind++) 1759 1739 { 1760 1740 fmpz_poly_get_coeff_fmpz (tmp1, f, ind + lf); … … 1762 1742 } 1763 1743 _fmpz_poly_normalise (buf1); 1764 //cout << "nmod_poly_length (buf1)= " << nmod_poly_length (buf1) << "\n";1765 1744 1766 1745 repLengthBuf1= fmpz_poly_length (buf1); … … 1773 1752 repLengthBuf2= deggSubLg + 1; 1774 1753 1775 //cout << "repLengthBuf2= " << repLengthBuf2 << "\n";1776 //cout << "nmod_poly_length (buf2)= " << nmod_poly_length (buf2) << "\n";1777 1754 fmpz_poly_init2 (buf2, repLengthBuf2); 1778 //cout << "nmod_poly_length (buf2)= " << nmod_poly_length (buf2) << "\n"; 1779 for (in t ind= 0; ind < repLengthBuf2; ind++)1755 1756 for (ind= 0; ind < repLengthBuf2; ind++) 1780 1757 { 1781 1758 fmpz_poly_get_coeff_fmpz (tmp1, g, ind + lg); … … 1784 1761 1785 1762 _fmpz_poly_normalise (buf2); 1786 //cout << "nmod_poly_length (buf2)= " << nmod_poly_length (buf2) << "\n";1787 1763 repLengthBuf2= fmpz_poly_length (buf2); 1788 1764 1789 1765 fmpz_poly_init2 (buf3, repLengthBuf2 + d); 1790 for (in t ind= 0; ind < repLengthBuf1; ind++)1766 for (ind= 0; ind < repLengthBuf1; ind++) 1791 1767 { 1792 1768 fmpz_poly_get_coeff_fmpz (tmp1, buf1, ind); //oder fmpz_set (fmpz_poly_get_coeff_ptr (buf3, ind),fmpz_poly_get_coeff_ptr (buf1, ind)) 1793 1769 fmpz_poly_set_coeff_fmpz (buf3, ind, tmp1); 1794 1770 } 1795 for (in t ind= repLengthBuf1; ind < d; ind++)1771 for (ind= repLengthBuf1; ind < d; ind++) 1796 1772 fmpz_poly_set_coeff_ui (buf3, ind, 0); 1797 for (in t ind= 0; ind < repLengthBuf2; ind++)1773 for (ind= 0; ind < repLengthBuf2; ind++) 1798 1774 { 1799 1775 fmpz_poly_get_coeff_fmpz (tmp1, buf2, ind); … … 1816 1792 if (repLengthBuf2 > degfSubLf + 1) 1817 1793 degfSubLf= repLengthBuf2 - 1; 1818 inttmp= tmin (repLengthBuf1, deggSubLg + 1);1819 for (in t ind= 0; ind < tmp; ind++)1794 tmp= tmin (repLengthBuf1, deggSubLg + 1); 1795 for (ind= 0; ind < tmp; ind++) 1820 1796 { 1821 1797 fmpz_poly_get_coeff_fmpz (tmp1, g, ind + lg); … … 1823 1799 fmpz_sub (tmp1, tmp1, tmp2); 1824 1800 fmpz_poly_set_coeff_fmpz (g, ind + lg, tmp1); 1825 //cout << "nmod_poly_get_coeff_ui (g, ind + lg)= " << nmod_poly_get_coeff_ui (g, ind + lg) << "\n";1826 1801 } 1827 1802 } … … 1835 1810 if (degfSubLf >= 0) 1836 1811 { 1837 for (in t ind= 0; ind < repLengthBuf2; ind++)1812 for (ind= 0; ind < repLengthBuf2; ind++) 1838 1813 { 1839 1814 fmpz_poly_get_coeff_fmpz (tmp1, f, ind + lf); … … 1846 1821 fmpz_poly_clear (buf2); 1847 1822 fmpz_poly_clear (buf3); 1848 /*nmod_poly_init_preinv (buf1, getCharacteristic(), ninv); 1849 nmod_poly_init_preinv (buf2, getCharacteristic(), ninv); 1850 nmod_poly_init_preinv (buf3, getCharacteristic(), ninv);*/ 1851 } 1852 1853 /*nmod_poly_clear (buf1); 1854 nmod_poly_clear (buf2); 1855 nmod_poly_clear (buf3);*/ 1823 } 1824 1856 1825 fmpz_poly_clear (f); 1857 1826 fmpz_poly_clear (g); … … 1873 1842 1874 1843 nmod_poly_t buf; 1875 //nmod_poly_init_preinv (buf, getCharacteristic(), ninv);1876 1844 CanonicalForm result= 0; 1877 1845 int i= 0; 1878 1846 int degf= nmod_poly_degree(f); 1879 1847 int k= 0; 1880 int degfSubK; 1881 int repLength; 1848 int degfSubK, repLength, j; 1882 1849 while (degf >= k) 1883 1850 { … … 1889 1856 1890 1857 nmod_poly_init2_preinv (buf, getCharacteristic(), ninv, repLength); 1891 for ( intj= 0; j < repLength; j++)1858 for (j= 0; j < repLength; j++) 1892 1859 nmod_poly_set_coeff_ui (buf, j, nmod_poly_get_coeff_ui (f, j + k)); 1893 //printf ("after set\n");1894 1860 _nmod_poly_normalise (buf); 1895 //printf ("after normalise\n");1896 1861 1897 1862 result += convertnmod_poly_t2FacCF (buf, x)*power (y, i); … … 1899 1864 k= d*i; 1900 1865 nmod_poly_clear (buf); 1901 //nmod_poly_init_preinv (buf, getCharacteristic(), ninv); 1902 } 1903 //printf ("after while\n"); 1904 //nmod_poly_clear (buf); 1866 } 1905 1867 nmod_poly_clear (f); 1906 //printf ("after clear\n");1907 1868 1908 1869 return result; … … 1922 1883 nmod_poly_init_preinv (F2, getCharacteristic(), ninv); 1923 1884 kronSubRecipro (F1, F2, F, d1); 1924 /*zz_pX TF1, TF2;1925 kronSubRecipro (TF1, TF2, F, d1);1926 Variable x= Variable (1);1927 cout << "testkronSubReci= " << (convertNTLzzpX2CF (TF1, x) == convertnmod_poly_t2FacCF (F1, x)) << "\n";1928 cout << "testkronSubReci= " << (convertNTLzzpX2CF (TF2, x) == convertnmod_poly_t2FacCF (F2, x)) << "\n";*/1929 1885 1930 1886 nmod_poly_t G1, G2; … … 1932 1888 nmod_poly_init_preinv (G2, getCharacteristic(), ninv); 1933 1889 kronSubRecipro (G1, G2, G, d1); 1934 /*zz_pX TG1, TG2;1935 kronSubRecipro (TG1, TG2, G, d1);1936 cout << "testkronSubReci= " << (convertNTLzzpX2CF (TG1, x) == convertnmod_poly_t2FacCF (G1, x)) << "\n";1937 cout << "testkronSubReci= " << (convertNTLzzpX2CF (TG2, x) == convertnmod_poly_t2FacCF (G2, x)) << "\n";*/1938 1939 1890 1940 1891 int k= d1*degree (M); 1941 1892 nmod_poly_mullow (F1, F1, G1, (long) k); 1942 /*MulTrunc (TF1, TF1, TG1, (long) k);1943 cout << "testkronSubReci= " << (convertNTLzzpX2CF (TF1, x) == convertnmod_poly_t2FacCF (F1, x)) << "\n";*/1944 1893 1945 1894 int degtailF= degree (tailcoeff (F), 1);; … … 1948 1897 int taildegG= taildegree (G); 1949 1898 1950 int b= nmod_poly_degree (F2) + nmod_poly_degree (G2) - k - degtailF - degtailG + d1*(2+taildegF + taildegG); 1899 int b= nmod_poly_degree (F2) + nmod_poly_degree (G2) - k - degtailF - degtailG 1900 + d1*(2+taildegF + taildegG); 1951 1901 nmod_poly_mulhigh (F2, F2, G2, b); 1952 1902 nmod_poly_shift_right (F2, F2, b); 1953 /*mul (TF2, TF2, TG2);1954 if (deg (TF2) > k)1955 {1956 int b= deg (TF2) - k + 2;1957 TF2 >>= b;1958 }1959 cout << "testkronSubReci= " << (convertNTLzzpX2CF (TF2, x) == convertnmod_poly_t2FacCF (F2, x)) << "\n";*/1960 1903 int d2= tmax (nmod_poly_degree (F2)/d1, nmod_poly_degree (F1)/d1); 1961 1904 1962 1905 1963 1906 CanonicalForm result= reverseSubst (F1, F2, d1, d2); 1964 //CanonicalForm NTLres= reverseSubst (TF1, TF2, d1, d2);1965 //cout << "FINALtestkronSubReci= " << (NTLres == result) << "\n";1966 1907 1967 1908 nmod_poly_clear (F1); … … 2018 1959 fmpz_poly_init (F2); 2019 1960 kronSubRecipro (F1, F2, F, d1); 2020 /*zz_pX TF1, TF2;2021 kronSubRecipro (TF1, TF2, F, d1);2022 Variable x= Variable (1);2023 cout << "testkronSubReci= " << (convertNTLzzpX2CF (TF1, x) == convertnmod_poly_t2FacCF (F1, x)) << "\n";2024 cout << "testkronSubReci= " << (convertNTLzzpX2CF (TF2, x) == convertnmod_poly_t2FacCF (F2, x)) << "\n";*/2025 1961 2026 1962 fmpz_poly_t G1, G2; … … 2028 1964 fmpz_poly_init (G2); 2029 1965 kronSubRecipro (G1, G2, G, d1); 2030 /*zz_pX TG1, TG2;2031 kronSubRecipro (TG1, TG2, G, d1);2032 cout << "testkronSubReci= " << (convertNTLzzpX2CF (TG1, x) == convertnmod_poly_t2FacCF (G1, x)) << "\n";2033 cout << "testkronSubReci= " << (convertNTLzzpX2CF (TG2, x) == convertnmod_poly_t2FacCF (G2, x)) << "\n";*/2034 2035 1966 2036 1967 int k= d1*degree (M); 2037 1968 fmpz_poly_mullow (F1, F1, G1, (long) k); 2038 /*MulTrunc (TF1, TF1, TG1, (long) k);2039 cout << "testkronSubReci= " << (convertNTLzzpX2CF (TF1, x) == convertnmod_poly_t2FacCF (F1, x)) << "\n";*/2040 1969 2041 1970 int degtailF= degree (tailcoeff (F), 1);; … … 2044 1973 int taildegG= taildegree (G); 2045 1974 2046 int b= fmpz_poly_degree (F2) + fmpz_poly_degree (G2) - k - degtailF - degtailG + d1*(2+taildegF + taildegG); 1975 int b= fmpz_poly_degree (F2) + fmpz_poly_degree (G2) - k - degtailF - degtailG 1976 + d1*(2+taildegF + taildegG); 2047 1977 fmpz_poly_mulhigh_n (F2, F2, G2, b); 2048 1978 fmpz_poly_shift_right (F2, F2, b); 2049 /*mul (TF2, TF2, TG2);2050 if (deg (TF2) > k)2051 {2052 int b= deg (TF2) - k + 2;2053 TF2 >>= b;2054 }2055 cout << "testkronSubReci= " << (convertNTLzzpX2CF (TF2, x) == convertnmod_poly_t2FacCF (F2, x)) << "\n";*/2056 1979 int d2= tmax (fmpz_poly_degree (F2)/d1, fmpz_poly_degree (F1)/d1); 2057 1980 2058 2059 1981 CanonicalForm result= reverseSubst (F1, F2, d1, d2); 2060 2061 //CanonicalForm NTLres= reverseSubst (TF1, TF2, d1, d2);2062 //cout << "FINALtestkronSubReci= " << (NTLres == result) << "\n";2063 1982 2064 1983 fmpz_poly_clear (F1); … … 2077 1996 2078 1997 int degAx= degree (A, 1); 2079 //int degAy= degree (A, 2);2080 1998 int degBx= degree (B, 1); 2081 //int degBy= degree (B, 2);2082 1999 int d1= degAx + 1 + degBx; 2083 //int d2= tmax (degAy, degBy);2084 2000 2085 2001 CanonicalForm f= bCommonDen (F);
Note: See TracChangeset
for help on using the changeset viewer.