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