NTLconvert.cc
Go to the documentation of this file.
1 
2 #include "config.h"
3 
4 
5 #include "cf_assert.h"
6 
7 #include "cf_defs.h"
8 #include "canonicalform.h"
9 #include "cf_iter.h"
10 #include "fac_sqrfree.h"
11 #include "cf_algorithm.h"
12 
13 #include <factory/cf_gmp.h>
14 
15 #ifdef HAVE_NTL
16 #ifndef NOSTREAMIO
17 #ifdef HAVE_CSTDIO
18 #include <cstdio>
19 #else
20 #include <stdio.h>
21 #endif
22 #endif
23 #include <string.h>
24 #include <NTL/ZZXFactoring.h>
25 #include <NTL/ZZ_pXFactoring.h>
26 #include <NTL/lzz_pXFactoring.h>
27 #include <NTL/GF2XFactoring.h>
28 #include <NTL/ZZ_pEXFactoring.h>
29 #include <NTL/lzz_pEXFactoring.h>
30 #include <NTL/GF2EXFactoring.h>
31 #include <NTL/tools.h>
32 #include <NTL/mat_ZZ.h>
33 #include <NTL/version.h>
34 #include "int_int.h"
35 #include <limits.h>
36 #include "NTLconvert.h"
37 
38 #define Alloc(L) malloc(L)
39 #define Free(A,L) free(A)
40 
41 void out_cf(const char *s1,const CanonicalForm &f,const char *s2);
42 
43 
44 long fac_NTL_char = -1; // the current characterstic for NTL calls
45  // -1: undefined
46 #ifdef NTL_CLIENT // in <NTL/tools.h>: using of name space NTL
47 NTL_CLIENT
48 #endif
49 
50 ////////////////////////////////////////////////////////////////////////////////
51 /// NAME: convertFacCF2NTLZZpX
52 ///
53 /// DESCRIPTION:
54 /// Conversion routine for Factory-type canonicalform into ZZpX of NTL,
55 /// i.e. polynomials over F_p. As a precondition for correct execution,
56 /// the characteristic has to a a prime number.
57 ///
58 /// INPUT: A canonicalform f
59 /// OUTPUT: The converted NTL-polynomial over F_p of type ZZpX
60 ////////////////////////////////////////////////////////////////////////////////
61 
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 }
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 }
161 
162 ////////////////////////////////////////////////////////////////////////////////
163 /// NAME: convertFacCF2NTLGF2X
164 ///
165 /// DESCRIPTION:
166 /// Conversion routine for Factory-type canonicalform into GF2X of NTL,
167 /// i.e. polynomials over F_2. As precondition for correct execution,
168 /// the characteristic must equal two.
169 /// This is a special case of the more general conversion routine for
170 /// canonicalform to ZZpX. It is included because NTL provides additional
171 /// support and faster algorithms over F_2, moreover the conversion code
172 /// can be optimized, because certain steps are either completely obsolent
173 /// (like normalizing the polynomial) or they can be made significantly
174 /// faster (like building up the NTL-polynomial).
175 ///
176 /// INPUT: A canonicalform f
177 /// OUTPUT: The converted NTL-polynomial over F_2 of type GF2X
178 ////////////////////////////////////////////////////////////////////////////////
179 
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 immidiate! : " << f << "\n";
209  #else
210  //NTL_SNS
211  printf("convertFacCF2NTLGF2X: coefficient not immidiate!");
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 }
229 
230 
231 ////////////////////////////////////////////////////////////////////////////////
232 /// NAME: convertNTLZZpX2CF
233 ///
234 /// DESCRIPTION:
235 /// Conversion routine for NTL-Type ZZpX to Factory-Type canonicalform.
236 /// Additionally a variable x is needed as a parameter indicating the
237 /// main variable of the computed canonicalform. To guarantee the correct
238 /// execution of the algorithm, the characteristic has a be an arbitrary
239 /// prime number.
240 ///
241 /// INPUT: A canonicalform f, a variable x
242 /// OUTPUT: The converted Factory-polynomial of type canonicalform,
243 /// built by the main variable x
244 ////////////////////////////////////////////////////////////////////////////////
245 
247 {
248  return convertNTLZZX2CF (to_ZZX (poly), x);
249 }
250 
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 }
280 
281 CanonicalForm convertNTLZZX2CF(const ZZX & polynom,const Variable & x)
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 }
301 
302 ////////////////////////////////////////////////////////////////////////////////
303 /// NAME: convertNTLGF2X2CF
304 ///
305 /// DESCRIPTION:
306 /// Conversion routine for NTL-Type GF2X to Factory-Type canonicalform,
307 /// the routine is again an optimized special case of the more general
308 /// conversion to ZZpX. Additionally a variable x is needed as a
309 /// parameter indicating the main variable of the computed canonicalform.
310 /// To guarantee the correct execution of the algorithm the characteristic
311 /// has a be an arbitrary prime number.
312 ///
313 /// INPUT: A canonicalform f, a variable x
314 /// OUTPUT: The converted Factory-polynomial of type canonicalform,
315 /// built by the main variable x
316 ////////////////////////////////////////////////////////////////////////////////
317 
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 }
348 
349 ////////////////////////////////////////////////////////////////////////////////
350 /// NAME: convertNTLvec_pair_ZZpX_long2FacCFFList
351 ///
352 /// DESCRIPTION:
353 /// Routine for converting a vector of polynomials from ZZpX to
354 /// a CFFList of Factory. This routine will be used after a successful
355 /// factorization of NTL to convert the result back to Factory.
356 ///
357 /// Additionally a variable x and the computed multiplicity, as a type ZZp
358 /// of NTL, is needed as parameters indicating the main variable of the
359 /// computed canonicalform and the multiplicity of the original polynomial.
360 /// To guarantee the correct execution of the algorithm the characteristic
361 /// has a be an arbitrary prime number.
362 ///
363 /// INPUT: A vector of polynomials over ZZp of type vec_pair_ZZ_pX_long and
364 /// a variable x and a multiplicity of type ZZp
365 /// OUTPUT: The converted list of polynomials of type CFFList, all polynomials
366 /// have x as their main variable
367 ////////////////////////////////////////////////////////////////////////////////
368 
370  (const vec_pair_ZZ_pX_long & e,const ZZ_p & multi,const Variable & x)
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 }
395  (const vec_pair_zz_pX_long & e,const zz_p multi,const Variable & x)
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 }
419 
420 ////////////////////////////////////////////////////////////////////////////////
421 /// NAME: convertNTLvec_pair_GF2X_long2FacCFFList
422 ///
423 /// DESCRIPTION:
424 /// Routine for converting a vector of polynomials of type GF2X from
425 /// NTL to a list CFFList of Factory. This routine will be used after a
426 /// successful factorization of NTL to convert the result back to Factory.
427 /// As usual this is simply a special case of the more general conversion
428 /// routine but again speeded up by leaving out unnecessary steps.
429 /// Additionally a variable x and the computed multiplicity, as type
430 /// GF2 of NTL, are needed as parameters indicating the main variable of the
431 /// computed canonicalform and the multiplicity of the original polynomial.
432 /// To guarantee the correct execution of the algorithm the characteristic
433 /// has a be an arbitrary prime number.
434 ///
435 /// INPUT: A vector of polynomials over GF2 of type vec_pair_GF2X_long and
436 /// a variable x and a multiplicity of type GF2
437 /// OUTPUT: The converted list of polynomials of type CFFList, all
438 /// polynomials have x as their main variable
439 ////////////////////////////////////////////////////////////////////////////////
440 
442  (const vec_pair_GF2X_long& e, GF2 /*multi*/, const Variable & x)
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 }
476 
477 static unsigned char *cf_stringtemp;
478 static unsigned long cf_stringtemp_l=0L;
479 ////////////////////////////////////////////////////////////////////////////////
480 /// NAME: convertZZ2CF
481 ///
482 /// DESCRIPTION:
483 /// Routine for conversion of integers represented in NTL as Type ZZ to
484 /// integers in Factory represented as canonicalform.
485 /// To guarantee the correct execution of the algorithm the characteristic
486 /// has to equal zero.
487 ///
488 /// INPUT: The value coefficient of type ZZ that has to be converted
489 /// OUTPUT: The converted Factory-integer of type canonicalform
490 ////////////////////////////////////////////////////////////////////////////////
492 convertZZ2CF (const ZZ & a)
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 }
554 
555 /*static char *cf_stringtemp;
556 static char *cf_stringtemp2;
557 static int cf_stringtemp_l=0;
558 CanonicalForm convertZZ2CF(const ZZ & coefficient)
559 {
560  long coeff_long;
561  //CanonicalForm tmp=0;
562  char dummy[2];
563  int minusremainder=0;
564  char numbers[]="0123456789abcdef";
565 
566  coeff_long=to_long(coefficient);
567 
568  //Test whether coefficient can be represented as an immediate integer in Factory
569  if ( (NumBits(coefficient)<((long)NTL_ZZ_NBITS))
570  && (coeff_long>((long)MINIMMEDIATE))
571  && (coeff_long<((long)MAXIMMEDIATE)))
572  {
573  // coefficient is immediate --> return the coefficient as canonicalform
574  return CanonicalForm(coeff_long);
575  }
576  else
577  {
578  // coefficient is not immediate (gmp-number)
579  if (cf_stringtemp_l==0)
580  {
581  cf_stringtemp=(char *)Alloc(1023);
582  cf_stringtemp2=(char *)Alloc(1023);
583  cf_stringtemp[0]='\0';
584  cf_stringtemp2[0]='\0';
585  cf_stringtemp_l=1023;
586  }
587 
588  // convert coefficient to char* (input for gmp)
589  dummy[1]='\0';
590 
591  if (coefficient<0)
592  {
593  // negate coefficient, but store the sign in minusremainder
594  minusremainder=1;
595  coefficient=-coefficient;
596  }
597 
598  int l=0;
599  while (coefficient>15)
600  {
601  ZZ quotient,remaind;
602  ZZ ten;ten=16;
603  DivRem(quotient,remaind,coefficient,ten);
604  dummy[0]=numbers[to_long(remaind)];
605  //tmp*=10; tmp+=to_long(remaind);
606 
607  l++;
608  if (l>=cf_stringtemp_l-2)
609  {
610  Free(cf_stringtemp2,cf_stringtemp_l);
611  char *p=(char *)Alloc(cf_stringtemp_l*2);
612  //NTL_SNS
613  memcpy(p,cf_stringtemp,cf_stringtemp_l);
614  Free(cf_stringtemp,cf_stringtemp_l);
615  cf_stringtemp_l*=2;
616  cf_stringtemp=p;
617  cf_stringtemp2=(char *)Alloc(cf_stringtemp_l);
618  }
619  cf_stringtemp[l-1]=dummy[0];
620  cf_stringtemp[l]='\0';
621  //strcat(stringtemp,dummy);
622 
623  coefficient=quotient;
624  }
625  //built up the string in dummy[0]
626  dummy[0]=numbers[to_long(coefficient)];
627  //NTL_SNS
628  l++;
629  cf_stringtemp[l-1]=dummy[0];
630  cf_stringtemp[l]='\0';
631  //tmp*=10; tmp+=to_long(coefficient);
632 
633  if (minusremainder==1)
634  {
635  //Check whether coefficient has been negative at the start of the procedure
636  cf_stringtemp2[0]='-';
637  //tmp*=(-1);
638  }
639 
640  //reverse the list to obtain the correct string
641  //NTL_SNS
642  for (int i=l-1;i>=0;i--) // l ist the position of \0
643  {
644  cf_stringtemp2[l-i-1+minusremainder]=cf_stringtemp[i];
645  }
646  cf_stringtemp2[l+minusremainder]='\0';
647  }
648 
649  //convert the string to canonicalform using the char*-Constructor
650  return CanonicalForm(cf_stringtemp2,16);
651  //return tmp;
652 }*/
653 
654 ////////////////////////////////////////////////////////////////////////////////
655 /// NAME: convertFacCF2NTLZZX
656 ///
657 /// DESCRIPTION:
658 /// Routine for conversion of canonicalforms in Factory to polynomials
659 /// of type ZZX of NTL. To guarantee the correct execution of the
660 /// algorithm the characteristic has to equal zero.
661 ///
662 /// INPUT: The canonicalform that has to be converted
663 /// OUTPUT: The converted NTL-polynom of type ZZX
664 ////////////////////////////////////////////////////////////////////////////////
665 
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 }
686 
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 }
728 
729 ////////////////////////////////////////////////////////////////////////////////
730 /// NAME: convertNTLvec_pair_ZZX_long2FacCFFList
731 ///
732 /// DESCRIPTION:
733 /// Routine for converting a vector of polynomials from ZZ to a list
734 /// CFFList of Factory. This routine will be used after a successful
735 /// factorization of NTL to convert the result back to Factory.
736 /// Additionally a variable x and the computed multiplicity, as a type
737 /// ZZ of NTL, is needed as parameters indicating the main variable of the
738 /// computed canonicalform and the multiplicity of the original polynomial.
739 /// To guarantee the correct execution of the algorithm the characteristic
740 /// has to equal zero.
741 ///
742 /// INPUT: A vector of polynomials over ZZ of type vec_pair_ZZX_long and
743 /// a variable x and a multiplicity of type ZZ
744 /// OUTPUT: The converted list of polynomials of type CFFList, all
745 /// have x as their main variable
746 ////////////////////////////////////////////////////////////////////////////////
747 
748 CFFList
749 convertNTLvec_pair_ZZX_long2FacCFFList (const vec_pair_ZZX_long & e,const ZZ & multi,const Variable & x)
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 }
774 
775 
776 ////////////////////////////////////////////////////////////////////////////////
777 /// NAME: convertNTLZZpX2CF
778 ///
779 /// DESCRIPTION:
780 /// Routine for conversion of elements of arbitrary extensions of ZZp,
781 /// having type ZZpE, of NTL to their corresponding values of type
782 /// canonicalform in Factory.
783 /// To guarantee the correct execution of the algorithm the characteristic
784 /// has to be an arbitrary prime number and Factory has to compute in an
785 /// extension of F_p.
786 ///
787 /// INPUT: The coefficient of type ZZpE and the variable x indicating the main//
788 /// variable of the computed canonicalform
789 /// OUTPUT: The converted value of coefficient as type canonicalform
790 ////////////////////////////////////////////////////////////////////////////////
791 
792 CanonicalForm convertNTLZZpE2CF(const ZZ_pE & coefficient,const Variable & x)
793 {
794  return convertNTLZZpX2CF(rep(coefficient),x);
795 }
796 CanonicalForm convertNTLzzpE2CF(const zz_pE & coefficient,const Variable & x)
797 {
798  return convertNTLzzpX2CF(rep(coefficient),x);
799 }
800 
801 ////////////////////////////////////////////////////////////////////////////////
802 /// NAME: convertNTLvec_pair_ZZpEX_long2FacCFFList
803 ///
804 /// DESCRIPTION:
805 /// Routine for converting a vector of polynomials from ZZpEX to a CFFList
806 /// of Factory. This routine will be used after a successful factorization
807 /// of NTL to convert the result back to Factory.
808 /// Additionally a variable x and the computed multiplicity, as a type
809 /// ZZpE of NTL, is needed as parameters indicating the main variable of the
810 /// computed canonicalform and the multiplicity of the original polynomial.
811 /// To guarantee the correct execution of the algorithm the characteristic
812 /// has a be an arbitrary prime number p and computations have to be done
813 /// in an extention of F_p.
814 ///
815 /// INPUT: A vector of polynomials over ZZpE of type vec_pair_ZZ_pEX_long and
816 /// a variable x and a multiplicity of type ZZpE
817 /// OUTPUT: The converted list of polynomials of type CFFList, all polynomials
818 /// have x as their main variable
819 ////////////////////////////////////////////////////////////////////////////////
820 
821 CFFList
822 convertNTLvec_pair_ZZpEX_long2FacCFFList(const vec_pair_ZZ_pEX_long & e,const ZZ_pE & multi,const Variable & x,const Variable & alpha)
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 }
866 CFFList
867 convertNTLvec_pair_zzpEX_long2FacCFFList(const vec_pair_zz_pEX_long & e,const zz_pE & multi,const Variable & x,const Variable & alpha)
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 }
911 
912 ////////////////////////////////////////////////////////////////////////////////
913 /// NAME: convertNTLGF2E2CF
914 ///
915 /// DESCRIPTION:
916 /// Routine for conversion of elements of extensions of GF2, having type
917 /// GF2E, of NTL to their corresponding values of type canonicalform in
918 /// Factory.
919 /// To guarantee the correct execution of the algorithm, the characteristic
920 /// must equal two and Factory has to compute in an extension of F_2.
921 /// As usual this is an optimized special case of the more general conversion
922 /// routine from ZZpE to Factory.
923 ///
924 /// INPUT: The coefficient of type GF2E and the variable x indicating the
925 /// main variable of the computed canonicalform
926 /// OUTPUT: The converted value of coefficient as type canonicalform
927 ////////////////////////////////////////////////////////////////////////////////
928 
929 CanonicalForm convertNTLGF2E2CF(const GF2E & coefficient,const Variable & x)
930 {
931  return convertNTLGF2X2CF(rep(coefficient),x);
932 }
933 
934 ////////////////////////////////////////////////////////////////////////////////
935 /// NAME: convertNTLvec_pair_GF2EX_long2FacCFFList
936 ///
937 /// DESCRIPTION:
938 /// Routine for converting a vector of polynomials from GF2EX to a CFFList
939 /// of Factory. This routine will be used after a successful factorization
940 /// of NTL to convert the result back to Factory.
941 /// This is a special, but optimized case of the more general conversion
942 /// from ZZpE to canonicalform.
943 /// Additionally a variable x and the computed multiplicity, as a type GF2E
944 /// of NTL, is needed as parameters indicating the main variable of the
945 /// computed canonicalform and the multiplicity of the original polynomial.
946 /// To guarantee the correct execution of the algorithm the characteristic
947 /// has to equal two and computations have to be done in an extention of F_2.
948 ///
949 /// INPUT: A vector of polynomials over GF2E of type vec_pair_GF2EX_long and
950 /// a variable x and a multiplicity of type GF2E
951 /// OUTPUT: The converted list of polynomials of type CFFList, all polynomials
952 /// have x as their main variable
953 ////////////////////////////////////////////////////////////////////////////////
954 
956  (const vec_pair_GF2EX_long & e, const GF2E & multi, const Variable & x, const Variable & alpha)
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 }
1004 
1005 ////////////////////////////////////////////////////
1006 /// CanonicalForm in Z_2(a)[X] to NTL GF2EX
1007 ////////////////////////////////////////////////////
1008 GF2EX convertFacCF2NTLGF2EX(const CanonicalForm & f,const GF2X & mipo)
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 }
1035 ////////////////////////////////////////////////////
1036 /// CanonicalForm in Z_p(a)[X] to NTL ZZ_pEX
1037 ////////////////////////////////////////////////////
1038 ZZ_pEX convertFacCF2NTLZZ_pEX(const CanonicalForm & f, const ZZ_pX & mipo)
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 }
1065 zz_pEX convertFacCF2NTLzz_pEX(const CanonicalForm & f, const zz_pX & mipo)
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 }
1092 
1093 CanonicalForm convertNTLzz_pEX2CF (const zz_pEX& f, const Variable & x, const Variable & alpha)
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 }
1115 
1116 CanonicalForm convertNTLZZ_pEX2CF (const ZZ_pEX& f, const Variable & x, const Variable & alpha)
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 }
1138 //----------------------------------------------------------------------
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 }
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 }
1167 
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 }
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 }
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 }
1213 CFMatrix* convertNTLmat_zz_pE2FacCFMatrix(const mat_zz_pE &m, const Variable & alpha)
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 }
1226 #endif
GF2EX convertFacCF2NTLGF2EX(const CanonicalForm &f, const GF2X &mipo)
CanonicalForm in Z_2(a)[X] to NTL GF2EX.
Definition: NTLconvert.cc:1008
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
ZZ convertFacCF2NTLZZ(const CanonicalForm &f)
NAME: convertFacCF2NTLZZX.
Definition: NTLconvert.cc:666
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.
Definition: NTLconvert.cc:956
Conversion to and from NTL.
const long MINIMMEDIATE
Definition: imm.h:50
CFFList convertNTLvec_pair_GF2X_long2FacCFFList(const vec_pair_GF2X_long &e, GF2, const Variable &x)
NAME: convertNTLvec_pair_GF2X_long2FacCFFList.
Definition: NTLconvert.cc:442
const poly a
Definition: syzextra.cc:212
CFFList convertNTLvec_pair_ZZpX_long2FacCFFList(const vec_pair_ZZ_pX_long &e, const ZZ_p &multi, const Variable &x)
NAME: convertNTLvec_pair_ZZpX_long2FacCFFList.
Definition: NTLconvert.cc:370
Matrix< CanonicalForm > CFMatrix
factory&#39;s class for variables
Definition: variable.h:32
CanonicalForm convertNTLzzpE2CF(const zz_pE &coefficient, const Variable &x)
Definition: NTLconvert.cc:796
CanonicalForm convertNTLZZpX2CF(const ZZ_pX &poly, const Variable &x)
NAME: convertNTLZZpX2CF.
Definition: NTLconvert.cc:246
GF2X convertFacCF2NTLGF2X(const CanonicalForm &f)
NAME: convertFacCF2NTLGF2X.
Definition: NTLconvert.cc:180
CFFList convertNTLvec_pair_zzpX_long2FacCFFList(const vec_pair_zz_pX_long &e, const zz_p multi, const Variable &x)
Definition: NTLconvert.cc:395
static unsigned char * cf_stringtemp
Definition: NTLconvert.cc:477
ZZ_pEX convertFacCF2NTLZZ_pEX(const CanonicalForm &f, const ZZ_pX &mipo)
CanonicalForm in Z_p(a)[X] to NTL ZZ_pEX.
Definition: NTLconvert.cc:1038
factory&#39;s main class
Definition: canonicalform.h:75
static unsigned long cf_stringtemp_l
Definition: NTLconvert.cc:478
assertions for Factory
CanonicalForm convertNTLzzpX2CF(const zz_pX &poly, const Variable &x)
Definition: NTLconvert.cc:251
ZZX convertFacCF2NTLZZX(const CanonicalForm &f)
Definition: NTLconvert.cc:687
int k
Definition: cfEzgcd.cc:93
Variable alpha
Definition: facAbsBiFact.cc:52
int columns() const
Definition: ftmpl_matrix.h:46
void insert(const T &)
Definition: ftmpl_list.cc:193
long intval() const
conversion functions
CFMatrix * convertNTLmat_zz_p2FacCFMatrix(const mat_zz_p &m)
Definition: NTLconvert.cc:1184
int getCharacteristic()
Definition: cf_char.cc:51
CF_NO_INLINE int hasTerms() const
check if iterator has reached < the end of CanonicalForm
CFFList convertNTLvec_pair_zzpEX_long2FacCFFList(const vec_pair_zz_pEX_long &e, const zz_pE &multi, const Variable &x, const Variable &alpha)
Definition: NTLconvert.cc:867
CFList conv(const CFFList &L)
convert a CFFList to a CFList by dropping the multiplicity
Definition: facBivar.cc:124
poly res
Definition: myNF.cc:322
CF_NO_INLINE CanonicalForm coeff() const
get the current coefficient
CanonicalForm convertNTLGF2E2CF(const GF2E &coefficient, const Variable &x)
NAME: convertNTLGF2E2CF.
Definition: NTLconvert.cc:929
mat_zz_p * convertFacCFMatrix2NTLmat_zz_p(const CFMatrix &m)
Definition: NTLconvert.cc:1168
CanonicalForm convertNTLZZ_pEX2CF(const ZZ_pEX &f, const Variable &x, const Variable &alpha)
Definition: NTLconvert.cc:1116
ZZ_pX convertFacCF2NTLZZpX(const CanonicalForm &f)
NAME: convertFacCF2NTLZZpX.
Definition: NTLconvert.cc:62
int j
Definition: myNF.cc:70
zz_pEX convertFacCF2NTLzz_pEX(const CanonicalForm &f, const zz_pX &mipo)
Definition: NTLconvert.cc:1065
#define Free(A, L)
Definition: NTLconvert.cc:39
virtual CanonicalForm coeff(int i)
CanonicalForm InternalCF::coeff ( int i )
Definition: int_cf.cc:120
int m
Definition: cfEzgcd.cc:119
Iterators for CanonicalForm&#39;s.
CanonicalForm mapinto() const
FILE * f
Definition: checklibs.c:7
int i
Definition: cfEzgcd.cc:123
factory switches.
#define Alloc(L)
Definition: NTLconvert.cc:38
declarations of higher level algorithms.
CanonicalForm convertNTLzz_pEX2CF(const zz_pEX &f, const Variable &x, const Variable &alpha)
Definition: NTLconvert.cc:1093
mat_ZZ * convertFacCFMatrix2NTLmat_ZZ(const CFMatrix &m)
Definition: NTLconvert.cc:1139
int rows() const
Definition: ftmpl_matrix.h:45
static BOOLEAN IsOne(number a, const coeffs r)
Definition: flintcf_Q.cc:363
class to iterate through CanonicalForm&#39;s
Definition: cf_iter.h:44
bool isImm() const
long intval() const
Definition: int_int.cc:533
const long MAXIMMEDIATE
Definition: imm.h:51
void out_cf(const char *s1, const CanonicalForm &f, const char *s2)
cf_algorithm.cc - simple mathematical algorithms.
Definition: cf_factor.cc:90
CF_NO_INLINE int exp() const
get the current exponent
zz_pX convertFacCF2NTLzzpX(const CanonicalForm &f)
Definition: NTLconvert.cc:103
Factor< CanonicalForm > CFFactor
void mpzval(mpz_t val) const
mat_zz_pE * convertFacCFMatrix2NTLmat_zz_pE(const CFMatrix &m)
Definition: NTLconvert.cc:1197
Variable x
Definition: cfModGcd.cc:4023
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.
Definition: NTLconvert.cc:822
CFMatrix * convertNTLmat_ZZ2FacCFMatrix(const mat_ZZ &m)
Definition: NTLconvert.cc:1154
static BOOLEAN IsZero(number a, const coeffs r)
Definition: flintcf_Q.cc:359
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
long fac_NTL_char
Definition: NTLconvert.cc:44
polyrec * poly
Definition: hilb.h:10
CanonicalForm convertZZ2CF(const ZZ &a)
NAME: convertZZ2CF.
Definition: NTLconvert.cc:492
CFMatrix * convertNTLmat_zz_pE2FacCFMatrix(const mat_zz_pE &m, const Variable &alpha)
Definition: NTLconvert.cc:1213
const poly b
Definition: syzextra.cc:213
CFFList convertNTLvec_pair_ZZX_long2FacCFFList(const vec_pair_ZZX_long &e, const ZZ &multi, const Variable &x)
NAME: convertNTLvec_pair_ZZX_long2FacCFFList.
Definition: NTLconvert.cc:749
CanonicalForm convertNTLZZX2CF(const ZZX &polynom, const Variable &x)
Definition: NTLconvert.cc:281
int l
Definition: cfEzgcd.cc:94
return result
Definition: facAbsBiFact.cc:76
CanonicalForm convertNTLGF2X2CF(const GF2X &poly, const Variable &x)
NAME: convertNTLGF2X2CF.
Definition: NTLconvert.cc:318
squarefree part and factorization over Q, Q(a)
Header for factory&#39;s main class CanonicalForm.
Factory&#39;s internal integers.