24 #include <NTL/ZZXFactoring.h> 25 #include <NTL/ZZ_pXFactoring.h> 26 #include <NTL/lzz_pXFactoring.h> 27 #include <NTL/GF2XFactoring.h> 28 #include <NTL/ZZ_pEXFactoring.h> 29 #include <NTL/lzz_pEXFactoring.h> 30 #include <NTL/GF2EXFactoring.h> 31 #include <NTL/tools.h> 32 #include <NTL/mat_ZZ.h> 33 #include <NTL/version.h> 38 #define Alloc(L) malloc(L) 39 #define Free(A,L) free(A) 46 #ifdef NTL_CLIENT // in <NTL/tools.h>: using of name space NTL 69 int NTLcurrentExp=i.
exp();
70 int largestExp=i.
exp();
74 ntl_poly.SetMaxLength(largestExp+1);
78 for (k=NTLcurrentExp;k>i.
exp();k--)
80 SetCoeff(ntl_poly,k,0);
82 NTLcurrentExp=i.
exp();
93 for (k=NTLcurrentExp;k>=0;k--)
95 SetCoeff(ntl_poly,k,0);
110 int NTLcurrentExp=i.
exp();
111 int largestExp=i.
exp();
115 ntl_poly.SetMaxLength(largestExp+1);
119 for (k=NTLcurrentExp;k>i.
exp();k--)
121 SetCoeff(ntl_poly,k,0);
123 NTLcurrentExp=i.
exp();
131 cout<<
"convertFacCF2NTLzz_pX: coefficient not immediate! : "<<f<<
"\n";
134 printf(
"convertFacCF2NTLzz_pX: coefficient not immediate!, char=%d\n",
141 SetCoeff(ntl_poly,NTLcurrentExp,c.
intval());
151 for (k=NTLcurrentExp;k>=0;k--)
153 SetCoeff(ntl_poly,k,0);
157 ntl_poly.normalize();
188 int NTLcurrentExp=i.
exp();
189 int largestExp=i.
exp();
193 ntl_poly.SetMaxLength(largestExp+1);
198 for (k=NTLcurrentExp;k>i.
exp();k--)
200 SetCoeff(ntl_poly,k,0);
202 NTLcurrentExp=i.
exp();
208 cout<<
"convertFacCF2NTLGF2X: coefficient not immediate! : " << f <<
"\n";
211 printf(
"convertFacCF2NTLGF2X: coefficient not immediate!");
217 SetCoeff(ntl_poly,NTLcurrentExp,i.
coeff().
intval());
221 for (k=NTLcurrentExp;k>=0;k--)
223 SetCoeff(ntl_poly,k,0);
264 for (
int j=0;
j<=deg(poly);
j++)
291 for (
int j=0;
j<=deg(polynom);
j++)
293 coefficient=
coeff(polynom,
j);
333 for (
int j=0;
j<=deg(poly);
j++)
370 (
const vec_pair_ZZ_pX_long & e,
const ZZ_p & multi,
const Variable &
x)
385 for (
int i=e.length()-1;
i>=0;
i--)
395 (
const vec_pair_zz_pX_long & e,
const zz_p multi,
const Variable & x)
410 for (
int i=e.length()-1;
i>=0;
i--)
442 (
const vec_pair_GF2X_long& e, GF2 ,
const Variable & x)
459 for (
int i=e.length()-1;
i>=0;
i--)
465 for (
int j=0;
j<=deg(polynom);
j++)
494 long coeff_long=to_long(a);
497 if ( (NumBits(a)<((
long)NTL_ZZ_NBITS))
506 #if NTL_MAJOR_VERSION <= 6 507 static_cast<long *
>( a.rep );
509 static_cast<long *
>( a.rep.rep );
511 long sizeofrep= rep[1];
512 bool lessZero=
false;
516 sizeofrep= -sizeofrep;
518 if (cf_stringtemp_l == 0)
520 cf_stringtemp_l= sizeofrep*
sizeof(mp_limb_t)*2;
521 cf_stringtemp= (
unsigned char*)
Alloc (cf_stringtemp_l);
523 else if (cf_stringtemp_l < sizeofrep*
sizeof(mp_limb_t)*2)
525 Free (cf_stringtemp, cf_stringtemp_l);
526 cf_stringtemp_l= sizeofrep*
sizeof(mp_limb_t)*2;
527 cf_stringtemp= (
unsigned char*)
Alloc (cf_stringtemp_l);
529 int cc= mpn_get_str (cf_stringtemp, 16, (mp_limb_t *) ((rep) + 2), sizeofrep);
531 char* cf_stringtemp2;
534 cf_stringtemp2=
new char [cc + 2];
535 cf_stringtemp2[0]=
'-';
536 for (
int j= 1;
j <= cc;
j++)
537 cf_stringtemp2[
j]= IntValToChar ((
int) cf_stringtemp [
j-1]);
538 cf_stringtemp2[cc+1]=
'\0';
542 cf_stringtemp2=
new char [cc + 1];
543 for (
int j= 0;
j < cc;
j++)
544 cf_stringtemp2[
j]= IntValToChar ((
int) cf_stringtemp [
j]);
545 cf_stringtemp2[cc]=
'\0';
549 delete [] cf_stringtemp2;
677 int l=mpz_sizeinbase(gmp_val,10)+2;
678 stringtemp=(
char*)
Alloc(l);
679 stringtemp=mpz_get_str(stringtemp,10,gmp_val);
681 conv(temp,stringtemp);
694 int NTLcurrentExp=i.
exp();
695 int largestExp=i.
exp();
699 ntl_poly.SetMaxLength(largestExp+1);
704 for (k=NTLcurrentExp;k>i.
exp();k--)
706 SetCoeff(ntl_poly,k,0);
708 NTLcurrentExp=i.
exp();
714 SetCoeff(ntl_poly,NTLcurrentExp,temp);
718 for (k=NTLcurrentExp;k>=0;k--)
720 SetCoeff(ntl_poly,k,0);
724 ntl_poly.normalize();
758 for (
int i=e.length()-1;
i>=0;
i--)
834 for (
int i=e.length()-1;
i>=0;
i--)
841 for (
int j=0;
j<=deg(polynom);
j++)
852 bigone += (
power(x,
j)*coefficient);
879 for (
int i=e.length()-1;
i>=0;
i--)
886 for (
int j=0;
j<=deg(polynom);
j++)
897 bigone += (
power(x,
j)*coefficient);
970 for (
int i=e.length()-1;
i>=0;
i--)
977 for (
int j=0;
j<=deg(polynom);
j++)
988 bigone += (
power(x,
j)*coefficient);
1015 int NTLcurrentExp=i.
exp();
1016 int largestExp=i.
exp();
1019 result.SetMaxLength(largestExp+1);
1022 for(k=NTLcurrentExp;k>i.
exp();k--) SetCoeff(result,k,0);
1023 NTLcurrentExp=i.
exp();
1028 SetCoeff(result,NTLcurrentExp,to_GF2E(cc));
1031 for(k=NTLcurrentExp;k>=0;k--) SetCoeff(result,k,0);
1045 int NTLcurrentExp=i.
exp();
1046 int largestExp=i.
exp();
1049 result.SetMaxLength(largestExp+1);
1052 for(k=NTLcurrentExp;k>i.
exp();k--) SetCoeff(result,k,0);
1053 NTLcurrentExp=i.
exp();
1058 SetCoeff(result,NTLcurrentExp,to_ZZ_pE(cc));
1061 for(k=NTLcurrentExp;k>=0;k--) SetCoeff(result,k,0);
1072 int NTLcurrentExp=i.
exp();
1073 int largestExp=i.
exp();
1076 result.SetMaxLength(largestExp+1);
1079 for(k=NTLcurrentExp;k>i.
exp();k--) SetCoeff(result,k,0);
1080 NTLcurrentExp=i.
exp();
1085 SetCoeff(result,NTLcurrentExp,to_zz_pE(cc));
1088 for(k=NTLcurrentExp;k>=0;k--) SetCoeff(result,k,0);
1100 for (
int j=0;
j<deg(f)+1;
j++)
1123 for (
int j=0;
j<deg(f)+1;
j++)
1141 mat_ZZ *
res=
new mat_ZZ;
1145 for(i=m.
rows();i>0;i--)
1158 for(i=res->
rows();i>0;i--)
1170 mat_zz_p *
res=
new mat_zz_p;
1174 for(i=m.
rows();i>0;i--)
1178 if(!(
m(i,j)).isImm()) printf(
"convertFacCFMatrix2NTLmat_zz_p: not imm.\n");
1188 for(i=res->
rows();i>0;i--)
1199 mat_zz_pE *
res=
new mat_zz_pE;
1203 for(i=m.
rows();i>0;i--)
1208 (*res)(
i,
j)=to_zz_pE(cc);
1217 for(i=res->
rows();i>0;i--)
GF2EX convertFacCF2NTLGF2EX(const CanonicalForm &f, const GF2X &mipo)
CanonicalForm in Z_2(a)[X] to NTL GF2EX.
ZZ convertFacCF2NTLZZ(const CanonicalForm &f)
NAME: convertFacCF2NTLZZX.
CFFList convertNTLvec_pair_GF2EX_long2FacCFFList(const vec_pair_GF2EX_long &e, const GF2E &multi, const Variable &x, const Variable &alpha)
NAME: convertNTLvec_pair_GF2EX_long2FacCFFList.
Conversion to and from NTL.
CFFList convertNTLvec_pair_GF2X_long2FacCFFList(const vec_pair_GF2X_long &e, GF2, const Variable &x)
NAME: convertNTLvec_pair_GF2X_long2FacCFFList.
CFFList convertNTLvec_pair_ZZpX_long2FacCFFList(const vec_pair_ZZ_pX_long &e, const ZZ_p &multi, const Variable &x)
NAME: convertNTLvec_pair_ZZpX_long2FacCFFList.
factory's class for variables
CF_NO_INLINE CanonicalForm coeff() const
get the current coefficient
CanonicalForm convertNTLzzpE2CF(const zz_pE &coefficient, const Variable &x)
CanonicalForm convertNTLZZpX2CF(const ZZ_pX &poly, const Variable &x)
NAME: convertNTLZZpX2CF.
GF2X convertFacCF2NTLGF2X(const CanonicalForm &f)
NAME: convertFacCF2NTLGF2X.
CFFList convertNTLvec_pair_zzpX_long2FacCFFList(const vec_pair_zz_pX_long &e, const zz_p multi, const Variable &x)
static unsigned char * cf_stringtemp
ZZ_pEX convertFacCF2NTLZZ_pEX(const CanonicalForm &f, const ZZ_pX &mipo)
CanonicalForm in Z_p(a)[X] to NTL ZZ_pEX.
static unsigned long cf_stringtemp_l
CanonicalForm convertNTLzzpX2CF(const zz_pX &poly, const Variable &x)
ZZX convertFacCF2NTLZZX(const CanonicalForm &f)
CFMatrix * convertNTLmat_zz_p2FacCFMatrix(const mat_zz_p &m)
CFFList convertNTLvec_pair_zzpEX_long2FacCFFList(const vec_pair_zz_pEX_long &e, const zz_pE &multi, const Variable &x, const Variable &alpha)
CFList conv(const CFFList &L)
convert a CFFList to a CFList by dropping the multiplicity
CanonicalForm convertNTLGF2E2CF(const GF2E &coefficient, const Variable &x)
NAME: convertNTLGF2E2CF.
mat_zz_p * convertFacCFMatrix2NTLmat_zz_p(const CFMatrix &m)
CanonicalForm convertNTLZZ_pEX2CF(const ZZ_pEX &f, const Variable &x, const Variable &alpha)
ZZ_pX convertFacCF2NTLZZpX(const CanonicalForm &f)
NAME: convertFacCF2NTLZZpX.
zz_pEX convertFacCF2NTLzz_pEX(const CanonicalForm &f, const zz_pX &mipo)
virtual CanonicalForm coeff(int i)
CanonicalForm InternalCF::coeff ( int i )
Iterators for CanonicalForm's.
declarations of higher level algorithms.
CanonicalForm convertNTLzz_pEX2CF(const zz_pEX &f, const Variable &x, const Variable &alpha)
mat_ZZ * convertFacCFMatrix2NTLmat_ZZ(const CFMatrix &m)
static BOOLEAN IsOne(number a, const coeffs r)
class to iterate through CanonicalForm's
void out_cf(const char *s1, const CanonicalForm &f, const char *s2)
cf_algorithm.cc - simple mathematical algorithms.
zz_pX convertFacCF2NTLzzpX(const CanonicalForm &f)
CF_NO_INLINE int hasTerms() const
check if iterator has reached < the end of CanonicalForm
mat_zz_pE * convertFacCFMatrix2NTLmat_zz_pE(const CFMatrix &m)
CFFList convertNTLvec_pair_ZZpEX_long2FacCFFList(const vec_pair_ZZ_pEX_long &e, const ZZ_pE &multi, const Variable &x, const Variable &alpha)
NAME: convertNTLvec_pair_ZZpEX_long2FacCFFList.
CFMatrix * convertNTLmat_ZZ2FacCFMatrix(const mat_ZZ &m)
static BOOLEAN IsZero(number a, const coeffs r)
CanonicalForm convertNTLZZpE2CF(const ZZ_pE &coefficient, const Variable &x)
NAME: convertNTLZZpX2CF.
int exponent(const CanonicalForm &f, int q)
int exponent ( const CanonicalForm & f, int q )
CF_NO_INLINE int exp() const
get the current exponent
CanonicalForm convertZZ2CF(const ZZ &a)
NAME: convertZZ2CF.
CFMatrix * convertNTLmat_zz_pE2FacCFMatrix(const mat_zz_pE &m, const Variable &alpha)
CFFList convertNTLvec_pair_ZZX_long2FacCFFList(const vec_pair_ZZX_long &e, const ZZ &multi, const Variable &x)
NAME: convertNTLvec_pair_ZZX_long2FacCFFList.
CanonicalForm convertNTLZZX2CF(const ZZX &polynom, const Variable &x)
CanonicalForm convertNTLGF2X2CF(const GF2X &poly, const Variable &x)
NAME: convertNTLGF2X2CF.
squarefree part and factorization over Q, Q(a)
Factory's internal integers.