My Project
Loading...
Searching...
No Matches
flintconv.cc
Go to the documentation of this file.
1// emacs edit mode for this file is -*- C++ -*-
2/****************************************
3* Computer Algebra System SINGULAR *
4****************************************/
5/*
6* ABSTRACT: convert data between Singular and Flint
7*/
8
9
10
11#include "misc/auxiliary.h"
12#include "flintconv.h"
13
14#ifdef HAVE_FLINT
15#if __FLINT_RELEASE >= 20500
16
17#include "coeffs/coeffs.h"
18#include "coeffs/longrat.h"
19#include "coeffs/rintegers.h"
21
22#include "polys/sbuckets.h"
23//#include "polys/clapconv.h"
24
25#include "simpleideals.h"
26
27
28int convFlintISingI (fmpz_t f)
29{
30 //return fmpz_get_si(f);
31 return (int)*f;
32}
33
34void convSingIFlintI(fmpz_t f, int p)
35{
36 fmpz_init(f);
37 *f=p;
38 //fmpz_set_si(f,p);
39 return;
40}
41
42void convFlintNSingN (mpz_t z, fmpz_t f)
43{
44 mpz_init(z);
45 fmpz_get_mpz(z,f);
46}
47
48number convFlintNSingN (fmpz_t f)
49{
50#if __FLINT_RELEASE > 20502
51 number z;
52 if(COEFF_IS_MPZ(*f))
53 nlMPZ(COEFF_TO_PTR(*f),z,NULL);
54 else
55 {
56 mpz_t a;
57 mpz_init(a);
58 fmpz_get_mpz(a,f);
59 nlMPZ(a,z,NULL);
60 mpz_clear(a);
61 }
62 return z;
63#else
64 WerrorS("not implemented");
65 return NULL;
66#endif
67}
68
69number convFlintNSingN (fmpq_t f, const coeffs cf)
70{
71#if __FLINT_RELEASE > 20502
72 if (getCoeffType(cf)==n_Q) /* QQ, bigint */
73 {
74 return convFlintNSingN_QQ(f,cf);
75 }
76 else
77 {
78 number z;
79 mpz_t a,b;
80 mpz_init(a);
81 mpz_init(b);
82 fmpq_get_mpz_frac(a,b,f);
83 if (mpz_cmp_si(b,1L)!=0)
84 {
85 number na=n_InitMPZ(a,cf);
86 number nb=n_InitMPZ(b,cf);
87 z=n_Div(na,nb,cf);
88 n_Delete(&nb,cf);
89 n_Delete(&na,cf);
90 n_Normalize(z,cf);
91 }
92 else
93 {
94 z=n_InitMPZ(a,cf);
95 }
96 mpz_clear(a);
97 mpz_clear(b);
98 n_Test(z,cf);
99 return z;
100 }
101#else
102 WerrorS("not implemented");
103 return NULL;
104#endif
105}
106
107number convFlintNSingN (fmpz_t f, const coeffs cf)
108{
109#if __FLINT_RELEASE > 20502
110 number z;
111 if(COEFF_IS_MPZ(*f))
112 z=n_InitMPZ(COEFF_TO_PTR(*f),cf);
113 else if (cf->rep==n_rep_gmp)
114 {
115 z=nrzInit(1,NULL); // alloc and initialization
116 fmpz_get_mpz((mpz_ptr)z,f);
117 }
118 else
119 {
120 if (fmpz_fits_si(f))
121 {
122 long i=fmpz_get_si(f);
123 z=n_Init(i,cf);
124 }
125 else
126 {
127 mpz_t a;
128 mpz_init(a);
129 fmpz_get_mpz(a,f);
130 z=n_InitMPZ(a,cf);
131 mpz_clear(a);
132 }
133 }
134 return z;
135#else
136 WerrorS("not implemented");
137 return NULL;
138#endif
139}
140
141number convFlintNSingN_QQ (fmpq_t f, const coeffs cf)
142{
143#if __FLINT_RELEASE > 20502
144 if (fmpz_is_one(fmpq_denref(f)))
145 {
146 if (fmpz_fits_si(fmpq_numref(f)))
147 {
148 long i=fmpz_get_si(fmpq_numref(f));
149 return n_Init(i,cf);
150 }
151 }
152 number z=ALLOC_RNUMBER();
153 #if defined(LDEBUG)
154 z->debug=123456;
155 #endif
156 mpz_init(z->z);
157 if (fmpz_is_one(fmpq_denref(f)))
158 {
159 z->s=3;
160 fmpz_get_mpz(z->z,fmpq_numref(f));
161 }
162 else
163 {
164 z->s=0;
165 mpz_init(z->n);
166 fmpq_get_mpz_frac(z->z,z->n,f);
167 }
168 return z;
169#else
170 WerrorS("not implemented");
171 return NULL;
172#endif
173}
174
175void convSingNFlintN(fmpz_t f, mpz_t n)
176{
177 fmpz_init(f);
178 fmpz_set_mpz(f,n);
179}
180
181void convSingNFlintN(fmpz_t f, number n)
182{
183 fmpz_init(f);
184 fmpz_set_mpz(f,(mpz_ptr)n);
185}
186
187void convSingNFlintN(fmpq_t f, number n, const coeffs cf)
188{
189 if (LIKELY(getCoeffType(cf)==n_Q)) /* QQ, bigint */
190 {
191 fmpq_init(f);
192 if (SR_HDL(n)&SR_INT)
193 fmpq_set_si(f,SR_TO_INT(n),1);
194 else if (n->s<3)
195 {
196 fmpz_set_mpz(fmpq_numref(f), n->z);
197 fmpz_set_mpz(fmpq_denref(f), n->n);
198 }
199 else
200 {
201 fmpz_set_mpz(fmpq_numref(f), n->z);
202 fmpz_set_si(fmpq_denref(f), 1);
203 }
204 }
205 else
206 {
208 nMapFunc nMap=n_SetMap(cf,QQ);
209 if (nMap!=NULL)
210 {
211 number nn=nMap(n,cf,QQ);
212 convSingNFlintN(f,nn,QQ);
213 }
214 nKillChar(QQ);
215 }
216}
217
218void convSingNFlintN_QQ(fmpq_t f, number n)
219{
220 fmpq_init(f);
221 if (SR_HDL(n)&SR_INT)
222 fmpq_set_si(f,SR_TO_INT(n),1);
223 else if (n->s<3)
224 {
225 fmpz_set_mpz(fmpq_numref(f), n->z);
226 fmpz_set_mpz(fmpq_denref(f), n->n);
227 }
228 else
229 {
230 mpz_t one;
231 mpz_init_set_si(one,1);
232 fmpz_set_mpz(fmpq_numref(f), n->z);
233 fmpz_set_mpz(fmpq_denref(f), one);
234 mpz_clear(one);
235 }
236}
237
238void convSingNFlintNN(fmpq_t re, fmpq_t im, number n, const coeffs cf)
239{
240 number n_2=n_RePart(n,cf);
241 convSingNFlintN(re,n_2,cf);
242 n_Delete(&n_2,cf);
243 n_2=n_ImPart(n,cf);
244 convSingNFlintN(im,n_2,cf);
245 n_Delete(&n_2,cf);
246}
247
248void convSingPFlintP(fmpq_poly_t res, poly p, const ring r)
249{
250 if (p==NULL)
251 {
252 fmpq_poly_init(res);
253 return;
254 }
255 int d=p_GetExp(p,1,r);
256 fmpq_poly_init2(res,d+1);
257 _fmpq_poly_set_length (res, d + 1);
258 while(p!=NULL)
259 {
260 number n=pGetCoeff(p);
261 fmpq_t c;
262 convSingNFlintN(c,n,r->cf);
263 fmpq_poly_set_coeff_fmpq(res,p_GetExp(p,1,r),c);
264 fmpq_clear(c);
265 pIter(p);
266 }
267}
268
269void convSingImPFlintP(fmpq_poly_t res, poly p, const ring r)
270{
271 int d=p_GetExp(p,1,r);
272 fmpq_poly_init2(res,d+1);
273 _fmpq_poly_set_length (res, d + 1);
274 while(p!=NULL)
275 {
276 number n=n_ImPart(pGetCoeff(p),r->cf);
277 fmpq_t c;
278 convSingNFlintN(c,n,r->cf);
279 fmpq_poly_set_coeff_fmpq(res,p_GetExp(p,1,r),c);
280 fmpq_clear(c);
281 n_Delete(&n,r->cf);
282 pIter(p);
283 }
284}
285
286poly convFlintPSingP(fmpq_poly_t f, const ring r)
287{
288 if (fmpq_poly_is_zero(f)) return NULL;
289 int d=fmpq_poly_length(f);
290 poly p=NULL;
291 fmpq_t c;
292 fmpq_init(c);
293 for(int i=0; i<=d; i++)
294 {
295 fmpq_poly_get_coeff_fmpq(c,f,i);
296 number n=convFlintNSingN(c,r->cf);
297 if(!n_IsZero(n,r->cf))
298 {
299 poly pp=p_Init(r);
300 pSetCoeff0(pp,n);
301 p_SetExp(pp,1,i,r);
302 p_Setm(pp,r);
303 p=p_Add_q(p,pp,r);
304 }
305 }
306 fmpq_clear(c);
307 p_Test(p,r);
308 return p;
309}
310
311void convSingPFlintnmod_poly_t(nmod_poly_t result, const poly p, const ring r)
312{
313 // assume univariate, r->cf=Z/p
314 nmod_poly_init2 (result,rChar(r),p_Deg(p,r));
315 poly h=p;
316 while(h!=NULL)
317 {
318 if (h==NULL)
319 nmod_poly_set_coeff_ui(result,0,0);
320 else
321 nmod_poly_set_coeff_ui(result,p_GetExp(h,1,r),n_Int(pGetCoeff(h),r->cf)+rChar(r));
322 pIter(h);
323 }
324}
325
326void convSingMFlintFq_nmod_mat(matrix m, fq_nmod_mat_t M, const fq_nmod_ctx_t fq_con, const ring r)
327{
328 fq_nmod_mat_init (M, (long)MATROWS(m), (long) MATCOLS(m), fq_con);
329 int i,j;
330 for(i=MATROWS(m);i>0;i--)
331 {
332 for(j=MATCOLS(m);j>0;j--)
333 {
334 convSingPFlintnmod_poly_t (M->rows[i-1]+j-1, MATELEM(m,i,j),r);
335 }
336 }
337}
338
339poly convFlintFq_nmodSingP(const fq_nmod_t Fp, const fq_nmod_ctx_t ctx, const ring r)
340{
341 poly p=NULL;
342 poly h;
343 for (int i= 0; i < nmod_poly_length (Fp); i++)
344 {
345 ulong coeff= nmod_poly_get_coeff_ui (Fp, i);
346 if (coeff != 0)
347 h=p_NSet(n_Init(coeff,r->cf),r);
348 if (h!=NULL)
349 {
350 p_SetExp(h,1,i,r);
351 p_Setm(h,r);
352 p=p_Add_q(p,h,r);
353 }
354 }
355 return p;
356}
357
358matrix convFlintFq_nmod_matSingM(fq_nmod_mat_t m, const fq_nmod_ctx_t fq_con, const ring r)
359{
360 matrix M=mpNew(fq_nmod_mat_nrows (m, fq_con),fq_nmod_mat_ncols (m, fq_con));
361 int i,j;
362 for(i=MATROWS(M);i>0;i--)
363 {
364 for(j=MATCOLS(M);j>0;j--)
365 {
366 MATELEM(M,i,j)=convFlintFq_nmodSingP(fq_nmod_mat_entry (m, i-1, j-1),
367 fq_con, r);
368 }
369 }
370 return M;
371}
372
373void convSingMFlintNmod_mat(matrix m, nmod_mat_t M, const ring r)
374{
375 nmod_mat_init (M, (long)MATROWS(m), (long) MATCOLS(m), rChar(r));
376 int i,j;
377 for(i=MATROWS(m);i>0;i--)
378 {
379 for(j=MATCOLS(m);j>0;j--)
380 {
381 poly h=MATELEM(m,i,j);
382 if (h!=NULL)
383 nmod_mat_entry(M,i-1,j-1)=(long)pGetCoeff(h);
384 }
385 }
386}
387
388matrix convFlintNmod_matSingM(nmod_mat_t m, const ring r)
389{
390 matrix M=mpNew(nmod_mat_nrows (m),nmod_mat_ncols (m));
391 int i,j;
392 for(i=MATROWS(M);i>0;i--)
393 {
394 for(j=MATCOLS(M);j>0;j--)
395 {
396 MATELEM(M,i,j)=p_ISet(nmod_mat_entry (m, i-1, j-1),r);
397 }
398 }
399 return M;
400}
401
402matrix singflint_rref(matrix m, const ring R)
403{
404 int r=m->rows();
405 int c=m->cols();
406 int i,j;
407 matrix M=NULL;
408 if (rField_is_Q(R))
409 {
410 fmpq_mat_t FLINTM;
411 fmpq_mat_init(FLINTM,r,c);
412 M=mpNew(r,c);
413 for(i=r;i>0;i--)
414 {
415 for(j=c;j>0;j--)
416 {
417 poly h=MATELEM(m,i,j);
418 if (h!=NULL)
419 {
420 if (p_Totaldegree(h,R)==0)
421 convSingNFlintN(fmpq_mat_entry(FLINTM,i-1,j-1),pGetCoeff(h),R->cf);
422 else
423 {
424 WerrorS("matrix for rref is not constant");
425 return M;
426 }
427 }
428 }
429 }
430 fmpq_mat_rref(FLINTM,FLINTM);
431 for(i=r;i>0;i--)
432 {
433 for(j=c;j>0;j--)
434 {
435 number n=convFlintNSingN(fmpq_mat_entry(FLINTM,i-1,j-1),R->cf);
436 MATELEM(M,i,j)=p_NSet(n,R);
437 }
438 }
439 fmpq_mat_clear(FLINTM);
440 }
441 else if (rField_is_Zp(R))
442 {
443 nmod_mat_t FLINTM;
444 // convert matrix
445 convSingMFlintNmod_mat(m,FLINTM,R);
446 // rank
447 long rk= nmod_mat_rref (FLINTM);
448 M=convFlintNmod_matSingM(FLINTM,R);
449 // clean up
450 nmod_mat_clear(FLINTM);
451 }
452 else
453 {
454 WerrorS("not implemented for these coefficients");
455 }
456 return M;
457}
458
459ideal singflint_rref(ideal m, const ring R) /*assume smatrix m*/
460{
461 int r=m->rank;
462 int c=m->ncols;
463 int i,j;
464 ideal M=idInit(c,r);
465 if (rField_is_Q(R))
466 {
467 fmpq_mat_t FLINTM;
468 fmpq_mat_init(FLINTM,r,c);
469 for(j=c-1;j>=0;j--)
470 {
471 poly h=m->m[j];
472 while(h!=NULL)
473 {
474 i=p_GetComp(h,R);
475 if (p_Totaldegree(h,R)==0)
476 convSingNFlintN(fmpq_mat_entry(FLINTM,i-1,j),p_GetCoeff(h,R),R->cf);
477 else
478 {
479 WerrorS("smatrix for rref is not constant");
480 return M;
481 }
482 pIter(h);
483 }
484 }
485 fmpq_mat_rref(FLINTM,FLINTM);
486 for(i=r;i>0;i--)
487 {
488 for(j=c-1;j>=0;j--)
489 {
490 number n=convFlintNSingN(fmpq_mat_entry(FLINTM,i-1,j),R->cf);
491 if(!n_IsZero(n,R->cf))
492 {
493 poly p=p_NSet(n,R);
494 p_SetComp(p,i,R);
495 M->m[j]=p_Add_q(M->m[j],p,R);
496 }
497 }
498 }
499 fmpq_mat_clear(FLINTM);
500 }
501 else if (rField_is_Zp(R))
502 {
503 nmod_mat_t FLINTM;
504 nmod_mat_init(FLINTM,r,c,rChar(R));
505 for(j=c-1;j>=0;j--)
506 {
507 poly h=m->m[j];
508 while(h!=NULL)
509 {
510 i=p_GetComp(h,R);
511 if (p_Totaldegree(h,R)==0)
512 nmod_mat_entry(FLINTM,i-1,j)=(long)p_GetCoeff(h,R);
513 else
514 {
515 WerrorS("smatrix for rref is not constant");
516 return M;
517 }
518 pIter(h);
519 }
520 }
521 nmod_mat_rref(FLINTM);
522 for(i=r;i>0;i--)
523 {
524 for(j=c-1;j>=0;j--)
525 {
526 number n=n_Init(nmod_mat_entry(FLINTM,i-1,j),R->cf);
527 if(!n_IsZero(n,R->cf))
528 {
529 poly p=p_NSet(n,R);
530 p_SetComp(p,i,R);
531 M->m[j]=p_Add_q(M->m[j],p,R);
532 }
533 }
534 }
535 nmod_mat_clear(FLINTM);
536 }
537 else
538 {
539 WerrorS("not implemented for these coefficients");
540 }
541 return M;
542}
543
544matrix singflint_kernel(matrix m, const ring R)
545{
546 matrix M=NULL;
547 if (rField_is_Zp(R))
548 {
549 nmod_mat_t FLINTM;
550 nmod_mat_t FLINTX;
551 nmod_mat_init (FLINTX, (long)MATROWS(m), (long) MATCOLS(m), rChar(R));
552 // convert matrix
553 convSingMFlintNmod_mat(m,FLINTM,R);
554 // rank
555 long rk= nmod_mat_nullspace(FLINTX,FLINTM);
556 nmod_mat_clear(FLINTM);
557 M=convFlintNmod_matSingM(FLINTX,R);
558 // clean up
559 nmod_mat_clear(FLINTX);
560 }
561 else
562 {
563 WerrorS("not implemented for these coefficients");
564 }
565 return M;
566}
567
568ideal singflint_kernel(ideal m, const ring R) /*assume smatrix m*/
569{
570 int r=m->rank;
571 int c=m->ncols;
572 int i,j;
573 ideal M=idInit(c,r);
574 if (rField_is_Zp(R))
575 {
576 nmod_mat_t FLINTM;
577 nmod_mat_t FLINTX;
578 nmod_mat_init(FLINTM,r,c,rChar(R));
579 nmod_mat_init(FLINTX,r,c,rChar(R));
580 for(j=c-1;j>=0;j--)
581 {
582 poly h=m->m[j];
583 while(h!=NULL)
584 {
585 i=p_GetComp(h,R);
586 if (p_Totaldegree(h,R)==0)
587 nmod_mat_entry(FLINTM,i-1,j)=(long)p_GetCoeff(h,R);
588 else
589 {
590 WerrorS("smatrix for rref is not constant");
591 return M;
592 }
593 pIter(h);
594 }
595 }
596 nmod_mat_nullspace(FLINTX,FLINTM);
597 nmod_mat_clear(FLINTM);
598 for(i=r;i>0;i--)
599 {
600 for(j=c-1;j>=0;j--)
601 {
602 number n=n_Init(nmod_mat_entry(FLINTX,i-1,j),R->cf);
603 if(!n_IsZero(n,R->cf))
604 {
605 poly p=p_NSet(n,R);
606 p_SetComp(p,i,R);
607 M->m[j]=p_Add_q(M->m[j],p,R);
608 }
609 }
610 }
611 nmod_mat_clear(FLINTX);
612 }
613 else
614 {
615 WerrorS("not implemented for these coefficients");
616 }
617 return M;
618}
619
621{
622 int r=m->rows();
623 int c=m->cols();
624 bigintmat* res=new bigintmat(r,c,m->basecoeffs());
625 fmpz_mat_t M, Transf;
626 fmpz_mat_init(M, r, c);
627 if(T != NULL)
628 {
629 fmpz_mat_init(Transf, T->rows(), T->rows());
630 }
631 fmpz_t dummy;
632 mpz_t n;
633 int i,j;
634 for(i=r;i>0;i--)
635 {
636 for(j=c;j>0;j--)
637 {
638 n_MPZ(n, BIMATELEM(*m, i, j),m->basecoeffs());
639 convSingNFlintN(dummy,n);
640 mpz_clear(n);
641 fmpz_set(fmpz_mat_entry(M, i-1, j-1), dummy);
642 fmpz_clear(dummy);
643 }
644 }
645 if(T != NULL)
646 {
647 for(i=T->rows();i>0;i--)
648 {
649 for(j=T->rows();j>0;j--)
650 {
651 n_MPZ(n, BIMATELEM(*T, i, j),T->basecoeffs());
652 convSingNFlintN(dummy,n);
653 mpz_clear(n);
654 fmpz_set(fmpz_mat_entry(Transf, i-1, j-1), dummy);
655 fmpz_clear(dummy);
656 }
657 }
658 }
659 fmpz_lll_t fl;
660 fmpz_lll_context_init_default(fl);
661 if(T != NULL)
662 fmpz_lll(M, Transf, fl);
663 else
664 fmpz_lll(M, NULL, fl);
665 for(i=r;i>0;i--)
666 {
667 for(j=c;j>0;j--)
668 {
669 convFlintNSingN(n, fmpz_mat_entry(M, i-1, j-1));
670 n_Delete(&(BIMATELEM(*res,i,j)),res->basecoeffs());
671 BIMATELEM(*res,i,j)=n_InitMPZ(n,res->basecoeffs());
672 mpz_clear(n);
673 }
674 }
675 if(T != NULL)
676 {
677 for(i=T->rows();i>0;i--)
678 {
679 for(j=T->cols();j>0;j--)
680 {
681 convFlintNSingN(n, fmpz_mat_entry(Transf, i-1, j-1));
682 n_Delete(&(BIMATELEM(*T,i,j)),T->basecoeffs());
683 BIMATELEM(*T,i,j)=n_InitMPZ(n,T->basecoeffs());
684 mpz_clear(n);
685 }
686 }
687 }
688 return res;
689}
690
692{
693 int r=m->rows();
694 int c=m->cols();
695 intvec* res = new intvec(r,c,(int)0);
696 fmpz_mat_t M,Transf;
697 fmpz_mat_init(M, r, c);
698 if(T != NULL)
699 fmpz_mat_init(Transf, r, r);
700 fmpz_t dummy;
701 int i,j;
702 for(i=r;i>0;i--)
703 {
704 for(j=c;j>0;j--)
705 {
706 convSingIFlintI(dummy,IMATELEM(*m,i,j));
707 fmpz_set(fmpz_mat_entry(M, i-1, j-1), dummy);
708 fmpz_clear(dummy);
709 }
710 }
711 if(T != NULL)
712 {
713 for(i=T->rows();i>0;i--)
714 {
715 for(j=T->rows();j>0;j--)
716 {
717 convSingIFlintI(dummy,IMATELEM(*T,i,j));
718 fmpz_set(fmpz_mat_entry(Transf, i-1, j-1), dummy);
719 fmpz_clear(dummy);
720 }
721 }
722 }
723 fmpz_lll_t fl;
724 fmpz_lll_context_init_default(fl);
725 if(T != NULL)
726 fmpz_lll(M, Transf, fl);
727 else
728 fmpz_lll(M, NULL, fl);
729 for(i=r;i>0;i--)
730 {
731 for(j=c;j>0;j--)
732 {
733 IMATELEM(*res,i,j)=convFlintISingI(fmpz_mat_entry(M, i-1, j-1));
734 }
735 }
736 if(T != NULL)
737 {
738 for(i=Transf->r;i>0;i--)
739 {
740 for(j=Transf->r;j>0;j--)
741 {
742 IMATELEM(*T,i,j)=convFlintISingI(fmpz_mat_entry(Transf, i-1, j-1));
743 }
744 }
745 }
746 return res;
747}
748#endif
749#endif
All the auxiliary stuff.
#define LIKELY(X)
Definition auxiliary.h:404
#define BIMATELEM(M, I, J)
Definition bigintmat.h:133
CanonicalForm FACTORY_PUBLIC pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f )
Definition cf_gcd.cc:676
int m
Definition cfEzgcd.cc:128
int i
Definition cfEzgcd.cc:132
int p
Definition cfModGcd.cc:4086
CanonicalForm cf
Definition cfModGcd.cc:4091
CanonicalForm b
Definition cfModGcd.cc:4111
FILE * f
Definition checklibs.c:9
Matrices of numbers.
Definition bigintmat.h:51
Coefficient rings, fields and other domains suitable for Singular polynomials.
static FORCE_INLINE long n_Int(number &n, const coeffs r)
conversion of n to an int; 0 if not possible in Z/pZ: the representing int lying in (-p/2 ....
Definition coeffs.h:548
#define n_Test(a, r)
BOOLEAN n_Test(number a, const coeffs r)
Definition coeffs.h:713
@ n_Q
rational (GMP) numbers
Definition coeffs.h:30
static FORCE_INLINE void n_MPZ(mpz_t result, number &n, const coeffs r)
conversion of n to a GMP integer; 0 if not possible
Definition coeffs.h:552
static FORCE_INLINE nMapFunc n_SetMap(const coeffs src, const coeffs dst)
set the mapping function pointers for translating numbers from src to dst
Definition coeffs.h:701
static FORCE_INLINE number n_Div(number a, number b, const coeffs r)
return the quotient of 'a' and 'b', i.e., a/b; raises an error if 'b' is not invertible in r exceptio...
Definition coeffs.h:616
static FORCE_INLINE number n_RePart(number i, const coeffs cf)
Definition coeffs.h:783
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
Definition numbers.cc:406
#define ALLOC_RNUMBER()
Definition coeffs.h:94
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
Definition coeffs.h:468
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition coeffs.h:429
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition coeffs.h:459
static FORCE_INLINE number n_InitMPZ(mpz_t n, const coeffs r)
conversion of a GMP integer to number
Definition coeffs.h:543
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition coeffs.h:539
@ n_rep_gmp
(mpz_ptr), see rmodulon,h
Definition coeffs.h:122
static FORCE_INLINE number n_ImPart(number i, const coeffs cf)
Definition coeffs.h:786
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition coeffs.h:80
static FORCE_INLINE void n_Normalize(number &n, const coeffs r)
inplace-normalization of n; produces some canonical representation of n;
Definition coeffs.h:579
void nKillChar(coeffs r)
undo all initialisations
Definition numbers.cc:556
return result
CanonicalForm res
Definition facAbsFact.cc:60
fq_nmod_ctx_t fq_con
Definition facHensel.cc:99
int j
Definition facHensel.cc:110
void WerrorS(const char *s)
Definition feFopen.cc:24
This file is work in progress and currently not part of the official Singular.
void convSingPFlintP(fmpq_poly_t res, poly p, const ring r)
void convSingNFlintN(fmpz_t f, mpz_t z)
matrix convFlintNmod_matSingM(nmod_mat_t m, const ring r)
void convSingNFlintNN(fmpq_t re, fmpq_t im, number n, const coeffs cf)
void convSingIFlintI(fmpz_t f, int p)
matrix singflint_kernel(matrix m, const ring R)
void convSingNFlintN_QQ(fmpq_t f, number n)
void convFlintNSingN(mpz_t z, fmpz_t f)
matrix singflint_rref(matrix m, const ring R)
poly convFlintPSingP(fmpq_poly_t f, const ring r)
void convSingImPFlintP(fmpq_poly_t res, poly p, const ring r)
int convFlintISingI(fmpz_t f)
number convFlintNSingN_QQ(fmpq_t f, const coeffs cf)
bigintmat * singflint_LLL(bigintmat *A, bigintmat *T)
void convSingMFlintNmod_mat(matrix m, nmod_mat_t M, const ring r)
#define IMATELEM(M, I, J)
Definition intvec.h:86
STATIC_VAR jList * T
Definition janet.cc:30
STATIC_VAR Poly * h
Definition janet.cc:971
void nlMPZ(mpz_t m, number &n, const coeffs r)
Definition longrat.cc:2811
#define SR_INT
Definition longrat.h:67
#define SR_TO_INT(SR)
Definition longrat.h:69
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition matpol.cc:37
#define MATELEM(mat, i, j)
1-based access to matrix
Definition matpol.h:29
ip_smatrix * matrix
Definition matpol.h:43
#define MATROWS(i)
Definition matpol.h:26
#define MATCOLS(i)
Definition matpol.h:27
#define p_GetComp(p, r)
Definition monomials.h:64
#define pIter(p)
Definition monomials.h:37
#define pSetCoeff0(p, n)
Definition monomials.h:59
#define p_GetCoeff(p, r)
Definition monomials.h:50
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
Definition monomials.h:44
The main handler for Singular numbers which are suitable for Singular polynomials.
#define NULL
Definition omList.c:12
poly p_ISet(long i, const ring r)
returns the poly representing the integer i
Definition p_polys.cc:1298
poly p_NSet(number n, const ring r)
returns the poly representing the number n, destroys n
Definition p_polys.cc:1474
long p_Deg(poly a, const ring r)
Definition p_polys.cc:586
static poly p_Add_q(poly p, poly q, const ring r)
Definition p_polys.h:938
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent @Note: VarOffset encodes the position in p->exp
Definition p_polys.h:490
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition p_polys.h:249
static void p_Setm(poly p, const ring r)
Definition p_polys.h:235
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent @Note: the integer VarOffset encodes:
Definition p_polys.h:471
static poly p_Init(const ring r, omBin bin)
Definition p_polys.h:1336
static long p_Totaldegree(poly p, const ring r)
Definition p_polys.h:1523
#define p_Test(p, r)
Definition p_polys.h:161
int rChar(ring r)
Definition ring.cc:718
static BOOLEAN rField_is_Zp(const ring r)
Definition ring.h:506
static BOOLEAN rField_is_Q(const ring r)
Definition ring.h:512
number nrzInit(long i, const coeffs r)
ideal idInit(int idsize, int rank)
initialise an ideal / module
#define R
Definition sirandom.c:27
#define M
Definition sirandom.c:25
#define SR_HDL(A)
Definition tgb.cc:35