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);
76 for (;
i.hasTerms();
i++)
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);
117 for (;
i.hasTerms();
i++)
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);
195 for (;
i.hasTerms();
i++)
198 for (
k=NTLcurrentExp;
k>
i.exp();
k--)
200 SetCoeff(ntl_poly,
k,0);
202 NTLcurrentExp=
i.exp();
204 if (!
i.coeff().isImm())
i.coeff()=
i.coeff().mapinto();
205 if (!
i.coeff().isImm())
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);
291 for (
int j=0;
j<=deg(polynom);
j++)
293 coefficient=
coeff(polynom,
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--)
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 );
508 #elif NTL_MAJOR_VERSION <=9 509 static_cast<long *
>(
a.rep.rep );
511 (
long*)(
a.rep.rep );
513 long sizeofrep= rep[1];
514 bool lessZero=
false;
518 sizeofrep= -sizeofrep;
531 int cc= mpn_get_str (
cf_stringtemp, 16, (mp_limb_t *) ((rep) + 2), sizeofrep);
533 char* cf_stringtemp2;
536 cf_stringtemp2=
new char [cc + 2];
537 cf_stringtemp2[0]=
'-';
538 for (
int j= 1;
j <= cc;
j++)
540 cf_stringtemp2[cc+1]=
'\0';
544 cf_stringtemp2=
new char [cc + 1];
545 for (
int j= 0;
j < cc;
j++)
547 cf_stringtemp2[cc]=
'\0';
551 delete [] cf_stringtemp2;
670 if (
f.isImm()) temp=
f.intval();
678 int l=mpz_sizeinbase(gmp_val,10)+2;
679 stringtemp=(
char*)
Alloc(
l);
680 stringtemp=mpz_get_str(stringtemp,10,gmp_val);
682 conv(temp,stringtemp);
695 int NTLcurrentExp=
i.exp();
696 int largestExp=
i.exp();
700 ntl_poly.SetMaxLength(largestExp+1);
703 for (;
i.hasTerms();
i++)
705 for (
k=NTLcurrentExp;
k>
i.exp();
k--)
707 SetCoeff(ntl_poly,
k,0);
709 NTLcurrentExp=
i.exp();
715 SetCoeff(ntl_poly,NTLcurrentExp,temp);
719 for (
k=NTLcurrentExp;
k>=0;
k--)
721 SetCoeff(ntl_poly,
k,0);
725 ntl_poly.normalize();
759 for (
int i=e.length()-1;
i>=0;
i--)
835 for (
int i=e.length()-1;
i>=0;
i--)
842 for (
int j=0;
j<=deg(polynom);
j++)
853 bigone += (
power(
x,
j)*coefficient);
880 for (
int i=e.length()-1;
i>=0;
i--)
887 for (
int j=0;
j<=deg(polynom);
j++)
898 bigone += (
power(
x,
j)*coefficient);
971 for (
int i=e.length()-1;
i>=0;
i--)
978 for (
int j=0;
j<=deg(polynom);
j++)
989 bigone += (
power(
x,
j)*coefficient);
1016 int NTLcurrentExp=
i.exp();
1017 int largestExp=
i.exp();
1020 result.SetMaxLength(largestExp+1);
1021 for(;
i.hasTerms();
i++)
1023 for(
k=NTLcurrentExp;
k>
i.exp();
k--) SetCoeff(
result,
k,0);
1024 NTLcurrentExp=
i.exp();
1029 SetCoeff(
result,NTLcurrentExp,to_GF2E(cc));
1032 for(
k=NTLcurrentExp;
k>=0;
k--) SetCoeff(
result,
k,0);
1046 int NTLcurrentExp=
i.exp();
1047 int largestExp=
i.exp();
1050 result.SetMaxLength(largestExp+1);
1051 for(;
i.hasTerms();
i++)
1053 for(
k=NTLcurrentExp;
k>
i.exp();
k--) SetCoeff(
result,
k,0);
1054 NTLcurrentExp=
i.exp();
1059 SetCoeff(
result,NTLcurrentExp,to_ZZ_pE(cc));
1062 for(
k=NTLcurrentExp;
k>=0;
k--) SetCoeff(
result,
k,0);
1073 int NTLcurrentExp=
i.exp();
1074 int largestExp=
i.exp();
1077 result.SetMaxLength(largestExp+1);
1078 for(;
i.hasTerms();
i++)
1080 for(
k=NTLcurrentExp;
k>
i.exp();
k--) SetCoeff(
result,
k,0);
1081 NTLcurrentExp=
i.exp();
1086 SetCoeff(
result,NTLcurrentExp,to_zz_pE(cc));
1089 for(
k=NTLcurrentExp;
k>=0;
k--) SetCoeff(
result,
k,0);
1101 for (
int j=0;
j<deg(
f)+1;
j++)
1124 for (
int j=0;
j<deg(
f)+1;
j++)
1142 mat_ZZ *
res=
new mat_ZZ;
1143 res->SetDims(
m.rows(),
m.columns());
1146 for(
i=
m.rows();
i>0;
i--)
1148 for(
j=
m.columns();
j>0;
j--)
1159 for(
i=
res->rows();
i>0;
i--)
1161 for(
j=
res->columns();
j>0;
j--)
1171 mat_zz_p *
res=
new mat_zz_p;
1172 res->SetDims(
m.rows(),
m.columns());
1175 for(
i=
m.rows();
i>0;
i--)
1177 for(
j=
m.columns();
j>0;
j--)
1179 if(!(
m(
i,
j)).isImm()) printf(
"convertFacCFMatrix2NTLmat_zz_p: not imm.\n");
1189 for(
i=
res->rows();
i>0;
i--)
1191 for(
j=
res->columns();
j>0;
j--)
1200 mat_zz_pE *
res=
new mat_zz_pE;
1201 res->SetDims(
m.rows(),
m.columns());
1204 for(
i=
m.rows();
i>0;
i--)
1206 for(
j=
m.columns();
j>0;
j--)
1209 (*res)(
i,
j)=to_zz_pE(cc);
1218 for(
i=
res->rows();
i>0;
i--)
1220 for(
j=
res->columns();
j>0;
j--)
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
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)
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 )
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.