Changeset 935e83 in git for factory


Ignore:
Timestamp:
Feb 2, 2012, 11:38:50 AM (12 years ago)
Author:
Martin Lee <martinlee84@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
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
Message:
chg: deleted some commented out debug stuff and formatted code
File:
1 edited

Legend:

Unmodified
Added
Removed
  • factory/facHensel.cc

    rc53fdc r935e83  
    5252      convertCF2Fmpz (fmpz_poly_get_coeff_ptr (result, i.exp()*d), i.coeff());
    5353    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());
    5657  }
    5758  _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
     62CanonicalForm
     63reverseSubst (const fmpz_poly_t F, int d, const Variable& alpha,
     64              const CanonicalForm& den)
    8365{
    8466  Variable x= Variable (1);
     
    8971  int k= 0;
    9072  int degfSubK;
    91   int repLength;
     73  int repLength, j;
    9274  CanonicalForm coeff;
    9375  fmpz* tmp;
     
    10183      repLength= degfSubK + 1;
    10284
    103     for (int j= 0; j < repLength; j++)
     85    for (j= 0; j < repLength; j++)
    10486    {
    10587      tmp= fmpz_poly_get_coeff_ptr (F, j+k);
     
    11799}
    118100
    119 CanonicalForm mulFLINTQa (const CanonicalForm& F, const CanonicalForm& G, const Variable& alpha)
     101CanonicalForm
     102mulFLINTQa (const CanonicalForm& F, const CanonicalForm& G,
     103            const Variable& alpha)
    120104{
    121105  CanonicalForm A= F;
     
    171155}
    172156
    173 CanonicalForm
     157/*CanonicalForm
    174158mulFLINTQ2 (const CanonicalForm& F, const CanonicalForm& G)
    175159{
     
    186170  fmpq_poly_clear (FLINTB);
    187171  return A;
    188 }
     172}*/
    189173
    190174CanonicalForm
     
    225209
    226210CanonicalForm
    227 mulFLINTQaTrunc (const CanonicalForm& F, const CanonicalForm& G, const Variable& alpha, int m)
     211mulFLINTQaTrunc (const CanonicalForm& F, const CanonicalForm& G,
     212                 const Variable& alpha, int m)
    228213{
    229214  CanonicalForm A= F;
     
    561546    Variable alpha;
    562547#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)))
    564550    {
    565551      CanonicalForm result= mulFLINTQa (F, G, alpha);
     
    624610      return modFLINTQ (F, G);
    625611    else
     612      //TODO newtonDivrem
    626613     return mod (F, G);
    627614#else
     
    683670      return divFLINTQ (F,G);
    684671    else
     672      //TODO newtonDivrem
    685673      return div (F, G);
    686674#else
     
    798786  nmod_poly_t buf;
    799787
     788  int j, k, bufRepLength;
    800789  for (CFIterator i= A; i.hasTerms(); i++)
    801790  {
    802791    convertFacCF2nmod_poly_t (buf, i.coeff());
    803792
    804     int k= i.exp()*d;
    805     int bufRepLength= (int) nmod_poly_length (buf);
    806     for (int j= 0; j < bufRepLength; j++)
     793    k= i.exp()*d;
     794    bufRepLength= (int) nmod_poly_length (buf);
     795    for (j= 0; j < bufRepLength; j++)
    807796      nmod_poly_set_coeff_ui (result, j + k, nmod_poly_get_coeff_ui (buf, j));
    808797    nmod_poly_clear (buf);
     
    895884  zz_pX buf;
    896885  zz_p *bufp;
     886  int j, k, bufRepLength;
    897887
    898888  for (CFIterator i= A; i.hasTerms(); i++)
     
    903893      buf= convertFacCF2NTLzzpX (i.coeff());
    904894
    905     int k= i.exp()*d;
     895    k= i.exp()*d;
    906896    bufp= buf.rep.elts();
    907     int bufRepLength= (int) buf.rep.length();
    908     for (int j= 0; j < bufRepLength; j++)
     897    bufRepLength= (int) buf.rep.length();
     898    for (j= 0; j < bufRepLength; j++)
    909899      resultp [j + k]= bufp [j];
    910900  }
     
    927917  zz_pX buf2;
    928918  zz_pX NTLMipo= convertFacCF2NTLzzpX (getMipo (alpha));
     919  int j, k, buf1RepLength;
    929920
    930921  for (CFIterator i= A; i.hasTerms(); i++)
     
    938929      buf1= convertFacCF2NTLzz_pEX (i.coeff(), NTLMipo);
    939930
    940     int k= i.exp()*d;
     931    k= i.exp()*d;
    941932    buf1p= buf1.rep.elts();
    942     int buf1RepLength= (int) buf1.rep.length();
    943     for (int j= 0; j < buf1RepLength; j++)
     933    buf1RepLength= (int) buf1.rep.length();
     934    for (j= 0; j < buf1RepLength; j++)
    944935      resultp [j + k]= buf1p [j];
    945936  }
     
    966957  zz_pX buf2;
    967958  zz_pX NTLMipo= convertFacCF2NTLzzpX (getMipo (alpha));
     959  int j, k, kk, bufRepLength;
    968960
    969961  for (CFIterator i= A; i.hasTerms(); i++)
     
    977969      buf= convertFacCF2NTLzz_pEX (i.coeff(), NTLMipo);
    978970
    979     int k= i.exp()*d;
    980     int kk= (degAy - i.exp())*d;
     971    k= i.exp()*d;
     972    kk= (degAy - i.exp())*d;
    981973    bufp= buf.rep.elts();
    982     int bufRepLength= (int) buf.rep.length();
    983     for (int j= 0; j < bufRepLength; j++)
     974    bufRepLength= (int) buf.rep.length();
     975    for (j= 0; j < bufRepLength; j++)
    984976    {
    985977      subA1p [j + k] += bufp [j];
     
    1004996  zz_pX buf;
    1005997  zz_p *bufp;
     998  int j, k, kk, bufRepLength;
    1006999
    10071000  for (CFIterator i= A; i.hasTerms(); i++)
     
    10091002    buf= convertFacCF2NTLzzpX (i.coeff());
    10101003
    1011     int k= i.exp()*d;
    1012     int kk= (degAy - i.exp())*d;
     1004    k= i.exp()*d;
     1005    kk= (degAy - i.exp())*d;
    10131006    bufp= buf.rep.elts();
    1014     int bufRepLength= (int) buf.rep.length();
    1015     for (int j= 0; j < bufRepLength; j++)
     1007    bufRepLength= (int) buf.rep.length();
     1008    for (j= 0; j < bufRepLength; j++)
    10161009    {
    10171010      subA1p [j + k] += bufp [j];
     
    10531046  int degfSubLf= degf;
    10541047  int deggSubLg= degg-lg;
    1055   int repLengthBuf2;
    1056   int repLengthBuf1;
     1048  int repLengthBuf2, repLengthBuf1, ind, tmp;
    10571049  zz_pE zzpEZero= zz_pE();
    10581050
     
    10681060
    10691061    buf1p= buf1.rep.elts();
    1070     for (int ind= 0; ind < repLengthBuf1; ind++)
     1062    for (ind= 0; ind < repLengthBuf1; ind++)
    10711063      buf1p [ind]= fp [ind + lf];
    10721064    buf1.normalize();
     
    10831075    buf2.rep.SetLength ((long) repLengthBuf2);
    10841076    buf2p= buf2.rep.elts();
    1085     for (int ind= 0; ind < repLengthBuf2; ind++)
    1086     {
     1077    for (ind= 0; ind < repLengthBuf2; ind++)
    10871078      buf2p [ind]= gp [ind + lg];
    1088     }
    10891079    buf2.normalize();
    10901080
     
    10951085    buf2p= buf2.rep.elts();
    10961086    buf1p= buf1.rep.elts();
    1097     for (int ind= 0; ind < repLengthBuf1; ind++)
     1087    for (ind= 0; ind < repLengthBuf1; ind++)
    10981088      buf3p [ind]= buf1p [ind];
    1099     for (int ind= repLengthBuf1; ind < d; ind++)
     1089    for (ind= repLengthBuf1; ind < d; ind++)
    11001090      buf3p [ind]= zzpEZero;
    1101     for (int ind= 0; ind < repLengthBuf2; ind++)
     1091    for (ind= 0; ind < repLengthBuf2; ind++)
    11021092      buf3p [ind + d]= buf2p [ind];
    11031093    buf3.normalize();
     
    11191109      if (repLengthBuf2 > degfSubLf + 1)
    11201110        degfSubLf= repLengthBuf2 - 1;
    1121       int tmp= tmin (repLengthBuf1, deggSubLg + 1);
    1122       for (int ind= 0; ind < tmp; ind++)
     1111      tmp= tmin (repLengthBuf1, deggSubLg + 1);
     1112      for (ind= 0; ind < tmp; ind++)
    11231113        gp [ind + lg] -= buf1p [ind];
    11241114    }
     
    11301120    if (degfSubLf >= 0)
    11311121    {
    1132       for (int ind= 0; ind < repLengthBuf2; ind++)
     1122      for (ind= 0; ind < repLengthBuf2; ind++)
    11331123        fp [ind + lf] -= buf2p [ind];
    11341124    }
     
    11681158  int degfSubLf= degf;
    11691159  int deggSubLg= degg-lg;
    1170   int repLengthBuf2;
    1171   int repLengthBuf1;
     1160  int repLengthBuf2, repLengthBuf1, ind, tmp;
    11721161  zz_p zzpZero= zz_p();
    11731162  while (degf >= lf || lg >= 0)
     
    11821171
    11831172    buf1p= buf1.rep.elts();
    1184     for (int ind= 0; ind < repLengthBuf1; ind++)
     1173    for (ind= 0; ind < repLengthBuf1; ind++)
    11851174      buf1p [ind]= fp [ind + lf];
    11861175    buf1.normalize();
     
    11971186    buf2.rep.SetLength ((long) repLengthBuf2);
    11981187    buf2p= buf2.rep.elts();
    1199     for (int ind= 0; ind < repLengthBuf2; ind++)
     1188    for (ind= 0; ind < repLengthBuf2; ind++)
    12001189      buf2p [ind]= gp [ind + lg];
    12011190
     
    12091198    buf2p= buf2.rep.elts();
    12101199    buf1p= buf1.rep.elts();
    1211     for (int ind= 0; ind < repLengthBuf1; ind++)
     1200    for (ind= 0; ind < repLengthBuf1; ind++)
    12121201      buf3p [ind]= buf1p [ind];
    1213     for (int ind= repLengthBuf1; ind < d; ind++)
     1202    for (ind= repLengthBuf1; ind < d; ind++)
    12141203      buf3p [ind]= zzpZero;
    1215     for (int ind= 0; ind < repLengthBuf2; ind++)
     1204    for (ind= 0; ind < repLengthBuf2; ind++)
    12161205      buf3p [ind + d]= buf2p [ind];
    12171206    buf3.normalize();
     
    12331222      if (repLengthBuf2 > degfSubLf + 1)
    12341223        degfSubLf= repLengthBuf2 - 1;
    1235       int tmp= tmin (repLengthBuf1, deggSubLg + 1);
    1236       for (int ind= 0; ind < tmp; ind++)
     1224      tmp= tmin (repLengthBuf1, deggSubLg + 1);
     1225      for (ind= 0; ind < tmp; ind++)
    12371226        gp [ind + lg] -= buf1p [ind];
    12381227    }
     
    12431232    if (degfSubLf >= 0)
    12441233    {
    1245       for (int ind= 0; ind < repLengthBuf2; ind++)
     1234      for (ind= 0; ind < repLengthBuf2; ind++)
    12461235        fp [ind + lf] -= buf2p [ind];
    12471236    }
     
    12651254  int degf= deg(f);
    12661255  int k= 0;
    1267   int degfSubK;
    1268   int repLength;
     1256  int degfSubK, repLength, j;
    12691257  while (degf >= k)
    12701258  {
     
    12771265    buf.rep.SetLength ((long) repLength);
    12781266    bufp= buf.rep.elts();
    1279     for (int j= 0; j < repLength; j++)
     1267    for (j= 0; j < repLength; j++)
    12801268      bufp [j]= fp [j + k];
    12811269    buf.normalize();
     
    13031291  int degf= deg(f);
    13041292  int k= 0;
    1305   int degfSubK;
    1306   int repLength;
     1293  int degfSubK, repLength, j;
    13071294  while (degf >= k)
    13081295  {
     
    13151302    buf.rep.SetLength ((long) repLength);
    13161303    bufp= buf.rep.elts();
    1317     for (int j= 0; j < repLength; j++)
     1304    for (j= 0; j < repLength; j++)
    13181305      bufp [j]= fp [j + k];
    13191306    buf.normalize();
     
    14721459#ifdef HAVE_FLINT
    14731460void
    1474 kronSubRecipro (nmod_poly_t subA1, nmod_poly_t subA2, const CanonicalForm& A, int d)
     1461kronSubRecipro (nmod_poly_t subA1, nmod_poly_t subA2, const CanonicalForm& A,
     1462                int d)
    14751463{
    14761464  int degAy= degree (A);
     
    14811469  nmod_poly_t buf;
    14821470
     1471  int k, kk, j, bufRepLength;
    14831472  for (CFIterator i= A; i.hasTerms(); i++)
    14841473  {
    14851474    convertFacCF2nmod_poly_t (buf, i.coeff());
    14861475
    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                             );
    14941493    }
    14951494    nmod_poly_clear (buf);
     
    15001499
    15011500void
    1502 kronSubRecipro (fmpz_poly_t subA1, fmpz_poly_t subA2, const CanonicalForm& A, int d)
     1501kronSubRecipro (fmpz_poly_t subA1, fmpz_poly_t subA2, const CanonicalForm& A,
     1502                int d)
    15031503{
    15041504  int degAy= degree (A);
     
    15091509  fmpz_t coeff1, coeff2;
    15101510
     1511  int k, kk, j, bufRepLength;
    15111512  for (CFIterator i= A; i.hasTerms(); i++)
    15121513  {
    15131514    convertFacCF2Fmpz_poly_t (buf, i.coeff());
    15141515
    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);
    15221522      fmpz_poly_get_coeff_fmpz (coeff2, buf, j);
    15231523      fmpz_add (coeff1, coeff1, coeff2);
     
    15491549  int degf= fmpz_poly_degree(f);
    15501550  int k= 0;
    1551   int degfSubK;
    1552   int repLength;
     1551  int degfSubK, repLength, j;
    15531552  fmpz_t coeff;
    15541553  while (degf >= k)
     
    15621561    fmpz_poly_init2 (buf, repLength);
    15631562    fmpz_init (coeff);
    1564     for (int j= 0; j < repLength; j++)
     1563    for (j= 0; j < repLength; j++)
    15651564    {
    15661565      fmpz_poly_get_coeff_fmpz (coeff, f, j + k);
     
    15971596
    15981597  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);*/
    16021598
    16031599  if (nmod_poly_length (f) < (long) d*(k+1)) //zero padding
     
    16101606  int degfSubLf= degf;
    16111607  int deggSubLg= degg-lg;
    1612   int repLengthBuf2;
    1613   int repLengthBuf1;
    1614   //zz_p zzpZero= zz_p();
     1608  int repLengthBuf2, repLengthBuf1, ind, tmp;
    16151609  while (degf >= lf || lg >= 0)
    16161610  {
     
    16211615    else
    16221616      repLengthBuf1= degfSubLf + 1;
    1623     //cout << "repLengthBuf1= " << repLengthBuf1 << "\n";
    1624     //cout << "nmod_poly_length (buf1)= " << nmod_poly_length (buf1) << "\n";
    16251617    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++)
    16291620      nmod_poly_set_coeff_ui (buf1, ind, nmod_poly_get_coeff_ui (f, ind+lf));
    16301621    _nmod_poly_normalise (buf1);
    1631     //cout << "nmod_poly_length (buf1)= " << nmod_poly_length (buf1) << "\n";
    16321622
    16331623    repLengthBuf1= nmod_poly_length (buf1);
     
    16401630      repLengthBuf2= deggSubLg + 1;
    16411631
    1642     //cout << "repLengthBuf2= " << repLengthBuf2 << "\n";
    1643     //cout << "nmod_poly_length (buf2)= " << nmod_poly_length (buf2) << "\n";
    16441632    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++)
    16471634      nmod_poly_set_coeff_ui (buf2, ind, nmod_poly_get_coeff_ui (g, ind + lg));
    16481635
    16491636    _nmod_poly_normalise (buf2);
    1650     //cout << "nmod_poly_length (buf2)= " << nmod_poly_length (buf2) << "\n";
    16511637    repLengthBuf2= nmod_poly_length (buf2);
    16521638
    16531639    nmod_poly_init2_preinv (buf3, getCharacteristic(), ninv, repLengthBuf2 + d);
    1654     for (int ind= 0; ind < repLengthBuf1; ind++)
     1640    for (ind= 0; ind < repLengthBuf1; ind++)
    16551641      nmod_poly_set_coeff_ui (buf3, ind, nmod_poly_get_coeff_ui (buf1, ind));
    1656     for (int ind= repLengthBuf1; ind < d; ind++)
     1642    for (ind= repLengthBuf1; ind < d; ind++)
    16571643      nmod_poly_set_coeff_ui (buf3, ind, 0);
    1658     for (int 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));
    16601646    _nmod_poly_normalise (buf3);
    16611647
     
    16741660      if (repLengthBuf2 > degfSubLf + 1)
    16751661        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                               );
    16821670    }
    16831671    if (lg < 0)
     
    16901678    if (degfSubLf >= 0)
    16911679    {
    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                               );
    16941687    }
    16951688    nmod_poly_clear (buf1);
    16961689    nmod_poly_clear (buf2);
    16971690    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
    17061693  nmod_poly_clear (f);
    17071694  nmod_poly_clear (g);
     
    17261713
    17271714  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);*/
    17311715
    17321716  if (fmpz_poly_length (f) < (long) d*(k+1)) //zero padding
     
    17391723  int degfSubLf= degf;
    17401724  int deggSubLg= degg-lg;
    1741   int repLengthBuf2;
    1742   int repLengthBuf1;
    1743   //zz_p zzpZero= zz_p();
     1725  int repLengthBuf2, repLengthBuf1, ind, tmp;
    17441726  fmpz_t tmp1, tmp2;
    17451727  while (degf >= lf || lg >= 0)
     
    17511733    else
    17521734      repLengthBuf1= degfSubLf + 1;
    1753     //cout << "repLengthBuf1= " << repLengthBuf1 << "\n";
    1754     //cout << "nmod_poly_length (buf1)= " << nmod_poly_length (buf1) << "\n";
     1735
    17551736    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++)
    17591739    {
    17601740      fmpz_poly_get_coeff_fmpz (tmp1, f, ind + lf);
     
    17621742    }
    17631743    _fmpz_poly_normalise (buf1);
    1764     //cout << "nmod_poly_length (buf1)= " << nmod_poly_length (buf1) << "\n";
    17651744
    17661745    repLengthBuf1= fmpz_poly_length (buf1);
     
    17731752      repLengthBuf2= deggSubLg + 1;
    17741753
    1775     //cout << "repLengthBuf2= " << repLengthBuf2 << "\n";
    1776     //cout << "nmod_poly_length (buf2)= " << nmod_poly_length (buf2) << "\n";
    17771754    fmpz_poly_init2 (buf2, repLengthBuf2);
    1778     //cout << "nmod_poly_length (buf2)= " << nmod_poly_length (buf2) << "\n";
    1779     for (int ind= 0; ind < repLengthBuf2; ind++)
     1755
     1756    for (ind= 0; ind < repLengthBuf2; ind++)
    17801757    {
    17811758      fmpz_poly_get_coeff_fmpz (tmp1, g, ind + lg);
     
    17841761
    17851762    _fmpz_poly_normalise (buf2);
    1786     //cout << "nmod_poly_length (buf2)= " << nmod_poly_length (buf2) << "\n";
    17871763    repLengthBuf2= fmpz_poly_length (buf2);
    17881764
    17891765    fmpz_poly_init2 (buf3, repLengthBuf2 + d);
    1790     for (int ind= 0; ind < repLengthBuf1; ind++)
     1766    for (ind= 0; ind < repLengthBuf1; ind++)
    17911767    {
    17921768      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))
    17931769      fmpz_poly_set_coeff_fmpz (buf3, ind, tmp1);
    17941770    }
    1795     for (int ind= repLengthBuf1; ind < d; ind++)
     1771    for (ind= repLengthBuf1; ind < d; ind++)
    17961772      fmpz_poly_set_coeff_ui (buf3, ind, 0);
    1797     for (int ind= 0; ind < repLengthBuf2; ind++)
     1773    for (ind= 0; ind < repLengthBuf2; ind++)
    17981774    {
    17991775      fmpz_poly_get_coeff_fmpz (tmp1, buf2, ind);
     
    18161792      if (repLengthBuf2 > degfSubLf + 1)
    18171793        degfSubLf= repLengthBuf2 - 1;
    1818       int tmp= tmin (repLengthBuf1, deggSubLg + 1);
    1819       for (int ind= 0; ind < tmp; ind++)
     1794      tmp= tmin (repLengthBuf1, deggSubLg + 1);
     1795      for (ind= 0; ind < tmp; ind++)
    18201796      {
    18211797        fmpz_poly_get_coeff_fmpz (tmp1, g, ind + lg);
     
    18231799        fmpz_sub (tmp1, tmp1, tmp2);
    18241800        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";
    18261801      }
    18271802    }
     
    18351810    if (degfSubLf >= 0)
    18361811    {
    1837       for (int ind= 0; ind < repLengthBuf2; ind++)
     1812      for (ind= 0; ind < repLengthBuf2; ind++)
    18381813      {
    18391814        fmpz_poly_get_coeff_fmpz (tmp1, f, ind + lf);
     
    18461821    fmpz_poly_clear (buf2);
    18471822    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
    18561825  fmpz_poly_clear (f);
    18571826  fmpz_poly_clear (g);
     
    18731842
    18741843  nmod_poly_t buf;
    1875   //nmod_poly_init_preinv (buf, getCharacteristic(), ninv);
    18761844  CanonicalForm result= 0;
    18771845  int i= 0;
    18781846  int degf= nmod_poly_degree(f);
    18791847  int k= 0;
    1880   int degfSubK;
    1881   int repLength;
     1848  int degfSubK, repLength, j;
    18821849  while (degf >= k)
    18831850  {
     
    18891856
    18901857    nmod_poly_init2_preinv (buf, getCharacteristic(), ninv, repLength);
    1891     for (int j= 0; j < repLength; j++)
     1858    for (j= 0; j < repLength; j++)
    18921859      nmod_poly_set_coeff_ui (buf, j, nmod_poly_get_coeff_ui (f, j + k));
    1893     //printf ("after set\n");
    18941860    _nmod_poly_normalise (buf);
    1895     //printf ("after normalise\n");
    18961861
    18971862    result += convertnmod_poly_t2FacCF (buf, x)*power (y, i);
     
    18991864    k= d*i;
    19001865    nmod_poly_clear (buf);
    1901     //nmod_poly_init_preinv (buf, getCharacteristic(), ninv);
    1902   }
    1903   //printf ("after while\n");
    1904   //nmod_poly_clear (buf);
     1866  }
    19051867  nmod_poly_clear (f);
    1906   //printf ("after clear\n");
    19071868
    19081869  return result;
     
    19221883  nmod_poly_init_preinv (F2, getCharacteristic(), ninv);
    19231884  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";*/
    19291885
    19301886  nmod_poly_t G1, G2;
     
    19321888  nmod_poly_init_preinv (G2, getCharacteristic(), ninv);
    19331889  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 
    19391890
    19401891  int k= d1*degree (M);
    19411892  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";*/
    19441893
    19451894  int degtailF= degree (tailcoeff (F), 1);;
     
    19481897  int taildegG= taildegree (G);
    19491898
    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);
    19511901  nmod_poly_mulhigh (F2, F2, G2, b);
    19521902  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";*/
    19601903  int d2= tmax (nmod_poly_degree (F2)/d1, nmod_poly_degree (F1)/d1);
    19611904
    19621905
    19631906  CanonicalForm result= reverseSubst (F1, F2, d1, d2);
    1964   //CanonicalForm NTLres= reverseSubst (TF1, TF2, d1, d2);
    1965   //cout << "FINALtestkronSubReci= " << (NTLres == result) << "\n";
    19661907
    19671908  nmod_poly_clear (F1);
     
    20181959  fmpz_poly_init (F2);
    20191960  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";*/
    20251961
    20261962  fmpz_poly_t G1, G2;
     
    20281964  fmpz_poly_init (G2);
    20291965  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 
    20351966
    20361967  int k= d1*degree (M);
    20371968  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";*/
    20401969
    20411970  int degtailF= degree (tailcoeff (F), 1);;
     
    20441973  int taildegG= taildegree (G);
    20451974
    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);
    20471977  fmpz_poly_mulhigh_n (F2, F2, G2, b);
    20481978  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";*/
    20561979  int d2= tmax (fmpz_poly_degree (F2)/d1, fmpz_poly_degree (F1)/d1);
    20571980
    2058 
    20591981  CanonicalForm result= reverseSubst (F1, F2, d1, d2);
    2060 
    2061   //CanonicalForm NTLres= reverseSubst (TF1, TF2, d1, d2);
    2062   //cout << "FINALtestkronSubReci= " << (NTLres == result) << "\n";
    20631982
    20641983  fmpz_poly_clear (F1);
     
    20771996
    20781997  int degAx= degree (A, 1);
    2079   //int degAy= degree (A, 2);
    20801998  int degBx= degree (B, 1);
    2081   //int degBy= degree (B, 2);
    20821999  int d1= degAx + 1 + degBx;
    2083   //int d2= tmax (degAy, degBy);
    20842000
    20852001  CanonicalForm f= bCommonDen (F);
Note: See TracChangeset for help on using the changeset viewer.