My Project
Functions | Variables
NTLconvert.h File Reference

Conversion to and from NTL. More...

#include "cf_defs.h"
#include "canonicalform.h"
#include "cf_iter.h"
#include "fac_sqrfree.h"
#include "cf_algorithm.h"
#include <NTL/config.h>
#include <NTL/ZZXFactoring.h>
#include <NTL/ZZ_pXFactoring.h>
#include <NTL/lzz_pXFactoring.h>
#include <NTL/GF2XFactoring.h>
#include <NTL/ZZ_pEXFactoring.h>
#include <NTL/lzz_pEXFactoring.h>
#include <NTL/GF2EXFactoring.h>
#include <NTL/mat_ZZ.h>
#include <NTL/mat_lzz_p.h>
#include <NTL/mat_lzz_pE.h>
#include "int_int.h"
#include "cf_assert.h"

Go to the source code of this file.

Functions

ZZ_pX convertFacCF2NTLZZpX (const CanonicalForm &f)
 NAME: convertFacCF2NTLZZpX. More...
 
zz_pX convertFacCF2NTLzzpX (const CanonicalForm &f)
 
GF2X convertFacCF2NTLGF2X (const CanonicalForm &f)
 NAME: convertFacCF2NTLGF2X. More...
 
CanonicalForm convertNTLZZpX2CF (const ZZ_pX &poly, const Variable &x)
 NAME: convertNTLZZpX2CF. More...
 
CanonicalForm convertNTLzzpX2CF (const zz_pX &poly, const Variable &x)
 
CanonicalForm convertNTLGF2X2CF (const GF2X &poly, const Variable &x)
 NAME: convertNTLGF2X2CF. More...
 
CanonicalForm convertNTLZZX2CF (const ZZX &polynom, const Variable &x)
 
CFFList convertNTLvec_pair_ZZpX_long2FacCFFList (const vec_pair_ZZ_pX_long &e, const ZZ_p &cont, const Variable &x)
 NAME: convertNTLvec_pair_ZZpX_long2FacCFFList. More...
 
CFFList convertNTLvec_pair_zzpX_long2FacCFFList (const vec_pair_zz_pX_long &e, const zz_p cont, const Variable &x)
 
CFFList convertNTLvec_pair_GF2X_long2FacCFFList (const vec_pair_GF2X_long &e, const GF2 cont, const Variable &x)
 NAME: convertNTLvec_pair_GF2X_long2FacCFFList. More...
 
CanonicalForm convertZZ2CF (const ZZ &coefficient)
 NAME: convertZZ2CF. More...
 
ZZ convertFacCF2NTLZZ (const CanonicalForm &f)
 NAME: convertFacCF2NTLZZX. More...
 
ZZX convertFacCF2NTLZZX (const CanonicalForm &f)
 
CFFList convertNTLvec_pair_ZZX_long2FacCFFList (const vec_pair_ZZX_long &e, const ZZ &cont, const Variable &x)
 NAME: convertNTLvec_pair_ZZX_long2FacCFFList. More...
 
CanonicalForm convertNTLZZpE2CF (const ZZ_pE &coefficient, const Variable &x)
 NAME: convertNTLZZpX2CF. More...
 
CFFList convertNTLvec_pair_ZZpEX_long2FacCFFList (const vec_pair_ZZ_pEX_long &e, const ZZ_pE &cont, const Variable &x, const Variable &alpha)
 NAME: convertNTLvec_pair_ZZpEX_long2FacCFFList. More...
 
CanonicalForm convertNTLGF2E2CF (const GF2E &coefficient, const Variable &x)
 NAME: convertNTLGF2E2CF. More...
 
CFFList convertNTLvec_pair_GF2EX_long2FacCFFList (const vec_pair_GF2EX_long &e, const GF2E &cont, const Variable &x, const Variable &alpha)
 NAME: convertNTLvec_pair_GF2EX_long2FacCFFList. More...
 
GF2EX convertFacCF2NTLGF2EX (const CanonicalForm &f, const GF2X &mipo)
 CanonicalForm in Z_2(a)[X] to NTL GF2EX. More...
 
ZZ_pEX convertFacCF2NTLZZ_pEX (const CanonicalForm &f, const ZZ_pX &mipo)
 CanonicalForm in Z_p(a)[X] to NTL ZZ_pEX. More...
 
zz_pEX convertFacCF2NTLzz_pEX (const CanonicalForm &f, const zz_pX &mipo)
 
CanonicalForm convertNTLzzpE2CF (const zz_pE &f, const Variable &x)
 
CFFList convertNTLvec_pair_zzpEX_long2FacCFFList (const vec_pair_zz_pEX_long &e, const zz_pE &cont, const Variable &x, const Variable &alpha)
 
CanonicalForm convertNTLzz_pEX2CF (const zz_pEX &f, const Variable &x, const Variable &alpha)
 
CanonicalForm convertNTLZZ_pEX2CF (const ZZ_pEX &f, const Variable &x, const Variable &alpha)
 
mat_ZZ * convertFacCFMatrix2NTLmat_ZZ (const CFMatrix &m)
 
CFMatrixconvertNTLmat_ZZ2FacCFMatrix (const mat_ZZ &m)
 
mat_zz_p * convertFacCFMatrix2NTLmat_zz_p (const CFMatrix &m)
 
CFMatrixconvertNTLmat_zz_p2FacCFMatrix (const mat_zz_p &m)
 
mat_zz_pE * convertFacCFMatrix2NTLmat_zz_pE (const CFMatrix &m)
 
CFMatrixconvertNTLmat_zz_pE2FacCFMatrix (const mat_zz_pE &m, const Variable &alpha)
 

Variables

EXTERN_VAR long fac_NTL_char
 

Detailed Description

Conversion to and from NTL.

Definition in file NTLconvert.h.

Function Documentation

◆ convertFacCF2NTLGF2EX()

GF2EX convertFacCF2NTLGF2EX ( const CanonicalForm f,
const GF2X &  mipo 
)

CanonicalForm in Z_2(a)[X] to NTL GF2EX.

Definition at line 1007 of file NTLconvert.cc.

1008 {
1009  GF2E::init(mipo);
1010  GF2EX result;
1011  CFIterator i;
1012  i=f;
1013 
1014  int NTLcurrentExp=i.exp();
1015  int largestExp=i.exp();
1016  int k;
1017 
1018  result.SetMaxLength(largestExp+1);
1019  for(;i.hasTerms();i++)
1020  {
1021  for(k=NTLcurrentExp;k>i.exp();k--) SetCoeff(result,k,0);
1022  NTLcurrentExp=i.exp();
1023  CanonicalForm c=i.coeff();
1024  GF2X cc=convertFacCF2NTLGF2X(c);
1025  //ZZ_pE ccc;
1026  //conv(ccc,cc);
1027  SetCoeff(result,NTLcurrentExp,to_GF2E(cc));
1028  NTLcurrentExp--;
1029  }
1030  for(k=NTLcurrentExp;k>=0;k--) SetCoeff(result,k,0);
1031  result.normalize();
1032  return result;
1033 }
GF2X convertFacCF2NTLGF2X(const CanonicalForm &f)
NAME: convertFacCF2NTLGF2X.
Definition: NTLconvert.cc:184
int i
Definition: cfEzgcd.cc:132
int k
Definition: cfEzgcd.cc:99
FILE * f
Definition: checklibs.c:9
class to iterate through CanonicalForm's
Definition: cf_iter.h:44
factory's main class
Definition: canonicalform.h:86
return result
Definition: facAbsBiFact.cc:75
CanonicalForm mipo
Definition: facAlgExt.cc:57
void init()
Definition: lintree.cc:864

◆ convertFacCF2NTLGF2X()

GF2X convertFacCF2NTLGF2X ( const CanonicalForm f)

NAME: convertFacCF2NTLGF2X.

DESCRIPTION: Conversion routine for Factory-type canonicalform into GF2X of NTL, i.e. polynomials over F_2. As precondition for correct execution, the characteristic must equal two. This is a special case of the more general conversion routine for canonicalform to ZZpX. It is included because NTL provides additional support and faster algorithms over F_2, moreover the conversion code can be optimized, because certain steps are either completely obsolent (like normalizing the polynomial) or they can be made significantly faster (like building up the NTL-polynomial).

INPUT: A canonicalform f OUTPUT: The converted NTL-polynomial over F_2 of type GF2X

Definition at line 184 of file NTLconvert.cc.

185 {
186  //printf("convertFacCF2NTLGF2X\n");
187  GF2X ntl_poly;
188 
189  CFIterator i;
190  i=f;
191 
192  int NTLcurrentExp=i.exp();
193  int largestExp=i.exp();
194  int k;
195 
196  //building the NTL-polynomial
197  ntl_poly.SetMaxLength(largestExp+1);
198 
199  for (;i.hasTerms();i++)
200  {
201 
202  for (k=NTLcurrentExp;k>i.exp();k--)
203  {
204  SetCoeff(ntl_poly,k,0);
205  }
206  NTLcurrentExp=i.exp();
207 
208  if (!i.coeff().isImm()) i.coeff()=i.coeff().mapinto();
209  if (!i.coeff().isImm())
210  {
211  #ifndef NOSTREAMIO
212  cout<<"convertFacCF2NTLGF2X: coefficient not immediate! : " << f << "\n";
213  #else
214  //NTL_SNS
215  printf("convertFacCF2NTLGF2X: coefficient not immediate!");
216  #endif
217  NTL_SNS exit(1);
218  }
219  else
220  {
221  SetCoeff(ntl_poly,NTLcurrentExp,i.coeff().intval());
222  }
223  NTLcurrentExp--;
224  }
225  for (k=NTLcurrentExp;k>=0;k--)
226  {
227  SetCoeff(ntl_poly,k,0);
228  }
229  //normalization is not necessary of F_2
230 
231  return ntl_poly;
232 }

◆ convertFacCF2NTLZZ()

ZZ convertFacCF2NTLZZ ( const CanonicalForm f)

NAME: convertFacCF2NTLZZX.

DESCRIPTION: Routine for conversion of canonicalforms in Factory to polynomials of type ZZX of NTL. To guarantee the correct execution of the algorithm the characteristic has to equal zero.

INPUT: The canonicalform that has to be converted OUTPUT: The converted NTL-polynom of type ZZX

Definition at line 670 of file NTLconvert.cc.

671 {
672  ZZ temp;
673  if (f.isImm()) temp=f.intval();
674  else
675  {
676  //Coefficient is a gmp-number
677  mpz_t gmp_val;
678  char* stringtemp;
679 
680  f.mpzval (gmp_val);
681  int l=mpz_sizeinbase(gmp_val,10)+2;
682  stringtemp=(char*)Alloc(l);
683  stringtemp=mpz_get_str(stringtemp,10,gmp_val);
684  mpz_clear(gmp_val);
685  conv(temp,stringtemp);
686  Free(stringtemp,l);
687  }
688  return temp;
689 }
#define Free(A, L)
Definition: NTLconvert.cc:37
#define Alloc(L)
Definition: NTLconvert.cc:36
int l
Definition: cfEzgcd.cc:100
CFList conv(const CFFList &L)
convert a CFFList to a CFList by dropping the multiplicity
Definition: facBivar.cc:126

◆ convertFacCF2NTLZZ_pEX()

ZZ_pEX convertFacCF2NTLZZ_pEX ( const CanonicalForm f,
const ZZ_pX &  mipo 
)

CanonicalForm in Z_p(a)[X] to NTL ZZ_pEX.

Definition at line 1037 of file NTLconvert.cc.

1038 {
1039  ZZ_pE::init(mipo);
1040  ZZ_pEX result;
1041  CFIterator i;
1042  i=f;
1043 
1044  int NTLcurrentExp=i.exp();
1045  int largestExp=i.exp();
1046  int k;
1047 
1048  result.SetMaxLength(largestExp+1);
1049  for(;i.hasTerms();i++)
1050  {
1051  for(k=NTLcurrentExp;k>i.exp();k--) SetCoeff(result,k,0);
1052  NTLcurrentExp=i.exp();
1053  CanonicalForm c=i.coeff();
1054  ZZ_pX cc=convertFacCF2NTLZZpX(c);
1055  //ZZ_pE ccc;
1056  //conv(ccc,cc);
1057  SetCoeff(result,NTLcurrentExp,to_ZZ_pE(cc));
1058  NTLcurrentExp--;
1059  }
1060  for(k=NTLcurrentExp;k>=0;k--) SetCoeff(result,k,0);
1061  result.normalize();
1062  return result;
1063 }
ZZ_pX convertFacCF2NTLZZpX(const CanonicalForm &f)
NAME: convertFacCF2NTLZZpX.
Definition: NTLconvert.cc:64

◆ convertFacCF2NTLzz_pEX()

zz_pEX convertFacCF2NTLzz_pEX ( const CanonicalForm f,
const zz_pX &  mipo 
)

Definition at line 1064 of file NTLconvert.cc.

1065 {
1066  zz_pE::init(mipo);
1067  zz_pEX result;
1068  CFIterator i;
1069  i=f;
1070 
1071  int NTLcurrentExp=i.exp();
1072  int largestExp=i.exp();
1073  int k;
1074 
1075  result.SetMaxLength(largestExp+1);
1076  for(;i.hasTerms();i++)
1077  {
1078  for(k=NTLcurrentExp;k>i.exp();k--) SetCoeff(result,k,0);
1079  NTLcurrentExp=i.exp();
1080  CanonicalForm c=i.coeff();
1081  zz_pX cc=convertFacCF2NTLzzpX(c);
1082  //ZZ_pE ccc;
1083  //conv(ccc,cc);
1084  SetCoeff(result,NTLcurrentExp,to_zz_pE(cc));
1085  NTLcurrentExp--;
1086  }
1087  for(k=NTLcurrentExp;k>=0;k--) SetCoeff(result,k,0);
1088  result.normalize();
1089  return result;
1090 }
zz_pX convertFacCF2NTLzzpX(const CanonicalForm &f)
Definition: NTLconvert.cc:105

◆ convertFacCF2NTLZZpX()

ZZ_pX convertFacCF2NTLZZpX ( const CanonicalForm f)

NAME: convertFacCF2NTLZZpX.

DESCRIPTION: Conversion routine for Factory-type canonicalform into ZZpX of NTL, i.e. polynomials over F_p. As a precondition for correct execution, the characteristic has to a a prime number.

INPUT: A canonicalform f OUTPUT: The converted NTL-polynomial over F_p of type ZZpX

Definition at line 64 of file NTLconvert.cc.

65 {
66  ZZ_pX ntl_poly;
67 
68  CFIterator i;
69  i=f;
70 
71  int NTLcurrentExp=i.exp();
72  int largestExp=i.exp();
73  int k;
74 
75  // we now build up the NTL-polynomial
76  ntl_poly.SetMaxLength(largestExp+1);
77 
78  for (;i.hasTerms();i++)
79  {
80  for (k=NTLcurrentExp;k>i.exp();k--)
81  {
82  SetCoeff(ntl_poly,k,0);
83  }
84  NTLcurrentExp=i.exp();
85 
86  SetCoeff(ntl_poly,NTLcurrentExp,to_ZZ_p (convertFacCF2NTLZZ (i.coeff())));
87  NTLcurrentExp--;
88  }
89 
90  //Set the remaining coefficients of ntl_poly to zero.
91  // This is necessary, because NTL internally
92  // also stores powers with zero coefficient,
93  // whereas factory stores tuples of degree and coefficient
94  //leaving out tuples if the coefficient equals zero
95  for (k=NTLcurrentExp;k>=0;k--)
96  {
97  SetCoeff(ntl_poly,k,0);
98  }
99 
100  //normalize the polynomial and return it
101  ntl_poly.normalize();
102 
103  return ntl_poly;
104 }
ZZ convertFacCF2NTLZZ(const CanonicalForm &f)
NAME: convertFacCF2NTLZZX.
Definition: NTLconvert.cc:670

◆ convertFacCF2NTLzzpX()

zz_pX convertFacCF2NTLzzpX ( const CanonicalForm f)

Definition at line 105 of file NTLconvert.cc.

106 {
107  zz_pX ntl_poly;
108 
109  CFIterator i;
110  i=f;
111 
112  int NTLcurrentExp=i.exp();
113  int largestExp=i.exp();
114  int k;
115 
116  // we now build up the NTL-polynomial
117  ntl_poly.SetMaxLength(largestExp+1);
118 
119  for (;i.hasTerms();i++)
120  {
121  for (k=NTLcurrentExp;k>i.exp();k--)
122  {
123  SetCoeff(ntl_poly,k,0);
124  }
125  NTLcurrentExp=i.exp();
126 
127  CanonicalForm c=i.coeff();
128  if (!c.isImm()) c=c.mapinto(); //c%= getCharacteristic();
129  if (!c.isImm())
130  { //This case will never happen if the characteristic is in fact a prime
131  // number, since all coefficients are represented as immediates
132  out_cf("f:->",f,"\n");
133  out_cf("c:->",c,"\n");
134  #ifndef NOSTREAMIO
135  cout<<"convertFacCF2NTLzz_pX: coefficient not immediate! : "<<f<<"\n";
136  #else
137  //NTL_SNS
138  printf("convertFacCF2NTLzz_pX: coefficient not immediate!, char=%d\n",
140  #endif
141  NTL_SNS exit(1);
142  }
143  else
144  {
145  SetCoeff(ntl_poly,NTLcurrentExp,c.intval());
146  }
147  NTLcurrentExp--;
148  }
149 
150  //Set the remaining coefficients of ntl_poly to zero.
151  // This is necessary, because NTL internally
152  // also stores powers with zero coefficient,
153  // whereas factory stores tuples of degree and coefficient
154  //leaving out tuples if the coefficient equals zero
155  for (k=NTLcurrentExp;k>=0;k--)
156  {
157  SetCoeff(ntl_poly,k,0);
158  }
159 
160  //normalize the polynomial and return it
161  ntl_poly.normalize();
162 
163  return ntl_poly;
164 }
void out_cf(const char *s1, const CanonicalForm &f, const char *s2)
cf_algorithm.cc - simple mathematical algorithms.
Definition: cf_factor.cc:99
int FACTORY_PUBLIC getCharacteristic()
Definition: cf_char.cc:70
long intval() const
conversion functions
bool isImm() const
CanonicalForm mapinto() const

◆ convertFacCF2NTLZZX()

ZZX convertFacCF2NTLZZX ( const CanonicalForm f)

Definition at line 691 of file NTLconvert.cc.

692 {
693  ZZX ntl_poly;
694 
695  CFIterator i;
696  i=f;
697 
698  int NTLcurrentExp=i.exp();
699  int largestExp=i.exp();
700  int k;
701 
702  //set the length of the NTL-polynomial
703  ntl_poly.SetMaxLength(largestExp+1);
704 
705  //Go through the coefficients of the canonicalform and build up the NTL-polynomial
706  for (;i.hasTerms();i++)
707  {
708  for (k=NTLcurrentExp;k>i.exp();k--)
709  {
710  SetCoeff(ntl_poly,k,0);
711  }
712  NTLcurrentExp=i.exp();
713 
714  //Coefficient is a gmp-number
715  ZZ temp=convertFacCF2NTLZZ(i.coeff());
716 
717  //set the computed coefficient
718  SetCoeff(ntl_poly,NTLcurrentExp,temp);
719 
720  NTLcurrentExp--;
721  }
722  for (k=NTLcurrentExp;k>=0;k--)
723  {
724  SetCoeff(ntl_poly,k,0);
725  }
726 
727  //normalize the polynomial
728  ntl_poly.normalize();
729 
730  return ntl_poly;
731 }

◆ convertFacCFMatrix2NTLmat_ZZ()

mat_ZZ* convertFacCFMatrix2NTLmat_ZZ ( const CFMatrix m)

Definition at line 1138 of file NTLconvert.cc.

1139 {
1140  mat_ZZ *res=new mat_ZZ;
1141  res->SetDims(m.rows(),m.columns());
1142 
1143  int i,j;
1144  for(i=m.rows();i>0;i--)
1145  {
1146  for(j=m.columns();j>0;j--)
1147  {
1148  (*res)(i,j)=convertFacCF2NTLZZ(m(i,j));
1149  }
1150  }
1151  return res;
1152 }
int m
Definition: cfEzgcd.cc:128
CanonicalForm res
Definition: facAbsFact.cc:60
int j
Definition: facHensel.cc:110

◆ convertFacCFMatrix2NTLmat_zz_p()

mat_zz_p* convertFacCFMatrix2NTLmat_zz_p ( const CFMatrix m)

Definition at line 1167 of file NTLconvert.cc.

1168 {
1169  mat_zz_p *res=new mat_zz_p;
1170  res->SetDims(m.rows(),m.columns());
1171 
1172  int i,j;
1173  for(i=m.rows();i>0;i--)
1174  {
1175  for(j=m.columns();j>0;j--)
1176  {
1177  if(!(m(i,j)).isImm()) printf("convertFacCFMatrix2NTLmat_zz_p: not imm.\n");
1178  (*res)(i,j)=(m(i,j)).intval();
1179  }
1180  }
1181  return res;
1182 }

◆ convertFacCFMatrix2NTLmat_zz_pE()

mat_zz_pE* convertFacCFMatrix2NTLmat_zz_pE ( const CFMatrix m)

Definition at line 1196 of file NTLconvert.cc.

1197 {
1198  mat_zz_pE *res=new mat_zz_pE;
1199  res->SetDims(m.rows(),m.columns());
1200 
1201  int i,j;
1202  for(i=m.rows();i>0;i--)
1203  {
1204  for(j=m.columns();j>0;j--)
1205  {
1206  zz_pX cc=convertFacCF2NTLzzpX(m(i,j));
1207  (*res)(i,j)=to_zz_pE(cc);
1208  }
1209  }
1210  return res;
1211 }

◆ convertNTLGF2E2CF()

CanonicalForm convertNTLGF2E2CF ( const GF2E &  coefficient,
const Variable x 
)

NAME: convertNTLGF2E2CF.

DESCRIPTION: Routine for conversion of elements of extensions of GF2, having type GF2E, of NTL to their corresponding values of type canonicalform in Factory. To guarantee the correct execution of the algorithm, the characteristic must equal two and Factory has to compute in an extension of F_2. As usual this is an optimized special case of the more general conversion routine from ZZpE to Factory.

INPUT: The coefficient of type GF2E and the variable x indicating the main variable of the computed canonicalform OUTPUT: The converted value of coefficient as type canonicalform

Definition at line 932 of file NTLconvert.cc.

933 {
934  return convertNTLGF2X2CF(rep(coefficient),x);
935 }
CanonicalForm convertNTLGF2X2CF(const GF2X &poly, const Variable &x)
NAME: convertNTLGF2X2CF.
Definition: NTLconvert.cc:322
Variable x
Definition: cfModGcd.cc:4084

◆ convertNTLGF2X2CF()

CanonicalForm convertNTLGF2X2CF ( const GF2X &  poly,
const Variable x 
)

NAME: convertNTLGF2X2CF.

DESCRIPTION: Conversion routine for NTL-Type GF2X to Factory-Type canonicalform, the routine is again an optimized special case of the more general conversion to ZZpX. Additionally a variable x is needed as a parameter indicating the main variable of the computed canonicalform. To guarantee the correct execution of the algorithm the characteristic has a be an arbitrary prime number.

INPUT: A canonicalform f, a variable x OUTPUT: The converted Factory-polynomial of type canonicalform, built by the main variable x

Definition at line 322 of file NTLconvert.cc.

323 {
324  //printf("convertNTLGF2X2CF\n");
325  CanonicalForm bigone;
326 
327  if (deg(poly)>0)
328  {
329  // poly is non-constant
330  bigone=0;
331  bigone.mapinto();
332  // Compute the canonicalform coefficient by coefficient,
333  // bigone summarizes the result.
334  // In constrast to the more general conversion to ZZpX
335  // the only possible coefficients are zero
336  // and one yielding the following simplified loop
337  for (int j=0;j<=deg(poly);j++)
338  {
339  if (coeff(poly,j)!=0) bigone+=power(x,j);
340  // *CanonicalForm(to_long(rep(coeff(poly,j))))) is not necessary any more;
341  }
342  }
343  else
344  {
345  // poly is immediate
346  bigone=CanonicalForm(to_long(rep(coeff(poly,0))));
347  bigone.mapinto();
348  }
349 
350  return bigone;
351 }
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation

◆ convertNTLmat_ZZ2FacCFMatrix()

CFMatrix* convertNTLmat_ZZ2FacCFMatrix ( const mat_ZZ &  m)

Definition at line 1153 of file NTLconvert.cc.

1154 {
1155  CFMatrix *res=new CFMatrix(m.NumRows(),m.NumCols());
1156  int i,j;
1157  for(i=res->rows();i>0;i--)
1158  {
1159  for(j=res->columns();j>0;j--)
1160  {
1161  (*res)(i,j)=convertZZ2CF(m(i,j));
1162  }
1163  }
1164  return res;
1165 }
CanonicalForm convertZZ2CF(const ZZ &a)
NAME: convertZZ2CF.
Definition: NTLconvert.cc:495
Matrix< CanonicalForm > CFMatrix

◆ convertNTLmat_zz_p2FacCFMatrix()

CFMatrix* convertNTLmat_zz_p2FacCFMatrix ( const mat_zz_p &  m)

Definition at line 1183 of file NTLconvert.cc.

1184 {
1185  CFMatrix *res=new CFMatrix(m.NumRows(),m.NumCols());
1186  int i,j;
1187  for(i=res->rows();i>0;i--)
1188  {
1189  for(j=res->columns();j>0;j--)
1190  {
1191  (*res)(i,j)=CanonicalForm(to_long(rep(m(i,j))));
1192  }
1193  }
1194  return res;
1195 }

◆ convertNTLmat_zz_pE2FacCFMatrix()

CFMatrix* convertNTLmat_zz_pE2FacCFMatrix ( const mat_zz_pE &  m,
const Variable alpha 
)

Definition at line 1212 of file NTLconvert.cc.

1213 {
1214  CFMatrix *res=new CFMatrix(m.NumRows(),m.NumCols());
1215  int i,j;
1216  for(i=res->rows();i>0;i--)
1217  {
1218  for(j=res->columns();j>0;j--)
1219  {
1220  (*res)(i,j)=convertNTLzzpE2CF(m(i,j), alpha);
1221  }
1222  }
1223  return res;
1224 }
CanonicalForm convertNTLzzpE2CF(const zz_pE &coefficient, const Variable &x)
Definition: NTLconvert.cc:799
Variable alpha
Definition: facAbsBiFact.cc:51

◆ convertNTLvec_pair_GF2EX_long2FacCFFList()

CFFList convertNTLvec_pair_GF2EX_long2FacCFFList ( const vec_pair_GF2EX_long &  e,
const GF2E &  cont,
const Variable x,
const Variable alpha 
)

NAME: convertNTLvec_pair_GF2EX_long2FacCFFList.

DESCRIPTION: Routine for converting a vector of polynomials from GF2EX to a CFFList of Factory. This routine will be used after a successful factorization of NTL to convert the result back to Factory. This is a special, but optimized case of the more general conversion from ZZpE to canonicalform. Additionally a variable x and the computed content, as a type GF2E of NTL, is needed as parameters indicating the main variable of the computed canonicalform and the content of the original polynomial. To guarantee the correct execution of the algorithm the characteristic has to equal two and computations have to be done in an extention of F_2.

INPUT: A vector of polynomials over GF2E of type vec_pair_GF2EX_long and a variable x and a content of type GF2E OUTPUT: The converted list of polynomials of type CFFList, all polynomials have x as their main variable

Definition at line 958 of file NTLconvert.cc.

960 {
961  CFFList result;
962  GF2EX polynom;
963  long exponent;
964  CanonicalForm bigone;
965 
966  // Maybe, e may additionally be sorted with respect to increasing degree of x, but this is not
967  //important for the factorization, but nevertheless would take computing time, so it is omitted
968 
969  // Go through the vector e and build up the CFFList
970  // As usual bigone summarizes the result during every loop
971  for (int i=e.length()-1;i>=0;i--)
972  {
973  bigone=0;
974 
975  polynom=e[i].a;
976  exponent=e[i].b;
977 
978  for (int j=0;j<=deg(polynom);j++)
979  {
980  if (IsOne(coeff(polynom,j)))
981  {
982  bigone+=power(x,j);
983  }
984  else
985  {
986  CanonicalForm coefficient=convertNTLGF2E2CF(coeff(polynom,j),alpha);
987  if (coeff(polynom,j)!=0)
988  {
989  bigone += (power(x,j)*coefficient);
990  }
991  }
992  }
993  // append the computed polynomial together with its multiplicity
994  result.append(CFFactor(bigone,exponent));
995  }
996 
997  if (!IsOne(cont))
998  result.insert(CFFactor(convertNTLGF2E2CF(cont,alpha),1));
999 
1000  // return the computed CFFList
1001  return result;
1002 }
CanonicalForm convertNTLGF2E2CF(const GF2E &coefficient, const Variable &x)
NAME: convertNTLGF2E2CF.
Definition: NTLconvert.cc:932
Factor< CanonicalForm > CFFactor
static BOOLEAN IsOne(number a, const coeffs)
Definition: flintcf_Q.cc:332
int exponent(const CanonicalForm &f, int q)
int exponent ( const CanonicalForm & f, int q )

◆ convertNTLvec_pair_GF2X_long2FacCFFList()

CFFList convertNTLvec_pair_GF2X_long2FacCFFList ( const vec_pair_GF2X_long &  e,
GF2  cont,
const Variable x 
)

NAME: convertNTLvec_pair_GF2X_long2FacCFFList.

DESCRIPTION: Routine for converting a vector of polynomials of type GF2X from NTL to a list CFFList of Factory. This routine will be used after a successful factorization of NTL to convert the result back to Factory. As usual this is simply a special case of the more general conversion routine but again speeded up by leaving out unnecessary steps. Additionally a variable x and the computed content, as type GF2 of NTL, are needed as parameters indicating the main variable of the computed canonicalform and the content of the original polynomial. To guarantee the correct execution of the algorithm the characteristic has a be an arbitrary prime number.

INPUT: A vector of polynomials over GF2 of type vec_pair_GF2X_long and a variable x and a content of type GF2 OUTPUT: The converted list of polynomials of type CFFList, all polynomials have x as their main variable

Definition at line 445 of file NTLconvert.cc.

447 {
448  //printf("convertNTLvec_pair_GF2X_long2FacCFFList\n");
449  CFFList result;
450  GF2X polynom;
451  long exponent;
452  CanonicalForm bigone;
453 
454  // Maybe, e may additionally be sorted with respect to increasing degree of x
455  // but this is not
456  //important for the factorization, but nevertheless would take computing time
457  // so it is omitted.
458 
459  // Go through the vector e and compute the CFFList
460  // bigone summarizes the result again
461  for (int i=e.length()-1;i>=0;i--)
462  {
463  bigone=0;
464 
465  polynom=e[i].a;
466  exponent=e[i].b;
467  for (int j=0;j<=deg(polynom);j++)
468  {
469  if (coeff(polynom,j)!=0)
470  bigone += (power(x,j)*CanonicalForm(to_long(rep(coeff(polynom,j)))));
471  }
472 
473  //append the converted polynomial to the CFFList
474  result.append(CFFactor(bigone,exponent));
475  }
476  // no constant factor for char 2: result.insert(CFFactor(1,1));
477  return result;
478 }

◆ convertNTLvec_pair_ZZpEX_long2FacCFFList()

CFFList convertNTLvec_pair_ZZpEX_long2FacCFFList ( const vec_pair_ZZ_pEX_long &  e,
const ZZ_pE &  cont,
const Variable x,
const Variable alpha 
)

NAME: convertNTLvec_pair_ZZpEX_long2FacCFFList.

DESCRIPTION: Routine for converting a vector of polynomials from ZZpEX to a CFFList of Factory. This routine will be used after a successful factorization of NTL to convert the result back to Factory. Additionally a variable x and the computed content, as a type ZZpE of NTL, is needed as parameters indicating the main variable of the computed canonicalform and the content of the original polynomial. To guarantee the correct execution of the algorithm the characteristic has a be an arbitrary prime number p and computations have to be done in an extention of F_p.

INPUT: A vector of polynomials over ZZpE of type vec_pair_ZZ_pEX_long and a variable x and a content of type ZZpE OUTPUT: The converted list of polynomials of type CFFList, all polynomials have x as their main variable

Definition at line 825 of file NTLconvert.cc.

826 {
827  CFFList result;
828  ZZ_pEX polynom;
829  long exponent;
830  CanonicalForm bigone;
831 
832  // Maybe, e may additionally be sorted with respect to increasing degree of x, but this is not
833  //important for the factorization, but nevertheless would take computing time, so it is omitted
834 
835  // Go through the vector e and build up the CFFList
836  // As usual bigone summarizes the result during every loop
837  for (int i=e.length()-1;i>=0;i--)
838  {
839  bigone=0;
840 
841  polynom=e[i].a;
842  exponent=e[i].b;
843 
844  for (int j=0;j<=deg(polynom);j++)
845  {
846  if (IsOne(coeff(polynom,j)))
847  {
848  bigone+=power(x,j);
849  }
850  else
851  {
852  CanonicalForm coefficient=convertNTLZZpE2CF(coeff(polynom,j),alpha);
853  if (coeff(polynom,j)!=0)
854  {
855  bigone += (power(x,j)*coefficient);
856  }
857  }
858  }
859  //append the computed polynomials together with its exponent to the CFFList
860  result.append(CFFactor(bigone,exponent));
861  }
862  // Start by insert the content
863  if(!IsOne(cont))
864  result.insert(CFFactor(convertNTLZZpE2CF(cont,alpha),1));
865 
866  //return the computed CFFList
867  return result;
868 }
CanonicalForm convertNTLZZpE2CF(const ZZ_pE &coefficient, const Variable &x)
NAME: convertNTLZZpX2CF.
Definition: NTLconvert.cc:795

◆ convertNTLvec_pair_zzpEX_long2FacCFFList()

CFFList convertNTLvec_pair_zzpEX_long2FacCFFList ( const vec_pair_zz_pEX_long &  e,
const zz_pE &  cont,
const Variable x,
const Variable alpha 
)

Definition at line 870 of file NTLconvert.cc.

871 {
872  CFFList result;
873  zz_pEX polynom;
874  long exponent;
875  CanonicalForm bigone;
876 
877  // Maybe, e may additionally be sorted with respect to increasing degree of x, but this is not
878  //important for the factorization, but nevertheless would take computing time, so it is omitted
879 
880  // Go through the vector e and build up the CFFList
881  // As usual bigone summarizes the result during every loop
882  for (int i=e.length()-1;i>=0;i--)
883  {
884  bigone=0;
885 
886  polynom=e[i].a;
887  exponent=e[i].b;
888 
889  for (int j=0;j<=deg(polynom);j++)
890  {
891  if (IsOne(coeff(polynom,j)))
892  {
893  bigone+=power(x,j);
894  }
895  else
896  {
897  CanonicalForm coefficient=convertNTLzzpE2CF(coeff(polynom,j),alpha);
898  if (coeff(polynom,j)!=0)
899  {
900  bigone += (power(x,j)*coefficient);
901  }
902  }
903  }
904  //append the computed polynomials together with its exponent to the CFFList
905  result.append(CFFactor(bigone,exponent));
906  }
907  // Start by insert the constant factor
908  if(!IsOne(cont))
909  result.insert(CFFactor(convertNTLzzpE2CF(cont,alpha),1));
910 
911  //return the computed CFFList
912  return result;
913 }

◆ convertNTLvec_pair_ZZpX_long2FacCFFList()

CFFList convertNTLvec_pair_ZZpX_long2FacCFFList ( const vec_pair_ZZ_pX_long &  e,
const ZZ_p &  cont,
const Variable x 
)

NAME: convertNTLvec_pair_ZZpX_long2FacCFFList.

DESCRIPTION: Routine for converting a vector of polynomials from ZZpX to a CFFList of Factory. This routine will be used after a successful factorization of NTL to convert the result back to Factory.

Additionally a variable x and the computed content, as a type ZZp of NTL, is needed as parameters indicating the main variable of the computed canonicalform and the conent of the original polynomial. To guarantee the correct execution of the algorithm the characteristic has a be an arbitrary prime number.

INPUT: A vector of polynomials over ZZp of type vec_pair_ZZ_pX_long and a variable x and a content of type ZZp OUTPUT: The converted list of polynomials of type CFFList, all polynomials have x as their main variable

Definition at line 373 of file NTLconvert.cc.

375 {
376  //printf("convertNTLvec_pair_ZZpX_long2FacCFFList\n");
377  CFFList result;
378  ZZ_pX polynom;
379  CanonicalForm bigone;
380 
381  // Maybe, e may additionally be sorted with respect to increasing degree of x
382  // but this is not
383  //important for the factorization, but nevertheless would take computing time,
384  // so it is omitted
385 
386 
387  // Go through the vector e and compute the CFFList
388  // again bigone summarizes the result
389  for (int i=e.length()-1;i>=0;i--)
390  {
391  result.append(CFFactor(convertNTLZZpX2CF(e[i].a,x),e[i].b));
392  }
393  // the content at pos 1
394  if (!IsOne(cont))
395  result.insert(CFFactor(CanonicalForm(to_long(rep(cont))),1));
396  return result;
397 }
CanonicalForm convertNTLZZpX2CF(const ZZ_pX &poly, const Variable &x)
NAME: convertNTLZZpX2CF.
Definition: NTLconvert.cc:250
CanonicalForm b
Definition: cfModGcd.cc:4105

◆ convertNTLvec_pair_zzpX_long2FacCFFList()

CFFList convertNTLvec_pair_zzpX_long2FacCFFList ( const vec_pair_zz_pX_long &  e,
const zz_p  cont,
const Variable x 
)

Definition at line 398 of file NTLconvert.cc.

400 {
401  //printf("convertNTLvec_pair_zzpX_long2FacCFFList\n");
402  CFFList result;
403  zz_pX polynom;
404  CanonicalForm bigone;
405 
406  // Maybe, e may additionally be sorted with respect to increasing degree of x
407  // but this is not
408  //important for the factorization, but nevertheless would take computing time,
409  // so it is omitted
410 
411 
412  // Go through the vector e and compute the CFFList
413  // again bigone summarizes the result
414  for (int i=e.length()-1;i>=0;i--)
415  {
416  result.append(CFFactor(convertNTLzzpX2CF(e[i].a,x),e[i].b));
417  }
418  // the content at pos 1
419  if (!IsOne(cont))
420  result.insert(CFFactor(CanonicalForm(to_long(rep(cont))),1));
421  return result;
422 }
CanonicalForm convertNTLzzpX2CF(const zz_pX &poly, const Variable &x)
Definition: NTLconvert.cc:255

◆ convertNTLvec_pair_ZZX_long2FacCFFList()

CFFList convertNTLvec_pair_ZZX_long2FacCFFList ( const vec_pair_ZZX_long &  e,
const ZZ &  cont,
const Variable x 
)

NAME: convertNTLvec_pair_ZZX_long2FacCFFList.

DESCRIPTION: Routine for converting a vector of polynomials from ZZ to a list CFFList of Factory. This routine will be used after a successful factorization of NTL to convert the result back to Factory. Additionally a variable x and the computed content, as a type ZZ of NTL, is needed as parameters indicating the main variable of the computed canonicalform and the content of the original polynomial. To guarantee the correct execution of the algorithm the characteristic has to equal zero.

INPUT: A vector of polynomials over ZZ of type vec_pair_ZZX_long and a variable x and a content of type ZZ OUTPUT: The converted list of polynomials of type CFFList, all have x as their main variable

Definition at line 753 of file NTLconvert.cc.

754 {
755  CFFList result;
756  ZZX polynom;
757  long exponent;
758  CanonicalForm bigone;
759 
760  // Go through the vector e and build up the CFFList
761  // As usual bigone summarizes the result
762  for (int i=e.length()-1;i>=0;i--)
763  {
764  ZZ coefficient;
765  polynom=e[i].a;
766  exponent=e[i].b;
767  bigone=convertNTLZZX2CF(polynom,x);
768  //append the converted polynomial to the list
769  result.append(CFFactor(bigone,exponent));
770  }
771  // the content at pos 1
772  result.insert(CFFactor(convertZZ2CF(cont),1));
773 
774  //return the converted list
775  return result;
776 }
CanonicalForm convertNTLZZX2CF(const ZZX &polynom, const Variable &x)
Definition: NTLconvert.cc:285

◆ convertNTLzz_pEX2CF()

CanonicalForm convertNTLzz_pEX2CF ( const zz_pEX &  f,
const Variable x,
const Variable alpha 
)

Definition at line 1092 of file NTLconvert.cc.

1093 {
1094  CanonicalForm bigone;
1095  if (deg (f) > 0)
1096  {
1097  bigone= 0;
1098  bigone.mapinto();
1099  for (int j=0;j<deg(f)+1;j++)
1100  {
1101  if (coeff(f,j)!=0)
1102  {
1103  bigone+=(power(x,j)*convertNTLzzpE2CF(coeff(f,j),alpha));
1104  }
1105  }
1106  }
1107  else
1108  {
1109  bigone= convertNTLzzpE2CF(coeff(f,0),alpha);
1110  bigone.mapinto();
1111  }
1112  return bigone;
1113 }

◆ convertNTLZZ_pEX2CF()

CanonicalForm convertNTLZZ_pEX2CF ( const ZZ_pEX &  f,
const Variable x,
const Variable alpha 
)

Definition at line 1115 of file NTLconvert.cc.

1116 {
1117  CanonicalForm bigone;
1118  if (deg (f) > 0)
1119  {
1120  bigone= 0;
1121  bigone.mapinto();
1122  for (int j=0;j<deg(f)+1;j++)
1123  {
1124  if (coeff(f,j)!=0)
1125  {
1126  bigone+=(power(x,j)*convertNTLZZpE2CF(coeff(f,j),alpha));
1127  }
1128  }
1129  }
1130  else
1131  {
1132  bigone= convertNTLZZpE2CF(coeff(f,0),alpha);
1133  bigone.mapinto();
1134  }
1135  return bigone;
1136 }

◆ convertNTLZZpE2CF()

CanonicalForm convertNTLZZpE2CF ( const ZZ_pE &  coefficient,
const Variable x 
)

NAME: convertNTLZZpX2CF.

DESCRIPTION: Routine for conversion of elements of arbitrary extensions of ZZp, having type ZZpE, of NTL to their corresponding values of type canonicalform in Factory. To guarantee the correct execution of the algorithm the characteristic has to be an arbitrary prime number and Factory has to compute in an extension of F_p.

INPUT: The coefficient of type ZZpE and the variable x indicating the main// variable of the computed canonicalform OUTPUT: The converted value of coefficient as type canonicalform

Definition at line 795 of file NTLconvert.cc.

796 {
797  return convertNTLZZpX2CF(rep(coefficient),x);
798 }

◆ convertNTLzzpE2CF()

CanonicalForm convertNTLzzpE2CF ( const zz_pE &  f,
const Variable x 
)

Definition at line 799 of file NTLconvert.cc.

800 {
801  return convertNTLzzpX2CF(rep(coefficient),x);
802 }

◆ convertNTLZZpX2CF()

CanonicalForm convertNTLZZpX2CF ( const ZZ_pX &  poly,
const Variable x 
)

NAME: convertNTLZZpX2CF.

DESCRIPTION: Conversion routine for NTL-Type ZZpX to Factory-Type canonicalform. Additionally a variable x is needed as a parameter indicating the main variable of the computed canonicalform. To guarantee the correct execution of the algorithm, the characteristic has a be an arbitrary prime number.

INPUT: A canonicalform f, a variable x OUTPUT: The converted Factory-polynomial of type canonicalform, built by the main variable x

Definition at line 250 of file NTLconvert.cc.

251 {
252  return convertNTLZZX2CF (to_ZZX (poly), x);
253 }

◆ convertNTLzzpX2CF()

CanonicalForm convertNTLzzpX2CF ( const zz_pX &  poly,
const Variable x 
)

Definition at line 255 of file NTLconvert.cc.

256 {
257  //printf("convertNTLzzpX2CF\n");
258  CanonicalForm bigone;
259 
260 
261  if (deg(poly)>0)
262  {
263  // poly is non-constant
264  bigone=0;
265  bigone.mapinto();
266  // Compute the canonicalform coefficient by coefficient,
267  // bigone summarizes the result.
268  for (int j=0;j<=deg(poly);j++)
269  {
270  if (coeff(poly,j)!=0)
271  {
272  bigone+=(power(x,j)*CanonicalForm(to_long(rep(coeff(poly,j)))));
273  }
274  }
275  }
276  else
277  {
278  // poly is immediate
279  bigone=CanonicalForm(to_long(rep(coeff(poly,0))));
280  bigone.mapinto();
281  }
282  return bigone;
283 }

◆ convertNTLZZX2CF()

CanonicalForm convertNTLZZX2CF ( const ZZX &  polynom,
const Variable x 
)

Definition at line 285 of file NTLconvert.cc.

286 {
287  //printf("convertNTLZZX2CF\n");
288  CanonicalForm bigone;
289 
290  // Go through the vector e and build up the CFFList
291  // As usual bigone summarizes the result
292  bigone=0;
293  ZZ coefficient;
294 
295  for (int j=0;j<=deg(polynom);j++)
296  {
297  coefficient=coeff(polynom,j);
298  if (!IsZero(coefficient))
299  {
300  bigone += (power(x,j)*convertZZ2CF(coefficient));
301  }
302  }
303  return bigone;
304 }
static BOOLEAN IsZero(number a, const coeffs)
Definition: flintcf_Q.cc:328

◆ convertZZ2CF()

CanonicalForm convertZZ2CF ( const ZZ &  a)

NAME: convertZZ2CF.

DESCRIPTION: Routine for conversion of integers represented in NTL as Type ZZ to integers in Factory represented as canonicalform. To guarantee the correct execution of the algorithm the characteristic has to equal zero.

INPUT: The value coefficient of type ZZ that has to be converted OUTPUT: The converted Factory-integer of type canonicalform

Definition at line 495 of file NTLconvert.cc.

496 {
497  long coeff_long=to_long(a);
498 
500  if ( (NumBits(a)<((long)NTL_ZZ_NBITS))
501  && (coeff_long>((long)MINIMMEDIATE))
502  && (coeff_long<((long)MAXIMMEDIATE)))
503  {
504  return CanonicalForm(coeff_long);
505  }
506  else
507  {
508  const long * rep =
509 #if NTL_MAJOR_VERSION <= 6
510  static_cast<long *>( a.rep );
511 #elif NTL_MAJOR_VERSION <=9
512  static_cast<long *>( a.rep.rep ); // what about NTL7?
513 #else
514  (long*)( a.rep.rep );
515 #endif
516  long sizeofrep= rep[1];
517  bool lessZero= false;
518  if (sizeofrep < 0)
519  {
520  lessZero= true;
521  sizeofrep= -sizeofrep;
522  }
523  if (cf_stringtemp_l == 0)
524  {
525  cf_stringtemp_l= sizeofrep*sizeof(mp_limb_t)*2;
526  cf_stringtemp= (unsigned char*) Alloc (cf_stringtemp_l);
527  }
528  else if (cf_stringtemp_l < sizeofrep*sizeof(mp_limb_t)*2)
529  {
531  cf_stringtemp_l= sizeofrep*sizeof(mp_limb_t)*2;
532  cf_stringtemp= (unsigned char*) Alloc (cf_stringtemp_l);
533  }
534  int cc= mpn_get_str (cf_stringtemp, 16, (mp_limb_t *) ((rep) + 2), sizeofrep);
535 
536  char* cf_stringtemp2;
537  if (lessZero)
538  {
539  cf_stringtemp2= new char [cc + 2];
540  cf_stringtemp2[0]='-';
541  for (int j= 1; j <= cc; j++)
542  cf_stringtemp2[j]= IntValToChar ((int) cf_stringtemp [j-1]);
543  cf_stringtemp2[cc+1]='\0';
544  }
545  else
546  {
547  cf_stringtemp2= new char [cc + 1];
548  for (int j= 0; j < cc; j++)
549  cf_stringtemp2[j]= IntValToChar ((int) cf_stringtemp [j]);
550  cf_stringtemp2[cc]='\0';
551  }
552 
553  result= CanonicalForm (cf_stringtemp2, 16);
554  delete [] cf_stringtemp2;
555  }
556  return result;
557 }
STATIC_VAR unsigned char * cf_stringtemp
Definition: NTLconvert.cc:480
STATIC_VAR unsigned long cf_stringtemp_l
Definition: NTLconvert.cc:481
const long MAXIMMEDIATE
Definition: imm.h:55
const long MINIMMEDIATE
Definition: imm.h:54

Variable Documentation

◆ fac_NTL_char

EXTERN_VAR long fac_NTL_char

Definition at line 91 of file NTLconvert.h.