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 
27 int convFlintISingI (fmpz_t f)
28 {
29  //return fmpz_get_si(f);
30  return (int)*f;
31 }
32 
33 void convSingIFlintI(fmpz_t f, int p)
34 {
35  fmpz_init(f);
36  *f=p;
37  //fmpz_set_si(f,p);
38  return;
39 }
40 
41 void convFlintNSingN (mpz_t z, fmpz_t f)
42 {
43  mpz_init(z);
44  fmpz_get_mpz(z,f);
45 }
46 
47 number 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 
63 number convFlintNSingN (fmpq_t f, const coeffs cf)
64 {
65 #if __FLINT_RELEASE > 20502
66  number z;
67  if (nCoeff_is_Q(cf))
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 
101 number 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 
119 number 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 
154 void convSingNFlintN(fmpz_t f, mpz_t n)
155 {
156  fmpz_init(f);
157  fmpz_set_mpz(f,n);
158 }
159 
160 void convSingNFlintN(fmpz_t f, number n)
161 {
162  fmpz_init(f);
163  fmpz_set_mpz(f,(mpz_ptr)n);
164 }
165 
166 void convSingNFlintN(fmpq_t f, number n, const coeffs cf)
167 {
168  if (nCoeff_is_Q(cf))
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  {
189  coeffs QQ=nInitChar(n_Q,NULL);
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 
200 void 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 
220 void 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 
230 void convSingPFlintP(fmpq_poly_t res, poly p, const ring r)
231 {
232  int d=p_GetExp(p,1,r);
233  fmpq_poly_init2(res,d+1);
234  _fmpq_poly_set_length (res, d + 1);
235  while(p!=NULL)
236  {
237  number n=pGetCoeff(p);
238  fmpq_t c;
239  convSingNFlintN(c,n,r->cf);
240  fmpq_poly_set_coeff_fmpq(res,p_GetExp(p,1,r),c);
241  fmpq_clear(c);
242  pIter(p);
243  }
244 }
245 
246 void convSingImPFlintP(fmpq_poly_t res, poly p, const ring r)
247 {
248  int d=p_GetExp(p,1,r);
249  fmpq_poly_init2(res,d+1);
250  _fmpq_poly_set_length (res, d + 1);
251  while(p!=NULL)
252  {
253  number n=n_ImPart(pGetCoeff(p),r->cf);
254  fmpq_t c;
255  convSingNFlintN(c,n,r->cf);
256  fmpq_poly_set_coeff_fmpq(res,p_GetExp(p,1,r),c);
257  fmpq_clear(c);
258  n_Delete(&n,r->cf);
259  pIter(p);
260  }
261 }
262 
263 poly convFlintPSingP(fmpq_poly_t f, const ring r)
264 {
265  int d=fmpq_poly_length(f);
266  poly p=NULL;
267  fmpq_t c;
268  fmpq_init(c);
269  for(int i=0; i<=d; i++)
270  {
271  fmpq_poly_get_coeff_fmpq(c,f,i);
272  number n=convFlintNSingN(c,r->cf);
273  poly pp=p_Init(r);
274  pSetCoeff0(pp,n);
275  p_SetExp(pp,1,i,r);
276  p_Setm(pp,r);
277  p=p_Add_q(p,pp,r);
278  }
279  fmpq_clear(c);
280  p_Test(p,r);
281  return p;
282 }
283 
284 void convSingPFlintnmod_poly_t(nmod_poly_t result, const poly p, const ring r)
285 {
286  // assume univariate, r->cf=Z/p
287  nmod_poly_init2 (result,rChar(r),p_Deg(p,r));
288  poly h=p;
289  while(h!=NULL)
290  {
291  if (h==NULL)
292  nmod_poly_set_coeff_ui(result,0,0);
293  else
294  nmod_poly_set_coeff_ui(result,p_GetExp(h,1,r),n_Int(pGetCoeff(h),r->cf)+rChar(r));
295  pIter(h);
296  }
297 }
298 
299 void convSingMFlintFq_nmod_mat(matrix m, fq_nmod_mat_t M, const fq_nmod_ctx_t fq_con, const ring r)
300 {
301  fq_nmod_mat_init (M, (long)MATROWS(m), (long) MATCOLS(m), fq_con);
302  int i,j;
303  for(i=MATROWS(m);i>0;i--)
304  {
305  for(j=MATCOLS(m);j>0;j--)
306  {
307  convSingPFlintnmod_poly_t (M->rows[i-1]+j-1, MATELEM(m,i,j),r);
308  }
309  }
310 }
311 
312 poly convFlintFq_nmodSingP(const fq_nmod_t Fp, const fq_nmod_ctx_t ctx, const ring r)
313 {
314  poly p=NULL;
315  poly h;
316  for (int i= 0; i < nmod_poly_length (Fp); i++)
317  {
318  ulong coeff= nmod_poly_get_coeff_ui (Fp, i);
319  if (coeff != 0)
320  h=p_NSet(n_Init(coeff,r->cf),r);
321  if (h!=NULL)
322  {
323  p_SetExp(h,1,i,r);
324  p_Setm(h,r);
325  p=p_Add_q(p,h,r);
326  }
327  }
328  return p;
329 }
330 
331 matrix convFlintFq_nmod_matSingM(fq_nmod_mat_t m, const fq_nmod_ctx_t fq_con, const ring r)
332 {
333  matrix M=mpNew(fq_nmod_mat_nrows (m, fq_con),fq_nmod_mat_ncols (m, fq_con));
334  int i,j;
335  for(i=MATROWS(M);i>0;i--)
336  {
337  for(j=MATCOLS(M);j>0;j--)
338  {
339  MATELEM(M,i,j)=convFlintFq_nmodSingP(fq_nmod_mat_entry (m, i-1, j-1),
340  fq_con, r);
341  }
342  }
343  return M;
344 }
345 
346 void convSingMFlintNmod_mat(matrix m, nmod_mat_t M, const ring r)
347 {
348  nmod_mat_init (M, (long)MATROWS(m), (long) MATCOLS(m), rChar(r));
349  int i,j;
350  for(i=MATROWS(m);i>0;i--)
351  {
352  for(j=MATCOLS(m);j>0;j--)
353  {
354  poly h=MATELEM(m,i,j);
355  if (h!=NULL)
356  nmod_mat_entry(M,i-1,j-1)=(long)pGetCoeff(h);
357  }
358  }
359 }
360 
361 matrix convFlintNmod_matSingM(nmod_mat_t m, const ring r)
362 {
363  matrix M=mpNew(nmod_mat_nrows (m),nmod_mat_ncols (m));
364  int i,j;
365  for(i=MATROWS(M);i>0;i--)
366  {
367  for(j=MATCOLS(M);j>0;j--)
368  {
369  MATELEM(M,i,j)=p_ISet(nmod_mat_entry (m, i-1, j-1),r);
370  }
371  }
372  return M;
373 }
374 
375 matrix singflint_rref(matrix m, const ring R)
376 {
377  int r=m->rows();
378  int c=m->cols();
379  int i,j;
380  matrix M=NULL;
381  if (rField_is_Q(R))
382  {
383  fmpq_mat_t FLINTM;
384  fmpq_mat_init(FLINTM,r,c);
385  M=mpNew(r,c);
386  for(i=r;i>0;i--)
387  {
388  for(j=c;j>0;j--)
389  {
390  poly h=MATELEM(m,i,j);
391  if (h!=NULL)
392  {
393  if (p_Totaldegree(h,R)==0)
394  convSingNFlintN(fmpq_mat_entry(FLINTM,i-1,j-1),pGetCoeff(h),R->cf);
395  else
396  {
397  WerrorS("matrix for rref is not constant");
398  return M;
399  }
400  }
401  }
402  }
403  fmpq_mat_rref(FLINTM,FLINTM);
404  for(i=r;i>0;i--)
405  {
406  for(j=c;j>0;j--)
407  {
408  number n=convFlintNSingN(fmpq_mat_entry(FLINTM,i-1,j-1),R->cf);
409  MATELEM(M,i,j)=p_NSet(n,R);
410  }
411  }
412  fmpq_mat_clear(FLINTM);
413  }
414  else if (rField_is_Zp(R))
415  {
416  nmod_mat_t FLINTM;
417  // convert matrix
418  convSingMFlintNmod_mat(m,FLINTM,R);
419  // rank
420  long rk= nmod_mat_rref (FLINTM);
421  M=convFlintNmod_matSingM(FLINTM,R);
422  // clean up
423  nmod_mat_clear(FLINTM);
424  }
425  else
426  {
427  WerrorS("not implemented for these coefficients");
428  }
429  return M;
430 }
431 
432 ideal singflint_rref(ideal m, const ring R) /*assume smatrix m*/
433 {
434  int r=m->rank;
435  int c=m->ncols;
436  int i,j;
437  ideal M=idInit(c,r);
438  if (rField_is_Q(R))
439  {
440  fmpq_mat_t FLINTM;
441  fmpq_mat_init(FLINTM,r,c);
442  for(j=c-1;j>=0;j--)
443  {
444  poly h=m->m[j];
445  while(h!=NULL)
446  {
447  i=p_GetComp(h,R);
448  if (p_Totaldegree(h,R)==0)
449  convSingNFlintN(fmpq_mat_entry(FLINTM,i-1,j),p_GetCoeff(h,R),R->cf);
450  else
451  {
452  WerrorS("smatrix for rref is not constant");
453  return M;
454  }
455  pIter(h);
456  }
457  }
458  fmpq_mat_rref(FLINTM,FLINTM);
459  for(i=r;i>0;i--)
460  {
461  for(j=c-1;j>=0;j--)
462  {
463  number n=convFlintNSingN(fmpq_mat_entry(FLINTM,i-1,j),R->cf);
464  if(!n_IsZero(n,R->cf))
465  {
466  poly p=p_NSet(n,R);
467  p_SetComp(p,i,R);
468  M->m[j]=p_Add_q(M->m[j],p,R);
469  }
470  }
471  }
472  fmpq_mat_clear(FLINTM);
473  }
474  else if (rField_is_Zp(R))
475  {
476  nmod_mat_t FLINTM;
477  nmod_mat_init(FLINTM,r,c,rChar(R));
478  for(j=c-1;j>=0;j--)
479  {
480  poly h=m->m[j];
481  while(h!=NULL)
482  {
483  i=p_GetComp(h,R);
484  if (p_Totaldegree(h,R)==0)
485  nmod_mat_entry(FLINTM,i-1,j)=(long)p_GetCoeff(h,R);
486  else
487  {
488  WerrorS("smatrix for rref is not constant");
489  return M;
490  }
491  pIter(h);
492  }
493  }
494  nmod_mat_rref(FLINTM);
495  for(i=r;i>0;i--)
496  {
497  for(j=c-1;j>=0;j--)
498  {
499  number n=n_Init(nmod_mat_entry(FLINTM,i-1,j),R->cf);
500  if(!n_IsZero(n,R->cf))
501  {
502  poly p=p_NSet(n,R);
503  p_SetComp(p,i,R);
504  M->m[j]=p_Add_q(M->m[j],p,R);
505  }
506  }
507  }
508  nmod_mat_clear(FLINTM);
509  }
510  else
511  {
512  WerrorS("not implemented for these coefficients");
513  }
514  return M;
515 }
516 
517 matrix singflint_kernel(matrix m, const ring R)
518 {
519  matrix M=NULL;
520  if (rField_is_Zp(R))
521  {
522  nmod_mat_t FLINTM;
523  nmod_mat_t FLINTX;
524  nmod_mat_init (FLINTX, (long)MATROWS(m), (long) MATCOLS(m), rChar(R));
525  // convert matrix
526  convSingMFlintNmod_mat(m,FLINTM,R);
527  // rank
528  long rk= nmod_mat_nullspace(FLINTX,FLINTM);
529  nmod_mat_clear(FLINTM);
530  M=convFlintNmod_matSingM(FLINTX,R);
531  // clean up
532  nmod_mat_clear(FLINTX);
533  }
534  else
535  {
536  WerrorS("not implemented for these coefficients");
537  }
538  return M;
539 }
540 
541 ideal singflint_kernel(ideal m, const ring R) /*assume smatrix m*/
542 {
543  int r=m->rank;
544  int c=m->ncols;
545  int i,j;
546  ideal M=idInit(c,r);
547  if (rField_is_Zp(R))
548  {
549  nmod_mat_t FLINTM;
550  nmod_mat_t FLINTX;
551  nmod_mat_init(FLINTM,r,c,rChar(R));
552  nmod_mat_init(FLINTX,r,c,rChar(R));
553  for(j=c-1;j>=0;j--)
554  {
555  poly h=m->m[j];
556  while(h!=NULL)
557  {
558  i=p_GetComp(h,R);
559  if (p_Totaldegree(h,R)==0)
560  nmod_mat_entry(FLINTM,i-1,j)=(long)p_GetCoeff(h,R);
561  else
562  {
563  WerrorS("smatrix for rref is not constant");
564  return M;
565  }
566  pIter(h);
567  }
568  }
569  nmod_mat_nullspace(FLINTX,FLINTM);
570  nmod_mat_clear(FLINTM);
571  for(i=r;i>0;i--)
572  {
573  for(j=c-1;j>=0;j--)
574  {
575  number n=n_Init(nmod_mat_entry(FLINTX,i-1,j),R->cf);
576  if(!n_IsZero(n,R->cf))
577  {
578  poly p=p_NSet(n,R);
579  p_SetComp(p,i,R);
580  M->m[j]=p_Add_q(M->m[j],p,R);
581  }
582  }
583  }
584  nmod_mat_clear(FLINTX);
585  }
586  else
587  {
588  WerrorS("not implemented for these coefficients");
589  }
590  return M;
591 }
592 
594 {
595  int r=m->rows();
596  int c=m->cols();
597  bigintmat* res=new bigintmat(r,c,m->basecoeffs());
598  fmpz_mat_t M, Transf;
599  fmpz_mat_init(M, r, c);
600  if(T != NULL)
601  {
602  fmpz_mat_init(Transf, T->rows(), T->rows());
603  }
604  fmpz_t dummy;
605  mpz_t n;
606  int i,j;
607  for(i=r;i>0;i--)
608  {
609  for(j=c;j>0;j--)
610  {
611  n_MPZ(n, BIMATELEM(*m, i, j),m->basecoeffs());
612  convSingNFlintN(dummy,n);
613  mpz_clear(n);
614  fmpz_set(fmpz_mat_entry(M, i-1, j-1), dummy);
615  fmpz_clear(dummy);
616  }
617  }
618  if(T != NULL)
619  {
620  for(i=T->rows();i>0;i--)
621  {
622  for(j=T->rows();j>0;j--)
623  {
624  n_MPZ(n, BIMATELEM(*T, i, j),T->basecoeffs());
625  convSingNFlintN(dummy,n);
626  mpz_clear(n);
627  fmpz_set(fmpz_mat_entry(Transf, i-1, j-1), dummy);
628  fmpz_clear(dummy);
629  }
630  }
631  }
632  fmpz_lll_t fl;
633  fmpz_lll_context_init_default(fl);
634  if(T != NULL)
635  fmpz_lll(M, Transf, fl);
636  else
637  fmpz_lll(M, NULL, fl);
638  for(i=r;i>0;i--)
639  {
640  for(j=c;j>0;j--)
641  {
642  convFlintNSingN(n, fmpz_mat_entry(M, i-1, j-1));
643  n_Delete(&(BIMATELEM(*res,i,j)),res->basecoeffs());
644  BIMATELEM(*res,i,j)=n_InitMPZ(n,res->basecoeffs());
645  mpz_clear(n);
646  }
647  }
648  if(T != NULL)
649  {
650  for(i=T->rows();i>0;i--)
651  {
652  for(j=T->cols();j>0;j--)
653  {
654  convFlintNSingN(n, fmpz_mat_entry(Transf, i-1, j-1));
655  n_Delete(&(BIMATELEM(*T,i,j)),T->basecoeffs());
656  BIMATELEM(*T,i,j)=n_InitMPZ(n,T->basecoeffs());
657  mpz_clear(n);
658  }
659  }
660  }
661  return res;
662 }
663 
665 {
666  int r=m->rows();
667  int c=m->cols();
668  intvec* res = new intvec(r,c,(int)0);
669  fmpz_mat_t M,Transf;
670  fmpz_mat_init(M, r, c);
671  if(T != NULL)
672  fmpz_mat_init(Transf, r, r);
673  fmpz_t dummy;
674  int i,j;
675  for(i=r;i>0;i--)
676  {
677  for(j=c;j>0;j--)
678  {
679  convSingIFlintI(dummy,IMATELEM(*m,i,j));
680  fmpz_set(fmpz_mat_entry(M, i-1, j-1), dummy);
681  fmpz_clear(dummy);
682  }
683  }
684  if(T != NULL)
685  {
686  for(i=T->rows();i>0;i--)
687  {
688  for(j=T->rows();j>0;j--)
689  {
690  convSingIFlintI(dummy,IMATELEM(*T,i,j));
691  fmpz_set(fmpz_mat_entry(Transf, i-1, j-1), dummy);
692  fmpz_clear(dummy);
693  }
694  }
695  }
696  fmpz_lll_t fl;
697  fmpz_lll_context_init_default(fl);
698  if(T != NULL)
699  fmpz_lll(M, Transf, fl);
700  else
701  fmpz_lll(M, NULL, fl);
702  for(i=r;i>0;i--)
703  {
704  for(j=c;j>0;j--)
705  {
706  IMATELEM(*res,i,j)=convFlintISingI(fmpz_mat_entry(M, i-1, j-1));
707  }
708  }
709  if(T != NULL)
710  {
711  for(i=Transf->r;i>0;i--)
712  {
713  for(j=Transf->r;j>0;j--)
714  {
715  IMATELEM(*T,i,j)=convFlintISingI(fmpz_mat_entry(Transf, i-1, j-1));
716  }
717  }
718  }
719  return res;
720 }
721 #endif
722 #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:547
#define n_Test(a, r)
BOOLEAN n_Test(number a, const coeffs r)
Definition: coeffs.h:712
@ 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:551
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:700
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:615
static FORCE_INLINE number n_RePart(number i, const coeffs cf)
Definition: coeffs.h:790
static FORCE_INLINE BOOLEAN nCoeff_is_Q(const coeffs r)
Definition: coeffs.h:806
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
Definition: numbers.cc:354
#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:464
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:455
static FORCE_INLINE number n_InitMPZ(mpz_t n, const coeffs r)
conversion of a GMP integer to number
Definition: coeffs.h:542
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:538
static FORCE_INLINE number n_ImPart(number i, const coeffs cf)
Definition: coeffs.h:793
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:578
void nKillChar(coeffs r)
undo all initialisations
Definition: numbers.cc:522
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)
bigintmat * singflint_LLL(bigintmat *A, bigintmat *T)
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)
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
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
#define pSetCoeff0(p, n)
Definition: monomials.h:59
#define p_GetCoeff(p, r)
Definition: monomials.h:50
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:936
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:488
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition: p_polys.h:247
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:233
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:469
static poly p_Init(const ring r, omBin bin)
Definition: p_polys.h:1320
static long p_Totaldegree(poly p, const ring r)
Definition: p_polys.h:1507
#define p_Test(p, r)
Definition: p_polys.h:162
int rChar(ring r)
Definition: ring.cc:713
static BOOLEAN rField_is_Zp(const ring r)
Definition: ring.h:501
static BOOLEAN rField_is_Q(const ring r)
Definition: ring.h:507
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