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