My Project
Loading...
Searching...
No Matches
Macros | Functions | Variables
mpr_complex.cc File Reference
#include "misc/auxiliary.h"
#include "reporter/reporter.h"
#include "coeffs/coeffs.h"
#include "coeffs/numbers.h"
#include "coeffs/mpr_complex.h"
#include "coeffs/longrat.h"
#include <cmath>

Go to the source code of this file.

Macros

#define SR_HDL(A)   ((long)(A))
 
#define SR_TO_INT(SR)   (((long)SR) >> 2)
 
#define SIGN_PLUS   1
 
#define SIGN_SPACE   2
 
#define SIGN_EMPTY   4
 
#define EXTRABYTES   4
 
#define DEFPREC   20
 

Functions

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 two parts: the "output" part a and the "rest" part b. More...
 
gmp_float operator+ (const gmp_float &a, const gmp_float &b)
 
gmp_float operator- (const gmp_float &a, const gmp_float &b)
 
gmp_float operator* (const gmp_float &a, const gmp_float &b)
 
gmp_float operator/ (const gmp_float &a, const gmp_float &b)
 
bool operator== (const gmp_float &a, const gmp_float &b)
 
bool operator> (const gmp_float &a, const gmp_float &b)
 
bool operator< (const gmp_float &a, const gmp_float &b)
 
bool operator>= (const gmp_float &a, const gmp_float &b)
 
bool operator<= (const gmp_float &a, const gmp_float &b)
 
gmp_float operator- (const gmp_float &a)
 
gmp_float abs (const gmp_float &a)
 
gmp_float sqrt (const gmp_float &a)
 
gmp_float sin (const gmp_float &a)
 
gmp_float cos (const gmp_float &a)
 
gmp_float log (const gmp_float &a)
 
gmp_float hypot (const gmp_float &a, const gmp_float &b)
 
gmp_float exp (const gmp_float &a)
 
gmp_float max (const gmp_float &a, const gmp_float &b)
 
gmp_float numberToFloat (number num, const coeffs src)
 
gmp_float numberFieldToFloat (number num, int cf)
 
char * nicifyFloatStr (char *in, mp_exp_t exponent, size_t oprec, int *size, int thesign)
 
char * floatToStr (const gmp_float &r, const unsigned int oprec)
 
gmp_complex operator+ (const gmp_complex &a, const gmp_complex &b)
 
gmp_complex operator- (const gmp_complex &a, const gmp_complex &b)
 
gmp_complex operator* (const gmp_complex &a, const gmp_complex &b)
 
gmp_complex operator/ (const gmp_complex &a, const gmp_complex &b)
 
gmp_complex sqrt (const gmp_complex &x)
 
char * complexToStr (gmp_complex &c, const unsigned int oprec, const coeffs src)
 
bool complexNearZero (gmp_complex *c, int digits)
 

Variables

VAR size_t gmp_output_digits = DEFPREC
 
STATIC_VAR gmp_floatgmpRel =NULL
 
STATIC_VAR gmp_floatdiff =NULL
 

Macro Definition Documentation

◆ DEFPREC

#define DEFPREC   20

Definition at line 41 of file mpr_complex.cc.

◆ EXTRABYTES

#define EXTRABYTES   4

Definition at line 39 of file mpr_complex.cc.

◆ SIGN_EMPTY

#define SIGN_EMPTY   4

Definition at line 37 of file mpr_complex.cc.

◆ SIGN_PLUS

#define SIGN_PLUS   1

Definition at line 35 of file mpr_complex.cc.

◆ SIGN_SPACE

#define SIGN_SPACE   2

Definition at line 36 of file mpr_complex.cc.

◆ SR_HDL

#define SR_HDL (   A)    ((long)(A))

Definition at line 32 of file mpr_complex.cc.

◆ SR_TO_INT

#define SR_TO_INT (   SR)    (((long)SR) >> 2)

Definition at line 33 of file mpr_complex.cc.

Function Documentation

◆ abs()

gmp_float abs ( const gmp_float a)

Definition at line 321 of file mpr_complex.cc.

322{
323 gmp_float tmp;
324 mpf_abs( *(tmp._mpfp()), *a.mpfp() );
325 return tmp;
326}
mpf_t * _mpfp()
Definition: mpr_complex.h:134
const mpf_t * mpfp() const
Definition: mpr_complex.h:133

◆ complexNearZero()

bool complexNearZero ( gmp_complex c,
int  digits 
)

Definition at line 765 of file mpr_complex.cc.

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}
Rational pow(const Rational &a, int e)
Definition: GMPrat.cc:411
gmp_float imag() const
Definition: mpr_complex.h:235
gmp_float real() const
Definition: mpr_complex.h:234
int sign()
Definition: mpr_complex.h:123

◆ complexToStr()

char * complexToStr ( gmp_complex c,
const unsigned int  oprec,
const coeffs  src 
)

Definition at line 704 of file mpr_complex.cc.

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}
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:56
void SmallToZero()
Definition: mpr_complex.cc:784
bool isOne() const
Definition: mpr_complex.cc:257
bool isMOne() const
Definition: mpr_complex.cc:273
bool isZero() const
Definition: mpr_complex.cc:252
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_long_C(const coeffs r)
Definition: coeffs.h:891
#define assume(x)
Definition: mod2.h:389
gmp_float abs(const gmp_float &a)
Definition: mpr_complex.cc:321
char * floatToStr(const gmp_float &r, const unsigned int oprec)
Definition: mpr_complex.cc:578
#define omAlloc(size)
Definition: omAllocDecl.h:210
#define omFree(addr)
Definition: omAllocDecl.h:261
#define NULL
Definition: omList.c:12

◆ cos()

gmp_float cos ( const gmp_float a)

Definition at line 338 of file mpr_complex.cc.

339{
340 gmp_float tmp( cos((double)a) );
341 return tmp;
342}
gmp_float cos(const gmp_float &a)
Definition: mpr_complex.cc:338

◆ exp()

gmp_float exp ( const gmp_float a)

Definition at line 357 of file mpr_complex.cc.

358{
359 gmp_float tmp( exp((double)a) );
360 return tmp;
361}
gmp_float exp(const gmp_float &a)
Definition: mpr_complex.cc:357

◆ floatToStr()

char * floatToStr ( const gmp_float r,
const unsigned int  oprec 
)

Definition at line 578 of file mpr_complex.cc.

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}
int size(const CanonicalForm &f, const Variable &v)
int size ( const CanonicalForm & f, const Variable & v )
Definition: cf_ops.cc:600
#define exponent
#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

◆ hypot()

gmp_float hypot ( const gmp_float a,
const gmp_float b 
)

Definition at line 348 of file mpr_complex.cc.

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}
CanonicalForm b
Definition: cfModGcd.cc:4103
gmp_float sqrt(const gmp_float &a)
Definition: mpr_complex.cc:327
gmp_float hypot(const gmp_float &a, const gmp_float &b)
Definition: mpr_complex.cc:348

◆ log()

gmp_float log ( const gmp_float a)

Definition at line 343 of file mpr_complex.cc.

344{
345 gmp_float tmp( log((double)a) );
346 return tmp;
347}
gmp_float log(const gmp_float &a)
Definition: mpr_complex.cc:343

◆ max()

gmp_float max ( const gmp_float a,
const gmp_float b 
)

Definition at line 362 of file mpr_complex.cc.

363{
364 gmp_float tmp;
365 a > b ? tmp= a : tmp= b;
366 return tmp;
367}

◆ nicifyFloatStr()

char * nicifyFloatStr ( char *  in,
mp_exp_t  exponent,
size_t  oprec,
int *  size,
int  thesign 
)

Definition at line 485 of file mpr_complex.cc.

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}
static int ABS(int v)
Definition: auxiliary.h:112
#define SIGN_SPACE
Definition: mpr_complex.cc:36
#define SIGN_PLUS
Definition: mpr_complex.cc:35
#define omStrDup(s)
Definition: omAllocDecl.h:263
static int sign(int x)
Definition: ring.cc:3427

◆ numberFieldToFloat()

gmp_float numberFieldToFloat ( number  num,
int  cf 
)

Definition at line 438 of file mpr_complex.cc.

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}
CanonicalForm num(const CanonicalForm &f)
CanonicalForm cf
Definition: cfModGcd.cc:4083
void WerrorS(const char *s)
Definition: feFopen.cc:24
#define SR_INT
Definition: longrat.h:67
#define SR_HDL(A)
Definition: mpr_complex.cc:32
#define SR_TO_INT(SR)
Definition: mpr_complex.cc:33
#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

◆ numberToFloat()

gmp_float numberToFloat ( number  num,
const coeffs  src 
)

Definition at line 372 of file mpr_complex.cc.

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}
static FORCE_INLINE BOOLEAN nCoeff_is_long_R(const coeffs r)
Definition: coeffs.h:888
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
void nlNormalize(number &x, const coeffs r)
Definition: longrat.cc:1486

◆ operator*() [1/2]

gmp_complex operator* ( const gmp_complex a,
const gmp_complex b 
)

Definition at line 627 of file mpr_complex.cc.

628{
629 return gmp_complex( a.r * b.r - a.i * b.i,
630 a.r * b.i + a.i * b.r);
631}
gmp_complex numbers based on
Definition: mpr_complex.h:179
gmp_float i
Definition: mpr_complex.h:181
gmp_float r
Definition: mpr_complex.h:181

◆ operator*() [2/2]

gmp_float operator* ( const gmp_float a,
const gmp_float b 
)

Definition at line 179 of file mpr_complex.cc.

180{
181 gmp_float tmp( a );
182 tmp *= b;
183 return tmp;
184}

◆ operator+() [1/2]

gmp_complex operator+ ( const gmp_complex a,
const gmp_complex b 
)

Definition at line 619 of file mpr_complex.cc.

620{
621 return gmp_complex( a.r + b.r, a.i + b.i );
622}

◆ operator+() [2/2]

gmp_float operator+ ( const gmp_float a,
const gmp_float b 
)

Definition at line 167 of file mpr_complex.cc.

168{
169 gmp_float tmp( a );
170 tmp += b;
171 return tmp;
172}

◆ operator-() [1/3]

gmp_complex operator- ( const gmp_complex a,
const gmp_complex b 
)

Definition at line 623 of file mpr_complex.cc.

624{
625 return gmp_complex( a.r - b.r, a.i - b.i );
626}

◆ operator-() [2/3]

gmp_float operator- ( const gmp_float a)

Definition at line 314 of file mpr_complex.cc.

315{
316 gmp_float tmp;
317 mpf_neg( *(tmp._mpfp()), *(a.mpfp()) );
318 return tmp;
319}

◆ operator-() [3/3]

gmp_float operator- ( const gmp_float a,
const gmp_float b 
)

Definition at line 173 of file mpr_complex.cc.

174{
175 gmp_float tmp( a );
176 tmp -= b;
177 return tmp;
178}

◆ operator/() [1/2]

gmp_complex operator/ ( const gmp_complex a,
const gmp_complex b 
)

Definition at line 632 of file mpr_complex.cc.

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}

◆ operator/() [2/2]

gmp_float operator/ ( const gmp_float a,
const gmp_float b 
)

Definition at line 185 of file mpr_complex.cc.

186{
187 gmp_float tmp( a );
188 tmp /= b;
189 return tmp;
190}

◆ operator<()

bool operator< ( const gmp_float a,
const gmp_float b 
)

Definition at line 294 of file mpr_complex.cc.

295{
296 if (a.t == b.t)
297 return false;
298 return mpf_cmp( a.t, b.t ) < 0;
299}

◆ operator<=()

bool operator<= ( const gmp_float a,
const gmp_float b 
)

Definition at line 306 of file mpr_complex.cc.

307{
308 if (a.t == b.t)
309 return true;
310 return mpf_cmp( a.t, b.t ) <= 0;
311}

◆ operator==()

bool operator== ( const gmp_float a,
const gmp_float b 
)

Definition at line 237 of file mpr_complex.cc.

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}
STATIC_VAR gmp_float * gmpRel
Definition: mpr_complex.cc:44
STATIC_VAR gmp_float * diff
Definition: mpr_complex.cc:45

◆ operator>()

bool operator> ( const gmp_float a,
const gmp_float b 
)

Definition at line 288 of file mpr_complex.cc.

289{
290 if (a.t == b.t)
291 return false;
292 return mpf_cmp( a.t, b.t ) > 0;
293}

◆ operator>=()

bool operator>= ( const gmp_float a,
const gmp_float b 
)

Definition at line 300 of file mpr_complex.cc.

301{
302 if (a.t == b.t)
303 return true;
304 return mpf_cmp( a.t, b.t ) >= 0;
305}

◆ 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 two parts: the "output" part a and the "rest" part b.

According to the GMP-precision digits is recomputed to bits (basis 2). Two numbers a, b are equal if | a - b | < | a | * 0.1^digits . In this case we have a - b = 0 . The epsilon e is e=0.1^(digits+rest) with 1+e != 1, but 1+0.1*e = 1.

Definition at line 60 of file mpr_complex.cc.

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}
VAR size_t gmp_output_digits
Definition: mpr_complex.cc:42

◆ sin()

gmp_float sin ( const gmp_float a)

Definition at line 333 of file mpr_complex.cc.

334{
335 gmp_float tmp( sin((double)a) );
336 return tmp;
337}
gmp_float sin(const gmp_float &a)
Definition: mpr_complex.cc:333

◆ sqrt() [1/2]

gmp_complex sqrt ( const gmp_complex x)

Definition at line 676 of file mpr_complex.cc.

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}
Variable x
Definition: cfModGcd.cc:4082

◆ sqrt() [2/2]

gmp_float sqrt ( const gmp_float a)

Definition at line 327 of file mpr_complex.cc.

328{
329 gmp_float tmp;
330 mpf_sqrt( *(tmp._mpfp()), *a.mpfp() );
331 return tmp;
332}

Variable Documentation

◆ diff

Definition at line 45 of file mpr_complex.cc.

◆ gmp_output_digits

VAR size_t gmp_output_digits = DEFPREC

Definition at line 42 of file mpr_complex.cc.

◆ gmpRel

Definition at line 44 of file mpr_complex.cc.