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