Changeset c729f2 in git for factory/NTLconvert.cc


Ignore:
Timestamp:
Mar 5, 2012, 10:05:50 PM (12 years ago)
Author:
Martin Lee <martinlee84@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
47dc5eae8e5fa15711c4af64c3ce91a844425401
Parents:
b78a13dc05baa2440a909f8b9174e8b4491d56cc
git-author:
Martin Lee <martinlee84@web.de>2012-03-05 22:05:50+01:00
git-committer:
Martin Lee <martinlee84@web.de>2012-04-04 14:42:26+02:00
Message:
chg: conversion to NTL ZZ_pX now allows non-word size p
chg: added conversion of NTL ZZ_pEX to CanonicalForm and back
File:
1 edited

Legend:

Unmodified
Added
Removed
  • factory/NTLconvert.cc

    rb78a13 rc729f2  
    8484    NTLcurrentExp=i.exp();
    8585
    86     CanonicalForm c=i.coeff();
    87     if (!c.isImm()) c=c.mapinto(); //c%= getCharacteristic();
    88     if (!c.isImm())
    89     {  //This case will never happen if the characteristic is in fact a prime
    90        // number, since all coefficients are represented as immediates
    91        #ifndef NOSTREAMIO
    92        cout<<"convertFacCF2NTLZZ_pX: coefficient not immediate! : "<<f<<"\n";
    93        #else
    94        //NTL_SNS
    95        printf("convertFacCF2NTLZZ_pX: coefficient not immediate!, char=%d\n",
    96               getCharacteristic());
    97        #endif
    98        NTL_SNS exit(1);
    99     }
    100     else
    101     {
    102       SetCoeff(ntl_poly,NTLcurrentExp,c.intval());
    103     }
     86    SetCoeff(ntl_poly,NTLcurrentExp,to_ZZ_p (convertFacCF2NTLZZ (i.coeff())));
    10487    NTLcurrentExp--;
    10588  }
     
    265248CanonicalForm convertNTLZZpX2CF(ZZ_pX poly,Variable x)
    266249{
    267   //printf("convertNTLZZpX2CF\n");
    268   CanonicalForm bigone;
    269 
    270 
    271   if (deg(poly)>0)
    272   {
    273     // poly is non-constant
    274     bigone=0;
    275     bigone.mapinto();
    276     // Compute the canonicalform coefficient by coefficient,
    277     // bigone summarizes the result.
    278     for (int j=0;j<=deg(poly);j++)
    279     {
    280       if (coeff(poly,j)!=0)
    281       {
    282         bigone+=(power(x,j)*CanonicalForm(to_long(rep(coeff(poly,j)))));
    283       }
    284     }
    285   }
    286   else
    287   {
    288     // poly is immediate
    289     bigone=CanonicalForm(to_long(rep(coeff(poly,0))));
    290     bigone.mapinto();
    291   }
    292   return bigone;
     250  return convertNTLZZX2CF (to_ZZX (poly), x);
    293251}
    294252
     
    11451103  return bigone;
    11461104}
     1105
     1106CanonicalForm convertNTLZZ_pEX2CF (ZZ_pEX f, Variable x, Variable alpha)
     1107{
     1108  CanonicalForm bigone;
     1109  if (deg (f) > 0)
     1110  {
     1111    bigone= 0;
     1112    bigone.mapinto();
     1113    for (int j=0;j<deg(f)+1;j++)
     1114    {
     1115      if (coeff(f,j)!=0)
     1116      {
     1117        bigone+=(power(x,j)*convertNTLZZpE2CF(coeff(f,j),alpha));
     1118      }
     1119    }
     1120  }
     1121  else
     1122  {
     1123    bigone= convertNTLZZpE2CF(coeff(f,0),alpha);
     1124    bigone.mapinto();
     1125  }
     1126  return bigone;
     1127}
    11471128//----------------------------------------------------------------------
    11481129mat_ZZ* convertFacCFMatrix2NTLmat_ZZ(CFMatrix &m)
Note: See TracChangeset for help on using the changeset viewer.