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 "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

#define Alloc (   L)    malloc(L)

Definition at line 37 of file NTLconvert.cc.

#define Free (   A,
 
)    free(A)

Definition at line 38 of file NTLconvert.cc.

Function Documentation

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

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

Definition at line 1001 of file NTLconvert.cc.

1002 {
1003  GF2E::init(mipo);
1004  GF2EX result;
1005  CFIterator i;
1006  i=f;
1007 
1008  int NTLcurrentExp=i.exp();
1009  int largestExp=i.exp();
1010  int k;
1011 
1012  result.SetMaxLength(largestExp+1);
1013  for(;i.hasTerms();i++)
1014  {
1015  for(k=NTLcurrentExp;k>i.exp();k--) SetCoeff(result,k,0);
1016  NTLcurrentExp=i.exp();
1017  CanonicalForm c=i.coeff();
1018  GF2X cc=convertFacCF2NTLGF2X(c);
1019  //ZZ_pE ccc;
1020  //conv(ccc,cc);
1021  SetCoeff(result,NTLcurrentExp,to_GF2E(cc));
1022  NTLcurrentExp--;
1023  }
1024  for(k=NTLcurrentExp;k>=0;k--) SetCoeff(result,k,0);
1025  result.normalize();
1026  return result;
1027 }
f
Definition: cfModGcd.cc:4022
GF2X convertFacCF2NTLGF2X(const CanonicalForm &f)
NAME: convertFacCF2NTLGF2X.
Definition: NTLconvert.cc:179
factory's main class
Definition: canonicalform.h:72
int k
Definition: cfEzgcd.cc:93
CF_NO_INLINE int hasTerms() const
check if iterator has reached < the end of CanonicalForm
CF_NO_INLINE CanonicalForm coeff() const
get the current coefficient
int i
Definition: cfEzgcd.cc:123
class to iterate through CanonicalForm's
Definition: cf_iter.h:44
CF_NO_INLINE int exp() const
get the current exponent
return result
Definition: facAbsBiFact.cc:76
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 179 of file NTLconvert.cc.

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

660 {
661  ZZ temp;
662  if (f.isImm()) temp=f.intval();
663  else
664  {
665  //Coefficient is a gmp-number
666  mpz_t gmp_val;
667  char* stringtemp;
668 
669  f.mpzval (gmp_val);
670  int l=mpz_sizeinbase(gmp_val,10)+2;
671  stringtemp=(char*)Alloc(l);
672  stringtemp=mpz_get_str(stringtemp,10,gmp_val);
673  mpz_clear(gmp_val);
674  conv(temp,stringtemp);
675  Free(stringtemp,l);
676  }
677  return temp;
678 }
long intval() const
conversion functions
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:38
#define Alloc(L)
Definition: NTLconvert.cc:37
bool isImm() const
Definition: canonicalform.h:97
void mpzval(mpz_t val) const
int l
Definition: cfEzgcd.cc:94
ZZ_pEX convertFacCF2NTLZZ_pEX ( const CanonicalForm f,
const ZZ_pX &  mipo 
)

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

Definition at line 1031 of file NTLconvert.cc.

1032 {
1033  ZZ_pE::init(mipo);
1034  ZZ_pEX result;
1035  CFIterator i;
1036  i=f;
1037 
1038  int NTLcurrentExp=i.exp();
1039  int largestExp=i.exp();
1040  int k;
1041 
1042  result.SetMaxLength(largestExp+1);
1043  for(;i.hasTerms();i++)
1044  {
1045  for(k=NTLcurrentExp;k>i.exp();k--) SetCoeff(result,k,0);
1046  NTLcurrentExp=i.exp();
1047  CanonicalForm c=i.coeff();
1048  ZZ_pX cc=convertFacCF2NTLZZpX(c);
1049  //ZZ_pE ccc;
1050  //conv(ccc,cc);
1051  SetCoeff(result,NTLcurrentExp,to_ZZ_pE(cc));
1052  NTLcurrentExp--;
1053  }
1054  for(k=NTLcurrentExp;k>=0;k--) SetCoeff(result,k,0);
1055  result.normalize();
1056  return result;
1057 }
f
Definition: cfModGcd.cc:4022
factory's main class
Definition: canonicalform.h:72
int k
Definition: cfEzgcd.cc:93
CF_NO_INLINE int hasTerms() const
check if iterator has reached < the end of CanonicalForm
CF_NO_INLINE CanonicalForm coeff() const
get the current coefficient
ZZ_pX convertFacCF2NTLZZpX(const CanonicalForm &f)
NAME: convertFacCF2NTLZZpX.
Definition: NTLconvert.cc:61
int i
Definition: cfEzgcd.cc:123
class to iterate through CanonicalForm's
Definition: cf_iter.h:44
CF_NO_INLINE int exp() const
get the current exponent
return result
Definition: facAbsBiFact.cc:76
zz_pEX convertFacCF2NTLzz_pEX ( const CanonicalForm f,
const zz_pX &  mipo 
)

Definition at line 1058 of file NTLconvert.cc.

1059 {
1060  zz_pE::init(mipo);
1061  zz_pEX result;
1062  CFIterator i;
1063  i=f;
1064 
1065  int NTLcurrentExp=i.exp();
1066  int largestExp=i.exp();
1067  int k;
1068 
1069  result.SetMaxLength(largestExp+1);
1070  for(;i.hasTerms();i++)
1071  {
1072  for(k=NTLcurrentExp;k>i.exp();k--) SetCoeff(result,k,0);
1073  NTLcurrentExp=i.exp();
1074  CanonicalForm c=i.coeff();
1075  zz_pX cc=convertFacCF2NTLzzpX(c);
1076  //ZZ_pE ccc;
1077  //conv(ccc,cc);
1078  SetCoeff(result,NTLcurrentExp,to_zz_pE(cc));
1079  NTLcurrentExp--;
1080  }
1081  for(k=NTLcurrentExp;k>=0;k--) SetCoeff(result,k,0);
1082  result.normalize();
1083  return result;
1084 }
f
Definition: cfModGcd.cc:4022
factory's main class
Definition: canonicalform.h:72
int k
Definition: cfEzgcd.cc:93
CF_NO_INLINE int hasTerms() const
check if iterator has reached < the end of CanonicalForm
CF_NO_INLINE CanonicalForm coeff() const
get the current coefficient
int i
Definition: cfEzgcd.cc:123
class to iterate through CanonicalForm's
Definition: cf_iter.h:44
CF_NO_INLINE int exp() const
get the current exponent
zz_pX convertFacCF2NTLzzpX(const CanonicalForm &f)
Definition: NTLconvert.cc:102
return result
Definition: facAbsBiFact.cc:76
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 61 of file NTLconvert.cc.

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

Definition at line 102 of file NTLconvert.cc.

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

Definition at line 680 of file NTLconvert.cc.

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

Definition at line 1132 of file NTLconvert.cc.

1133 {
1134  mat_ZZ *res=new mat_ZZ;
1135  res->SetDims(m.rows(),m.columns());
1136 
1137  int i,j;
1138  for(i=m.rows();i>0;i--)
1139  {
1140  for(j=m.columns();j>0;j--)
1141  {
1142  (*res)(i,j)=convertFacCF2NTLZZ(m(i,j));
1143  }
1144  }
1145  return res;
1146 }
ZZ convertFacCF2NTLZZ(const CanonicalForm &f)
NAME: convertFacCF2NTLZZX.
Definition: NTLconvert.cc:659
int columns() const
Definition: ftmpl_matrix.h:46
poly res
Definition: myNF.cc:322
int j
Definition: myNF.cc:70
int m
Definition: cfEzgcd.cc:119
int i
Definition: cfEzgcd.cc:123
int rows() const
Definition: ftmpl_matrix.h:45
mat_zz_p* convertFacCFMatrix2NTLmat_zz_p ( const CFMatrix m)

Definition at line 1161 of file NTLconvert.cc.

1162 {
1163  mat_zz_p *res=new mat_zz_p;
1164  res->SetDims(m.rows(),m.columns());
1165 
1166  int i,j;
1167  for(i=m.rows();i>0;i--)
1168  {
1169  for(j=m.columns();j>0;j--)
1170  {
1171  if(!(m(i,j)).isImm()) printf("convertFacCFMatrix2NTLmat_zz_p: not imm.\n");
1172  (*res)(i,j)=(m(i,j)).intval();
1173  }
1174  }
1175  return res;
1176 }
int columns() const
Definition: ftmpl_matrix.h:46
poly res
Definition: myNF.cc:322
int j
Definition: myNF.cc:70
int m
Definition: cfEzgcd.cc:119
int i
Definition: cfEzgcd.cc:123
int rows() const
Definition: ftmpl_matrix.h:45
mat_zz_pE* convertFacCFMatrix2NTLmat_zz_pE ( const CFMatrix m)

Definition at line 1190 of file NTLconvert.cc.

1191 {
1192  mat_zz_pE *res=new mat_zz_pE;
1193  res->SetDims(m.rows(),m.columns());
1194 
1195  int i,j;
1196  for(i=m.rows();i>0;i--)
1197  {
1198  for(j=m.columns();j>0;j--)
1199  {
1200  zz_pX cc=convertFacCF2NTLzzpX(m(i,j));
1201  (*res)(i,j)=to_zz_pE(cc);
1202  }
1203  }
1204  return res;
1205 }
int columns() const
Definition: ftmpl_matrix.h:46
poly res
Definition: myNF.cc:322
int j
Definition: myNF.cc:70
int m
Definition: cfEzgcd.cc:119
int i
Definition: cfEzgcd.cc:123
int rows() const
Definition: ftmpl_matrix.h:45
zz_pX convertFacCF2NTLzzpX(const CanonicalForm &f)
Definition: NTLconvert.cc:102
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 922 of file NTLconvert.cc.

923 {
924  return convertNTLGF2X2CF(rep(coefficient),x);
925 }
CanonicalForm convertNTLGF2X2CF(const GF2X &poly, const Variable &x)
NAME: convertNTLGF2X2CF.
Definition: NTLconvert.cc:317
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 317 of file NTLconvert.cc.

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

Definition at line 1147 of file NTLconvert.cc.

1148 {
1149  CFMatrix *res=new CFMatrix(m.NumRows(),m.NumCols());
1150  int i,j;
1151  for(i=res->rows();i>0;i--)
1152  {
1153  for(j=res->columns();j>0;j--)
1154  {
1155  (*res)(i,j)=convertZZ2CF(m(i,j));
1156  }
1157  }
1158  return res;
1159 }
Matrix< CanonicalForm > CFMatrix
int columns() const
Definition: ftmpl_matrix.h:46
poly res
Definition: myNF.cc:322
int j
Definition: myNF.cc:70
int m
Definition: cfEzgcd.cc:119
int i
Definition: cfEzgcd.cc:123
int rows() const
Definition: ftmpl_matrix.h:45
CanonicalForm convertZZ2CF(const ZZ &a)
NAME: convertZZ2CF.
Definition: NTLconvert.cc:491
CFMatrix* convertNTLmat_zz_p2FacCFMatrix ( const mat_zz_p &  m)

Definition at line 1177 of file NTLconvert.cc.

1178 {
1179  CFMatrix *res=new CFMatrix(m.NumRows(),m.NumCols());
1180  int i,j;
1181  for(i=res->rows();i>0;i--)
1182  {
1183  for(j=res->columns();j>0;j--)
1184  {
1185  (*res)(i,j)=CanonicalForm(to_long(rep(m(i,j))));
1186  }
1187  }
1188  return res;
1189 }
Matrix< CanonicalForm > CFMatrix
factory's main class
Definition: canonicalform.h:72
int columns() const
Definition: ftmpl_matrix.h:46
poly res
Definition: myNF.cc:322
int j
Definition: myNF.cc:70
int m
Definition: cfEzgcd.cc:119
int i
Definition: cfEzgcd.cc:123
int rows() const
Definition: ftmpl_matrix.h:45
CFMatrix* convertNTLmat_zz_pE2FacCFMatrix ( const mat_zz_pE &  m,
const Variable alpha 
)

Definition at line 1206 of file NTLconvert.cc.

1207 {
1208  CFMatrix *res=new CFMatrix(m.NumRows(),m.NumCols());
1209  int i,j;
1210  for(i=res->rows();i>0;i--)
1211  {
1212  for(j=res->columns();j>0;j--)
1213  {
1214  (*res)(i,j)=convertNTLzzpE2CF(m(i,j), alpha);
1215  }
1216  }
1217  return res;
1218 }
Matrix< CanonicalForm > CFMatrix
CanonicalForm convertNTLzzpE2CF(const zz_pE &coefficient, const Variable &x)
Definition: NTLconvert.cc:789
Variable alpha
Definition: facAbsBiFact.cc:52
int columns() const
Definition: ftmpl_matrix.h:46
poly res
Definition: myNF.cc:322
int j
Definition: myNF.cc:70
int m
Definition: cfEzgcd.cc:119
int i
Definition: cfEzgcd.cc:123
int rows() const
Definition: ftmpl_matrix.h:45
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 949 of file NTLconvert.cc.

950 {
951  CFFList result;
952  GF2EX polynom;
953  long exponent;
954  CanonicalForm bigone;
955 
956  // Maybe, e may additionally be sorted with respect to increasing degree of x, but this is not
957  //important for the factorization, but nevertheless would take computing time, so it is omitted
958 
959  // multiplicity is always one, so we do not have to worry about that
960 
961  // Go through the vector e and build up the CFFList
962  // As usual bigone summarizes the result during every loop
963  for (int i=e.length()-1;i>=0;i--)
964  {
965  bigone=0;
966 
967  polynom=e[i].a;
968  exponent=e[i].b;
969 
970  for (int j=0;j<=deg(polynom);j++)
971  {
972  if (IsOne(coeff(polynom,j)))
973  {
974  bigone+=power(x,j);
975  }
976  else
977  {
978  CanonicalForm coefficient=convertNTLGF2E2CF(coeff(polynom,j),alpha);
979  if (coeff(polynom,j)!=0)
980  {
981  bigone += (power(x,j)*coefficient);
982  }
983  }
984  }
985 
986  // append the computed polynomial together with its multiplicity
987  result.append(CFFactor(bigone,exponent));
988 
989  }
990 
991  if (!IsOne(multi))
992  result.insert(CFFactor(convertNTLGF2E2CF(multi,alpha),1));
993 
994  // return the computed CFFList
995  return result;
996 }
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
factory's main class
Definition: canonicalform.h:72
void insert(const T &)
Definition: ftmpl_list.cc:193
CanonicalForm convertNTLGF2E2CF(const GF2E &coefficient, const Variable &x)
NAME: convertNTLGF2E2CF.
Definition: NTLconvert.cc:922
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
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 441 of file NTLconvert.cc.

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

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

861 {
862  CFFList result;
863  zz_pEX polynom;
864  long exponent;
865  CanonicalForm bigone;
866 
867  // Maybe, e may additionally be sorted with respect to increasing degree of x, but this is not
868  //important for the factorization, but nevertheless would take computing time, so it is omitted
869 
870  // Go through the vector e and build up the CFFList
871  // As usual bigone summarizes the result during every loop
872  for (int i=e.length()-1;i>=0;i--)
873  {
874  bigone=0;
875 
876  polynom=e[i].a;
877  exponent=e[i].b;
878 
879  for (int j=0;j<=deg(polynom);j++)
880  {
881  if (IsOne(coeff(polynom,j)))
882  {
883  bigone+=power(x,j);
884  }
885  else
886  {
887  CanonicalForm coefficient=convertNTLzzpE2CF(coeff(polynom,j),alpha);
888  if (coeff(polynom,j)!=0)
889  {
890  bigone += (power(x,j)*coefficient);
891  }
892  }
893  }
894  //append the computed polynomials together with its exponent to the CFFList
895  result.append(CFFactor(bigone,exponent));
896  }
897  // Start by appending the multiplicity
898  if (!IsOne(multi))
899  result.insert(CFFactor(convertNTLzzpE2CF(multi,alpha),1));
900 
901  //return the computed CFFList
902  return result;
903 }
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
CanonicalForm convertNTLzzpE2CF(const zz_pE &coefficient, const Variable &x)
Definition: NTLconvert.cc:789
factory's main class
Definition: canonicalform.h:72
void insert(const T &)
Definition: ftmpl_list.cc:193
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
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 369 of file NTLconvert.cc.

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

Definition at line 394 of file NTLconvert.cc.

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

743 {
744  CFFList result;
745  ZZX polynom;
746  long exponent;
747  CanonicalForm bigone;
748 
749  // Go through the vector e and build up the CFFList
750  // As usual bigone summarizes the result
751  for (int i=e.length()-1;i>=0;i--)
752  {
753  ZZ coefficient;
754  polynom=e[i].a;
755  exponent=e[i].b;
756  bigone=convertNTLZZX2CF(polynom,x);
757  //append the converted polynomial to the list
758  result.append(CFFactor(bigone,exponent));
759  }
760  // the multiplicity at pos 1
761  //if (!IsOne(multi))
762  result.insert(CFFactor(convertZZ2CF(multi),1));
763 
764  //return the converted list
765  return result;
766 }
factory's main class
Definition: canonicalform.h:72
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:491
CanonicalForm convertNTLZZX2CF(const ZZX &polynom, const Variable &x)
Definition: NTLconvert.cc:280
return result
Definition: facAbsBiFact.cc:76
CanonicalForm convertNTLzz_pEX2CF ( const zz_pEX &  f,
const Variable x,
const Variable alpha 
)

Definition at line 1086 of file NTLconvert.cc.

1087 {
1088  CanonicalForm bigone;
1089  if (deg (f) > 0)
1090  {
1091  bigone= 0;
1092  bigone.mapinto();
1093  for (int j=0;j<deg(f)+1;j++)
1094  {
1095  if (coeff(f,j)!=0)
1096  {
1097  bigone+=(power(x,j)*convertNTLzzpE2CF(coeff(f,j),alpha));
1098  }
1099  }
1100  }
1101  else
1102  {
1103  bigone= convertNTLzzpE2CF(coeff(f,0),alpha);
1104  bigone.mapinto();
1105  }
1106  return bigone;
1107 }
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
f
Definition: cfModGcd.cc:4022
CanonicalForm convertNTLzzpE2CF(const zz_pE &coefficient, const Variable &x)
Definition: NTLconvert.cc:789
factory's main class
Definition: canonicalform.h:72
int j
Definition: myNF.cc:70
CanonicalForm mapinto() const
CanonicalForm convertNTLZZ_pEX2CF ( const ZZ_pEX &  f,
const Variable x,
const Variable alpha 
)

Definition at line 1109 of file NTLconvert.cc.

1110 {
1111  CanonicalForm bigone;
1112  if (deg (f) > 0)
1113  {
1114  bigone= 0;
1115  bigone.mapinto();
1116  for (int j=0;j<deg(f)+1;j++)
1117  {
1118  if (coeff(f,j)!=0)
1119  {
1120  bigone+=(power(x,j)*convertNTLZZpE2CF(coeff(f,j),alpha));
1121  }
1122  }
1123  }
1124  else
1125  {
1126  bigone= convertNTLZZpE2CF(coeff(f,0),alpha);
1127  bigone.mapinto();
1128  }
1129  return bigone;
1130 }
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
f
Definition: cfModGcd.cc:4022
factory's main class
Definition: canonicalform.h:72
int j
Definition: myNF.cc:70
CanonicalForm mapinto() const
CanonicalForm convertNTLZZpE2CF(const ZZ_pE &coefficient, const Variable &x)
NAME: convertNTLZZpX2CF.
Definition: NTLconvert.cc:785
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 785 of file NTLconvert.cc.

786 {
787  return convertNTLZZpX2CF(rep(coefficient),x);
788 }
CanonicalForm convertNTLZZpX2CF(const ZZ_pX &poly, const Variable &x)
NAME: convertNTLZZpX2CF.
Definition: NTLconvert.cc:245
CanonicalForm convertNTLzzpE2CF ( const zz_pE &  coefficient,
const Variable x 
)

Definition at line 789 of file NTLconvert.cc.

790 {
791  return convertNTLzzpX2CF(rep(coefficient),x);
792 }
CanonicalForm convertNTLzzpX2CF(const zz_pX &poly, const Variable &x)
Definition: NTLconvert.cc:250
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 245 of file NTLconvert.cc.

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

Definition at line 250 of file NTLconvert.cc.

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

Definition at line 280 of file NTLconvert.cc.

281 {
282  //printf("convertNTLZZX2CF\n");
283  CanonicalForm bigone;
284 
285  // Go through the vector e and build up the CFFList
286  // As usual bigone summarizes the result
287  bigone=0;
288  ZZ coefficient;
289 
290  for (int j=0;j<=deg(polynom);j++)
291  {
292  coefficient=coeff(polynom,j);
293  if (!IsZero(coefficient))
294  {
295  bigone += (power(x,j)*convertZZ2CF(coefficient));
296  }
297  }
298  return bigone;
299 }
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
factory's main class
Definition: canonicalform.h:72
int j
Definition: myNF.cc:70
CanonicalForm convertZZ2CF(const ZZ &a)
NAME: convertZZ2CF.
Definition: NTLconvert.cc:491
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 491 of file NTLconvert.cc.

492 {
493  long coeff_long=to_long(a);
494 
496  if ( (NumBits(a)<((long)NTL_ZZ_NBITS))
497  && (coeff_long>((long)MINIMMEDIATE))
498  && (coeff_long<((long)MAXIMMEDIATE)))
499  {
500  return CanonicalForm(coeff_long);
501  }
502  else
503  {
504  long sizeofrep= ((long *) a.rep) [1];
505  bool lessZero= false;
506  if (sizeofrep < 0)
507  {
508  lessZero= true;
509  sizeofrep= -sizeofrep;
510  }
511  if (cf_stringtemp_l == 0)
512  {
513  cf_stringtemp_l= sizeofrep*sizeof(mp_limb_t)*2;
514  cf_stringtemp= (unsigned char*) Alloc (cf_stringtemp_l);
515  }
516  else if (cf_stringtemp_l < sizeofrep*sizeof(mp_limb_t)*2)
517  {
518  Free (cf_stringtemp, cf_stringtemp_l);
519  cf_stringtemp_l= sizeofrep*sizeof(mp_limb_t)*2;
520  cf_stringtemp= (unsigned char*) Alloc (cf_stringtemp_l);
521  }
522  int cc= mpn_get_str (cf_stringtemp, 16, (mp_limb_t *) (((long *) (a.rep)) + 2), sizeofrep);
523 
524  char* cf_stringtemp2;
525  if (lessZero)
526  {
527  cf_stringtemp2= new char [cc + 2];
528  cf_stringtemp2[0]='-';
529  for (int j= 1; j <= cc; j++)
530  cf_stringtemp2[j]= IntValToChar ((int) cf_stringtemp [j-1]);
531  cf_stringtemp2[cc+1]='\0';
532  }
533  else
534  {
535  cf_stringtemp2= new char [cc + 1];
536  for (int j= 0; j < cc; j++)
537  cf_stringtemp2[j]= IntValToChar ((int) cf_stringtemp [j]);
538  cf_stringtemp2[cc]='\0';
539  }
540 
541  result= CanonicalForm (cf_stringtemp2, 16);
542  delete [] cf_stringtemp2;
543  return result;
544  }
545  return result;
546 }
const long MINIMMEDIATE
Definition: imm.h:50
const poly a
Definition: syzextra.cc:212
static unsigned char * cf_stringtemp
Definition: NTLconvert.cc:476
factory's main class
Definition: canonicalform.h:72
static unsigned long cf_stringtemp_l
Definition: NTLconvert.cc:477
int j
Definition: myNF.cc:70
#define Free(A, L)
Definition: NTLconvert.cc:38
#define Alloc(L)
Definition: NTLconvert.cc:37
const long MAXIMMEDIATE
Definition: imm.h:51
return result
Definition: facAbsBiFact.cc:76
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 }
void gmp_numerator(const CanonicalForm &f, mpz_ptr result)
Definition: singext.cc:20
bool inQ() const
const poly a
Definition: syzextra.cc:212
f
Definition: cfModGcd.cc:4022
char gf_name
Definition: gfops.cc:52
bool inZ() const
predicates
CF_NO_INLINE bool isZero() const
Definition: cf_inline.cc:372
bool inExtension() const
long intval() const
conversion functions
int level() const
level() returns the level of CO.
int gf_q
Definition: gfops.cc:47
int m
Definition: cfEzgcd.cc:119
int i
Definition: cfEzgcd.cc:123
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's
Definition: cf_iter.h:44
bool isImm() const
Definition: canonicalform.h:97
long imm2int(const InternalCF *const imm)
Definition: imm.h:66
void gmp_denominator(const CanonicalForm &f, mpz_ptr result)
Definition: singext.cc:40
static int gettype()
Definition: cf_factory.h:27
#define GaloisFieldDomain
Definition: cf_defs.h:22
bool inBaseDomain() const
InternalCF * getval() const
int l
Definition: cfEzgcd.cc:94

Variable Documentation

unsigned char* cf_stringtemp
static

Definition at line 476 of file NTLconvert.cc.

unsigned long cf_stringtemp_l =0L
static

Definition at line 477 of file NTLconvert.cc.

long fac_NTL_char = -1

Definition at line 43 of file NTLconvert.cc.