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