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#include <string.h>
19
20#include "canonicalform.h"
21#include "fac_util.h"
22#include "cf_iter.h"
23#include "cf_factory.h"
24#include "gmpext.h"
25#include "singext.h"
26#include "cf_algorithm.h"
27
28#ifdef HAVE_OMALLOC
29#define Alloc(L) omAlloc(L)
30#define Free(A,L) omFreeSize(A,L)
31#else
32#define Alloc(L) malloc(L)
33#define Free(A,L) free(A)
34#endif
35
36#ifdef HAVE_FLINT
37#ifdef HAVE_CSTDIO
38#include <cstdio>
39#else
40#include <stdio.h>
41#endif
42#ifdef __cplusplus
43extern "C"
44{
45#endif
46#ifndef __GMP_BITS_PER_MP_LIMB
47#define __GMP_BITS_PER_MP_LIMB GMP_LIMB_BITS
48#endif
49#include <flint/fmpz.h>
50#include <flint/fmpq.h>
51#include <flint/fmpz_poly.h>
52#include <flint/fmpz_mod_poly.h>
53#include <flint/nmod_poly.h>
54#include <flint/fmpq_poly.h>
55#include <flint/nmod_mat.h>
56#include <flint/fmpz_mat.h>
57#if ( __FLINT_RELEASE >= 20400)
58#include <flint/fq.h>
59#include <flint/fq_poly.h>
60#include <flint/fq_nmod.h>
61#include <flint/fq_nmod_poly.h>
62#include <flint/fq_nmod_mat.h>
63#endif
64#if ( __FLINT_RELEASE >= 20503)
65#include <flint/fmpq_mpoly.h>
66#include <flint/fmpz_mod.h>
67
68// planed, but not yet in FLINT:
69#if (__FLINT_RELEASE < 20700)
70// helper for fq_nmod_t -> nmod_poly_t
72{
73 FLINT_ASSERT(b->mod.n == ctx->modulus->mod.n);
74 a->mod = ctx->modulus->mod;
75 nmod_poly_set(a, b);
76}
77#else
78#include <flint/fq_nmod_mpoly.h>
79#endif
80
81#if (__FLINT_RELEASE < 20700)
82// helper for nmod_poly_t -> fq_nmod_t
84{
85 FLINT_ASSERT(a->mod.n == b->mod.n);
86 FLINT_ASSERT(a->mod.n == ctx->modulus->mod.n);
87 nmod_poly_set(a, b);
89}
90#elif (__FLINT_RELEASE < 30000)
92 const fq_nmod_ctx_t ctx)
93{
94 FLINT_ASSERT(a->mod.n == b->mod.n);
95 FLINT_ASSERT(a->mod.n == ctx->modulus->mod.n);
96
97 if (b->length <= 2*(ctx->modulus->length - 1))
98 {
99 nmod_poly_set(a, b);
101 }
102 else
103 {
104 nmod_poly_rem(a, b, ctx->modulus);
105 }
106}
107#endif
108
109
110#endif
111#ifdef __cplusplus
112}
113#endif
114
115#include "FLINTconvert.h"
116
117// assumes result to be uninitialiazed
119{
120 if (f.isImm())
121 *result=f.intval();
122 else
123 {
125 f.mpzval(gmp_val);
129 }
130}
131
132// special version assuming result is already initialized
134{
135 if (f.isImm())
136 fmpz_set_si (result, f.intval());
137 else
138 {
140 f.mpzval(gmp_val);
141
144
146 }
147}
148
150{
153 for (CFIterator i= f; i.hasTerms(); i++)
154 convertCF2initFmpz (fmpz_poly_get_coeff_ptr(result, i.exp()), i.coeff()); // assumes initialized
155}
156
158{
162 {
163 long coeff= fmpz_get_si (coefficient);
164 return CanonicalForm (coeff);
165 }
166 else
167 {
172 return result;
173 }
174}
175
178{
180 fmpz* coeff;
181 for (int i= 0; i < fmpz_poly_length (poly); i++)
182 {
183 coeff= fmpz_poly_get_coeff_ptr (poly, i);
184 if (!fmpz_is_zero (coeff))
185 result += convertFmpz2CF (coeff)*power (x,i);
186 }
187 return result;
188}
189
190void
192{
196 for (CFIterator i= f; i.hasTerms(); i++)
197 {
198 CanonicalForm c= i.coeff();
199 if (!c.isImm()) c=c.mapinto(); //c%= getCharacteristic();
200 if (!c.isImm())
201 { //This case will never happen if the characteristic is in fact a prime
202 // number, since all coefficients are represented as immediates
203 printf("convertCF2nmod_poly_t: coefficient not immediate!, char=%d\n",
205 }
206 else
208 }
210}
211
214{
216 for (int i= 0; i < nmod_poly_length (poly); i++)
217 {
218 ulong coeff= nmod_poly_get_coeff_ui (poly, i);
219 if (coeff != 0)
220 result += CanonicalForm ((long)coeff)*power (x,i);
221 }
222 return result;
223}
224
226{
227 //ASSERT (isOn (SW_RATIONAL), "expected rational");
228 if (f.isImm ())
229 {
230 fmpq_set_si (result, f.intval(), 1);
231 }
232 else if(f.inQ())
233 {
241 }
242 else if(f.inZ())
243 {
245 f.mpzval(gmp_val);
249 }
250 else
251 {
252 printf("wrong type\n");
253 }
254}
255
257{
258 bool isRat= isOn (SW_RATIONAL);
259 if (!isRat)
260 On (SW_RATIONAL);
261
263 mpz_t nnum, nden;
264 mpz_init (nnum);
265 mpz_init (nden);
268
270 if (mpz_is_imm (nden))
271 {
272 if (mpz_is_imm(nnum))
273 {
276 mpz_clear (nnum);
277 mpz_clear (nden);
278 result= num/den;
279 }
280 else if (mpz_cmp_si(nden,1)==0)
281 {
283 mpz_clear (nden);
284 }
285 else
287 }
288 else
289 {
291 }
292 if (!isRat)
294 return result;
295}
296
299{
301 fmpq_t coeff;
302 long n= p->length;
303 for (long i= 0; i < n; i++)
304 {
305 fmpq_init (coeff);
306 fmpq_poly_get_coeff_fmpq (coeff, p, i);
307 if (fmpq_is_zero (coeff))
308 {
309 fmpq_clear (coeff);
310 continue;
311 }
312 result += convertFmpq2CF (coeff)*power (x, i);
313 fmpq_clear (coeff);
314 }
315 return result;
316}
317
319{
320 for (CFIterator i= f; i.hasTerms(); i++)
321 convertCF2initFmpz (&result[i.exp()], i.coeff()); // assumes initialized
322}
323
339
343 const Variable& x
344 )
345{
347 if (leadingCoeff != 1)
349
350 long i;
351
352 for (i = 0; i < fac->num; i++)
354 (nmod_poly_t &)fac->p[i],x),
355 fac->exp[i]));
356 return result;
357}
358
359#if __FLINT_RELEASE >= 20503
362 const fmpz_poly_factor_t fac, ///< [in] a nmod_poly_factor_t
363 const Variable& x ///< [in] variable the result should
364 ///< have
365 )
366
367{
369 long i;
370
371 result.append (CFFactor(convertFmpz2CF(&fac->c),1));
372
373 for (i = 0; i < fac->num; i++)
375 (fmpz_poly_t &)fac->p[i],x),
376 fac->exp[i]));
377 return result;
378}
379#endif
380
381#if __FLINT_RELEASE >= 20400
384 const Variable& x, const Variable& alpha,
386 )
387{
389
390 long i;
391
392 for (i = 0; i < fac->num; i++)
394 (fq_nmod_poly_t &)fac->poly[i], x, alpha, fq_con),
395 fac->exp[i]));
396 return result;
397}
398#endif
399
400void
402 const fmpz_t p)
403{
404 #if (__FLINT_RELEASE >= 20700)
408 #else
410 #endif
413 #if (__FLINT_RELEASE >= 20700)
416 #else
418 #endif
420}
421
424 const modpk& b)
425{
428 #if (__FLINT_RELEASE >= 20700)
431 convertCF2initFmpz (FLINTp, b.getpk()); // assumes initialized
436 #else
438 #endif
441 return b (result);
442}
443
444#if __FLINT_RELEASE >= 20400
445void
447 const fq_nmod_ctx_t ctx)
448{
451 #if __FLINT_RELEASE >= 20503
454 #endif
455 for (CFIterator i= f; i.hasTerms(); i++)
456 {
457 CanonicalForm c= i.coeff();
458 if (!c.isImm()) c=c.mapinto(); //c%= getCharacteristic();
459 if (!c.isImm())
460 { //This case will never happen if the characteristic is in fact a prime
461 // number, since all coefficients are represented as immediates
462 printf("convertFacCF2Fq_nmod_t: coefficient not immediate!, char=%d\n",
464 }
465 else
466 {
467 STICKYASSERT (i.exp() <= fq_nmod_ctx_degree(ctx), "convertFacCF2Fq_nmod_t: element is not reduced");
468 #if __FLINT_RELEASE >= 20503
469 nmod_poly_set_coeff_ui (res, i.exp(), c.intval());
470 #else
472 #endif
473 }
474 }
475 #if __FLINT_RELEASE >= 20503
478 #endif
480}
481
484{
485 return convertnmod_poly_t2FacCF (poly, alpha);
486}
487
488void
490{
493
494 for (CFIterator i= f; i.hasTerms(); i++)
495 {
496 ASSERT(i.exp() < result->length, "input is not reduced");
497 convertCF2initFmpz (fmpz_poly_get_coeff_ptr(result, i.exp()), i.coeff()); // assumes initialized
498 }
499
500 _fmpz_vec_scalar_mod_fmpz (result->coeffs, result->coeffs, result->length,
502
504}
505
508{
509 return convertFmpz_poly_t2FacCF (poly, alpha);
510}
511
512void
514 const fq_ctx_t ctx)
515{
517
519
520 for (CFIterator i= f; i.hasTerms(); i++)
521 {
522 fq_t buf;
523 convertFacCF2Fq_t (buf, i.coeff(), ctx);
524 fq_poly_set_coeff (result, i.exp(), buf, ctx);
525 fq_clear (buf, ctx);
526 }
527}
528
529void
531 const fq_nmod_ctx_t ctx)
532{
537 for (CFIterator i= f; i.hasTerms(); i++)
538 {
539 convertFacCF2Fq_nmod_t (buf, i.coeff(), ctx);
542 }
544}
545
548 const Variable& alpha, const fq_ctx_t ctx)
549{
551 fq_t coeff;
552 long n= fq_poly_length (p, ctx);
553 fq_init2 (coeff, ctx);
554 for (long i= 0; i < n; i++)
555 {
556 fq_poly_get_coeff (coeff, p, i, ctx);
557 if (fq_is_zero (coeff, ctx))
558 continue;
559 result += convertFq_t2FacCF (coeff, alpha)*power (x, i);
560 fq_zero (coeff, ctx);
561 }
562 fq_clear (coeff, ctx);
563
564 return result;
565}
566
569 const Variable& alpha, const fq_nmod_ctx_t ctx)
570{
572 fq_nmod_t coeff;
573 long n= fq_nmod_poly_length (p, ctx);
574 fq_nmod_init2 (coeff, ctx);
575 for (long i= 0; i < n; i++)
576 {
577 fq_nmod_poly_get_coeff (coeff, p, i, ctx);
578 if (fq_nmod_is_zero (coeff, ctx))
579 continue;
581 fq_nmod_zero (coeff, ctx);
582 }
583 fq_nmod_clear (coeff, ctx);
584
585 return result;
586}
587#endif
588
590{
591 fmpz_mat_init (M, (long) m.rows(), (long) m.columns());
592
593 int i,j;
594 for(i=m.rows();i>0;i--)
595 {
596 for(j=m.columns();j>0;j--)
597 {
598 convertCF2initFmpz (fmpz_mat_entry (M,i-1,j-1), m(i,j)); // assumes initialized
599 }
600 }
601}
603{
605 int i,j;
606 for(i=res->rows();i>0;i--)
607 {
608 for(j=res->columns();j>0;j--)
609 {
610 (*res)(i,j)=convertFmpz2CF(fmpz_mat_entry (m,i-1,j-1));
611 }
612 }
613 return res;
614}
615
617{
618 nmod_mat_init (M, (long) m.rows(), (long) m.columns(), getCharacteristic());
619
622 int i,j;
623 for(i=m.rows();i>0;i--)
624 {
625 for(j=m.columns();j>0;j--)
626 {
627 if(!(m(i,j)).isImm()) printf("convertFacCFMatrix2FLINTmat_zz_p: not imm.\n");
628 nmod_mat_entry (M,i-1,j-1)= (m(i,j)).intval();
629 }
630 }
632}
633
635{
637 int i,j;
638 for(i=res->rows();i>0;i--)
639 {
640 for(j=res->columns();j>0;j--)
641 {
642 (*res)(i,j)=CanonicalForm((long) nmod_mat_entry (m, i-1, j-1));
643 }
644 }
645 return res;
646}
647
648#if __FLINT_RELEASE >= 20400
649void
651 const fq_nmod_ctx_t fq_con, const CFMatrix &m)
652{
653 fq_nmod_mat_init (M, (long) m.rows(), (long) m.columns(), fq_con);
654 int i,j;
655 for(i=m.rows();i>0;i--)
656 {
657 for(j=m.columns();j>0;j--)
658 {
659 convertFacCF2nmod_poly_t (M->rows[i-1]+j-1, m (i,j));
660 }
661 }
662}
663
666 const fq_nmod_ctx_t& fq_con,
667 const Variable& alpha)
668{
671 int i,j;
672 for(i=res->rows();i>0;i--)
673 {
674 for(j=res->columns();j>0;j--)
675 {
677 alpha, fq_con);
678 }
679 }
680 return res;
681}
682#endif
683#if __FLINT_RELEASE >= 20503
685{
686 // assume f!=0
687 if ( ! f.inCoeffDomain() )
688 {
689 int l = f.level();
690 for ( CFIterator i = f; i.hasTerms(); i++ )
691 {
692 exp[N-l] = i.exp();
693 convFlint_RecPP( i.coeff(), exp, result, ctx, N );
694 }
695 exp[N-l] = 0;
696 }
697 else
698 {
699 int c=f.intval(); // with Off(SW_SYMMETRIC_FF): 0<=c<p
701 }
702}
703
705{
706 // assume f!=0
707 if ( ! f.inBaseDomain() )
708 {
709 int l = f.level();
710 for ( CFIterator i = f; i.hasTerms(); i++ )
711 {
712 exp[N-l] = i.exp();
713 convFlint_RecPP( i.coeff(), exp, result, ctx, N );
714 }
715 exp[N-l] = 0;
716 }
717 else
718 {
719 fmpq_t c;
720 fmpq_init(c);
721 convertCF2Fmpq(c,f);
723 fmpq_clear(c);
724 }
725}
726
728{
729 // assume f!=0
730 if ( ! f.inBaseDomain() )
731 {
732 int l = f.level();
733 for ( CFIterator i = f; i.hasTerms(); i++ )
734 {
735 exp[N-l] = i.exp();
736 convFlint_RecPP( i.coeff(), exp, result, ctx, N );
737 }
738 exp[N-l] = 0;
739 }
740 else
741 {
742 fmpz_t c;
743 fmpz_init(c);
744 convertCF2initFmpz(c,f); // assumes initialized
746 fmpz_clear(c);
747 }
748}
749
750#if __FLINT_RELEASE >= 20700
752{
753 // assume f!=0
754 if ( ! f.inCoeffDomain() )
755 {
756 int l = f.level();
757 for ( CFIterator i = f; i.hasTerms(); i++ )
758 {
759 exp[N-l] = i.exp();
760 convFlint_RecPP( i.coeff(), exp, result, ctx, N, fq_ctx );
761 }
762 exp[N-l] = 0;
763 }
764 else
765 {
766 fq_nmod_t c;
769 }
770}
771#endif
772
774{
775 if (f.isZero()) return;
776 ulong * exp = (ulong*)Alloc(N*sizeof(ulong));
777 memset(exp,0,N*sizeof(ulong));
780 convFlint_RecPP( f, exp, res, ctx, N );
782 Free(exp,N*sizeof(ulong));
783}
784
786{
787 if (f.isZero()) return;
788 ulong * exp = (ulong*)Alloc(N*sizeof(ulong));
789 memset(exp,0,N*sizeof(ulong));
790 convFlint_RecPP( f, exp, res, ctx, N );
792 Free(exp,N*sizeof(ulong));
793}
794
796{
797 if (f.isZero()) return;
798 ulong * exp = (ulong*)Alloc(N*sizeof(ulong));
799 memset(exp,0,N*sizeof(ulong));
800 convFlint_RecPP( f, exp, res, ctx, N );
801 //fmpz_mpoly_reduce(res,ctx);
802 Free(exp,N*sizeof(ulong));
803}
804
805#if __FLINT_RELEASE >= 20700
807{
808 if (f.isZero()) return;
809 ulong * exp = (ulong*)Alloc(N*sizeof(ulong));
810 memset(exp,0,N*sizeof(ulong));
815 Free(exp,N*sizeof(ulong));
816}
817#endif
818
820{
822 int d=nmod_mpoly_length(f,ctx)-1;
823 ulong* exp=(ulong*)Alloc(N*sizeof(ulong));
824 for(int i=d; i>=0; i--)
825 {
829 for ( int i = 0; i <N; i++ )
830 {
831 if (exp[i]!=0) term*=CanonicalForm( Variable( N-i ), exp[i] );
832 }
833 result+=term;
834 }
835 Free(exp,N*sizeof(ulong));
836 return result;
837}
838
840{
842 int d=fmpq_mpoly_length(f,ctx)-1;
843 ulong* exp=(ulong*)Alloc(N*sizeof(ulong));
844 fmpq_t c;
845 fmpq_init(c);
846 for(int i=d; i>=0; i--)
847 {
851 for ( int i = 0; i <N; i++ )
852 {
853 if (exp[i]!=0) term*=CanonicalForm( Variable( N-i ), exp[i] );
854 }
855 result+=term;
856 }
857 fmpq_clear(c);
858 Free(exp,N*sizeof(ulong));
859 return result;
860}
861
863{
865 int d=fmpz_mpoly_length(f,ctx)-1;
866 ulong* exp=(ulong*)Alloc(N*sizeof(ulong));
867 fmpz_t c;
868 fmpz_init(c);
869 for(int i=d; i>=0; i--)
870 {
874 for ( int i = 0; i <N; i++ )
875 {
876 if (exp[i]!=0) term*=CanonicalForm( Variable( N-i ), exp[i] );
877 }
878 result+=term;
879 }
880 fmpz_clear(c);
881 Free(exp,N*sizeof(ulong));
882 return result;
883}
884
885CanonicalForm mulFlintMP_Zp(const CanonicalForm& F,int lF, const CanonicalForm& G, int lG,int m)
886{
887 int bits=SI_LOG2(m)+1;
888 int N=F.level();
903 return RES;
904}
905
906CanonicalForm mulFlintMP_QQ(const CanonicalForm& F,int lF, const CanonicalForm& G, int lG, int m)
907{
908 int bits=SI_LOG2(m)+1;
909 int N=F.level();
924 return RES;
925}
926
928{
929 int N=F.level();
930 int lf,lg,m=1<<MPOLY_MIN_BITS;
931 lf=size_maxexp(F,m);
932 lg=size_maxexp(G,m);
933 int bits=SI_LOG2(m)+1;
942 int ok=nmod_mpoly_gcd(res,f,g,ctx);
946 if (ok)
947 {
949 }
952 return RES;
953}
954
955static CanonicalForm b_content ( const CanonicalForm & f )
956{
957 if ( f.inCoeffDomain() )
958 return f;
959 else
960 {
963 for ( i = f; i.hasTerms() && (!result.isOne()); i++ )
964 result=bgcd( b_content(i.coeff()) , result );
965 return result;
966 }
967}
968
969
971{
972 int N=F.level();
981 int ok=fmpq_mpoly_gcd(res,f,g,ctx);
985 if (ok)
986 {
987 // Flint normalizes the gcd to be monic.
988 // Singular wants a gcd defined over ZZ that is primitive and has a positive leading coeff.
990 {
996 }
998 // gcd(2x,4x) should be 2x, so RES should also have the gcd(lc(F),lc(G))
1000 }
1003 return RES;
1004}
1005
1006#endif // FLINT 2.5.3
1007
1008#if __FLINT_RELEASE >= 20700
1009CFFList
1012 const fq_nmod_mpoly_ctx_t& ctx,
1013 const int N,
1014 const fq_nmod_ctx_t& fq_ctx,
1015 const Variable alpha)
1016{
1018
1019 long i;
1020
1021 fq_nmod_t c;
1026
1029 long exp;
1030 for (i = 0; i < fac->num; i++)
1031 {
1035 p,ctx,N,fq_ctx,alpha), exp));
1036 }
1038 return result;
1039}
1040
1041void
1043 const CanonicalForm& f,
1045 const int N,
1046 const fq_nmod_ctx_t fq_ctx
1047 )
1048{
1049 if (f.isZero()) return;
1050 ulong * exp = (ulong*)Alloc(N*sizeof(ulong));
1051 memset(exp,0,N*sizeof(ulong));
1053 Free(exp,N*sizeof(ulong));
1054}
1055
1058 const fq_nmod_mpoly_ctx_t& ctx,
1059 const int N,
1060 const fq_nmod_ctx_t& fq_ctx,
1061 const Variable alpha)
1062{
1064 int d=fq_nmod_mpoly_length(f,ctx)-1;
1065 ulong* exp=(ulong*)Alloc(N*sizeof(ulong));
1066 fq_nmod_t c;
1068 for(int i=d; i>=0; i--)
1069 {
1073 for ( int i = 0; i <N; i++ )
1074 {
1075 if (exp[i]!=0) term*=CanonicalForm( Variable( N-i ), exp[i] );
1076 }
1077 result+=term;
1078 }
1079 Free(exp,N*sizeof(ulong));
1080 return result;
1081}
1082
1083#endif
1084#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:4090
int p
Definition cfModGcd.cc:4086
g
Definition cfModGcd.cc:4098
CanonicalForm b
Definition cfModGcd.cc:4111
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:69
helper functions for conversion to and from Singular
#define M
Definition sirandom.c:25