mpr_complex.cc
Go to the documentation of this file.
1 /****************************************
2 * Computer Algebra System SINGULAR *
3 ****************************************/
4 
5 /*
6 * ABSTRACT - multipolynomial resultants - real floating-point numbers using gmp
7 * and complex numbers based on pairs of real floating-point numbers
8 *
9 */
10 
11 // WARNING! ALWAYS use omAlloc and FreeL when alloc. memory for some char* !!
12 
13 
14 #include <misc/auxiliary.h>
15 #include <omalloc/omalloc.h>
16 
17 #include <reporter/reporter.h>
18 
19 //#ifdef HAVE_MPR
20 #include <coeffs/coeffs.h>
21 #include <coeffs/numbers.h>
22 
23 #include <coeffs/mpr_complex.h>
24 
25 #include "longrat.h"
26 
27 #include <math.h>
28 
29 
30 //%s
31 // this was copied form longrat0.cc
32 // and will be used in numberToFloat.
33 // Make sure that it is up to date!!
34 #define SR_HDL(A) ((long)(A))
35 #define SR_TO_INT(SR) (((long)SR) >> 2)
36 
37 #define SIGN_PLUS 1
38 #define SIGN_SPACE 2
39 #define SIGN_EMPTY 4
40 
41 #define EXTRABYTES 4
42 
43 #define DEFPREC 20 // minimum number of digits (output operations)
45 
48 
49 
50 /** Set size of mantissa
51  * digits - the number of output digits (basis 10)
52  * the size of mantissa consists of two parts:
53  * the "output" part a and the "rest" part b.
54  * According to the GMP-precision digits is
55  * recomputed to bits (basis 2).
56  * Two numbers a, b are equal if
57  * | a - b | < | a | * 0.1^digits .
58  * In this case we have a - b = 0 .
59  * The epsilon e is e=0.1^(digits+rest) with
60  * 1+e != 1, but 1+0.1*e = 1.
61  */
62 void setGMPFloatDigits( size_t digits, size_t rest )
63 {
64  size_t bits = 1 + (size_t) ((float)digits * 3.5);
65  size_t rb = 1 + (size_t) ((float)rest * 3.5);
66  size_t db = bits+rb;
67  gmp_output_digits= digits;
68  mpf_set_default_prec( db );
69  if (diff!=NULL) delete diff;
70  diff=new gmp_float(0.0);
71  mpf_set_prec(*diff->_mpfp(),32);
72  if (gmpRel!=NULL) delete gmpRel;
73  gmpRel=new gmp_float(0.0);
74  mpf_set_prec(*gmpRel->_mpfp(),32);
75  mpf_set_d(*gmpRel->_mpfp(),0.1);
76  mpf_pow_ui(*gmpRel->_mpfp(),*gmpRel->_mpfp(),digits);
77 }
78 
79 #if 1
80 void gmp_float::setFromStr(const char * in )
81 {
82  BOOLEAN neg=false;
83  if (*in == '-') { in++; neg=TRUE; }
84  char *s;
85  if ((s=strchr((char *)in,'E')) !=NULL)
86  {
87  *s='e';
88  }
89 
90  // gmp doesn't understand number which begin with "." -- it needs 0.
91  // so, insert the zero
92  if (*in == '.')
93  {
94  int len = strlen(in)+2;
95  char* c_in = (char*) omAlloc(len);
96  *c_in = '0';
97  strcpy(&(c_in[1]), in);
98 
99  if(mpf_set_str( t, c_in, 10 )!=0) WerrorS("syntax error in GMP float");
100  omFreeSize((void*)c_in, len);
101  }
102  else
103  {
104  if(mpf_set_str( t, in, 10 )!=0) WerrorS("syntax error in GMP float");
105  }
106  if (neg) mpf_neg( t, t );
107 }
108 #else
109 // problemns with solve_s.tst
110 void gmp_float::setFromStr(const char * in )
111 {
112  BOOLEAN neg=false;
113  BOOLEAN E_found=FALSE;
114  if (*in == '-') { in++; neg=TRUE; }
115  char *s;
116  if ((s=strchr(in,'E')) !=NULL)
117  {
118  *s='e';
119  E_found=TRUE;
120  }
121  // gmp doesn't understand number like 1e1, it need 1e+1
122  // so, insert the +
123  if (E_found ||((s=strchr(in,'e')) !=NULL))
124  {
125  if ((*(s+1)!='+') && (*(s+1)!='-'))
126  {
127  int len = strlen(in)+3;
128  char* c_in = (char*) omAlloc(len);
129  if (*in == '.')
130  {
131  *c_in = '0';
132  strcpy(&(c_in[1]), in);
133  }
134  else
135  {
136  strcpy(c_in, in);
137  }
138  char * ss=strchr(c_in,'e');
139  memmove(ss+2,s+1,strlen(s+1));
140  *(ss+1)+'+';
141 
142  mpf_set_str( t, c_in, 10 );
143  omFreeSize((void*)c_in, len);
144  }
145  }
146 
147  // gmp doesn't understand number which begin with "." -- it needs 0.
148  // so, insert the zero
149  else if (*in == '.')
150  {
151  int len = strlen(in)+2;
152  char* c_in = (char*) omAlloc(len);
153  *c_in = '0';
154  strcpy(&(c_in[1]), in);
155 
156  mpf_set_str( t, c_in, 10 );
157  omFreeSize((void*)c_in, len);
158  }
159  else
160  {
161  mpf_set_str( t, in, 10 );
162  }
163  if (neg) mpf_neg( t, t );
164 }
165 #endif
166 
167 
168 // <gmp_float> = <gmp_float> operator <gmp_float>
170 {
171  gmp_float tmp( a );
172  tmp += b;
173  return tmp;
174 }
176 {
177  gmp_float tmp( a );
178  tmp -= b;
179  return tmp;
180 }
182 {
183  gmp_float tmp( a );
184  tmp *= b;
185  return tmp;
186 }
188 {
189  gmp_float tmp( a );
190  tmp /= b;
191  return tmp;
192 }
193 
194 // <gmp_float> operator <gmp_float>
196 {
197  if (mpf_sgn(t) != -(mpf_sgn(a.t)))
198  {
199  mpf_add( t, t, a.t);
200  return *this;
201  }
202  if((mpf_sgn(a.t)==0) && (mpf_sgn(t)==0))
203  {
204  mpf_set_d( t, 0.0);
205  return *this;
206  }
207  mpf_add( t, t, a.t );
208  mpf_set(diff->t, t);
209  mpf_set_prec(diff->t, 32);
210  mpf_div(diff->t, diff->t, a.t);
211  mpf_abs(diff->t, diff->t);
212  if(mpf_cmp(diff->t, gmpRel->t) < 0)
213  mpf_set_d( t, 0.0);
214  return *this;
215 }
217 {
218  if (mpf_sgn(t) != mpf_sgn(a.t))
219  {
220  mpf_sub( t, t, a.t);
221  return *this;
222  }
223  if((mpf_sgn(a.t)==0) && (mpf_sgn(t)==0))
224  {
225  mpf_set_d( t, 0.0);
226  return *this;
227  }
228  mpf_sub( t, t, a.t );
229  mpf_set(diff->t, t);
230  mpf_set_prec(diff->t, 32);
231  mpf_div(diff->t, diff->t, a.t);
232  mpf_abs(diff->t, diff->t);
233  if(mpf_cmp(diff->t, gmpRel->t) < 0)
234  mpf_set_d( t, 0.0);
235  return *this;
236 }
237 
238 // <gmp_float> == <gmp_float> ??
239 bool operator == ( const gmp_float & a, const gmp_float & b )
240 {
241  if(mpf_sgn(a.t) != mpf_sgn(b.t))
242  return false;
243  if((mpf_sgn(a.t)==0) && (mpf_sgn(b.t)==0))
244  return true;
245  mpf_sub(diff->t, a.t, b.t);
246  mpf_div(diff->t, diff->t, a.t);
247  mpf_abs(diff->t, diff->t);
248  if(mpf_cmp(diff->t, gmpRel->t) < 0)
249  return true;
250  else
251  return false;
252 }
253 // t == 0 ?
254 bool gmp_float::isZero() const
255 {
256  return (mpf_sgn( t ) == 0);
257 }
258 // t == 1 ?
259 bool gmp_float::isOne() const
260 {
261 #ifdef VARIANTE_1
262  return (mpf_cmp_ui( t , 1 ) == 0);
263 #else
264  if (mpf_sgn(t) <= 0)
265  return false;
266  mpf_sub_ui(diff->t, t, 1);
267  mpf_abs(diff->t, diff->t);
268  if(mpf_cmp(diff->t, gmpRel->t) < 0)
269  return true;
270  else
271  return false;
272 #endif
273 }
274 // t == -1 ?
275 bool gmp_float::isMOne() const
276 {
277 #ifdef VARIANTE_1
278  return (mpf_cmp_si( t , -1 ) == 0);
279 #else
280  if (mpf_sgn(t) >= 0)
281  return false;
282  mpf_add_ui(diff->t, t, 1);
283  mpf_abs(diff->t, diff->t);
284  if(mpf_cmp(diff->t, gmpRel->t) < 0)
285  return true;
286  else
287  return false;
288 #endif
289 }
290 bool operator > ( const gmp_float & a, const gmp_float & b )
291 {
292  if (a.t == b.t)
293  return false;
294  return mpf_cmp( a.t, b.t ) > 0;
295 }
296 bool operator < ( const gmp_float & a, const gmp_float & b )
297 {
298  if (a.t == b.t)
299  return false;
300  return mpf_cmp( a.t, b.t ) < 0;
301 }
302 bool operator >= ( const gmp_float & a, const gmp_float & b )
303 {
304  if (a.t == b.t)
305  return true;
306  return mpf_cmp( a.t, b.t ) >= 0;
307 }
308 bool operator <= ( const gmp_float & a, const gmp_float & b )
309 {
310  if (a.t == b.t)
311  return true;
312  return mpf_cmp( a.t, b.t ) <= 0;
313 }
314 
315 // unary -
317 {
318  gmp_float tmp;
319  mpf_neg( *(tmp._mpfp()), *(a.mpfp()) );
320  return tmp;
321 }
322 
324 {
325  gmp_float tmp;
326  mpf_abs( *(tmp._mpfp()), *a.mpfp() );
327  return tmp;
328 }
330 {
331  gmp_float tmp;
332  mpf_sqrt( *(tmp._mpfp()), *a.mpfp() );
333  return tmp;
334 }
336 {
337  gmp_float tmp( sin((double)a) );
338  return tmp;
339 }
341 {
342  gmp_float tmp( cos((double)a) );
343  return tmp;
344 }
346 {
347  gmp_float tmp( log((double)a) );
348  return tmp;
349 }
350 gmp_float hypot( const gmp_float & a, const gmp_float & b )
351 {
352 #if 1
353  return ( sqrt( (a*a) + (b*b) ) );
354 #else
355  gmp_float tmp( hypot( (double)a, (double)b ) );
356  return tmp;
357 #endif
358 }
360 {
361  gmp_float tmp( exp((double)a) );
362  return tmp;
363 }
364 gmp_float max( const gmp_float & a, const gmp_float & b )
365 {
366  gmp_float tmp;
367  a > b ? tmp= a : tmp= b;
368  return tmp;
369 }
370 //
371 // number to float, number = Q, R, C
372 // makes a COPY of num! (Ist das gut?)
373 //
374 gmp_float numberToFloat( number num, const coeffs src)
375 {
376  gmp_float r;
377 
378  if ( nCoeff_is_Q(src) )
379  {
380  if ( num != NULL )
381  {
382  if (SR_HDL(num) & SR_INT)
383  {
384  //n_Print(num, src);printf("\n");
385  int nn = SR_TO_INT(num);
386  if((long)nn == SR_TO_INT(num))
387  r = SR_TO_INT(num);
388  else
389  r = gmp_float(SR_TO_INT(num));
390  //int dd = 20;
391  //gmp_printf("\nr = %.*Ff\n",dd,*r.mpfp());
392  //getchar();
393  }
394  else
395  {
396  if ( num->s == 0 )
397  {
398  nlNormalize( num, src ); // FIXME? TODO? // extern void nlNormalize(number &x, const coeffs r); // FIXME
399  }
400  if (SR_HDL(num) & SR_INT)
401  {
402  r= SR_TO_INT(num);
403  }
404  else
405  {
406  if ( num->s != 3 )
407  {
408  r= num->z;
409  r/= (gmp_float)num->n;
410  }
411  else
412  {
413  r= num->z;
414  }
415  }
416  }
417  }
418  else
419  {
420  r= 0.0;
421  }
422  }
423  else if (nCoeff_is_long_R(src) || nCoeff_is_long_C(src))
424  {
425  r= *(gmp_float*)num;
426  }
427  else if ( nCoeff_is_R(src) )
428  {
429  // Add some code here :-)
430  WerrorS("Ground field not implemented!");
431  }
432  else
433  {
434  WerrorS("Ground field not implemented!");
435  }
436 
437  return r;
438 }
439 
440 gmp_float numberFieldToFloat( number num, int k, const coeffs src)
441 {
442  gmp_float r;
443 
444  switch (k)
445  {
446  case QTOF:
447  if ( num != NULL )
448  {
449  if (SR_HDL(num) & SR_INT)
450  {
451  r = gmp_float(SR_TO_INT(num));
452  }
453  else
454  {
455  if ( num->s == 0 )
456  {
457  nlNormalize( num, src ); // FIXME? TODO? // extern void nlNormalize(number &x, const coeffs r); // FIXME
458  }
459  if (SR_HDL(num) & SR_INT)
460  {
461  r = gmp_float(SR_TO_INT(num));
462  }
463  else
464  {
465  if ( num->s != 3 )
466  {
467  r= num->z;
468  r/= (gmp_float)num->n;
469  }
470  else
471  {
472  r= num->z;
473  }
474  }
475  }
476  }
477  else
478  {
479  r= 0.0;
480  }
481  break;
482  case RTOF:
483  r= *(gmp_float*)num;
484  break;
485  case CTOF:
486  WerrorS("Can not map from field C to field R!");
487  break;
488  case ZTOF:
489  default:
490  WerrorS("Ground field not implemented!");
491  } // switch
492 
493  return r;
494 }
495 
496 // Do some strange things with the mantissa string and the exponent
497 // to get some nice output string.
498 char *nicifyFloatStr( char * in, mp_exp_t exponent, size_t oprec, int *size, int thesign )
499 {
500  char *out;
501 
502  int sign= (in[0] == '-') ? 1 : 0;
503  char csign[2];
504 
505  switch (thesign)
506  {
507  case SIGN_PLUS:
508  sign ? strcpy(csign,"-") : strcpy(csign,"+"); //+123, -123
509  break;
510  case SIGN_SPACE:
511  sign ? strcpy(csign,"-") : strcpy(csign," "); // 123, -123
512  break;
513  case SIGN_EMPTY:
514  default:
515  sign ? strcpy(csign,"-") : strcpy(csign,""); //123, -123
516  break;
517  }
518 
519  if ( strlen(in) == 0 )
520  {
521  *size= 2*sizeof(char);
522  return omStrDup("0");
523  }
524 
525  if ( ((unsigned int)ABS(exponent) <= oprec)
526  /*|| (exponent+sign >= (int)strlen(in))*/ )
527  {
528  if ( exponent+sign < (int)strlen(in) )
529  {
530  int eexponent= (exponent >= 0) ? 0 : -exponent;
531  int eeexponent= (exponent >= 0) ? exponent : 0;
532  *size= (strlen(in)+15+eexponent) * sizeof(char);
533  out= (char*)omAlloc(*size);
534  memset(out,0,*size);
535 
536  strcpy(out,csign);
537  strncat(out,in+sign,eeexponent);
538 
539  if (exponent == 0)
540  strcat(out,"0.");
541  else if ( exponent > 0 )
542  strcat(out,".");
543  else
544  {
545  strcat(out,"0.");
546  memset(out+strlen(out),'0',eexponent);
547  }
548  strcat(out,in+sign+eeexponent);
549  }
550  else if ( exponent+sign > (int)strlen(in) )
551  {
552  *size= (strlen(in)+exponent+12)*sizeof(char);
553  out= (char*)omAlloc(*size);
554  memset(out,0,*size);
555  sprintf(out,"%s%s",csign,in+sign);
556  memset(out+strlen(out),'0',exponent-strlen(in)+sign);
557  }
558  else
559  {
560  *size= (strlen(in)+2) * sizeof(char) + 10;
561  out= (char*)omAlloc(*size);
562  memset(out,0,*size);
563  sprintf(out,"%s%s",csign,in+sign);
564  }
565  }
566  else
567  {
568 // if ( exponent > 0 )
569 // {
570  int c=1,d=10;
571  while ( exponent / d > 0 )
572  { // count digits
573  d*=10;
574  c++;
575  }
576  *size= (strlen(in)+12+c) * sizeof(char) + 10;
577  out= (char*)omAlloc(*size);
578  memset(out,0,*size);
579  sprintf(out,"%s0.%se%s%d",csign,in+sign,exponent>=0?"+":"",(int)exponent);
580 // }
581 // else
582 // {
583 // *size=2;
584 // out= (char*)omAlloc(*size);
585 // strcpy(out,"0");
586 // }
587  }
588  return out;
589 }
590 
591 char *floatToStr( const gmp_float & r, const unsigned int oprec )
592 {
593 #if 1
594  mp_exp_t exponent;
595  int size,insize;
596  char *nout,*out,*in;
597 
598  insize= (oprec+2) * sizeof(char) + 10;
599  in= (char*)omAlloc( insize );
600 
601  mpf_get_str(in,&exponent,10,oprec,*(r.mpfp()));
602 
603  if ( (exponent > 0)
604  && (exponent < (int)oprec)
605  && (strlen(in)-(in[0]=='-'?1:0) == oprec) )
606  {
607  omFree( (void *) in );
608  insize= (exponent+oprec+2) * sizeof(char) + 10;
609  in= (char*)omAlloc( insize );
610  int newprec= exponent+oprec;
611  mpf_get_str(in,&exponent,10,newprec,*(r.mpfp()));
612  }
613  nout= nicifyFloatStr( in, exponent, oprec, &size, SIGN_EMPTY );
614  omFree( (void *) in );
615  out= (char*)omAlloc( (strlen(nout)+1) * sizeof(char) );
616  strcpy( out, nout );
617  omFree( (void *) nout );
618 
619  return out;
620 #else
621  // for testing purpose...
622  char *out= (char*)omAlloc( (1024) * sizeof(char) );
623  sprintf(out,"% .10f",(double)r);
624  return out;
625 #endif
626 }
627 //<-
628 
629 //-> gmp_complex::*
630 // <gmp_complex> = <gmp_complex> operator <gmp_complex>
631 //
633 {
634  return gmp_complex( a.r + b.r, a.i + b.i );
635 }
637 {
638  return gmp_complex( a.r - b.r, a.i - b.i );
639 }
641 {
642  return gmp_complex( a.r * b.r - a.i * b.i,
643  a.r * b.i + a.i * b.r);
644 }
646 {
647  gmp_float d = b.r*b.r + b.i*b.i;
648  return gmp_complex( (a.r * b.r + a.i * b.i) / d,
649  (a.i * b.r - a.r * b.i) / d);
650 }
651 
652 // <gmp_complex> operator <gmp_complex>
653 //
655 {
656  r+=b.r;
657  i+=b.i;
658  return *this;
659 }
661 {
662  r-=b.r;
663  i-=b.i;
664  return *this;
665 }
667 {
668  gmp_float f = r * b.r - i * b.i;
669  i = r * b.i + i * b.r;
670  r = f;
671  return *this;
672 }
674 {
675  i.neg();
676  r.neg();
677  return *this;
678 }
680 {
681  gmp_float d = b.r*b.r + b.i*b.i;
682  r = (r * b.r + i * b.i) / d;
683  i = (i * b.r - r * b.i) / d;
684  return *this;
685 }
686 
687 // Returns square root of gmp_complex number
688 //
690 {
691  gmp_float r = abs(x);
692  gmp_float nr, ni;
693  if (r == (gmp_float) 0.0)
694  {
695  nr = ni = r;
696  }
697  else if ( x.real() > (gmp_float)0)
698  {
699  nr = sqrt((gmp_float)0.5 * (r + x.real()));
700  ni = x.imag() / nr / (gmp_float)2;
701  }
702  else
703  {
704  ni = sqrt((gmp_float)0.5 * (r - x.real()));
705  if (x.imag() < (gmp_float)0)
706  {
707  ni = - ni;
708  }
709  nr = x.imag() / ni / (gmp_float)2;
710  }
711  gmp_complex tmp(nr, ni);
712  return tmp;
713 }
714 
715 // converts a gmp_complex to a string ( <real part> + I * <imaginary part> )
716 //
717 char *complexToStr( gmp_complex & c, const unsigned int oprec, const coeffs src )
718 {
719  const char * complex_parameter = "I";
720  int N = 1; // strlen(complex_parameter);
721 
722  if (nCoeff_is_long_C(src))
723  {
724  complex_parameter = n_ParameterNames(src)[0];
725  N = strlen(complex_parameter);
726  }
727 
728  assume( complex_parameter != NULL && N > 0);
729 
730  char *out,*in_imag,*in_real;
731 
732  c.SmallToZero();
733  if ( !c.imag().isZero() )
734  {
735 
736  in_real=floatToStr( c.real(), oprec ); // get real part
737  in_imag=floatToStr( abs(c.imag()), oprec ); // get imaginary part
738 
739  if (nCoeff_is_long_C(src))
740  {
741  int len=(strlen(in_real)+strlen(in_imag)+7+N)*sizeof(char);
742  out=(char*)omAlloc(len);
743  memset(out,0,len);
744  if ( !c.real().isZero() ) // (-23-i*5.43) or (15.1+i*5.3)
745  sprintf(out,"(%s%s%s*%s)",in_real,c.imag().sign()>=0?"+":"-",complex_parameter,in_imag);
746  else // (-i*43) or (i*34)
747  {
748  if (c.imag().isOne())
749  sprintf(out,"%s", complex_parameter);
750  else if (c.imag().isMOne())
751  sprintf(out,"-%s", complex_parameter);
752  else
753  sprintf(out,"(%s%s*%s)",c.imag().sign()>=0?"":"-", complex_parameter,in_imag);
754  }
755  }
756  else
757  {
758  int len=(strlen(in_real)+strlen(in_imag)+9) * sizeof(char);
759  out=(char*)omAlloc( len );
760  memset(out,0,len);
761  if ( !c.real().isZero() )
762  sprintf(out,"(%s%s%s)",in_real,c.imag().sign()>=0?"+I*":"-I*",in_imag);
763  else
764  sprintf(out,"(%s%s)",c.imag().sign()>=0?"I*":"-I*",in_imag);
765  }
766  omFree( (void *) in_real );
767  omFree( (void *) in_imag );
768  }
769  else
770  {
771  out= floatToStr( c.real(), oprec );
772  }
773 
774  return out;
775 }
776 //<-
777 
778 bool complexNearZero( gmp_complex * c, int digits )
779 {
780  gmp_float eps,epsm;
781 
782  if ( digits < 1 ) return true;
783 
784  eps=pow(10.0,(int)digits);
785  //Print("eps: %s\n",floatToStr(eps,gmp_output_digits));
786  eps=(gmp_float)1.0/eps;
787  epsm=-eps;
788 
789  //Print("eps: %s\n",floatToStr(eps,gmp_output_digits));
790 
791  if ( c->real().sign() > 0 ) // +
792  return (c->real() < eps && (c->imag() < eps && c->imag() > epsm));
793  else // -
794  return (c->real() > epsm && (c->imag() < eps && c->imag() > epsm));
795 }
796 
798 {
799  gmp_float ar=this->real();
800  gmp_float ai=this->imag();
801  if (ar.isZero() || ai.isZero()) return;
802  mpf_abs(*ar._mpfp(), *ar._mpfp());
803  mpf_abs(*ai._mpfp(), *ai._mpfp());
804  mpf_set_prec(*ar._mpfp(), 32);
805  mpf_set_prec(*ai._mpfp(), 32);
806  if (ar > ai)
807  {
808  mpf_div(*ai._mpfp(), *ai._mpfp(), *ar._mpfp());
809  if (ai < *gmpRel) this->imag(0.0);
810  }
811  else
812  {
813  mpf_div(*ar._mpfp(), *ar._mpfp(), *ai._mpfp());
814  if (ar < *gmpRel) this->real(0.0);
815  }
816 }
817 
818 //%e
819 
820 //#endif // HAVE_MPR
821 
822 // local Variables: ***
823 // folded-file: t ***
824 // compile-command-1: "make installg" ***
825 // compile-command-2: "make install" ***
826 // End: ***
const mpf_t * mpfp() const
Definition: mpr_complex.h:133
bool operator==(const gmp_float &a, const gmp_float &b)
Definition: mpr_complex.cc:239
void SmallToZero()
Definition: mpr_complex.cc:797
static FORCE_INLINE char const ** n_ParameterNames(const coeffs r)
Returns a (const!) pointer to (const char*) names of parameters.
Definition: coeffs.h:796
char * nicifyFloatStr(char *in, mp_exp_t exponent, size_t oprec, int *size, int thesign)
Definition: mpr_complex.cc:498
const CanonicalForm int s
Definition: facAbsFact.cc:55
static gmp_float * diff
Definition: mpr_complex.cc:47
#define ZTOF
Definition: mpr_complex.h:18
const poly a
Definition: syzextra.cc:212
gmp_float exp(const gmp_float &a)
Definition: mpr_complex.cc:359
CanonicalForm num(const CanonicalForm &f)
#define FALSE
Definition: auxiliary.h:140
bool isZero() const
Definition: mpr_complex.cc:254
mpf_t * _mpfp()
Definition: mpr_complex.h:134
static FORCE_INLINE BOOLEAN nCoeff_is_long_R(const coeffs r)
Definition: coeffs.h:892
#define SIGN_EMPTY
Definition: mpr_complex.cc:39
#define SIGN_SPACE
Definition: mpr_complex.cc:38
#define SIGN_PLUS
Definition: mpr_complex.cc:37
static FORCE_INLINE BOOLEAN nCoeff_is_R(const coeffs r)
Definition: coeffs.h:834
bool isMOne() const
Definition: mpr_complex.cc:275
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
gmp_float & neg()
Definition: mpr_complex.h:100
gmp_float operator+(const gmp_float &a, const gmp_float &b)
Definition: mpr_complex.cc:169
gmp_float log(const gmp_float &a)
Definition: mpr_complex.cc:345
void setFromStr(const char *in)
Definition: mpr_complex.cc:80
#define TRUE
Definition: auxiliary.h:144
gmp_float i
Definition: mpr_complex.h:181
void WerrorS(const char *s)
Definition: feFopen.cc:23
int k
Definition: cfEzgcd.cc:93
gmp_complex numbers based on
Definition: mpr_complex.h:178
bool complexNearZero(gmp_complex *c, int digits)
Definition: mpr_complex.cc:778
gmp_float operator*(const gmp_float &a, const gmp_float &b)
Definition: mpr_complex.cc:181
static FORCE_INLINE BOOLEAN nCoeff_is_Q(const coeffs r)
Definition: coeffs.h:824
static FORCE_INLINE BOOLEAN nCoeff_is_long_C(const coeffs r)
Definition: coeffs.h:895
#define omAlloc(size)
Definition: omAllocDecl.h:210
gmp_complex & operator+=(const gmp_complex &a)
Definition: mpr_complex.cc:654
int sign()
Definition: mpr_complex.h:123
gmp_float operator/(const gmp_float &a, const gmp_float &b)
Definition: mpr_complex.cc:187
#define CTOF
Definition: mpr_complex.h:21
const ring r
Definition: syzextra.cc:208
Coefficient rings, fields and other domains suitable for Singular polynomials.
gmp_float r
Definition: mpr_complex.h:181
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:49
gmp_float numberToFloat(number num, const coeffs src)
Definition: mpr_complex.cc:374
#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.
gmp_float hypot(const gmp_float &a, const gmp_float &b)
Definition: mpr_complex.cc:350
gmp_complex & operator-=(const gmp_complex &a)
Definition: mpr_complex.cc:660
gmp_float sqrt(const gmp_float &a)
Definition: mpr_complex.cc:329
bool isOne() const
Definition: mpr_complex.cc:259
gmp_float abs(const gmp_float &a)
Definition: mpr_complex.cc:323
All the auxiliary stuff.
FILE * f
Definition: checklibs.c:7
bool operator<(const gmp_float &a, const gmp_float &b)
Definition: mpr_complex.cc:296
#define QTOF
Definition: mpr_complex.h:19
gmp_float cos(const gmp_float &a)
Definition: mpr_complex.cc:340
gmp_float & operator-=(const gmp_float &a)
Definition: mpr_complex.cc:216
gmp_float imag() const
Definition: mpr_complex.h:235
int size(const CanonicalForm &f, const Variable &v)
int size ( const CanonicalForm & f, const Variable & v )
Definition: cf_ops.cc:600
gmp_complex & neg()
Definition: mpr_complex.cc:673
#define SR_TO_INT(SR)
Definition: mpr_complex.cc:35
void nlNormalize(number &x, const coeffs r)
Definition: longrat.cc:1277
gmp_float operator-(const gmp_float &a, const gmp_float &b)
Definition: mpr_complex.cc:175
#define DEFPREC
Definition: mpr_complex.cc:43
gmp_complex & operator/=(const gmp_complex &a)
Definition: mpr_complex.cc:679
#define NULL
Definition: omList.c:10
bool operator>=(const gmp_float &a, const gmp_float &b)
Definition: mpr_complex.cc:302
char * floatToStr(const gmp_float &r, const unsigned int oprec)
Definition: mpr_complex.cc:591
#define SR_HDL(A)
Definition: mpr_complex.cc:34
#define ABS(x)
Definition: auxiliary.h:157
gmp_float numberFieldToFloat(number num, int k, const coeffs src)
Definition: mpr_complex.cc:440
gmp_complex & operator*=(const gmp_complex &a)
Definition: mpr_complex.cc:666
#define SR_INT
Definition: longrat.h:65
Variable x
Definition: cfModGcd.cc:4023
static gmp_float * gmpRel
Definition: mpr_complex.cc:46
gmp_float & operator+=(const gmp_float &a)
Definition: mpr_complex.cc:195
gmp_float max(const gmp_float &a, const gmp_float &b)
Definition: mpr_complex.cc:364
#define RTOF
Definition: mpr_complex.h:20
char * complexToStr(gmp_complex &c, const unsigned int oprec, const coeffs src)
Definition: mpr_complex.cc:717
int exponent(const CanonicalForm &f, int q)
int exponent ( const CanonicalForm & f, int q )
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
size_t gmp_output_digits
Definition: mpr_complex.cc:44
bool operator>(const gmp_float &a, const gmp_float &b)
Definition: mpr_complex.cc:290
Rational pow(const Rational &a, int e)
Definition: GMPrat.cc:418
int BOOLEAN
Definition: auxiliary.h:131
const poly b
Definition: syzextra.cc:213
gmp_float sin(const gmp_float &a)
Definition: mpr_complex.cc:335
gmp_float real() const
Definition: mpr_complex.h:234
int sign(const CanonicalForm &a)
#define omStrDup(s)
Definition: omAllocDecl.h:263
bool operator<=(const gmp_float &a, const gmp_float &b)
Definition: mpr_complex.cc:308