My Project
Loading...
Searching...
No Matches
FLINTconvert.cc
Go to the documentation of this file.
1/*****************************************************************************\
2 * Computer Algebra System SINGULAR
3\*****************************************************************************/
4/** @file FLINTconvert.cc
5 *
6 * This file implements functions for conversion to FLINT (www.flintlib.org)
7 * and back.
8 *
9 * @author Martin Lee
10 *
11 **/
12/*****************************************************************************/
13
14
15
16#include <config.h>
17
18
19#include "canonicalform.h"
20#include "fac_util.h"
21#include "cf_iter.h"
22#include "cf_factory.h"
23#include "gmpext.h"
24#include "singext.h"
25#include "cf_algorithm.h"
26
27#ifdef HAVE_OMALLOC
28#define Alloc(L) omAlloc(L)
29#define Free(A,L) omFreeSize(A,L)
30#else
31#define Alloc(L) malloc(L)
32#define Free(A,L) free(A)
33#endif
34
35#ifdef HAVE_FLINT
36#ifdef HAVE_CSTDIO
37#include <cstdio>
38#else
39#include <stdio.h>
40#endif
41#ifdef __cplusplus
42extern "C"
43{
44#endif
45#ifndef __GMP_BITS_PER_MP_LIMB
46#define __GMP_BITS_PER_MP_LIMB GMP_LIMB_BITS
47#endif
48#include <flint/fmpz.h>
49#include <flint/fmpq.h>
50#include <flint/fmpz_poly.h>
51#include <flint/fmpz_mod_poly.h>
52#include <flint/nmod_poly.h>
53#include <flint/fmpq_poly.h>
54#include <flint/nmod_mat.h>
55#include <flint/fmpz_mat.h>
56#if ( __FLINT_RELEASE >= 20400)
57#include <flint/fq.h>
58#include <flint/fq_poly.h>
59#include <flint/fq_nmod.h>
60#include <flint/fq_nmod_poly.h>
61#include <flint/fq_nmod_mat.h>
62#endif
63#if ( __FLINT_RELEASE >= 20503)
64#include <flint/fmpq_mpoly.h>
65#include <flint/fmpz_mod.h>
66
67// planed, but not yet in FLINT:
68#if (__FLINT_RELEASE < 20700)
69// helper for fq_nmod_t -> nmod_poly_t
71{
72 FLINT_ASSERT(b->mod.n == ctx->modulus->mod.n);
73 a->mod = ctx->modulus->mod;
74 nmod_poly_set(a, b);
75}
76#else
77#include <flint/fq_nmod_mpoly.h>
78#endif
79
80#if (__FLINT_RELEASE < 20700)
81// helper for nmod_poly_t -> fq_nmod_t
83{
84 FLINT_ASSERT(a->mod.n == b->mod.n);
85 FLINT_ASSERT(a->mod.n == ctx->modulus->mod.n);
86 nmod_poly_set(a, b);
88}
89#else
91 const fq_nmod_ctx_t ctx)
92{
93 FLINT_ASSERT(a->mod.n == b->mod.n);
94 FLINT_ASSERT(a->mod.n == ctx->modulus->mod.n);
95
96 if (b->length <= 2*(ctx->modulus->length - 1))
97 {
98 nmod_poly_set(a, b);
100 }
101 else
102 {
103 nmod_poly_rem(a, b, ctx->modulus);
104 }
105}
106#endif
107
108
109#endif
110#ifdef __cplusplus
111}
112#endif
113
114#include "FLINTconvert.h"
115
116// assumes result to be uninitialiazed
118{
119 if (f.isImm())
120 *result=f.intval();
121 else
122 {
124 f.mpzval(gmp_val);
128 }
129}
130
131// special version assuming result is already initialized
133{
134 if (f.isImm())
135 fmpz_set_si (result, f.intval());
136 else
137 {
139 f.mpzval(gmp_val);
140
143
145 }
146}
147
149{
152 for (CFIterator i= f; i.hasTerms(); i++)
153 convertCF2initFmpz (fmpz_poly_get_coeff_ptr(result, i.exp()), i.coeff()); // assumes initialized
154}
155
157{
161 {
162 long coeff= fmpz_get_si (coefficient);
163 return CanonicalForm (coeff);
164 }
165 else
166 {
171 return result;
172 }
173}
174
177{
179 fmpz* coeff;
180 for (int i= 0; i < fmpz_poly_length (poly); i++)
181 {
182 coeff= fmpz_poly_get_coeff_ptr (poly, i);
183 if (!fmpz_is_zero (coeff))
184 result += convertFmpz2CF (coeff)*power (x,i);
185 }
186 return result;
187}
188
189void
191{
195 for (CFIterator i= f; i.hasTerms(); i++)
196 {
197 CanonicalForm c= i.coeff();
198 if (!c.isImm()) c=c.mapinto(); //c%= getCharacteristic();
199 if (!c.isImm())
200 { //This case will never happen if the characteristic is in fact a prime
201 // number, since all coefficients are represented as immediates
202 printf("convertCF2nmod_poly_t: coefficient not immediate!, char=%d\n",
204 }
205 else
207 }
209}
210
213{
215 for (int i= 0; i < nmod_poly_length (poly); i++)
216 {
217 ulong coeff= nmod_poly_get_coeff_ui (poly, i);
218 if (coeff != 0)
219 result += CanonicalForm ((long)coeff)*power (x,i);
220 }
221 return result;
222}
223
225{
226 //ASSERT (isOn (SW_RATIONAL), "expected rational");
227 if (f.isImm ())
228 {
229 fmpq_set_si (result, f.intval(), 1);
230 }
231 else if(f.inQ())
232 {
240 }
241 else if(f.inZ())
242 {
244 f.mpzval(gmp_val);
248 }
249 else
250 {
251 printf("wrong type\n");
252 }
253}
254
256{
257 bool isRat= isOn (SW_RATIONAL);
258 if (!isRat)
259 On (SW_RATIONAL);
260
262 mpz_t nnum, nden;
263 mpz_init (nnum);
264 mpz_init (nden);
267
269 if (mpz_is_imm (nden))
270 {
271 if (mpz_is_imm(nnum))
272 {
275 mpz_clear (nnum);
276 mpz_clear (nden);
277 result= num/den;
278 }
279 else if (mpz_cmp_si(nden,1)==0)
280 {
282 mpz_clear (nden);
283 }
284 else
286 }
287 else
288 {
290 }
291 if (!isRat)
293 return result;
294}
295
298{
300 fmpq_t coeff;
301 long n= p->length;
302 for (long i= 0; i < n; i++)
303 {
304 fmpq_init (coeff);
305 fmpq_poly_get_coeff_fmpq (coeff, p, i);
306 if (fmpq_is_zero (coeff))
307 {
308 fmpq_clear (coeff);
309 continue;
310 }
311 result += convertFmpq2CF (coeff)*power (x, i);
312 fmpq_clear (coeff);
313 }
314 return result;
315}
316
318{
319 for (CFIterator i= f; i.hasTerms(); i++)
320 convertCF2initFmpz (&result[i.exp()], i.coeff()); // assumes initialized
321}
322
338
342 const Variable& x
343 )
344{
346 if (leadingCoeff != 1)
348
349 long i;
350
351 for (i = 0; i < fac->num; i++)
353 (nmod_poly_t &)fac->p[i],x),
354 fac->exp[i]));
355 return result;
356}
357
358#if __FLINT_RELEASE >= 20503
361 const fmpz_poly_factor_t fac, ///< [in] a nmod_poly_factor_t
362 const Variable& x ///< [in] variable the result should
363 ///< have
364 )
365
366{
368 long i;
369
370 result.append (CFFactor(convertFmpz2CF(&fac->c),1));
371
372 for (i = 0; i < fac->num; i++)
374 (fmpz_poly_t &)fac->p[i],x),
375 fac->exp[i]));
376 return result;
377}
378#endif
379
380#if __FLINT_RELEASE >= 20400
383 const Variable& x, const Variable& alpha,
385 )
386{
388
389 long i;
390
391 for (i = 0; i < fac->num; i++)
393 (fq_nmod_poly_t &)fac->poly[i], x, alpha, fq_con),
394 fac->exp[i]));
395 return result;
396}
397#endif
398
399void
401 const fmpz_t p)
402{
403 #if (__FLINT_RELEASE >= 20700)
407 #else
409 #endif
412 #if (__FLINT_RELEASE >= 20700)
415 #else
417 #endif
419}
420
423 const modpk& b)
424{
427 #if (__FLINT_RELEASE >= 20700)
430 convertCF2initFmpz (FLINTp, b.getpk()); // assumes initialized
435 #else
437 #endif
440 return b (result);
441}
442
443#if __FLINT_RELEASE >= 20400
444void
446 const fq_nmod_ctx_t ctx)
447{
450 #if __FLINT_RELEASE >= 20503
453 #endif
454 for (CFIterator i= f; i.hasTerms(); i++)
455 {
456 CanonicalForm c= i.coeff();
457 if (!c.isImm()) c=c.mapinto(); //c%= getCharacteristic();
458 if (!c.isImm())
459 { //This case will never happen if the characteristic is in fact a prime
460 // number, since all coefficients are represented as immediates
461 printf("convertFacCF2Fq_nmod_t: coefficient not immediate!, char=%d\n",
463 }
464 else
465 {
466 STICKYASSERT (i.exp() <= fq_nmod_ctx_degree(ctx), "convertFacCF2Fq_nmod_t: element is not reduced");
467 #if __FLINT_RELEASE >= 20503
468 nmod_poly_set_coeff_ui (res, i.exp(), c.intval());
469 #else
471 #endif
472 }
473 }
474 #if __FLINT_RELEASE >= 20503
477 #endif
479}
480
483{
484 return convertnmod_poly_t2FacCF (poly, alpha);
485}
486
487void
489{
492
493 for (CFIterator i= f; i.hasTerms(); i++)
494 {
495 ASSERT(i.exp() < result->length, "input is not reduced");
496 convertCF2initFmpz (fmpz_poly_get_coeff_ptr(result, i.exp()), i.coeff()); // assumes initialized
497 }
498
499 _fmpz_vec_scalar_mod_fmpz (result->coeffs, result->coeffs, result->length,
501
503}
504
507{
508 return convertFmpz_poly_t2FacCF (poly, alpha);
509}
510
511void
513 const fq_ctx_t ctx)
514{
516
518
519 for (CFIterator i= f; i.hasTerms(); i++)
520 {
521 fq_t buf;
522 convertFacCF2Fq_t (buf, i.coeff(), ctx);
523 fq_poly_set_coeff (result, i.exp(), buf, ctx);
524 fq_clear (buf, ctx);
525 }
526}
527
528void
530 const fq_nmod_ctx_t ctx)
531{
536 for (CFIterator i= f; i.hasTerms(); i++)
537 {
538 convertFacCF2Fq_nmod_t (buf, i.coeff(), ctx);
541 }
543}
544
547 const Variable& alpha, const fq_ctx_t ctx)
548{
550 fq_t coeff;
551 long n= fq_poly_length (p, ctx);
552 fq_init2 (coeff, ctx);
553 for (long i= 0; i < n; i++)
554 {
555 fq_poly_get_coeff (coeff, p, i, ctx);
556 if (fq_is_zero (coeff, ctx))
557 continue;
558 result += convertFq_t2FacCF (coeff, alpha)*power (x, i);
559 fq_zero (coeff, ctx);
560 }
561 fq_clear (coeff, ctx);
562
563 return result;
564}
565
568 const Variable& alpha, const fq_nmod_ctx_t ctx)
569{
571 fq_nmod_t coeff;
572 long n= fq_nmod_poly_length (p, ctx);
573 fq_nmod_init2 (coeff, ctx);
574 for (long i= 0; i < n; i++)
575 {
576 fq_nmod_poly_get_coeff (coeff, p, i, ctx);
577 if (fq_nmod_is_zero (coeff, ctx))
578 continue;
580 fq_nmod_zero (coeff, ctx);
581 }
582 fq_nmod_clear (coeff, ctx);
583
584 return result;
585}
586#endif
587
589{
590 fmpz_mat_init (M, (long) m.rows(), (long) m.columns());
591
592 int i,j;
593 for(i=m.rows();i>0;i--)
594 {
595 for(j=m.columns();j>0;j--)
596 {
597 convertCF2initFmpz (fmpz_mat_entry (M,i-1,j-1), m(i,j)); // assumes initialized
598 }
599 }
600}
602{
604 int i,j;
605 for(i=res->rows();i>0;i--)
606 {
607 for(j=res->columns();j>0;j--)
608 {
609 (*res)(i,j)=convertFmpz2CF(fmpz_mat_entry (m,i-1,j-1));
610 }
611 }
612 return res;
613}
614
616{
617 nmod_mat_init (M, (long) m.rows(), (long) m.columns(), getCharacteristic());
618
621 int i,j;
622 for(i=m.rows();i>0;i--)
623 {
624 for(j=m.columns();j>0;j--)
625 {
626 if(!(m(i,j)).isImm()) printf("convertFacCFMatrix2FLINTmat_zz_p: not imm.\n");
627 nmod_mat_entry (M,i-1,j-1)= (m(i,j)).intval();
628 }
629 }
631}
632
634{
636 int i,j;
637 for(i=res->rows();i>0;i--)
638 {
639 for(j=res->columns();j>0;j--)
640 {
641 (*res)(i,j)=CanonicalForm((long) nmod_mat_entry (m, i-1, j-1));
642 }
643 }
644 return res;
645}
646
647#if __FLINT_RELEASE >= 20400
648void
650 const fq_nmod_ctx_t fq_con, const CFMatrix &m)
651{
652 fq_nmod_mat_init (M, (long) m.rows(), (long) m.columns(), fq_con);
653 int i,j;
654 for(i=m.rows();i>0;i--)
655 {
656 for(j=m.columns();j>0;j--)
657 {
658 convertFacCF2nmod_poly_t (M->rows[i-1]+j-1, m (i,j));
659 }
660 }
661}
662
665 const fq_nmod_ctx_t& fq_con,
666 const Variable& alpha)
667{
670 int i,j;
671 for(i=res->rows();i>0;i--)
672 {
673 for(j=res->columns();j>0;j--)
674 {
676 alpha, fq_con);
677 }
678 }
679 return res;
680}
681#endif
682#if __FLINT_RELEASE >= 20503
684{
685 // assume f!=0
686 if ( ! f.inCoeffDomain() )
687 {
688 int l = f.level();
689 for ( CFIterator i = f; i.hasTerms(); i++ )
690 {
691 exp[N-l] = i.exp();
692 convFlint_RecPP( i.coeff(), exp, result, ctx, N );
693 }
694 exp[N-l] = 0;
695 }
696 else
697 {
698 int c=f.intval(); // with Off(SW_SYMMETRIC_FF): 0<=c<p
700 }
701}
702
704{
705 // assume f!=0
706 if ( ! f.inBaseDomain() )
707 {
708 int l = f.level();
709 for ( CFIterator i = f; i.hasTerms(); i++ )
710 {
711 exp[N-l] = i.exp();
712 convFlint_RecPP( i.coeff(), exp, result, ctx, N );
713 }
714 exp[N-l] = 0;
715 }
716 else
717 {
718 fmpq_t c;
719 fmpq_init(c);
720 convertCF2Fmpq(c,f);
722 fmpq_clear(c);
723 }
724}
725
727{
728 // assume f!=0
729 if ( ! f.inBaseDomain() )
730 {
731 int l = f.level();
732 for ( CFIterator i = f; i.hasTerms(); i++ )
733 {
734 exp[N-l] = i.exp();
735 convFlint_RecPP( i.coeff(), exp, result, ctx, N );
736 }
737 exp[N-l] = 0;
738 }
739 else
740 {
741 fmpz_t c;
742 fmpz_init(c);
743 convertCF2initFmpz(c,f); // assumes initialized
745 fmpz_clear(c);
746 }
747}
748
749#if __FLINT_RELEASE >= 20700
751{
752 // assume f!=0
753 if ( ! f.inCoeffDomain() )
754 {
755 int l = f.level();
756 for ( CFIterator i = f; i.hasTerms(); i++ )
757 {
758 exp[N-l] = i.exp();
759 convFlint_RecPP( i.coeff(), exp, result, ctx, N, fq_ctx );
760 }
761 exp[N-l] = 0;
762 }
763 else
764 {
765 fq_nmod_t c;
768 }
769}
770#endif
771
773{
774 if (f.isZero()) return;
775 ulong * exp = (ulong*)Alloc(N*sizeof(ulong));
776 memset(exp,0,N*sizeof(ulong));
779 convFlint_RecPP( f, exp, res, ctx, N );
781 Free(exp,N*sizeof(ulong));
782}
783
785{
786 if (f.isZero()) return;
787 ulong * exp = (ulong*)Alloc(N*sizeof(ulong));
788 memset(exp,0,N*sizeof(ulong));
789 convFlint_RecPP( f, exp, res, ctx, N );
791 Free(exp,N*sizeof(ulong));
792}
793
795{
796 if (f.isZero()) return;
797 ulong * exp = (ulong*)Alloc(N*sizeof(ulong));
798 memset(exp,0,N*sizeof(ulong));
799 convFlint_RecPP( f, exp, res, ctx, N );
800 //fmpz_mpoly_reduce(res,ctx);
801 Free(exp,N*sizeof(ulong));
802}
803
804#if __FLINT_RELEASE >= 20700
806{
807 if (f.isZero()) return;
808 ulong * exp = (ulong*)Alloc(N*sizeof(ulong));
809 memset(exp,0,N*sizeof(ulong));
814 Free(exp,N*sizeof(ulong));
815}
816#endif
817
819{
821 int d=nmod_mpoly_length(f,ctx)-1;
822 ulong* exp=(ulong*)Alloc(N*sizeof(ulong));
823 for(int i=d; i>=0; i--)
824 {
828 for ( int i = 0; i <N; i++ )
829 {
830 if (exp[i]!=0) term*=CanonicalForm( Variable( N-i ), exp[i] );
831 }
832 result+=term;
833 }
834 Free(exp,N*sizeof(ulong));
835 return result;
836}
837
839{
841 int d=fmpq_mpoly_length(f,ctx)-1;
842 ulong* exp=(ulong*)Alloc(N*sizeof(ulong));
843 fmpq_t c;
844 fmpq_init(c);
845 for(int i=d; i>=0; i--)
846 {
850 for ( int i = 0; i <N; i++ )
851 {
852 if (exp[i]!=0) term*=CanonicalForm( Variable( N-i ), exp[i] );
853 }
854 result+=term;
855 }
856 fmpq_clear(c);
857 Free(exp,N*sizeof(ulong));
858 return result;
859}
860
862{
864 int d=fmpz_mpoly_length(f,ctx)-1;
865 ulong* exp=(ulong*)Alloc(N*sizeof(ulong));
866 fmpz_t c;
867 fmpz_init(c);
868 for(int i=d; i>=0; i--)
869 {
873 for ( int i = 0; i <N; i++ )
874 {
875 if (exp[i]!=0) term*=CanonicalForm( Variable( N-i ), exp[i] );
876 }
877 result+=term;
878 }
879 fmpz_clear(c);
880 Free(exp,N*sizeof(ulong));
881 return result;
882}
883
884CanonicalForm mulFlintMP_Zp(const CanonicalForm& F,int lF, const CanonicalForm& G, int lG,int m)
885{
886 int bits=SI_LOG2(m)+1;
887 int N=F.level();
902 return RES;
903}
904
905CanonicalForm mulFlintMP_QQ(const CanonicalForm& F,int lF, const CanonicalForm& G, int lG, int m)
906{
907 int bits=SI_LOG2(m)+1;
908 int N=F.level();
923 return RES;
924}
925
927{
928 int N=F.level();
929 int lf,lg,m=1<<MPOLY_MIN_BITS;
930 lf=size_maxexp(F,m);
931 lg=size_maxexp(G,m);
932 int bits=SI_LOG2(m)+1;
941 int ok=nmod_mpoly_gcd(res,f,g,ctx);
945 if (ok)
946 {
948 }
951 return RES;
952}
953
954static CanonicalForm b_content ( const CanonicalForm & f )
955{
956 if ( f.inCoeffDomain() )
957 return f;
958 else
959 {
962 for ( i = f; i.hasTerms() && (!result.isOne()); i++ )
963 result=bgcd( b_content(i.coeff()) , result );
964 return result;
965 }
966}
967
968
970{
971 int N=F.level();
980 int ok=fmpq_mpoly_gcd(res,f,g,ctx);
984 if (ok)
985 {
986 // Flint normalizes the gcd to be monic.
987 // Singular wants a gcd defined over ZZ that is primitive and has a positive leading coeff.
989 {
995 }
997 // gcd(2x,4x) should be 2x, so RES should also have the gcd(lc(F),lc(G))
999 }
1002 return RES;
1003}
1004
1005#endif // FLINT 2.5.3
1006
1007#if __FLINT_RELEASE >= 20700
1008CFFList
1011 const fq_nmod_mpoly_ctx_t& ctx,
1012 const int N,
1013 const fq_nmod_ctx_t& fq_ctx,
1014 const Variable alpha)
1015{
1017
1018 long i;
1019
1020 fq_nmod_t c;
1025
1028 long exp;
1029 for (i = 0; i < fac->num; i++)
1030 {
1034 p,ctx,N,fq_ctx,alpha), exp));
1035 }
1037 return result;
1038}
1039
1040void
1042 const CanonicalForm& f,
1044 const int N,
1045 const fq_nmod_ctx_t fq_ctx
1046 )
1047{
1048 if (f.isZero()) return;
1049 ulong * exp = (ulong*)Alloc(N*sizeof(ulong));
1050 memset(exp,0,N*sizeof(ulong));
1052 Free(exp,N*sizeof(ulong));
1053}
1054
1057 const fq_nmod_mpoly_ctx_t& ctx,
1058 const int N,
1059 const fq_nmod_ctx_t& fq_ctx,
1060 const Variable alpha)
1061{
1063 int d=fq_nmod_mpoly_length(f,ctx)-1;
1064 ulong* exp=(ulong*)Alloc(N*sizeof(ulong));
1065 fq_nmod_t c;
1067 for(int i=d; i>=0; i--)
1068 {
1072 for ( int i = 0; i <N; i++ )
1073 {
1074 if (exp[i]!=0) term*=CanonicalForm( Variable( N-i ), exp[i] );
1075 }
1076 result+=term;
1077 }
1078 Free(exp,N*sizeof(ulong));
1079 return result;
1080}
1081
1082#endif
1083#endif // FLINT
void convertFacCFMatrix2Fmpz_mat_t(fmpz_mat_t M, const CFMatrix &m)
conversion of a factory matrix over Z to a fmpz_mat_t
CanonicalForm convertFq_poly_t2FacCF(const fq_poly_t p, const Variable &x, const Variable &alpha, const fq_ctx_t ctx)
conversion of a FLINT poly over Fq (for non-word size p) to a CanonicalForm with alg....
CFMatrix * convertFmpz_mat_t2FacCFMatrix(const fmpz_mat_t m)
conversion of a FLINT matrix over Z to a factory matrix
void convertFacCF2Fq_t(fq_t result, const CanonicalForm &f, const fq_ctx_t ctx)
conversion of a factory element of F_q (for non-word size p) to a FLINT fq_t
CFMatrix * convertNmod_mat_t2FacCFMatrix(const nmod_mat_t m)
conversion of a FLINT matrix over Z/p to a factory matrix
#define Free(A, L)
void convertFacCFMatrix2nmod_mat_t(nmod_mat_t M, const CFMatrix &m)
conversion of a factory matrix over Z/p to a nmod_mat_t
#define Alloc(L)
CanonicalForm convertFq_nmod_poly_t2FacCF(const fq_nmod_poly_t p, const Variable &x, const Variable &alpha, const fq_nmod_ctx_t ctx)
conversion of a FLINT poly over Fq to a CanonicalForm with alg. variable alpha and polynomial variabl...
CanonicalForm convertFmpz2CF(const fmpz_t coefficient)
conversion of a FLINT integer to CanonicalForm
CanonicalForm convertFq_t2FacCF(const fq_t poly, const Variable &alpha)
conversion of a FLINT element of F_q with non-word size p to a CanonicalForm with alg....
void convertFacCF2Fq_nmod_t(fq_nmod_t result, const CanonicalForm &f, const fq_nmod_ctx_t ctx)
conversion of a factory element of F_q to a FLINT fq_nmod_t, does not do any memory allocation for po...
CanonicalForm convertFmpq_poly_t2FacCF(const fmpq_poly_t p, const Variable &x)
conversion of a FLINT poly over Q to CanonicalForm
void convertFacCFMatrix2Fq_nmod_mat_t(fq_nmod_mat_t M, const fq_nmod_ctx_t fq_con, const CFMatrix &m)
conversion of a factory matrix over F_q to a fq_nmod_mat_t
CanonicalForm convertFmpz_mod_poly_t2FacCF(const fmpz_mod_poly_t poly, const Variable &x, const modpk &b)
conversion of a FLINT poly over Z/p (for non word size p) to a CanonicalForm over Z
void convertFacCF2Fmpz_array(fmpz *result, const CanonicalForm &f)
void convertFacCF2nmod_poly_t(nmod_poly_t result, const CanonicalForm &f)
conversion of a factory univariate polynomials over Z/p (for word size p) to nmod_poly_t
CFFList convertFLINTFq_nmod_poly_factor2FacCFFList(const fq_nmod_poly_factor_t fac, const Variable &x, const Variable &alpha, const fq_nmod_ctx_t fq_con)
conversion of a FLINT factorization over Fq (for word size p) to a CFFList
void convertCF2Fmpz(fmpz_t result, const CanonicalForm &f)
conversion of a factory integer to fmpz_t
void convertCF2Fmpq(fmpq_t result, const CanonicalForm &f)
conversion of a factory rationals to fmpq_t
CanonicalForm convertnmod_poly_t2FacCF(const nmod_poly_t poly, const Variable &x)
conversion of a FLINT poly over Z/p to CanonicalForm
void convertFacCF2Fmpz_mod_poly_t(fmpz_mod_poly_t result, const CanonicalForm &f, const fmpz_t p)
conversion of a factory univariate poly over Z to a FLINT poly over Z/p (for non word size p)
void convertFacCF2Fq_nmod_poly_t(fq_nmod_poly_t result, const CanonicalForm &f, const fq_nmod_ctx_t ctx)
conversion of a factory univariate poly over F_q to a FLINT fq_nmod_poly_t
CanonicalForm convertFmpz_poly_t2FacCF(const fmpz_poly_t poly, const Variable &x)
conversion of a FLINT poly over Z to CanonicalForm
CanonicalForm convertFq_nmod_t2FacCF(const fq_nmod_t poly, const Variable &alpha, const fq_nmod_ctx_t)
conversion of a FLINT element of F_q to a CanonicalForm with alg. variable alpha
CFFList convertFLINTnmod_poly_factor2FacCFFList(const nmod_poly_factor_t fac, const mp_limb_t leadingCoeff, const Variable &x)
conversion of a FLINT factorization over Z/p (for word size p) to a CFFList
CanonicalForm convertFmpq2CF(const fmpq_t q)
conversion of a FLINT rational to CanonicalForm
void convertFacCF2Fmpq_poly_t(fmpq_poly_t result, const CanonicalForm &f)
conversion of a factory univariate polynomials over Q to fmpq_poly_t
void convertFacCF2Fmpz_poly_t(fmpz_poly_t result, const CanonicalForm &f)
conversion of a factory univariate polynomial over Z to a fmpz_poly_t
void convertCF2initFmpz(fmpz_t result, const CanonicalForm &f)
conversion of a factory integer to fmpz_t(init.)
CFMatrix * convertFq_nmod_mat_t2FacCFMatrix(const fq_nmod_mat_t m, const fq_nmod_ctx_t &fq_con, const Variable &alpha)
conversion of a FLINT matrix over F_q to a factory matrix
void convertFacCF2Fq_poly_t(fq_poly_t result, const CanonicalForm &f, const fq_ctx_t ctx)
conversion of a factory univariate poly over F_q (for non-word size p) to a FLINT fq_poly_t
This file defines functions for conversion to FLINT (www.flintlib.org) and back.
CFFList convertFLINTfmpz_poly_factor2FacCFFList(const fmpz_poly_factor_t fac, const Variable &x)
conversion of a FLINT factorization over Z to a CFFList
CanonicalForm bgcd(const CanonicalForm &f, const CanonicalForm &g)
CanonicalForm bgcd ( const CanonicalForm & f, const CanonicalForm & g )
bool isOn(int sw)
switches
void On(int sw)
switches
void Off(int sw)
switches
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
Header for factory's main class CanonicalForm.
CanonicalForm FACTORY_PUBLIC content(const CanonicalForm &)
CanonicalForm content ( const CanonicalForm & f )
Definition cf_gcd.cc:603
int degree(const CanonicalForm &f)
int size_maxexp(const CanonicalForm &f, int &maxexp)
Definition cf_ops.cc:641
Matrix< CanonicalForm > CFMatrix
CanonicalForm num(const CanonicalForm &f)
CanonicalForm den(const CanonicalForm &f)
Factor< CanonicalForm > CFFactor
int FACTORY_PUBLIC getCharacteristic()
Definition cf_char.cc:70
const CanonicalForm CFMap CFMap & N
Definition cfEzgcd.cc:56
int l
Definition cfEzgcd.cc:100
int m
Definition cfEzgcd.cc:128
int i
Definition cfEzgcd.cc:132
Variable x
Definition cfModGcd.cc:4082
int p
Definition cfModGcd.cc:4078
g
Definition cfModGcd.cc:4090
CanonicalForm b
Definition cfModGcd.cc:4103
CanonicalForm bCommonDen(const CanonicalForm &f)
CanonicalForm bCommonDen ( const CanonicalForm & f )
declarations of higher level algorithms.
#define STICKYASSERT(expression, message)
Definition cf_assert.h:64
#define ASSERT(expression, message)
Definition cf_assert.h:99
static const int SW_RATIONAL
set to 1 for computations over Q
Definition cf_defs.h:31
static const int SW_SYMMETRIC_FF
set to 1 for symmetric representation over F_q
Definition cf_defs.h:33
Interface to generate InternalCF's over various domains from intrinsic types or mpz_t's.
Iterators for CanonicalForm's.
FILE * f
Definition checklibs.c:9
static InternalCF * basic(int value)
Definition cf_factory.cc:61
static InternalCF * rational(long num, long den)
class to iterate through CanonicalForm's
Definition cf_iter.h:44
factory's main class
long intval() const
conversion functions
int level() const
level() returns the level of CO.
bool isImm() const
CanonicalForm & mod(const CanonicalForm &)
CanonicalForm mapinto() const
int length() const
void append(const T &)
void insert(const T &)
factory's class for variables
Definition factory.h:127
class to do operations mod p^k for int's p and k
Definition fac_util.h:23
Variable alpha
return result
CanonicalForm res
Definition facAbsFact.cc:60
fq_nmod_ctx_t fq_con
Definition facHensel.cc:99
int j
Definition facHensel.cc:110
nmod_poly_init(FLINTmipo, getCharacteristic())
operations mod p^k and some other useful functions for factorization
void FACTORY_PUBLIC gmp_numerator(const CanonicalForm &f, mpz_ptr result)
Definition singext.cc:20
void FACTORY_PUBLIC gmp_denominator(const CanonicalForm &f, mpz_ptr result)
Definition singext.cc:40
utility functions for gmp
bool mpz_is_imm(const mpz_t mpi)
Definition gmpext.h:19
const long MAXIMMEDIATE
Definition imm.h:55
const long MINIMMEDIATE
Definition imm.h:54
STATIC_VAR TreeM * G
Definition janet.cc:31
gmp_float exp(const gmp_float &a)
static int SI_LOG2(int v)
Definition si_log2.h:6
int status int void * buf
Definition si_signals.h:59
helper functions for conversion to and from Singular
#define M
Definition sirandom.c:25