Macros | Functions | Variables
NTLconvert.cc File Reference
#include "config.h"
#include "cf_assert.h"
#include "cf_defs.h"
#include "canonicalform.h"
#include "cf_iter.h"
#include "fac_sqrfree.h"
#include "cf_algorithm.h"
#include <factory/cf_gmp.h>
#include <stdio.h>
#include <string.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/tools.h>
#include <NTL/mat_ZZ.h>
#include <NTL/version.h>
#include "int_int.h"
#include <limits.h>
#include "NTLconvert.h"

Go to the source code of this file.

Macros

#define Alloc(L)   malloc(L)
 
#define Free(A, L)   free(A)
 

Functions

void out_cf (const char *s1, const CanonicalForm &f, const char *s2)
 cf_algorithm.cc - simple mathematical algorithms. More...
 
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 convertNTLZZX2CF (const ZZX &polynom, const Variable &x)
 
CanonicalForm convertNTLGF2X2CF (const GF2X &poly, const Variable &x)
 NAME: convertNTLGF2X2CF. More...
 
CFFList convertNTLvec_pair_ZZpX_long2FacCFFList (const vec_pair_ZZ_pX_long &e, const ZZ_p &multi, const Variable &x)
 NAME: convertNTLvec_pair_ZZpX_long2FacCFFList. More...
 
CFFList convertNTLvec_pair_zzpX_long2FacCFFList (const vec_pair_zz_pX_long &e, const zz_p multi, const Variable &x)
 
CFFList convertNTLvec_pair_GF2X_long2FacCFFList (const vec_pair_GF2X_long &e, GF2, const Variable &x)
 NAME: convertNTLvec_pair_GF2X_long2FacCFFList. More...
 
CanonicalForm convertZZ2CF (const ZZ &a)
 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 &multi, const Variable &x)
 NAME: convertNTLvec_pair_ZZX_long2FacCFFList. More...
 
CanonicalForm convertNTLZZpE2CF (const ZZ_pE &coefficient, const Variable &x)
 NAME: convertNTLZZpX2CF. More...
 
CanonicalForm convertNTLzzpE2CF (const zz_pE &coefficient, const Variable &x)
 
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. More...
 
CFFList convertNTLvec_pair_zzpEX_long2FacCFFList (const vec_pair_zz_pEX_long &e, const zz_pE &multi, const Variable &x, const Variable &alpha)
 
CanonicalForm convertNTLGF2E2CF (const GF2E &coefficient, const Variable &x)
 NAME: convertNTLGF2E2CF. More...
 
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. 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 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

long fac_NTL_char = -1
 
static unsigned char * cf_stringtemp
 
static unsigned long cf_stringtemp_l =0L
 

Macro Definition Documentation

§ Alloc

#define Alloc (   L)    malloc(L)

Definition at line 38 of file NTLconvert.cc.

§ Free

#define Free (   A,
 
)    free(A)

Definition at line 39 of file NTLconvert.cc.

Function Documentation

§ convertFacCF2NTLGF2EX()

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

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

Definition at line 1008 of file NTLconvert.cc.

1009 {
1010  GF2E::init(mipo);
1011  GF2EX result;
1012  CFIterator i;
1013  i=f;
1014 
1015  int NTLcurrentExp=i.exp();
1016  int largestExp=i.exp();
1017  int k;
1018 
1019  result.SetMaxLength(largestExp+1);
1020  for(;i.hasTerms();i++)
1021  {
1022  for(k=NTLcurrentExp;k>i.exp();k--) SetCoeff(result,k,0);
1023  NTLcurrentExp=i.exp();
1024  CanonicalForm c=i.coeff();
1025  GF2X cc=convertFacCF2NTLGF2X(c);
1026  //ZZ_pE ccc;
1027  //conv(ccc,cc);
1028  SetCoeff(result,NTLcurrentExp,to_GF2E(cc));
1029  NTLcurrentExp--;
1030  }
1031  for(k=NTLcurrentExp;k>=0;k--) SetCoeff(result,k,0);
1032  result.normalize();
1033  return result;
1034 }
CF_NO_INLINE CanonicalForm coeff() const
get the current coefficient
GF2X convertFacCF2NTLGF2X(const CanonicalForm &f)
NAME: convertFacCF2NTLGF2X.
Definition: NTLconvert.cc:180
factory&#39;s main class
Definition: canonicalform.h:75
int k
Definition: cfEzgcd.cc:93
FILE * f
Definition: checklibs.c:7
int i
Definition: cfEzgcd.cc:123
class to iterate through CanonicalForm&#39;s
Definition: cf_iter.h:44
CF_NO_INLINE int hasTerms() const
check if iterator has reached < the end of CanonicalForm
CF_NO_INLINE int exp() const
get the current exponent
return result
Definition: facAbsBiFact.cc:76

§ 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 180 of file NTLconvert.cc.

181 {
182  //printf("convertFacCF2NTLGF2X\n");
183  GF2X ntl_poly;
184 
185  CFIterator i;
186  i=f;
187 
188  int NTLcurrentExp=i.exp();
189  int largestExp=i.exp();
190  int k;
191 
192  //building the NTL-polynomial
193  ntl_poly.SetMaxLength(largestExp+1);
194 
195  for (;i.hasTerms();i++)
196  {
197 
198  for (k=NTLcurrentExp;k>i.exp();k--)
199  {
200  SetCoeff(ntl_poly,k,0);
201  }
202  NTLcurrentExp=i.exp();
203 
204  if (!i.coeff().isImm()) i.coeff()=i.coeff().mapinto();
205  if (!i.coeff().isImm())
206  {
207  #ifndef NOSTREAMIO
208  cout<<"convertFacCF2NTLGF2X: coefficient not immediate! : " << f << "\n";
209  #else
210  //NTL_SNS
211  printf("convertFacCF2NTLGF2X: coefficient not immediate!");
212  #endif
213  NTL_SNS exit(1);
214  }
215  else
216  {
217  SetCoeff(ntl_poly,NTLcurrentExp,i.coeff().intval());
218  }
219  NTLcurrentExp--;
220  }
221  for (k=NTLcurrentExp;k>=0;k--)
222  {
223  SetCoeff(ntl_poly,k,0);
224  }
225  //normalization is not necessary of F_2
226 
227  return ntl_poly;
228 }
long intval() const
conversion functions
bool isImm() const
CF_NO_INLINE CanonicalForm coeff() const
get the current coefficient
int k
Definition: cfEzgcd.cc:93
CanonicalForm mapinto() const
FILE * f
Definition: checklibs.c:7
int i
Definition: cfEzgcd.cc:123
class to iterate through CanonicalForm&#39;s
Definition: cf_iter.h:44
CF_NO_INLINE int hasTerms() const
check if iterator has reached < the end of CanonicalForm
CF_NO_INLINE int exp() const
get the current exponent

§ 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 666 of file NTLconvert.cc.

667 {
668  ZZ temp;
669  if (f.isImm()) temp=f.intval();
670  else
671  {
672  //Coefficient is a gmp-number
673  mpz_t gmp_val;
674  char* stringtemp;
675 
676  f.mpzval (gmp_val);
677  int l=mpz_sizeinbase(gmp_val,10)+2;
678  stringtemp=(char*)Alloc(l);
679  stringtemp=mpz_get_str(stringtemp,10,gmp_val);
680  mpz_clear(gmp_val);
681  conv(temp,stringtemp);
682  Free(stringtemp,l);
683  }
684  return temp;
685 }
long intval() const
conversion functions
bool isImm() const
void mpzval(mpz_t val) const
CFList conv(const CFFList &L)
convert a CFFList to a CFList by dropping the multiplicity
Definition: facBivar.cc:124
#define Free(A, L)
Definition: NTLconvert.cc:39
#define Alloc(L)
Definition: NTLconvert.cc:38
int l
Definition: cfEzgcd.cc:94

§ 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 1038 of file NTLconvert.cc.

1039 {
1040  ZZ_pE::init(mipo);
1041  ZZ_pEX result;
1042  CFIterator i;
1043  i=f;
1044 
1045  int NTLcurrentExp=i.exp();
1046  int largestExp=i.exp();
1047  int k;
1048 
1049  result.SetMaxLength(largestExp+1);
1050  for(;i.hasTerms();i++)
1051  {
1052  for(k=NTLcurrentExp;k>i.exp();k--) SetCoeff(result,k,0);
1053  NTLcurrentExp=i.exp();
1054  CanonicalForm c=i.coeff();
1055  ZZ_pX cc=convertFacCF2NTLZZpX(c);
1056  //ZZ_pE ccc;
1057  //conv(ccc,cc);
1058  SetCoeff(result,NTLcurrentExp,to_ZZ_pE(cc));
1059  NTLcurrentExp--;
1060  }
1061  for(k=NTLcurrentExp;k>=0;k--) SetCoeff(result,k,0);
1062  result.normalize();
1063  return result;
1064 }
CF_NO_INLINE CanonicalForm coeff() const
get the current coefficient
factory&#39;s main class
Definition: canonicalform.h:75
int k
Definition: cfEzgcd.cc:93
ZZ_pX convertFacCF2NTLZZpX(const CanonicalForm &f)
NAME: convertFacCF2NTLZZpX.
Definition: NTLconvert.cc:62
FILE * f
Definition: checklibs.c:7
int i
Definition: cfEzgcd.cc:123
class to iterate through CanonicalForm&#39;s
Definition: cf_iter.h:44
CF_NO_INLINE int hasTerms() const
check if iterator has reached < the end of CanonicalForm
CF_NO_INLINE int exp() const
get the current exponent
return result
Definition: facAbsBiFact.cc:76

§ convertFacCF2NTLzz_pEX()

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

Definition at line 1065 of file NTLconvert.cc.

1066 {
1067  zz_pE::init(mipo);
1068  zz_pEX result;
1069  CFIterator i;
1070  i=f;
1071 
1072  int NTLcurrentExp=i.exp();
1073  int largestExp=i.exp();
1074  int k;
1075 
1076  result.SetMaxLength(largestExp+1);
1077  for(;i.hasTerms();i++)
1078  {
1079  for(k=NTLcurrentExp;k>i.exp();k--) SetCoeff(result,k,0);
1080  NTLcurrentExp=i.exp();
1081  CanonicalForm c=i.coeff();
1082  zz_pX cc=convertFacCF2NTLzzpX(c);
1083  //ZZ_pE ccc;
1084  //conv(ccc,cc);
1085  SetCoeff(result,NTLcurrentExp,to_zz_pE(cc));
1086  NTLcurrentExp--;
1087  }
1088  for(k=NTLcurrentExp;k>=0;k--) SetCoeff(result,k,0);
1089  result.normalize();
1090  return result;
1091 }
CF_NO_INLINE CanonicalForm coeff() const
get the current coefficient
factory&#39;s main class
Definition: canonicalform.h:75
int k
Definition: cfEzgcd.cc:93
FILE * f
Definition: checklibs.c:7
int i
Definition: cfEzgcd.cc:123
class to iterate through CanonicalForm&#39;s
Definition: cf_iter.h:44
zz_pX convertFacCF2NTLzzpX(const CanonicalForm &f)
Definition: NTLconvert.cc:103
CF_NO_INLINE int hasTerms() const
check if iterator has reached < the end of CanonicalForm
CF_NO_INLINE int exp() const
get the current exponent
return result
Definition: facAbsBiFact.cc:76

§ 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 62 of file NTLconvert.cc.

63 {
64  ZZ_pX ntl_poly;
65 
66  CFIterator i;
67  i=f;
68 
69  int NTLcurrentExp=i.exp();
70  int largestExp=i.exp();
71  int k;
72 
73  // we now build up the NTL-polynomial
74  ntl_poly.SetMaxLength(largestExp+1);
75 
76  for (;i.hasTerms();i++)
77  {
78  for (k=NTLcurrentExp;k>i.exp();k--)
79  {
80  SetCoeff(ntl_poly,k,0);
81  }
82  NTLcurrentExp=i.exp();
83 
84  SetCoeff(ntl_poly,NTLcurrentExp,to_ZZ_p (convertFacCF2NTLZZ (i.coeff())));
85  NTLcurrentExp--;
86  }
87 
88  //Set the remaining coefficients of ntl_poly to zero.
89  // This is necessary, because NTL internally
90  // also stores powers with zero coefficient,
91  // whereas factory stores tuples of degree and coefficient
92  //leaving out tuples if the coefficient equals zero
93  for (k=NTLcurrentExp;k>=0;k--)
94  {
95  SetCoeff(ntl_poly,k,0);
96  }
97 
98  //normalize the polynomial and return it
99  ntl_poly.normalize();
100 
101  return ntl_poly;
102 }
ZZ convertFacCF2NTLZZ(const CanonicalForm &f)
NAME: convertFacCF2NTLZZX.
Definition: NTLconvert.cc:666
CF_NO_INLINE CanonicalForm coeff() const
get the current coefficient
int k
Definition: cfEzgcd.cc:93
FILE * f
Definition: checklibs.c:7
int i
Definition: cfEzgcd.cc:123
class to iterate through CanonicalForm&#39;s
Definition: cf_iter.h:44
CF_NO_INLINE int hasTerms() const
check if iterator has reached < the end of CanonicalForm
CF_NO_INLINE int exp() const
get the current exponent

§ convertFacCF2NTLzzpX()

zz_pX convertFacCF2NTLzzpX ( const CanonicalForm f)

Definition at line 103 of file NTLconvert.cc.

104 {
105  zz_pX ntl_poly;
106 
107  CFIterator i;
108  i=f;
109 
110  int NTLcurrentExp=i.exp();
111  int largestExp=i.exp();
112  int k;
113 
114  // we now build up the NTL-polynomial
115  ntl_poly.SetMaxLength(largestExp+1);
116 
117  for (;i.hasTerms();i++)
118  {
119  for (k=NTLcurrentExp;k>i.exp();k--)
120  {
121  SetCoeff(ntl_poly,k,0);
122  }
123  NTLcurrentExp=i.exp();
124 
125  CanonicalForm c=i.coeff();
126  if (!c.isImm()) c=c.mapinto(); //c%= getCharacteristic();
127  if (!c.isImm())
128  { //This case will never happen if the characteristic is in fact a prime
129  // number, since all coefficients are represented as immediates
130  #ifndef NOSTREAMIO
131  cout<<"convertFacCF2NTLzz_pX: coefficient not immediate! : "<<f<<"\n";
132  #else
133  //NTL_SNS
134  printf("convertFacCF2NTLzz_pX: coefficient not immediate!, char=%d\n",
136  #endif
137  NTL_SNS exit(1);
138  }
139  else
140  {
141  SetCoeff(ntl_poly,NTLcurrentExp,c.intval());
142  }
143  NTLcurrentExp--;
144  }
145 
146  //Set the remaining coefficients of ntl_poly to zero.
147  // This is necessary, because NTL internally
148  // also stores powers with zero coefficient,
149  // whereas factory stores tuples of degree and coefficient
150  //leaving out tuples if the coefficient equals zero
151  for (k=NTLcurrentExp;k>=0;k--)
152  {
153  SetCoeff(ntl_poly,k,0);
154  }
155 
156  //normalize the polynomial and return it
157  ntl_poly.normalize();
158 
159  return ntl_poly;
160 }
long intval() const
conversion functions
bool isImm() const
CF_NO_INLINE CanonicalForm coeff() const
get the current coefficient
factory&#39;s main class
Definition: canonicalform.h:75
int k
Definition: cfEzgcd.cc:93
int getCharacteristic()
Definition: cf_char.cc:51
CanonicalForm mapinto() const
FILE * f
Definition: checklibs.c:7
int i
Definition: cfEzgcd.cc:123
class to iterate through CanonicalForm&#39;s
Definition: cf_iter.h:44
CF_NO_INLINE int hasTerms() const
check if iterator has reached < the end of CanonicalForm
CF_NO_INLINE int exp() const
get the current exponent

§ convertFacCF2NTLZZX()

ZZX convertFacCF2NTLZZX ( const CanonicalForm f)

Definition at line 687 of file NTLconvert.cc.

688 {
689  ZZX ntl_poly;
690 
691  CFIterator i;
692  i=f;
693 
694  int NTLcurrentExp=i.exp();
695  int largestExp=i.exp();
696  int k;
697 
698  //set the length of the NTL-polynomial
699  ntl_poly.SetMaxLength(largestExp+1);
700 
701  //Go through the coefficients of the canonicalform and build up the NTL-polynomial
702  for (;i.hasTerms();i++)
703  {
704  for (k=NTLcurrentExp;k>i.exp();k--)
705  {
706  SetCoeff(ntl_poly,k,0);
707  }
708  NTLcurrentExp=i.exp();
709 
710  //Coefficient is a gmp-number
711  ZZ temp=convertFacCF2NTLZZ(i.coeff());
712 
713  //set the computed coefficient
714  SetCoeff(ntl_poly,NTLcurrentExp,temp);
715 
716  NTLcurrentExp--;
717  }
718  for (k=NTLcurrentExp;k>=0;k--)
719  {
720  SetCoeff(ntl_poly,k,0);
721  }
722 
723  //normalize the polynomial
724  ntl_poly.normalize();
725 
726  return ntl_poly;
727 }
ZZ convertFacCF2NTLZZ(const CanonicalForm &f)
NAME: convertFacCF2NTLZZX.
Definition: NTLconvert.cc:666
CF_NO_INLINE CanonicalForm coeff() const
get the current coefficient
int k
Definition: cfEzgcd.cc:93
FILE * f
Definition: checklibs.c:7
int i
Definition: cfEzgcd.cc:123
class to iterate through CanonicalForm&#39;s
Definition: cf_iter.h:44
CF_NO_INLINE int hasTerms() const
check if iterator has reached < the end of CanonicalForm
CF_NO_INLINE int exp() const
get the current exponent

§ convertFacCFMatrix2NTLmat_ZZ()

mat_ZZ* convertFacCFMatrix2NTLmat_ZZ ( const CFMatrix m)

Definition at line 1139 of file NTLconvert.cc.

1140 {
1141  mat_ZZ *res=new mat_ZZ;
1142  res->SetDims(m.rows(),m.columns());
1143 
1144  int i,j;
1145  for(i=m.rows();i>0;i--)
1146  {
1147  for(j=m.columns();j>0;j--)
1148  {
1149  (*res)(i,j)=convertFacCF2NTLZZ(m(i,j));
1150  }
1151  }
1152  return res;
1153 }
ZZ convertFacCF2NTLZZ(const CanonicalForm &f)
NAME: convertFacCF2NTLZZX.
Definition: NTLconvert.cc:666
poly res
Definition: myNF.cc:322
int j
Definition: myNF.cc:70
int rows() const
Definition: ftmpl_matrix.h:45
int columns() const
Definition: ftmpl_matrix.h:46
int m
Definition: cfEzgcd.cc:119
int i
Definition: cfEzgcd.cc:123

§ convertFacCFMatrix2NTLmat_zz_p()

mat_zz_p* convertFacCFMatrix2NTLmat_zz_p ( const CFMatrix m)

Definition at line 1168 of file NTLconvert.cc.

1169 {
1170  mat_zz_p *res=new mat_zz_p;
1171  res->SetDims(m.rows(),m.columns());
1172 
1173  int i,j;
1174  for(i=m.rows();i>0;i--)
1175  {
1176  for(j=m.columns();j>0;j--)
1177  {
1178  if(!(m(i,j)).isImm()) printf("convertFacCFMatrix2NTLmat_zz_p: not imm.\n");
1179  (*res)(i,j)=(m(i,j)).intval();
1180  }
1181  }
1182  return res;
1183 }
poly res
Definition: myNF.cc:322
int j
Definition: myNF.cc:70
int rows() const
Definition: ftmpl_matrix.h:45
int columns() const
Definition: ftmpl_matrix.h:46
int m
Definition: cfEzgcd.cc:119
int i
Definition: cfEzgcd.cc:123

§ convertFacCFMatrix2NTLmat_zz_pE()

mat_zz_pE* convertFacCFMatrix2NTLmat_zz_pE ( const CFMatrix m)

Definition at line 1197 of file NTLconvert.cc.

1198 {
1199  mat_zz_pE *res=new mat_zz_pE;
1200  res->SetDims(m.rows(),m.columns());
1201 
1202  int i,j;
1203  for(i=m.rows();i>0;i--)
1204  {
1205  for(j=m.columns();j>0;j--)
1206  {
1207  zz_pX cc=convertFacCF2NTLzzpX(m(i,j));
1208  (*res)(i,j)=to_zz_pE(cc);
1209  }
1210  }
1211  return res;
1212 }
poly res
Definition: myNF.cc:322
int j
Definition: myNF.cc:70
int rows() const
Definition: ftmpl_matrix.h:45
int columns() const
Definition: ftmpl_matrix.h:46
int m
Definition: cfEzgcd.cc:119
int i
Definition: cfEzgcd.cc:123
zz_pX convertFacCF2NTLzzpX(const CanonicalForm &f)
Definition: NTLconvert.cc:103

§ 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 929 of file NTLconvert.cc.

930 {
931  return convertNTLGF2X2CF(rep(coefficient),x);
932 }
CanonicalForm convertNTLGF2X2CF(const GF2X &poly, const Variable &x)
NAME: convertNTLGF2X2CF.
Definition: NTLconvert.cc:318

§ 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 318 of file NTLconvert.cc.

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

§ convertNTLmat_ZZ2FacCFMatrix()

CFMatrix* convertNTLmat_ZZ2FacCFMatrix ( const mat_ZZ &  m)

Definition at line 1154 of file NTLconvert.cc.

1155 {
1156  CFMatrix *res=new CFMatrix(m.NumRows(),m.NumCols());
1157  int i,j;
1158  for(i=res->rows();i>0;i--)
1159  {
1160  for(j=res->columns();j>0;j--)
1161  {
1162  (*res)(i,j)=convertZZ2CF(m(i,j));
1163  }
1164  }
1165  return res;
1166 }
Matrix< CanonicalForm > CFMatrix
poly res
Definition: myNF.cc:322
int j
Definition: myNF.cc:70
int rows() const
Definition: ftmpl_matrix.h:45
int columns() const
Definition: ftmpl_matrix.h:46
int m
Definition: cfEzgcd.cc:119
int i
Definition: cfEzgcd.cc:123
CanonicalForm convertZZ2CF(const ZZ &a)
NAME: convertZZ2CF.
Definition: NTLconvert.cc:492

§ convertNTLmat_zz_p2FacCFMatrix()

CFMatrix* convertNTLmat_zz_p2FacCFMatrix ( const mat_zz_p &  m)

Definition at line 1184 of file NTLconvert.cc.

1185 {
1186  CFMatrix *res=new CFMatrix(m.NumRows(),m.NumCols());
1187  int i,j;
1188  for(i=res->rows();i>0;i--)
1189  {
1190  for(j=res->columns();j>0;j--)
1191  {
1192  (*res)(i,j)=CanonicalForm(to_long(rep(m(i,j))));
1193  }
1194  }
1195  return res;
1196 }
Matrix< CanonicalForm > CFMatrix
factory&#39;s main class
Definition: canonicalform.h:75
poly res
Definition: myNF.cc:322
int j
Definition: myNF.cc:70
int rows() const
Definition: ftmpl_matrix.h:45
int columns() const
Definition: ftmpl_matrix.h:46
int m
Definition: cfEzgcd.cc:119
int i
Definition: cfEzgcd.cc:123

§ convertNTLmat_zz_pE2FacCFMatrix()

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

Definition at line 1213 of file NTLconvert.cc.

1214 {
1215  CFMatrix *res=new CFMatrix(m.NumRows(),m.NumCols());
1216  int i,j;
1217  for(i=res->rows();i>0;i--)
1218  {
1219  for(j=res->columns();j>0;j--)
1220  {
1221  (*res)(i,j)=convertNTLzzpE2CF(m(i,j), alpha);
1222  }
1223  }
1224  return res;
1225 }
Matrix< CanonicalForm > CFMatrix
CanonicalForm convertNTLzzpE2CF(const zz_pE &coefficient, const Variable &x)
Definition: NTLconvert.cc:796
Variable alpha
Definition: facAbsBiFact.cc:52
poly res
Definition: myNF.cc:322
int j
Definition: myNF.cc:70
int rows() const
Definition: ftmpl_matrix.h:45
int columns() const
Definition: ftmpl_matrix.h:46
int m
Definition: cfEzgcd.cc:119
int i
Definition: cfEzgcd.cc:123

§ convertNTLvec_pair_GF2EX_long2FacCFFList()

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.

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 multiplicity, as a type GF2E of NTL, is needed as parameters indicating the main variable of the computed canonicalform and the multiplicity 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 multiplicity of type GF2E OUTPUT: The converted list of polynomials of type CFFList, all polynomials have x as their main variable

Definition at line 956 of file NTLconvert.cc.

957 {
958  CFFList result;
959  GF2EX polynom;
960  long exponent;
961  CanonicalForm bigone;
962 
963  // Maybe, e may additionally be sorted with respect to increasing degree of x, but this is not
964  //important for the factorization, but nevertheless would take computing time, so it is omitted
965 
966  // multiplicity is always one, so we do not have to worry about that
967 
968  // Go through the vector e and build up the CFFList
969  // As usual bigone summarizes the result during every loop
970  for (int i=e.length()-1;i>=0;i--)
971  {
972  bigone=0;
973 
974  polynom=e[i].a;
975  exponent=e[i].b;
976 
977  for (int j=0;j<=deg(polynom);j++)
978  {
979  if (IsOne(coeff(polynom,j)))
980  {
981  bigone+=power(x,j);
982  }
983  else
984  {
985  CanonicalForm coefficient=convertNTLGF2E2CF(coeff(polynom,j),alpha);
986  if (coeff(polynom,j)!=0)
987  {
988  bigone += (power(x,j)*coefficient);
989  }
990  }
991  }
992 
993  // append the computed polynomial together with its multiplicity
994  result.append(CFFactor(bigone,exponent));
995 
996  }
997 
998  if (!IsOne(multi))
999  result.insert(CFFactor(convertNTLGF2E2CF(multi,alpha),1));
1000 
1001  // return the computed CFFList
1002  return result;
1003 }
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
factory&#39;s main class
Definition: canonicalform.h:75
void insert(const T &)
Definition: ftmpl_list.cc:193
CanonicalForm convertNTLGF2E2CF(const GF2E &coefficient, const Variable &x)
NAME: convertNTLGF2E2CF.
Definition: NTLconvert.cc:929
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
static BOOLEAN IsOne(number a, const coeffs r)
Definition: flintcf_Q.cc:360
Factor< CanonicalForm > CFFactor
int exponent(const CanonicalForm &f, int q)
int exponent ( const CanonicalForm & f, int q )
void append(const T &)
Definition: ftmpl_list.cc:256
return result
Definition: facAbsBiFact.cc:76

§ convertNTLvec_pair_GF2X_long2FacCFFList()

CFFList convertNTLvec_pair_GF2X_long2FacCFFList ( const vec_pair_GF2X_long &  e,
GF2  ,
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 multiplicity, as type GF2 of NTL, are needed as parameters indicating the main variable of the computed canonicalform and the multiplicity 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 multiplicity of type GF2 OUTPUT: The converted list of polynomials of type CFFList, all polynomials have x as their main variable

Definition at line 442 of file NTLconvert.cc.

443 {
444  //printf("convertNTLvec_pair_GF2X_long2FacCFFList\n");
445  CFFList result;
446  GF2X polynom;
447  long exponent;
448  CanonicalForm bigone;
449 
450  // Maybe, e may additionally be sorted with respect to increasing degree of x
451  // but this is not
452  //important for the factorization, but nevertheless would take computing time
453  // so it is omitted.
454 
455  //We do not have to worry about the multiplicity in GF2 since it equals one.
456 
457  // Go through the vector e and compute the CFFList
458  // bigone summarizes the result again
459  for (int i=e.length()-1;i>=0;i--)
460  {
461  bigone=0;
462 
463  polynom=e[i].a;
464  exponent=e[i].b;
465  for (int j=0;j<=deg(polynom);j++)
466  {
467  if (coeff(polynom,j)!=0)
468  bigone += (power(x,j)*CanonicalForm(to_long(rep(coeff(polynom,j)))));
469  }
470 
471  //append the converted polynomial to the CFFList
472  result.append(CFFactor(bigone,exponent));
473  }
474  return result;
475 }
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
factory&#39;s main class
Definition: canonicalform.h:75
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
Factor< CanonicalForm > CFFactor
int exponent(const CanonicalForm &f, int q)
int exponent ( const CanonicalForm & f, int q )
void append(const T &)
Definition: ftmpl_list.cc:256
return result
Definition: facAbsBiFact.cc:76

§ convertNTLvec_pair_ZZpEX_long2FacCFFList()

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.

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 multiplicity, as a type ZZpE of NTL, is needed as parameters indicating the main variable of the computed canonicalform and the multiplicity 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 multiplicity of type ZZpE OUTPUT: The converted list of polynomials of type CFFList, all polynomials have x as their main variable

Definition at line 822 of file NTLconvert.cc.

823 {
824  CFFList result;
825  ZZ_pEX polynom;
826  long exponent;
827  CanonicalForm bigone;
828 
829  // Maybe, e may additionally be sorted with respect to increasing degree of x, but this is not
830  //important for the factorization, but nevertheless would take computing time, so it is omitted
831 
832  // Go through the vector e and build up the CFFList
833  // As usual bigone summarizes the result during every loop
834  for (int i=e.length()-1;i>=0;i--)
835  {
836  bigone=0;
837 
838  polynom=e[i].a;
839  exponent=e[i].b;
840 
841  for (int j=0;j<=deg(polynom);j++)
842  {
843  if (IsOne(coeff(polynom,j)))
844  {
845  bigone+=power(x,j);
846  }
847  else
848  {
849  CanonicalForm coefficient=convertNTLZZpE2CF(coeff(polynom,j),alpha);
850  if (coeff(polynom,j)!=0)
851  {
852  bigone += (power(x,j)*coefficient);
853  }
854  }
855  }
856  //append the computed polynomials together with its exponent to the CFFList
857  result.append(CFFactor(bigone,exponent));
858  }
859  // Start by appending the multiplicity
860  if (!IsOne(multi))
861  result.insert(CFFactor(convertNTLZZpE2CF(multi,alpha),1));
862 
863  //return the computed CFFList
864  return result;
865 }
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
factory&#39;s main class
Definition: canonicalform.h:75
void insert(const T &)
Definition: ftmpl_list.cc:193
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
static BOOLEAN IsOne(number a, const coeffs r)
Definition: flintcf_Q.cc:360
Factor< CanonicalForm > CFFactor
CanonicalForm convertNTLZZpE2CF(const ZZ_pE &coefficient, const Variable &x)
NAME: convertNTLZZpX2CF.
Definition: NTLconvert.cc:792
int exponent(const CanonicalForm &f, int q)
int exponent ( const CanonicalForm & f, int q )
void append(const T &)
Definition: ftmpl_list.cc:256
return result
Definition: facAbsBiFact.cc:76

§ convertNTLvec_pair_zzpEX_long2FacCFFList()

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

Definition at line 867 of file NTLconvert.cc.

868 {
869  CFFList result;
870  zz_pEX polynom;
871  long exponent;
872  CanonicalForm bigone;
873 
874  // Maybe, e may additionally be sorted with respect to increasing degree of x, but this is not
875  //important for the factorization, but nevertheless would take computing time, so it is omitted
876 
877  // Go through the vector e and build up the CFFList
878  // As usual bigone summarizes the result during every loop
879  for (int i=e.length()-1;i>=0;i--)
880  {
881  bigone=0;
882 
883  polynom=e[i].a;
884  exponent=e[i].b;
885 
886  for (int j=0;j<=deg(polynom);j++)
887  {
888  if (IsOne(coeff(polynom,j)))
889  {
890  bigone+=power(x,j);
891  }
892  else
893  {
894  CanonicalForm coefficient=convertNTLzzpE2CF(coeff(polynom,j),alpha);
895  if (coeff(polynom,j)!=0)
896  {
897  bigone += (power(x,j)*coefficient);
898  }
899  }
900  }
901  //append the computed polynomials together with its exponent to the CFFList
902  result.append(CFFactor(bigone,exponent));
903  }
904  // Start by appending the multiplicity
905  if (!IsOne(multi))
906  result.insert(CFFactor(convertNTLzzpE2CF(multi,alpha),1));
907 
908  //return the computed CFFList
909  return result;
910 }
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
CanonicalForm convertNTLzzpE2CF(const zz_pE &coefficient, const Variable &x)
Definition: NTLconvert.cc:796
factory&#39;s main class
Definition: canonicalform.h:75
void insert(const T &)
Definition: ftmpl_list.cc:193
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
static BOOLEAN IsOne(number a, const coeffs r)
Definition: flintcf_Q.cc:360
Factor< CanonicalForm > CFFactor
int exponent(const CanonicalForm &f, int q)
int exponent ( const CanonicalForm & f, int q )
void append(const T &)
Definition: ftmpl_list.cc:256
return result
Definition: facAbsBiFact.cc:76

§ convertNTLvec_pair_ZZpX_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.

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 multiplicity, as a type ZZp of NTL, is needed as parameters indicating the main variable of the computed canonicalform and the multiplicity 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 multiplicity of type ZZp OUTPUT: The converted list of polynomials of type CFFList, all polynomials have x as their main variable

Definition at line 370 of file NTLconvert.cc.

371 {
372  //printf("convertNTLvec_pair_ZZpX_long2FacCFFList\n");
373  CFFList result;
374  ZZ_pX polynom;
375  CanonicalForm bigone;
376 
377  // Maybe, e may additionally be sorted with respect to increasing degree of x
378  // but this is not
379  //important for the factorization, but nevertheless would take computing time,
380  // so it is omitted
381 
382 
383  // Go through the vector e and compute the CFFList
384  // again bigone summarizes the result
385  for (int i=e.length()-1;i>=0;i--)
386  {
387  result.append(CFFactor(convertNTLZZpX2CF(e[i].a,x),e[i].b));
388  }
389  // the multiplicity at pos 1
390  if (!IsOne(multi))
391  result.insert(CFFactor(CanonicalForm(to_long(rep(multi))),1));
392  return result;
393 }
const poly a
Definition: syzextra.cc:212
CanonicalForm convertNTLZZpX2CF(const ZZ_pX &poly, const Variable &x)
NAME: convertNTLZZpX2CF.
Definition: NTLconvert.cc:246
factory&#39;s main class
Definition: canonicalform.h:75
void insert(const T &)
Definition: ftmpl_list.cc:193
int i
Definition: cfEzgcd.cc:123
static BOOLEAN IsOne(number a, const coeffs r)
Definition: flintcf_Q.cc:360
Factor< CanonicalForm > CFFactor
void append(const T &)
Definition: ftmpl_list.cc:256
const poly b
Definition: syzextra.cc:213
return result
Definition: facAbsBiFact.cc:76

§ convertNTLvec_pair_zzpX_long2FacCFFList()

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

Definition at line 395 of file NTLconvert.cc.

396 {
397  //printf("convertNTLvec_pair_zzpX_long2FacCFFList\n");
398  CFFList result;
399  zz_pX polynom;
400  CanonicalForm bigone;
401 
402  // Maybe, e may additionally be sorted with respect to increasing degree of x
403  // but this is not
404  //important for the factorization, but nevertheless would take computing time,
405  // so it is omitted
406 
407 
408  // Go through the vector e and compute the CFFList
409  // again bigone summarizes the result
410  for (int i=e.length()-1;i>=0;i--)
411  {
412  result.append(CFFactor(convertNTLzzpX2CF(e[i].a,x),e[i].b));
413  }
414  // the multiplicity at pos 1
415  if (!IsOne(multi))
416  result.insert(CFFactor(CanonicalForm(to_long(rep(multi))),1));
417  return result;
418 }
const poly a
Definition: syzextra.cc:212
factory&#39;s main class
Definition: canonicalform.h:75
CanonicalForm convertNTLzzpX2CF(const zz_pX &poly, const Variable &x)
Definition: NTLconvert.cc:251
void insert(const T &)
Definition: ftmpl_list.cc:193
int i
Definition: cfEzgcd.cc:123
static BOOLEAN IsOne(number a, const coeffs r)
Definition: flintcf_Q.cc:360
Factor< CanonicalForm > CFFactor
void append(const T &)
Definition: ftmpl_list.cc:256
const poly b
Definition: syzextra.cc:213
return result
Definition: facAbsBiFact.cc:76

§ convertNTLvec_pair_ZZX_long2FacCFFList()

CFFList convertNTLvec_pair_ZZX_long2FacCFFList ( const vec_pair_ZZX_long &  e,
const ZZ &  multi,
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 multiplicity, as a type ZZ of NTL, is needed as parameters indicating the main variable of the computed canonicalform and the multiplicity 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 multiplicity of type ZZ OUTPUT: The converted list of polynomials of type CFFList, all have x as their main variable

Definition at line 749 of file NTLconvert.cc.

750 {
751  CFFList result;
752  ZZX polynom;
753  long exponent;
754  CanonicalForm bigone;
755 
756  // Go through the vector e and build up the CFFList
757  // As usual bigone summarizes the result
758  for (int i=e.length()-1;i>=0;i--)
759  {
760  ZZ coefficient;
761  polynom=e[i].a;
762  exponent=e[i].b;
763  bigone=convertNTLZZX2CF(polynom,x);
764  //append the converted polynomial to the list
765  result.append(CFFactor(bigone,exponent));
766  }
767  // the multiplicity at pos 1
768  //if (!IsOne(multi))
769  result.insert(CFFactor(convertZZ2CF(multi),1));
770 
771  //return the converted list
772  return result;
773 }
factory&#39;s main class
Definition: canonicalform.h:75
void insert(const T &)
Definition: ftmpl_list.cc:193
int i
Definition: cfEzgcd.cc:123
Factor< CanonicalForm > CFFactor
int exponent(const CanonicalForm &f, int q)
int exponent ( const CanonicalForm & f, int q )
void append(const T &)
Definition: ftmpl_list.cc:256
CanonicalForm convertZZ2CF(const ZZ &a)
NAME: convertZZ2CF.
Definition: NTLconvert.cc:492
CanonicalForm convertNTLZZX2CF(const ZZX &polynom, const Variable &x)
Definition: NTLconvert.cc:281
return result
Definition: facAbsBiFact.cc:76

§ convertNTLzz_pEX2CF()

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

Definition at line 1093 of file NTLconvert.cc.

1094 {
1095  CanonicalForm bigone;
1096  if (deg (f) > 0)
1097  {
1098  bigone= 0;
1099  bigone.mapinto();
1100  for (int j=0;j<deg(f)+1;j++)
1101  {
1102  if (coeff(f,j)!=0)
1103  {
1104  bigone+=(power(x,j)*convertNTLzzpE2CF(coeff(f,j),alpha));
1105  }
1106  }
1107  }
1108  else
1109  {
1110  bigone= convertNTLzzpE2CF(coeff(f,0),alpha);
1111  bigone.mapinto();
1112  }
1113  return bigone;
1114 }
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
CanonicalForm convertNTLzzpE2CF(const zz_pE &coefficient, const Variable &x)
Definition: NTLconvert.cc:796
factory&#39;s main class
Definition: canonicalform.h:75
CanonicalForm mapinto() const
int j
Definition: myNF.cc:70
FILE * f
Definition: checklibs.c:7

§ convertNTLZZ_pEX2CF()

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

Definition at line 1116 of file NTLconvert.cc.

1117 {
1118  CanonicalForm bigone;
1119  if (deg (f) > 0)
1120  {
1121  bigone= 0;
1122  bigone.mapinto();
1123  for (int j=0;j<deg(f)+1;j++)
1124  {
1125  if (coeff(f,j)!=0)
1126  {
1127  bigone+=(power(x,j)*convertNTLZZpE2CF(coeff(f,j),alpha));
1128  }
1129  }
1130  }
1131  else
1132  {
1133  bigone= convertNTLZZpE2CF(coeff(f,0),alpha);
1134  bigone.mapinto();
1135  }
1136  return bigone;
1137 }
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
factory&#39;s main class
Definition: canonicalform.h:75
CanonicalForm mapinto() const
int j
Definition: myNF.cc:70
FILE * f
Definition: checklibs.c:7
CanonicalForm convertNTLZZpE2CF(const ZZ_pE &coefficient, const Variable &x)
NAME: convertNTLZZpX2CF.
Definition: NTLconvert.cc:792

§ 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 792 of file NTLconvert.cc.

793 {
794  return convertNTLZZpX2CF(rep(coefficient),x);
795 }
CanonicalForm convertNTLZZpX2CF(const ZZ_pX &poly, const Variable &x)
NAME: convertNTLZZpX2CF.
Definition: NTLconvert.cc:246

§ convertNTLzzpE2CF()

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

Definition at line 796 of file NTLconvert.cc.

797 {
798  return convertNTLzzpX2CF(rep(coefficient),x);
799 }
CanonicalForm convertNTLzzpX2CF(const zz_pX &poly, const Variable &x)
Definition: NTLconvert.cc:251

§ 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 246 of file NTLconvert.cc.

247 {
248  return convertNTLZZX2CF (to_ZZX (poly), x);
249 }
polyrec * poly
Definition: hilb.h:10
CanonicalForm convertNTLZZX2CF(const ZZX &polynom, const Variable &x)
Definition: NTLconvert.cc:281

§ convertNTLzzpX2CF()

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

Definition at line 251 of file NTLconvert.cc.

252 {
253  //printf("convertNTLzzpX2CF\n");
254  CanonicalForm bigone;
255 
256 
257  if (deg(poly)>0)
258  {
259  // poly is non-constant
260  bigone=0;
261  bigone.mapinto();
262  // Compute the canonicalform coefficient by coefficient,
263  // bigone summarizes the result.
264  for (int j=0;j<=deg(poly);j++)
265  {
266  if (coeff(poly,j)!=0)
267  {
268  bigone+=(power(x,j)*CanonicalForm(to_long(rep(coeff(poly,j)))));
269  }
270  }
271  }
272  else
273  {
274  // poly is immediate
275  bigone=CanonicalForm(to_long(rep(coeff(poly,0))));
276  bigone.mapinto();
277  }
278  return bigone;
279 }
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
factory&#39;s main class
Definition: canonicalform.h:75
CanonicalForm mapinto() const
int j
Definition: myNF.cc:70
polyrec * poly
Definition: hilb.h:10

§ convertNTLZZX2CF()

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

Definition at line 281 of file NTLconvert.cc.

282 {
283  //printf("convertNTLZZX2CF\n");
284  CanonicalForm bigone;
285 
286  // Go through the vector e and build up the CFFList
287  // As usual bigone summarizes the result
288  bigone=0;
289  ZZ coefficient;
290 
291  for (int j=0;j<=deg(polynom);j++)
292  {
293  coefficient=coeff(polynom,j);
294  if (!IsZero(coefficient))
295  {
296  bigone += (power(x,j)*convertZZ2CF(coefficient));
297  }
298  }
299  return bigone;
300 }
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
factory&#39;s main class
Definition: canonicalform.h:75
int j
Definition: myNF.cc:70
static BOOLEAN IsZero(number a, const coeffs r)
Definition: flintcf_Q.cc:356
CanonicalForm convertZZ2CF(const ZZ &a)
NAME: convertZZ2CF.
Definition: NTLconvert.cc:492

§ 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 492 of file NTLconvert.cc.

493 {
494  long coeff_long=to_long(a);
495 
497  if ( (NumBits(a)<((long)NTL_ZZ_NBITS))
498  && (coeff_long>((long)MINIMMEDIATE))
499  && (coeff_long<((long)MAXIMMEDIATE)))
500  {
501  return CanonicalForm(coeff_long);
502  }
503  else
504  {
505  const long * rep =
506 #if NTL_MAJOR_VERSION <= 6
507  static_cast<long *>( a.rep );
508 #else
509  static_cast<long *>( a.rep.rep ); // what about NTL7?
510 #endif
511  long sizeofrep= rep[1];
512  bool lessZero= false;
513  if (sizeofrep < 0)
514  {
515  lessZero= true;
516  sizeofrep= -sizeofrep;
517  }
518  if (cf_stringtemp_l == 0)
519  {
520  cf_stringtemp_l= sizeofrep*sizeof(mp_limb_t)*2;
521  cf_stringtemp= (unsigned char*) Alloc (cf_stringtemp_l);
522  }
523  else if (cf_stringtemp_l < sizeofrep*sizeof(mp_limb_t)*2)
524  {
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);
528  }
529  int cc= mpn_get_str (cf_stringtemp, 16, (mp_limb_t *) ((rep) + 2), sizeofrep);
530 
531  char* cf_stringtemp2;
532  if (lessZero)
533  {
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';
539  }
540  else
541  {
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';
546  }
547 
548  result= CanonicalForm (cf_stringtemp2, 16);
549  delete [] cf_stringtemp2;
550  return result;
551  }
552  return result;
553 }
const long MINIMMEDIATE
Definition: imm.h:50
const poly a
Definition: syzextra.cc:212
static unsigned char * cf_stringtemp
Definition: NTLconvert.cc:477
factory&#39;s main class
Definition: canonicalform.h:75
static unsigned long cf_stringtemp_l
Definition: NTLconvert.cc:478
int j
Definition: myNF.cc:70
#define Free(A, L)
Definition: NTLconvert.cc:39
#define Alloc(L)
Definition: NTLconvert.cc:38
const long MAXIMMEDIATE
Definition: imm.h:51
return result
Definition: facAbsBiFact.cc:76

§ out_cf()

void out_cf ( const char *  s1,
const CanonicalForm f,
const char *  s2 
)

cf_algorithm.cc - simple mathematical algorithms.

Hierarchy: mathematical algorithms on canonical forms

Developers note:

A "mathematical" algorithm is an algorithm which calculates some mathematical function in contrast to a "structural" algorithm which gives structural information on polynomials.

Compare these functions to the functions in `cf_ops.cc', which are structural algorithms.

Definition at line 90 of file cf_factor.cc.

91 {
92  printf("%s",s1);
93  if (f.isZero()) printf("+0");
94  //else if (! f.inCoeffDomain() )
95  else if (! f.inBaseDomain() )
96  {
97  int l = f.level();
98  for ( CFIterator i = f; i.hasTerms(); i++ )
99  {
100  int e=i.exp();
101  if (i.coeff().isOne())
102  {
103  printf("+");
104  if (e==0) printf("1");
105  else
106  {
107  printf("v(%d)",l);
108  if (e!=1) printf("^%d",e);
109  }
110  }
111  else
112  {
113  out_cf("+(",i.coeff(),")");
114  if (e!=0)
115  {
116  printf("*v(%d)",l);
117  if (e!=1) printf("^%d",e);
118  }
119  }
120  }
121  }
122  else
123  {
124  if ( f.isImm() )
125  {
127  {
128  long a= imm2int (f.getval());
129  if ( a == gf_q )
130  printf ("+%ld", a);
131  else if ( a == 0L )
132  printf ("+1");
133  else if ( a == 1L )
134  printf ("+%c",gf_name);
135  else
136  {
137  printf ("+%c",gf_name);
138  printf ("^%ld",a);
139  }
140  }
141  else
142  printf("+%ld",f.intval());
143  }
144  else
145  {
146  #ifdef NOSTREAMIO
147  if (f.inZ())
148  {
149  mpz_t m;
150  gmp_numerator(f,m);
151  char * str = new char[mpz_sizeinbase( m, 10 ) + 2];
152  str = mpz_get_str( str, 10, m );
153  printf("%s",str);
154  delete[] str;
155  mpz_clear(m);
156  }
157  else if (f.inQ())
158  {
159  mpz_t m;
160  gmp_numerator(f,m);
161  char * str = new char[mpz_sizeinbase( m, 10 ) + 2];
162  str = mpz_get_str( str, 10, m );
163  printf("%s/",str);
164  delete[] str;
165  mpz_clear(m);
166  gmp_denominator(f,m);
167  str = new char[mpz_sizeinbase( m, 10 ) + 2];
168  str = mpz_get_str( str, 10, m );
169  printf("%s",str);
170  delete[] str;
171  mpz_clear(m);
172  }
173  #else
174  std::cout << f;
175  #endif
176  }
177  //if (f.inZ()) printf("(Z)");
178  //else if (f.inQ()) printf("(Q)");
179  //else if (f.inFF()) printf("(FF)");
180  //else if (f.inPP()) printf("(PP)");
181  //else if (f.inGF()) printf("(PP)");
182  //else
183  if (f.inExtension()) printf("E(%d)",f.level());
184  }
185  printf("%s",s2);
186 }
long intval() const
conversion functions
const poly a
Definition: syzextra.cc:212
bool isImm() const
CF_NO_INLINE bool isZero() const
Definition: cf_inline.cc:372
char gf_name
Definition: gfops.cc:52
int gf_q
Definition: gfops.cc:47
bool inBaseDomain() const
int m
Definition: cfEzgcd.cc:119
FILE * f
Definition: checklibs.c:7
int i
Definition: cfEzgcd.cc:123
bool inExtension() const
void out_cf(const char *s1, const CanonicalForm &f, const char *s2)
cf_algorithm.cc - simple mathematical algorithms.
Definition: cf_factor.cc:90
class to iterate through CanonicalForm&#39;s
Definition: cf_iter.h:44
void gmp_numerator(const CanonicalForm &f, mpz_ptr result)
Definition: singext.cc:20
long imm2int(const InternalCF *const imm)
Definition: imm.h:66
static int gettype()
Definition: cf_factory.h:27
bool inQ() const
bool inZ() const
predicates
#define GaloisFieldDomain
Definition: cf_defs.h:22
int level() const
level() returns the level of CO.
InternalCF * getval() const
int l
Definition: cfEzgcd.cc:94
void gmp_denominator(const CanonicalForm &f, mpz_ptr result)
Definition: singext.cc:40

Variable Documentation

§ cf_stringtemp

unsigned char* cf_stringtemp
static

Definition at line 477 of file NTLconvert.cc.

§ cf_stringtemp_l

unsigned long cf_stringtemp_l =0L
static

Definition at line 478 of file NTLconvert.cc.

§ fac_NTL_char

long fac_NTL_char = -1

Definition at line 44 of file NTLconvert.cc.