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