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