gnumpc.cc
Go to the documentation of this file.
1 /****************************************
2 * Computer Algebra System SINGULAR *
3 ****************************************/
4 /*
5 * ABSTRACT: computations with GMP complex floating-point numbers
6 *
7 * ngc == number gnu complex
8 */
9 #include <misc/auxiliary.h>
10 #include <omalloc/omalloc.h>
11 
12 #include <misc/mylimits.h>
13 #include <reporter/reporter.h>
14 
15 #include "coeffs.h"
16 #include "numbers.h"
17 
18 #include "mpr_complex.h"
19 
20 #include "gnumpc.h"
21 #include "longrat.h"
22 #include "gnumpfl.h"
23 #include "modulop.h"
24 #include "shortfl.h"
25 
26 /// Get a mapping function from src into the domain of this type: long_C!
27 nMapFunc ngcSetMap(const coeffs src, const coeffs dst);
28 
29 number ngcMapQ(number from, const coeffs r, const coeffs aRing);
30 
31 void ngcSetChar(const coeffs r);
32 
33 // Private interface should be hidden!!!
34 
35 /// Note: MAY NOT WORK AS EXPECTED!
36 BOOLEAN ngcGreaterZero(number za, const coeffs r);
37 BOOLEAN ngcGreater(number a, number b, const coeffs r);
38 BOOLEAN ngcEqual(number a, number b, const coeffs r);
39 BOOLEAN ngcIsOne(number a, const coeffs r);
40 BOOLEAN ngcIsMOne(number a, const coeffs r);
41 BOOLEAN ngcIsZero(number za, const coeffs r);
42 number ngcInit(long i, const coeffs r);
43 long ngcInt(number &n, const coeffs r);
44 number ngcNeg(number za, const coeffs r);
45 number ngcInvers(number a, const coeffs r);
46 number ngcParameter(int i, const coeffs r);
47 number ngcAdd(number la, number li, const coeffs r);
48 number ngcSub(number la, number li, const coeffs r);
49 number ngcMult(number a, number b, const coeffs r);
50 number ngcDiv(number a, number b, const coeffs r);
51 void ngcPower(number x, int exp, number *lu, const coeffs r);
52 number ngcCopy(number a, const coeffs r);
53 number ngc_Copy(number a, coeffs r);
54 const char * ngcRead (const char *s, number *a, const coeffs r);
55 void ngcWrite(number a, const coeffs r);
56 number ngcRePart(number a, const coeffs r);
57 number ngcImPart(number a, const coeffs r);
58 
59 void ngcDelete(number *a, const coeffs r);
60 void ngcCoeffWrite(const coeffs r, BOOLEAN details);
61 
62 #ifdef LDEBUG
63 BOOLEAN ngcDBTest(number a, const char *f, const int l, const coeffs r);
64 #endif
65 
66 
67 // Why is this here? who needs it?
68 // number ngcMapQ(number from, const coeffs r, const coeffs aRing);
69 
70 #ifdef LDEBUG
71 // not yet implemented
72 BOOLEAN ngcDBTest(number, const char *, const int, const coeffs r)
73 {
74  assume( getCoeffType(r) == n_long_C );
75 
76  return TRUE;
77 }
78 #endif
79 
80 number ngcParameter(int i, const coeffs r)
81 {
82  assume( getCoeffType(r) == n_long_C );
83  assume(i==1);
84 
85  if( i == 1 )
86  return (number)(new gmp_complex( 0L, 1L ));
87 
88  return NULL; // new gmp_complex( ) // 0?
89 }
90 
91 /*2
92 * n := i
93 */
94 number ngcInit (long i, const coeffs r)
95 {
96  assume( getCoeffType(r) == n_long_C );
97 
98  gmp_complex* n= new gmp_complex( (long)i, 0L );
99 
100  return (number)n;
101 }
102 
103 /*2
104 * convert number to int
105 */
106 long ngcInt(number &i, const coeffs r)
107 {
108  assume( getCoeffType(r) == n_long_C );
109 
110  return ((gmp_complex*)i)->real();
111 }
112 
113 int ngcSize(number n, const coeffs R)
114 {
115  int r = (int)((gmp_complex*)n)->real();
116  if (r < 0) r = -r;
117  int i = (int)((gmp_complex*)n)->imag();
118  if (i < 0) i = -i;
119  int oneNorm = r + i;
120  /* basically return the 1-norm of n;
121  only if this happens to be zero although n != 0,
122  return 1;
123  (this code ensures that zero has the size zero) */
124  if ((oneNorm == 0.0) & (ngcIsZero(n,R) == FALSE)) oneNorm = 1;
125  return oneNorm;
126 }
127 
128 /*2
129 * delete a
130 */
131 void ngcDelete (number * a, const coeffs r)
132 {
133  assume( getCoeffType(r) == n_long_C );
134 
135  if ( *a != NULL )
136  {
137  delete *(gmp_complex**)a;
138  *a=NULL;
139  }
140 }
141 
142 /*2
143  * copy a to b
144 */
145 number ngcCopy(number a, const coeffs r)
146 {
147  assume( getCoeffType(r) == n_long_C );
148 
149  gmp_complex* b= new gmp_complex( *(gmp_complex*)a );
150  return (number)b;
151 }
152 
153 
154 /*2
155 * za:= - za
156 */
157 number ngcNeg (number a, const coeffs R)
158 {
159  assume( getCoeffType(R) == n_long_C );
160 
162  (*r).neg();
163  return (number)a;
164 }
165 
166 /*
167 * 1/a
168 */
169 number ngcInvers(number a, const coeffs R)
170 {
171  assume( getCoeffType(R) == n_long_C );
172 
173  gmp_complex* r = NULL;
174  if (((gmp_complex*)a)->isZero())
175  {
176  WerrorS(nDivBy0);
177  }
178  else
179  {
180  r = new gmp_complex( (gmp_complex)1 / (*(gmp_complex*)a) );
181  }
182  return (number)r;
183 }
184 
185 /*2
186 * u:= a + b
187 */
188 number ngcAdd (number a, number b, const coeffs R)
189 {
190  assume( getCoeffType(R) == n_long_C );
191 
192  gmp_complex* r= new gmp_complex( (*(gmp_complex*)a) + (*(gmp_complex*)b) );
193  return (number)r;
194 }
195 
196 /*2
197 * u:= a - b
198 */
199 number ngcSub (number a, number b, const coeffs R)
200 {
201  assume( getCoeffType(R) == n_long_C );
202 
203  gmp_complex* r= new gmp_complex( (*(gmp_complex*)a) - (*(gmp_complex*)b) );
204  return (number)r;
205 }
206 
207 /*2
208 * u := a * b
209 */
210 number ngcMult (number a, number b, const coeffs R)
211 {
212  assume( getCoeffType(R) == n_long_C );
213 
214  gmp_complex* r= new gmp_complex( (*(gmp_complex*)a) * (*(gmp_complex*)b) );
215  return (number)r;
216 }
217 
218 /*2
219 * u := a / b
220 */
221 number ngcDiv (number a, number b, const coeffs r)
222 {
223  assume( getCoeffType(r) == n_long_C );
224 
225  if (((gmp_complex*)b)->isZero())
226  {
227  // a/0 = error
228  WerrorS(nDivBy0);
229  return NULL;
230  }
231  gmp_complex* res = new gmp_complex( (*(gmp_complex*)a) / (*(gmp_complex*)b) );
232  return (number)res;
233 }
234 
235 /*2
236 * u:= x ^ exp
237 */
238 void ngcPower ( number x, int exp, number * u, const coeffs r)
239 {
240  assume( getCoeffType(r) == n_long_C );
241 
242  if ( exp == 0 )
243  {
244  gmp_complex* n = new gmp_complex(1);
245  *u=(number)n;
246  return;
247  }
248  else if ( exp == 1 )
249  {
250  n_New(u, r);
251  gmp_complex* n = new gmp_complex();
252  *n= *(gmp_complex*)x;
253  *u=(number)n;
254  return;
255  }
256  else if (exp == 2)
257  {
258  n_New(u, r);
259  gmp_complex* n = new gmp_complex();
260  *n= *(gmp_complex*)x;
261  *u=(number)n;
262  *(gmp_complex*)(*u) *= *(gmp_complex*)n;
263  return;
264  }
265  if ( (exp & 1) == 1 )
266  {
267  ngcPower(x,exp-1,u, r);
268  gmp_complex *n = new gmp_complex();
269  *n=*(gmp_complex*)x;
270  *(gmp_complex*)(*u) *= *(gmp_complex*)n;
271  delete n;
272  }
273  else
274  {
275  number w;
276  n_New(&w, r);
277  ngcPower(x,exp/2,&w, r);
278  ngcPower(w,2,u, r);
279  n_Delete(&w, r);
280  }
281 }
282 
283 BOOLEAN ngcIsZero (number a, const coeffs r)
284 {
285  assume( getCoeffType(r) == n_long_C );
286 
287  return ( ((gmp_complex*)a)->real().isZero() && ((gmp_complex*)a)->imag().isZero());
288 }
289 
290 number ngcRePart(number a, const coeffs r)
291 {
292  assume( getCoeffType(r) == n_long_C );
293 
294  gmp_complex* n = new gmp_complex(((gmp_complex*)a)->real());
295  return (number)n;
296 }
297 
298 number ngcImPart(number a, const coeffs r)
299 {
300  assume( getCoeffType(r) == n_long_C );
301 
302  gmp_complex* n = new gmp_complex(((gmp_complex*)a)->imag());
303  return (number)n;
304 }
305 
306 /*2
307 * za >= 0 ?
308 */
309 BOOLEAN ngcGreaterZero (number a, const coeffs r)
310 {
311  assume( getCoeffType(r) == n_long_C );
312 
313  if ( ! ((gmp_complex*)a)->imag().isZero() )
314  return ( abs( *(gmp_complex*)a).sign() >= 0 );
315  else
316  return ( ((gmp_complex*)a)->real().sign() >= 0 );
317 }
318 
319 /*2
320 * a > b ?
321 */
322 BOOLEAN ngcGreater (number a, number b, const coeffs r)
323 {
324  assume( getCoeffType(r) == n_long_C );
325 
326  gmp_complex *aa=(gmp_complex*)a;
327  gmp_complex *bb=(gmp_complex*)b;
328  return (*aa) > (*bb);
329 }
330 
331 /*2
332 * a = b ?
333 */
334 BOOLEAN ngcEqual (number a, number b, const coeffs r)
335 {
336  assume( getCoeffType(r) == n_long_C );
337 
338  gmp_complex *aa=(gmp_complex*)a;
339  gmp_complex *bb=(gmp_complex*)b;
340  return (*aa) == (*bb);
341 }
342 
343 /*2
344 * a == 1 ?
345 */
346 BOOLEAN ngcIsOne (number a, const coeffs r)
347 {
348  assume( getCoeffType(r) == n_long_C );
349 
350  return (((gmp_complex*)a)->real().isOne() && ((gmp_complex*)a)->imag().isZero());
351  //return (((gmp_complex*)a)->real().isOne());
352 }
353 
354 /*2
355 * a == -1 ?
356 */
357 BOOLEAN ngcIsMOne (number a, const coeffs r)
358 {
359  assume( getCoeffType(r) == n_long_C );
360 
361  return (((gmp_complex*)a)->real().isMOne() && ((gmp_complex*)a)->imag().isZero());
362  //return (((gmp_complex*)a)->real().isMOne());
363 }
364 
365 /*2
366 * extracts the number a from s, returns the rest
367 */
368 const char * ngcRead (const char * s, number * a, const coeffs r)
369 {
370  assume( getCoeffType(r) == n_long_C );
371  const char * const complex_parameter = n_ParameterNames(r)[0];
372  assume( complex_parameter != NULL );
373  const int N = strlen(complex_parameter);
374 
375  if ((*s >= '0') && (*s <= '9'))
376  {
377  gmp_float *re=NULL;
378  s=ngfRead(s,(number *)&re, r); // FIXME? TODO? // extern const char * ngfRead (const char *s, number *a, const coeffs r);
379  gmp_complex *aa=new gmp_complex(*re);
380  *a=(number)aa;
381  delete re;
382  }
383  else if (strncmp(s, complex_parameter, N)==0)
384  {
385  s += N;
386  gmp_complex *aa=new gmp_complex(0L,1L);
387  *a=(number)aa;
388  }
389  else
390  {
391  *a=(number) new gmp_complex(1L);
392  }
393  return s;
394 }
395 
396 
397 
398 /*2
399 * write a floating point number
400 */
401 void ngcWrite (number a, const coeffs r)
402 {
403  assume( getCoeffType(r) == n_long_C );
404 
405  if (a==NULL)
406  StringAppendS("0");
407  else
408  {
409  char *out;
410  out= complexToStr(*(gmp_complex*)a, r->float_len, r);
411  StringAppendS(out);
412  // omFreeSize((void *)out, (strlen(out)+1)* sizeof(char) );
413  omFree( (void *)out );
414  }
415 }
416 
417 BOOLEAN ngcCoeffIsEqual (const coeffs r, n_coeffType n, void * parameter)
418 {
419  if (n==n_long_C)
420  {
421  LongComplexInfo* p = (LongComplexInfo *)(parameter);
422 
423  if ((p==NULL)
424  && (6==r->float_len)
425  && (6==r->float_len2)
426  && (strcmp("i",n_ParameterNames(r)[0]) == 0)
427  )
428  return TRUE;
429  if ((p!=NULL) &&
430  (p->float_len == r->float_len) &&
431  (p->float_len2 == r->float_len2)
432  )
433  if (strcmp(p->par_name, n_ParameterNames(r)[0]) == 0)
434  return (TRUE);
435  }
436  return (FALSE);
437 }
438 
439 static void ngcKillChar(coeffs r)
440 {
441  char** p = (char**)n_ParameterNames(r);
442 
443  const int P = n_NumberOfParameters(r);
444 
445  for( int i = 1; i <= P; i++ )
446  if (p[i-1] != NULL)
447  omFree( (ADDRESS)p[i-1] );
448 
449  omFreeSize((ADDRESS)p, P * sizeof(char*));
450 }
451 
452 static char* ngcCoeffString(const coeffs r)
453 {
454  const char *p=n_ParameterNames(r)[0];
455  char *s=(char*)omAlloc(31+strlen(p));
456  sprintf(s,"complex,%d,%d,%s",r->float_len,r->float_len2,p);
457  return s;
458 }
459 
460 BOOLEAN ngcInitChar(coeffs n, void* parameter)
461 {
462  assume( getCoeffType(n) == n_long_C );
463  n->is_field=TRUE;
464  n->is_domain=TRUE;
465  n->rep=n_rep_gmp_complex;
466 
467  n->cfKillChar = ngcKillChar;
468  n->ch = 0;
469  n->cfCoeffString=ngcCoeffString;
470 
471  n->cfDelete = ngcDelete;
472  //n->cfNormalize=ndNormalize;
473  n->cfInit = ngcInit;
474  n->cfInt = ngcInt;
475  n->cfAdd = ngcAdd;
476  n->cfSub = ngcSub;
477  n->cfMult = ngcMult;
478  n->cfDiv = ngcDiv;
479  n->cfExactDiv= ngcDiv;
480  n->cfInpNeg = ngcNeg;
481  n->cfInvers = ngcInvers;
482  n->cfCopy = ngcCopy;
483  n->cfGreater = ngcGreater;
484  n->cfEqual = ngcEqual;
485  n->cfIsZero = ngcIsZero;
486  n->cfIsOne = ngcIsOne;
487  n->cfIsMOne = ngcIsMOne;
488  n->cfGreaterZero = ngcGreaterZero;
489 
490  n->cfWriteLong = ngcWrite;
491  n->cfWriteShort = ngcWrite;
492 
493  n->cfRead = ngcRead;
494  n->cfPower = ngcPower;
495  n->cfSetMap = ngcSetMap;
496  n->cfRePart = ngcRePart;
497  n->cfImPart = ngcImPart;
498  n->cfCoeffWrite = ngcCoeffWrite;
499  // cfSize = ndSize;
500 #ifdef LDEBUG
501  //n->cfDBTest = ndDBTest; // not yet implemented: ngcDBTest
502 #endif
503 
504  n->nCoeffIsEqual = ngcCoeffIsEqual;
505 
506  n->cfSetChar=ngcSetChar;
507 
508 // we need to initialize n->nNULL at least for minpoly printing
509  n->nNULL = n->cfInit(0,n);
510 
511 /*
512  //r->cfInitChar=nlInitChar;
513  r->cfKillChar=NULL;
514 
515  r->cfMult = nlMult;
516  r->cfSub = nlSub;
517  r->cfAdd = nlAdd;
518  r->cfDiv = nlDiv;
519  r->cfIntMod= nlIntMod;
520  r->cfExactDiv= nlExactDiv;
521  r->cfInit = nlInit;
522  r->cfSize = nlSize;
523  r->cfInt = nlInt;
524 #ifdef HAVE_RINGS
525  r->cfDivComp = NULL; // only for ring stuff
526  r->cfIsUnit = NULL; // only for ring stuff
527  r->cfGetUnit = NULL; // only for ring stuff
528  r->cfExtGcd = NULL; // only for ring stuff
529 #endif
530  r->cfInpNeg = nlNeg;
531  r->cfInvers= nlInvers;
532  r->cfCopy = nl_Copy;
533  r->cfRePart = nl_Copy;
534  r->cfImPart = ndReturn0;
535  r->cfWriteLong = nlWrite;
536  r->cfRead = nlRead;
537  r->cfNormalize=nlNormalize;
538  r->cfGreater = nlGreater;
539 #ifdef HAVE_RINGS
540  r->cfDivBy = NULL; // only for ring stuff
541 #endif
542  r->cfEqual = nlEqual;
543  r->cfIsZero = nlIsZero;
544  r->cfIsOne = nlIsOne;
545  r->cfIsMOne = nlIsMOne;
546  r->cfGreaterZero = nlGreaterZero;
547  r->cfPower = nlPower;
548  r->cfGetDenom = nlGetDenom;
549  r->cfGetNumerator = nlGetNumerator;
550  r->cfGcd = nlGcd;
551  r->cfLcm = nlLcm;
552  r->cfDelete= nlDelete;
553  r->cfSetMap = nlSetMap;
554  r->cfName = ndName;
555  r->cfInpMult=nlInpMult;
556  r->cfInit_bigint=nlCopyMap;
557 #ifdef LDEBUG
558  // debug stuff
559  r->cfDBTest=nlDBTest;
560 #endif
561 
562  // the variables:
563  r->nNULL = INT_TO_SR(0);
564  r->type = n_Q;
565  r->ch = 0;
566  r->has_simple_Alloc=FALSE;
567  r->has_simple_Inverse=FALSE;
568 */
569 
570  n->iNumberOfParameters = 1;
571  n->cfParameter = ngcParameter;
572 
573  char ** pParameterNames = (char **) omAlloc0(sizeof(char *));
574 
575  if( parameter != NULL)
576  {
577  LongComplexInfo* p = (LongComplexInfo*)parameter;
578  pParameterNames[0] = omStrDup(p->par_name);
579  // fix wrong parameters:
581  n->float_len = p->float_len;
582  n->float_len2 = p->float_len2;
583 
584  } else // default values, just for testing!
585  {
586  pParameterNames[0] = omStrDup("i");
587  n->float_len = SHORT_REAL_LENGTH;
588  n->float_len2 = SHORT_REAL_LENGTH;
589  }
590 
591  assume( pParameterNames != NULL );
592  assume( pParameterNames[0] != NULL );
593 
594  n->pParameterNames = (const char**)pParameterNames;
595 
596  // NOTE: n->complex_parameter was replaced by n_ParameterNames(n)[0]
597  // TODO: nfKillChar MUST destroy n->pParameterNames[0] (0-term. string) && n->pParameterNames (array of size 1)
598 
599  return FALSE;
600 }
601 
602 void ngcSetChar(const coeffs r)
603 {
604  setGMPFloatDigits(r->float_len, r->float_len2);
605 }
606 
607 
608 
609 number ngcMapQ(number from, const coeffs aRing, const coeffs r)
610 {
611  assume( getCoeffType(r) == n_long_C );
612  assume( aRing->rep == n_rep_gap_rat);
613 
614  if ( from != NULL )
615  {
617  return (number)res;
618  }
619  else
620  return NULL;
621 }
622 
623 number ngcMapZ(number from, const coeffs aRing, const coeffs r)
624 {
625  assume( getCoeffType(r) == n_long_C );
626  assume( aRing->rep == n_rep_gap_gmp);
627 
628  if ( from != NULL )
629  {
630  if (SR_HDL(from) & SR_INT)
631  {
632  gmp_float f_i= gmp_float(SR_TO_INT(from));
633  gmp_complex *res=new gmp_complex(f_i);
634  return (number)res;
635  }
636  gmp_float f_i=(mpz_ptr)from;
637  gmp_complex *res=new gmp_complex(f_i);
638  return (number)res;
639  }
640  else
641  return NULL;
642 }
643 
644 static number ngcMapLongR(number from, const coeffs aRing, const coeffs r)
645 {
646  assume( getCoeffType(r) == n_long_C );
647  assume( getCoeffType(aRing) == n_long_R );
648 
649  if ( from != NULL )
650  {
651  gmp_complex *res=new gmp_complex(*((gmp_float *)from));
652  return (number)res;
653  }
654  else
655  return NULL;
656 }
657 
658 static number ngcMapR(number from, const coeffs aRing, const coeffs r)
659 {
660  assume( getCoeffType(r) == n_long_C );
661  assume( getCoeffType(aRing) == n_R );
662 
663  if ( from != NULL )
664  {
665  gmp_complex *res=new gmp_complex((double)nrFloat(from)); // FIXME? TODO? // extern float nrFloat(number n);
666  return (number)res;
667  }
668  else
669  return NULL;
670 }
671 
672 static number ngcMapP(number from, const coeffs aRing, const coeffs r)
673 {
674  assume( getCoeffType(r) == n_long_C );
675  assume( getCoeffType(aRing) == n_Zp );
676 
677  if ( from != NULL )
678  return ngcInit(npInt(from, aRing), r); // FIXME? TODO? // extern int npInt (number &n, const coeffs r);
679  else
680  return NULL;
681 }
682 
683 static number ngcCopyMap(number from, const coeffs aRing, const coeffs r)
684 {
685  assume( getCoeffType(r) == n_long_C );
686  assume( getCoeffType(aRing) == n_long_C );
687 
688  gmp_complex* b = NULL;
689 
690  if ( from != NULL )
691  {
692  b = new gmp_complex( *(gmp_complex*)from );
693  }
694  return (number)b;
695 }
696 
697 nMapFunc ngcSetMap(const coeffs src, const coeffs dst)
698 {
699  assume( getCoeffType(dst) == n_long_C );
700 
701  if (src->rep==n_rep_gap_rat) /* Q, Z*/
702  {
703  return ngcMapQ;
704  }
705  if (src->rep==n_rep_gap_gmp) /* Z */
706  {
707  return ngcMapZ;
708  }
709  if ((src->rep==n_rep_gmp_float) && nCoeff_is_long_R(src))
710  {
711  return ngcMapLongR;
712  }
713  if ((src->rep==n_rep_gmp_complex) && nCoeff_is_long_C(src))
714  {
715  return ngcCopyMap;
716  }
717  if ((src->rep==n_rep_float) && nCoeff_is_R(src))
718  {
719  return ngcMapR;
720  }
721  if ((src->rep==n_rep_int) && nCoeff_is_Zp(src))
722  {
723  return ngcMapP;
724  }
725  return NULL;
726 }
727 
728 void ngcCoeffWrite (const coeffs r, BOOLEAN /*details*/)
729 {
730  Print("// characteristic : 0 (complex:%d digits, additional %d digits)\n",
731  r->float_len, r->float_len2); /* long C */
732  Print("// 1 parameter : %s \n", n_ParameterNames(r)[0]); // this trailing space is for compatibility with the legacy Singular
733  Print("// minpoly : (%s^2+1)\n", n_ParameterNames(r)[0]);
734 }
#define n_New(n, r)
Definition: coeffs.h:444
void ngcPower(number x, int exp, number *lu, const coeffs r)
Definition: gnumpc.cc:238
static void ngcKillChar(coeffs r)
Definition: gnumpc.cc:439
static FORCE_INLINE char const ** n_ParameterNames(const coeffs r)
Returns a (const!) pointer to (const char*) names of parameters.
Definition: coeffs.h:812
const CanonicalForm int s
Definition: facAbsFact.cc:55
number ngcRePart(number a, const coeffs r)
Definition: gnumpc.cc:290
void ngcDelete(number *a, const coeffs r)
Definition: gnumpc.cc:131
number ngcInit(long i, const coeffs r)
Definition: gnumpc.cc:94
void ngcWrite(number a, const coeffs r)
Definition: gnumpc.cc:401
number ngcImPart(number a, const coeffs r)
Definition: gnumpc.cc:298
const poly a
Definition: syzextra.cc:212
#define Print
Definition: emacs.cc:83
static FORCE_INLINE BOOLEAN nCoeff_is_Zp(const coeffs r)
Definition: coeffs.h:834
#define SHORT_REAL_LENGTH
Definition: numbers.h:54
long npInt(number &n, const coeffs r)
Definition: modulop.cc:140
#define FALSE
Definition: auxiliary.h:97
static number ngcMapR(number from, const coeffs aRing, const coeffs r)
Definition: gnumpc.cc:658
return P p
Definition: myNF.cc:203
char const ** pParameterNames
array containing the names of Parameters (default NULL)
Definition: coeffs.h:326
static FORCE_INLINE BOOLEAN nCoeff_is_long_R(const coeffs r)
Definition: coeffs.h:905
nMapFunc ngcSetMap(const coeffs src, const coeffs dst)
Get a mapping function from src into the domain of this type: long_C!
Definition: gnumpc.cc:697
static FORCE_INLINE BOOLEAN nCoeff_is_R(const coeffs r)
Definition: coeffs.h:850
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
{p < 2^31}
Definition: coeffs.h:30
long ngcInt(number &n, const coeffs r)
Definition: gnumpc.cc:106
(), see rinteger.h, new impl.
Definition: coeffs.h:112
number ngcMapZ(number from, const coeffs aRing, const coeffs r)
Definition: gnumpc.cc:623
#define TRUE
Definition: auxiliary.h:101
number ngcDiv(number a, number b, const coeffs r)
Definition: gnumpc.cc:221
void * ADDRESS
Definition: auxiliary.h:118
number ngcMapQ(number from, const coeffs r, const coeffs aRing)
Definition: gnumpc.cc:609
void WerrorS(const char *s)
Definition: feFopen.cc:24
gmp_complex numbers based on
Definition: mpr_complex.h:178
int ngcSize(number n, const coeffs R)
Definition: gnumpc.cc:113
static FORCE_INLINE BOOLEAN nCoeff_is_long_C(const coeffs r)
Definition: coeffs.h:908
#define omAlloc(size)
Definition: omAllocDecl.h:210
BOOLEAN ngcCoeffIsEqual(const coeffs r, n_coeffType n, void *parameter)
Definition: gnumpc.cc:417
Rational abs(const Rational &a)
Definition: GMPrat.cc:443
real floating point (GMP) numbers
Definition: coeffs.h:34
short float_len2
additional char-flags, rInit
Definition: coeffs.h:102
void ngcCoeffWrite(const coeffs r, BOOLEAN details)
Definition: gnumpc.cc:728
static FORCE_INLINE int n_NumberOfParameters(const coeffs r)
Returns the number of parameters.
Definition: coeffs.h:808
static number ngcMapP(number from, const coeffs aRing, const coeffs r)
Definition: gnumpc.cc:672
poly res
Definition: myNF.cc:322
static char * ngcCoeffString(const coeffs r)
Definition: gnumpc.cc:452
single prescision (6,6) real numbers
Definition: coeffs.h:32
void ngcSetChar(const coeffs r)
Definition: gnumpc.cc:602
BOOLEAN ngcInitChar(coeffs n, void *parameter)
Initialize r (n_long_C)
Definition: gnumpc.cc:460
short float_len
additional char-flags, rInit
Definition: coeffs.h:101
const ring r
Definition: syzextra.cc:208
float nrFloat(number n)
Converts a n_R number into a float. Needed by Maps.
Definition: shortfl.cc:75
Coefficient rings, fields and other domains suitable for Singular polynomials.
BOOLEAN ngcGreaterZero(number za, const coeffs r)
Note: MAY NOT WORK AS EXPECTED!
Definition: gnumpc.cc:309
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:49
number ngcSub(number la, number li, const coeffs r)
Definition: gnumpc.cc:199
#define omFree(addr)
Definition: omAllocDecl.h:261
#define assume(x)
Definition: mod2.h:403
The main handler for Singular numbers which are suitable for Singular polynomials.
void StringAppendS(const char *st)
Definition: reporter.cc:107
const char * ngfRead(const char *s, number *a, const coeffs r)
Definition: gnumpfl.cc:338
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:73
const ring R
Definition: DebugPrint.cc:36
complex floating point (GMP) numbers
Definition: coeffs.h:42
(gmp_complex), see gnumpc.h
Definition: coeffs.h:118
All the auxiliary stuff.
BOOLEAN ngcDBTest(number a, const char *f, const int l, const coeffs r)
Definition: gnumpc.cc:72
const char *const nDivBy0
Definition: numbers.h:83
FILE * f
Definition: checklibs.c:7
int i
Definition: cfEzgcd.cc:123
#define QTOF
Definition: mpr_complex.h:19
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425
BOOLEAN ngcIsOne(number a, const coeffs r)
Definition: gnumpc.cc:346
#define SR_TO_INT(SR)
Definition: longrat.h:70
(number), see longrat.h
Definition: coeffs.h:111
BOOLEAN ngcIsZero(number za, const coeffs r)
Definition: gnumpc.cc:283
n_coeffType
Definition: coeffs.h:27
BOOLEAN ngcIsMOne(number a, const coeffs r)
Definition: gnumpc.cc:357
#define NULL
Definition: omList.c:10
number ngcMult(number a, number b, const coeffs r)
Definition: gnumpc.cc:210
number ngcAdd(number la, number li, const coeffs r)
Definition: gnumpc.cc:188
const char * ngcRead(const char *s, number *a, const coeffs r)
Definition: gnumpc.cc:368
(gmp_float), see
Definition: coeffs.h:117
BOOLEAN ngcGreater(number a, number b, const coeffs r)
Definition: gnumpc.cc:322
gmp_float numberFieldToFloat(number num, int k, const coeffs src)
Definition: mpr_complex.cc:440
#define SR_INT
Definition: longrat.h:68
const CanonicalForm & w
Definition: facAbsFact.cc:55
number ngcParameter(int i, const coeffs r)
Definition: gnumpc.cc:80
Variable x
Definition: cfModGcd.cc:4023
bool isZero(const CFArray &A)
checks if entries of A are zero
const char * par_name
parameter name
Definition: coeffs.h:103
p exp[i]
Definition: DebugPrint.cc:39
char * complexToStr(gmp_complex &c, const unsigned int oprec, const coeffs src)
Definition: mpr_complex.cc:717
(int), see modulop.h
Definition: coeffs.h:110
#define SR_HDL(A)
Definition: tgb.cc:35
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:459
number ngc_Copy(number a, coeffs r)
void setGMPFloatDigits(size_t digits, size_t rest)
Set size of mantissa digits - the number of output digits (basis 10) the size of mantissa consists of...
Definition: mpr_complex.cc:62
kBucketDestroy & P
Definition: myNF.cc:191
number ngcInvers(number a, const coeffs r)
Definition: gnumpc.cc:169
static number ngcCopyMap(number from, const coeffs aRing, const coeffs r)
Definition: gnumpc.cc:683
static number ngcMapLongR(number from, const coeffs aRing, const coeffs r)
Definition: gnumpc.cc:644
int BOOLEAN
Definition: auxiliary.h:88
const poly b
Definition: syzextra.cc:213
number ngcNeg(number za, const coeffs r)
Definition: gnumpc.cc:157
static int sign(int x)
Definition: ring.cc:3412
static CanonicalForm oneNorm(const CanonicalForm &F)
BOOLEAN ngcEqual(number a, number b, const coeffs r)
Definition: gnumpc.cc:334
#define omAlloc0(size)
Definition: omAllocDecl.h:211
number ngcCopy(number a, const coeffs r)
Definition: gnumpc.cc:145
int l
Definition: cfEzgcd.cc:94
(float), see shortfl.h
Definition: coeffs.h:116
#define omStrDup(s)
Definition: omAllocDecl.h:263