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#include "int_int.h"
28#include "int_rat.h"
29
30#ifdef HAVE_OMALLOC
31#define Alloc(L) omAlloc(L)
32#define Free(A,L) omFreeSize(A,L)
33#else
34#define Alloc(L) malloc(L)
35#define Free(A,L) free(A)
36#endif
37
38#ifdef HAVE_FLINT
39#ifdef HAVE_CSTDIO
40#include <cstdio>
41#else
42#include <stdio.h>
43#endif
44#ifdef __cplusplus
45extern "C"
46{
47#endif
48#ifndef __GMP_BITS_PER_MP_LIMB
49#define __GMP_BITS_PER_MP_LIMB GMP_LIMB_BITS
50#endif
51#include <flint/fmpz.h>
52#include <flint/fmpq.h>
53#include <flint/fmpz_poly.h>
54#include <flint/fmpz_mod_poly.h>
55#include <flint/nmod_poly.h>
56#include <flint/fmpq_poly.h>
57#include <flint/nmod_mat.h>
58#include <flint/fmpz_mat.h>
59#if ( __FLINT_RELEASE >= 20400)
60#include <flint/fq.h>
61#include <flint/fq_poly.h>
62#include <flint/fq_nmod.h>
63#include <flint/fq_nmod_poly.h>
64#include <flint/fq_nmod_mat.h>
65#endif
66#if ( __FLINT_RELEASE >= 20503)
67#include <flint/fmpq_mpoly.h>
68#include <flint/fmpz_mod.h>
69
70// planed, but not yet in FLINT:
71#if (__FLINT_RELEASE < 20700)
72// helper for fq_nmod_t -> nmod_poly_t
74{
75 FLINT_ASSERT(b->mod.n == ctx->modulus->mod.n);
76 a->mod = ctx->modulus->mod;
77 nmod_poly_set(a, b);
78}
79#else
80#include <flint/fq_nmod_mpoly.h>
81#endif
82
83#if (__FLINT_RELEASE < 20700)
84// helper for nmod_poly_t -> fq_nmod_t
86{
87 FLINT_ASSERT(a->mod.n == b->mod.n);
88 FLINT_ASSERT(a->mod.n == ctx->modulus->mod.n);
89 nmod_poly_set(a, b);
91}
92#elif (__FLINT_RELEASE < 30000)
94 const fq_nmod_ctx_t ctx)
95{
96 FLINT_ASSERT(a->mod.n == b->mod.n);
97 FLINT_ASSERT(a->mod.n == ctx->modulus->mod.n);
98
99 if (b->length <= 2*(ctx->modulus->length - 1))
100 {
101 nmod_poly_set(a, b);
103 }
104 else
105 {
106 nmod_poly_rem(a, b, ctx->modulus);
107 }
108}
109#endif
110
111
112#endif
113#ifdef __cplusplus
114}
115#endif
116
117#include "FLINTconvert.h"
118
119// assumes result to be uninitialiazed
121{
122 if (f.isImm())
123 *result=f.intval();
124 else
125 {
128 fmpz_set_mpz (result, fi->thempi);
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 mpz_set(_fmpz_promote(result),fi->thempi);
142 fi->deleteObject();
143 }
144}
145
147{
150 for (CFIterator i= f; i.hasTerms(); i++)
151 convertCF2initFmpz (fmpz_poly_get_coeff_ptr(result, i.exp()), i.coeff()); // assumes initialized
152}
153
157 {
158 long coeff= fmpz_get_si(coefficient);
159 return CanonicalForm(coeff);
160 }
161 else
162 {
167 return result;
168 }
169}
170
173{
175 fmpz* coeff;
176 for (int i= 0; i < fmpz_poly_length (poly); i++)
177 {
178 coeff= fmpz_poly_get_coeff_ptr(poly, i);
179 if (!fmpz_is_zero(coeff))
180 result += convertFmpz2CF(coeff)*power (x,i);
181 }
182 return result;
183}
184
185void
187{
191 for (CFIterator i= f; i.hasTerms(); i++)
192 {
193 CanonicalForm c= i.coeff();
194 if (!c.isImm()) c=c.mapinto(); //c%= getCharacteristic();
195 if (!c.isImm())
196 { //This case will never happen if the characteristic is in fact a prime
197 // number, since all coefficients are represented as immediates
198 printf("convertCF2nmod_poly_t: coefficient not immediate!, char=%d\n",
200 }
201 else
203 }
205}
206
209{
211 for (int i= 0; i < nmod_poly_length(poly); i++)
212 {
213 ulong coeff= nmod_poly_get_coeff_ui(poly, i);
214 if (coeff != 0)
215 result += CanonicalForm ((long)coeff)*power (x,i);
216 }
217 return result;
218}
219
221{
222 //ASSERT (isOn (SW_RATIONAL), "expected rational");
223 if (f.isImm ())
224 {
225 fmpq_set_si(result, f.intval(), 1);
226 }
227 else if(f.inQ())
228 {
229 InternalCF *fi=f.getval();
230 if (fi->levelcoeff() == RationalDomain)
231 {
234 }
235 else
236 {
244 }
245 fi->deleteObject();
246 }
247 else if(f.inZ()) /* and not isImm() */
248 {
250 fmpz_set_mpz (fmpq_numref (result), fi->thempi);
252 fi->deleteObject();
253 }
254 else
255 {
256 printf("wrong type\n");
257 }
258}
259
261{
262 bool isRat= isOn (SW_RATIONAL);
263 if (!isRat) On (SW_RATIONAL);
265 if (fmpz_is_one(fmpq_denref(q)))
266 {
268 {
269 long i=fmpz_get_si(fmpq_numref(q));
270 if (!isRat) Off (SW_RATIONAL);
271 return CanonicalForm(i);
272 }
273 mpz_t nnum;
274 mpz_init (nnum);
277 if (!isRat) Off (SW_RATIONAL);
278 return result;
279 }
280
282 mpz_t nnum, nden;
283 mpz_init (nnum);
284 mpz_init (nden);
287
289 if (!isRat) Off (SW_RATIONAL);
290 return result;
291}
292
295{
297 fmpq_t coeff;
298 long n= p->length;
299 for (long i= 0; i < n; i++)
300 {
301 fmpq_init (coeff);
302 fmpq_poly_get_coeff_fmpq (coeff, p, i);
303 if (fmpq_is_zero (coeff))
304 {
305 fmpq_clear (coeff);
306 continue;
307 }
308 result += convertFmpq2CF (coeff)*power (x, i);
309 fmpq_clear (coeff);
310 }
311 return result;
312}
313
315{
316 for (CFIterator i= f; i.hasTerms(); i++)
317 convertCF2initFmpz (&result[i.exp()], i.coeff()); // assumes initialized
318}
319
335
339 const Variable& x
340 )
341{
343 if (leadingCoeff != 1)
345
346 long i;
347
348 for (i = 0; i < fac->num; i++)
350 (nmod_poly_t &)fac->p[i],x),
351 fac->exp[i]));
352 return result;
353}
354
355#if __FLINT_RELEASE >= 20503
358 const fmpz_poly_factor_t fac, ///< [in] a nmod_poly_factor_t
359 const Variable& x ///< [in] variable the result should
360 ///< have
361 )
362
363{
365 long i;
366
367 result.append (CFFactor(convertFmpz2CF(&fac->c),1));
368
369 for (i = 0; i < fac->num; i++)
371 (fmpz_poly_t &)fac->p[i],x),
372 fac->exp[i]));
373 return result;
374}
375#endif
376
377#if __FLINT_RELEASE >= 20400
380 const Variable& x, const Variable& alpha,
382 )
383{
385
386 long i;
387
388 for (i = 0; i < fac->num; i++)
390 (fq_nmod_poly_t &)fac->poly[i], x, alpha, fq_con),
391 fac->exp[i]));
392 return result;
393}
394#endif
395
396void
398 const fmpz_t p)
399{
400 #if (__FLINT_RELEASE >= 20700)
404 #else
406 #endif
409 #if (__FLINT_RELEASE >= 20700)
412 #else
414 #endif
416}
417
420 const modpk& b)
421{
424 #if (__FLINT_RELEASE >= 20700)
427 convertCF2initFmpz (FLINTp, b.getpk()); // assumes initialized
432 #else
434 #endif
437 return b (result);
438}
439
440#if __FLINT_RELEASE >= 20400
441void
443 const fq_nmod_ctx_t ctx)
444{
447 #if __FLINT_RELEASE >= 20503
450 #endif
451 for (CFIterator i= f; i.hasTerms(); i++)
452 {
453 CanonicalForm c= i.coeff();
454 if (!c.isImm()) c=c.mapinto(); //c%= getCharacteristic();
455 if (!c.isImm())
456 { //This case will never happen if the characteristic is in fact a prime
457 // number, since all coefficients are represented as immediates
458 printf("convertFacCF2Fq_nmod_t: coefficient not immediate!, char=%d\n",
460 }
461 else
462 {
463 STICKYASSERT (i.exp() <= fq_nmod_ctx_degree(ctx), "convertFacCF2Fq_nmod_t: element is not reduced");
464 #if __FLINT_RELEASE >= 20503
465 nmod_poly_set_coeff_ui (res, i.exp(), c.intval());
466 #else
468 #endif
469 }
470 }
471 #if __FLINT_RELEASE >= 20503
474 #endif
476}
477
480{
481 return convertnmod_poly_t2FacCF (poly, alpha);
482}
483
484void
486{
489
490 for (CFIterator i= f; i.hasTerms(); i++)
491 {
492 ASSERT(i.exp() < result->length, "input is not reduced");
493 convertCF2initFmpz (fmpz_poly_get_coeff_ptr(result, i.exp()), i.coeff()); // assumes initialized
494 }
495
496 _fmpz_vec_scalar_mod_fmpz (result->coeffs, result->coeffs, result->length,
498
500}
501
504{
505 return convertFmpz_poly_t2FacCF (poly, alpha);
506}
507
508void
510 const fq_ctx_t ctx)
511{
513
515
516 for (CFIterator i= f; i.hasTerms(); i++)
517 {
518 fq_t buf;
519 convertFacCF2Fq_t (buf, i.coeff(), ctx);
520 fq_poly_set_coeff (result, i.exp(), buf, ctx);
521 fq_clear (buf, ctx);
522 }
523}
524
525void
527 const fq_nmod_ctx_t ctx)
528{
533 for (CFIterator i= f; i.hasTerms(); i++)
534 {
535 convertFacCF2Fq_nmod_t (buf, i.coeff(), ctx);
538 }
540}
541
544 const Variable& alpha, const fq_ctx_t ctx)
545{
547 fq_t coeff;
548 long n= fq_poly_length (p, ctx);
549 fq_init2 (coeff, ctx);
550 for (long i= 0; i < n; i++)
551 {
552 fq_poly_get_coeff (coeff, p, i, ctx);
553 if (fq_is_zero (coeff, ctx))
554 continue;
555 result += convertFq_t2FacCF (coeff, alpha)*power (x, i);
556 fq_zero (coeff, ctx);
557 }
558 fq_clear (coeff, ctx);
559
560 return result;
561}
562
565 const Variable& alpha, const fq_nmod_ctx_t ctx)
566{
568 fq_nmod_t coeff;
569 long n= fq_nmod_poly_length (p, ctx);
570 fq_nmod_init2 (coeff, ctx);
571 for (long i= 0; i < n; i++)
572 {
573 fq_nmod_poly_get_coeff (coeff, p, i, ctx);
574 if (fq_nmod_is_zero (coeff, ctx))
575 continue;
577 fq_nmod_zero (coeff, ctx);
578 }
579 fq_nmod_clear (coeff, ctx);
580
581 return result;
582}
583#endif
584
586{
587 fmpz_mat_init (M, (long) m.rows(), (long) m.columns());
588
589 int i,j;
590 for(i=m.rows();i>0;i--)
591 {
592 for(j=m.columns();j>0;j--)
593 {
594 convertCF2initFmpz (fmpz_mat_entry (M,i-1,j-1), m(i,j)); // assumes initialized
595 }
596 }
597}
599{
601 int i,j;
602 for(i=res->rows();i>0;i--)
603 {
604 for(j=res->columns();j>0;j--)
605 {
606 (*res)(i,j)=convertFmpz2CF(fmpz_mat_entry (m,i-1,j-1));
607 }
608 }
609 return res;
610}
611
613{
614 nmod_mat_init (M, (long) m.rows(), (long) m.columns(), getCharacteristic());
615
618 int i,j;
619 for(i=m.rows();i>0;i--)
620 {
621 for(j=m.columns();j>0;j--)
622 {
623 if(!(m(i,j)).isImm()) printf("convertFacCFMatrix2FLINTmat_zz_p: not imm.\n");
624 nmod_mat_entry (M,i-1,j-1)= (m(i,j)).intval();
625 }
626 }
628}
629
631{
633 int i,j;
634 for(i=res->rows();i>0;i--)
635 {
636 for(j=res->columns();j>0;j--)
637 {
638 (*res)(i,j)=CanonicalForm((long) nmod_mat_entry (m, i-1, j-1));
639 }
640 }
641 return res;
642}
643
644#if __FLINT_RELEASE >= 20400
645void
647 const fq_nmod_ctx_t fq_con, const CFMatrix &m)
648{
649 fq_nmod_mat_init (M, (long) m.rows(), (long) m.columns(), fq_con);
650 int i,j;
651 for(i=m.rows();i>0;i--)
652 {
653 for(j=m.columns();j>0;j--)
654 {
655 convertFacCF2nmod_poly_t (M->rows[i-1]+j-1, m (i,j));
656 }
657 }
658}
659
662 const fq_nmod_ctx_t& fq_con,
663 const Variable& alpha)
664{
667 int i,j;
668 for(i=res->rows();i>0;i--)
669 {
670 for(j=res->columns();j>0;j--)
671 {
673 alpha, fq_con);
674 }
675 }
676 return res;
677}
678#endif
679#if __FLINT_RELEASE >= 20503
681{
682 // assume f!=0
683 if ( ! f.inCoeffDomain() )
684 {
685 int l = f.level();
686 for ( CFIterator i = f; i.hasTerms(); i++ )
687 {
688 exp[N-l] = i.exp();
689 convFlint_RecPP( i.coeff(), exp, result, ctx, N );
690 }
691 exp[N-l] = 0;
692 }
693 else
694 {
695 int c=f.intval(); // with Off(SW_SYMMETRIC_FF): 0<=c<p
697 }
698}
699
701{
702 // assume f!=0
703 if ( ! f.inBaseDomain() )
704 {
705 int l = f.level();
706 for ( CFIterator i = f; i.hasTerms(); i++ )
707 {
708 exp[N-l] = i.exp();
709 convFlint_RecPP( i.coeff(), exp, result, ctx, N );
710 }
711 exp[N-l] = 0;
712 }
713 else
714 {
715 fmpq_t c;
716 fmpq_init(c);
717 convertCF2Fmpq(c,f);
719 fmpq_clear(c);
720 }
721}
722
724{
725 // assume f!=0
726 if ( ! f.inBaseDomain() )
727 {
728 int l = f.level();
729 for ( CFIterator i = f; i.hasTerms(); i++ )
730 {
731 exp[N-l] = i.exp();
732 convFlint_RecPP( i.coeff(), exp, result, ctx, N );
733 }
734 exp[N-l] = 0;
735 }
736 else
737 {
738 fmpz_t c;
739 fmpz_init(c);
740 convertCF2initFmpz(c,f); // assumes initialized
742 fmpz_clear(c);
743 }
744}
745
746#if __FLINT_RELEASE >= 20700
748{
749 // assume f!=0
750 if ( ! f.inCoeffDomain() )
751 {
752 int l = f.level();
753 for ( CFIterator i = f; i.hasTerms(); i++ )
754 {
755 exp[N-l] = i.exp();
756 convFlint_RecPP( i.coeff(), exp, result, ctx, N, fq_ctx );
757 }
758 exp[N-l] = 0;
759 }
760 else
761 {
762 fq_nmod_t c;
765 }
766}
767#endif
768
770{
771 if (f.isZero()) return;
772 ulong * exp = (ulong*)Alloc(N*sizeof(ulong));
773 memset(exp,0,N*sizeof(ulong));
776 convFlint_RecPP( f, exp, res, ctx, N );
778 Free(exp,N*sizeof(ulong));
779}
780
782{
783 if (f.isZero()) return;
784 ulong * exp = (ulong*)Alloc(N*sizeof(ulong));
785 memset(exp,0,N*sizeof(ulong));
786 convFlint_RecPP( f, exp, res, ctx, N );
788 Free(exp,N*sizeof(ulong));
789}
790
792{
793 if (f.isZero()) return;
794 ulong * exp = (ulong*)Alloc(N*sizeof(ulong));
795 memset(exp,0,N*sizeof(ulong));
796 convFlint_RecPP( f, exp, res, ctx, N );
797 //fmpz_mpoly_reduce(res,ctx);
798 Free(exp,N*sizeof(ulong));
799}
800
801#if __FLINT_RELEASE >= 20700
803{
804 if (f.isZero()) return;
805 ulong * exp = (ulong*)Alloc(N*sizeof(ulong));
806 memset(exp,0,N*sizeof(ulong));
811 Free(exp,N*sizeof(ulong));
812}
813#endif
814
816{
818 int d=nmod_mpoly_length(f,ctx)-1;
819 ulong* exp=(ulong*)Alloc(N*sizeof(ulong));
820 for(int i=d; i>=0; i--)
821 {
825 for ( int i = 0; i <N; i++ )
826 {
827 if (exp[i]!=0) term*=CanonicalForm( Variable( N-i ), exp[i] );
828 }
829 result+=term;
830 }
831 Free(exp,N*sizeof(ulong));
832 return result;
833}
834
836{
838 int d=fmpq_mpoly_length(f,ctx)-1;
839 ulong* exp=(ulong*)Alloc(N*sizeof(ulong));
840 fmpq_t c;
841 fmpq_init(c);
842 for(int i=d; i>=0; i--)
843 {
847 for ( int i = 0; i <N; i++ )
848 {
849 if (exp[i]!=0) term*=CanonicalForm( Variable( N-i ), exp[i] );
850 }
851 result+=term;
852 }
853 fmpq_clear(c);
854 Free(exp,N*sizeof(ulong));
855 return result;
856}
857
859{
861 int d=fmpz_mpoly_length(f,ctx)-1;
862 ulong* exp=(ulong*)Alloc(N*sizeof(ulong));
863 fmpz_t c;
864 fmpz_init(c);
865 for(int i=d; i>=0; i--)
866 {
870 for ( int i = 0; i <N; i++ )
871 {
872 if (exp[i]!=0) term*=CanonicalForm( Variable( N-i ), exp[i] );
873 }
874 result+=term;
875 }
876 fmpz_clear(c);
877 Free(exp,N*sizeof(ulong));
878 return result;
879}
880
881CanonicalForm mulFlintMP_Zp(const CanonicalForm& F,int lF, const CanonicalForm& G, int lG,int m)
882{
883 int bits=SI_LOG2(m)+1;
884 int N=F.level();
899 return RES;
900}
901
902CanonicalForm mulFlintMP_QQ(const CanonicalForm& F,int lF, const CanonicalForm& G, int lG, int m)
903{
904 int bits=SI_LOG2(m)+1;
905 int N=F.level();
920 return RES;
921}
922
924{
925 int N=F.level();
926 int lf,lg,m=1<<MPOLY_MIN_BITS;
927 lf=size_maxexp(F,m);
928 lg=size_maxexp(G,m);
929 int bits=SI_LOG2(m)+1;
938 int ok=nmod_mpoly_gcd(res,f,g,ctx);
942 if (ok)
943 {
945 }
948 return RES;
949}
950
951static CanonicalForm b_content ( const CanonicalForm & f )
952{
953 if ( f.inCoeffDomain() )
954 return f;
955 else
956 {
959 for ( i = f; i.hasTerms() && (!result.isOne()); i++ )
960 result=bgcd( b_content(i.coeff()) , result );
961 return result;
962 }
963}
964
965
967{
968 int N=F.level();
977 int ok=fmpq_mpoly_gcd(res,f,g,ctx);
981 if (ok)
982 {
983 // Flint normalizes the gcd to be monic.
984 // Singular wants a gcd defined over ZZ that is primitive and has a positive leading coeff.
986 {
992 }
994 // gcd(2x,4x) should be 2x, so RES should also have the gcd(lc(F),lc(G))
996 }
999 return RES;
1000}
1001
1002#endif // FLINT 2.5.3
1003
1004#if __FLINT_RELEASE >= 20700
1005CFFList
1008 const fq_nmod_mpoly_ctx_t& ctx,
1009 const int N,
1010 const fq_nmod_ctx_t& fq_ctx,
1011 const Variable alpha)
1012{
1014
1015 long i;
1016
1017 fq_nmod_t c;
1022
1025 long exp;
1026 for (i = 0; i < fac->num; i++)
1027 {
1031 p,ctx,N,fq_ctx,alpha), exp));
1032 }
1034 return result;
1035}
1036
1037void
1039 const CanonicalForm& f,
1041 const int N,
1042 const fq_nmod_ctx_t fq_ctx
1043 )
1044{
1045 if (f.isZero()) return;
1046 ulong * exp = (ulong*)Alloc(N*sizeof(ulong));
1047 memset(exp,0,N*sizeof(ulong));
1049 Free(exp,N*sizeof(ulong));
1050}
1051
1054 const fq_nmod_mpoly_ctx_t& ctx,
1055 const int N,
1056 const fq_nmod_ctx_t& fq_ctx,
1057 const Variable alpha)
1058{
1060 int d=fq_nmod_mpoly_length(f,ctx)-1;
1061 ulong* exp=(ulong*)Alloc(N*sizeof(ulong));
1062 fq_nmod_t c;
1064 for(int i=d; i>=0; i--)
1065 {
1069 for ( int i = 0; i <N; i++ )
1070 {
1071 if (exp[i]!=0) term*=CanonicalForm( Variable( N-i ), exp[i] );
1072 }
1073 result+=term;
1074 }
1075 Free(exp,N*sizeof(ulong));
1076 return result;
1077}
1078
1079#endif
1080#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
#define RationalDomain
Definition cf_defs.h:20
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
virtual class for internal CanonicalForm's
Definition int_cf.h:47
factory's class for integers
Definition int_int.h:56
static mpz_ptr MPQDEN(const InternalCF *const c)
Definition int_rat.h:143
static mpz_ptr MPQNUM(const InternalCF *const c)
Definition int_rat.h:138
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
Factory's internal integers.
Factory's internal rationals.
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