32#define SR_HDL(A) ((long)(A))
33#define SR_TO_INT(SR) (((long)SR) >> 2)
62 size_t bits = 1 + (size_t) ((
float)digits * 3.5);
63 size_t rb = 1 + (size_t) ((
float)rest * 3.5);
66 mpf_set_default_prec( db );
81 if (*in ==
'-') { in++;
neg=
TRUE; }
83 if ((
s=strchr((
char *)in,
'E')) !=
NULL)
92 int len = strlen(in)+2;
93 char* c_in = (
char*)
omAlloc(len);
95 strcpy(&(c_in[1]), in);
97 if(mpf_set_str(
t, c_in, 10 )!=0)
WerrorS(
"syntax error in GMP float");
102 if(mpf_set_str(
t, in, 10 )!=0)
WerrorS(
"syntax error in GMP float");
104 if (
neg) mpf_neg(
t,
t );
112 if (*in ==
'-') { in++;
neg=
TRUE; }
114 if ((
s=strchr(in,
'E')) !=
NULL)
121 if (E_found ||((
s=strchr(in,
'e')) !=
NULL))
123 if ((*(
s+1)!=
'+') && (*(
s+1)!=
'-'))
125 int len = strlen(in)+3;
126 char* c_in = (
char*)
omAlloc(len);
130 strcpy(&(c_in[1]), in);
136 char * ss=strchr(c_in,
'e');
137 memmove(ss+2,
s+1,strlen(
s+1));
140 mpf_set_str(
t, c_in, 10 );
149 int len = strlen(in)+2;
150 char* c_in = (
char*)
omAlloc(len);
152 strcpy(&(c_in[1]), in);
154 mpf_set_str(
t, c_in, 10 );
159 mpf_set_str(
t, in, 10 );
161 if (
neg) mpf_neg(
t,
t );
195 if (mpf_sgn(
t) != -(mpf_sgn(a.
t)))
200 if((mpf_sgn(a.
t)==0) && (mpf_sgn(
t)==0))
205 mpf_add(
t,
t, a.
t );
207 mpf_set_prec(
diff->
t, 32);
216 if (mpf_sgn(
t) != mpf_sgn(a.
t))
221 if((mpf_sgn(a.
t)==0) && (mpf_sgn(
t)==0))
226 mpf_sub(
t,
t, a.
t );
228 mpf_set_prec(
diff->
t, 32);
239 if(mpf_sgn(a.
t) != mpf_sgn(
b.t))
241 if((mpf_sgn(a.
t)==0) && (mpf_sgn(
b.t)==0))
254 return (mpf_sgn(
t ) == 0);
260 return (mpf_cmp_ui(
t , 1 ) == 0);
264 mpf_sub_ui(
diff->
t,
t, 1);
276 return (mpf_cmp_si(
t , -1 ) == 0);
280 mpf_add_ui(
diff->
t,
t, 1);
292 return mpf_cmp( a.
t,
b.t ) > 0;
298 return mpf_cmp( a.
t,
b.t ) < 0;
304 return mpf_cmp( a.
t,
b.t ) >= 0;
310 return mpf_cmp( a.
t,
b.t ) <= 0;
351 return (
sqrt( (a*a) + (
b*
b) ) );
365 a >
b ? tmp= a : tmp=
b;
428 WerrorS(
"Ground field not implemented!");
432 WerrorS(
"Ground field not implemented!");
473 WerrorS(
"Can not map from field C to field R!");
477 WerrorS(
"Ground field not implemented!");
489 int sign= (in[0] ==
'-') ? 1 : 0;
495 sign ? strcpy(csign,
"-") : strcpy(csign,
"+");
498 sign ? strcpy(csign,
"-") : strcpy(csign,
" ");
502 sign ? strcpy(csign,
"-") : strcpy(csign,
"");
506 if ( strlen(in) == 0 )
508 *
size= 2*
sizeof(char);
519 *
size= (strlen(in)+15+eexponent) *
sizeof(
char);
524 strncat(out,in+
sign,eeexponent);
533 memset(out+strlen(out),
'0',eexponent);
535 strcat(out,in+
sign+eeexponent);
542 sprintf(out,
"%s%s",csign,in+
sign);
547 *
size= (strlen(in)+2) *
sizeof(
char) + 10;
550 sprintf(out,
"%s%s",csign,in+
sign);
563 *
size= (strlen(in)+12+c) *
sizeof(
char) + 10;
585 insize= (oprec+2) *
sizeof(
char) + 10;
602 out= (
char*)
omAlloc( (strlen(nout)+1) *
sizeof(char) );
609 char *out= (
char*)
omAlloc( (1024) *
sizeof(char) );
610 sprintf(out,
"% .10f",(
double)r);
630 a.
r *
b.i + a.
i *
b.r);
636 (a.
i *
b.r - a.
r *
b.i) / d);
656 i =
r *
b.i +
i *
b.r;
669 r = (
r *
b.r +
i *
b.i) / d;
670 i = (
i *
b.r -
r *
b.i) / d;
706 const char * complex_parameter =
"I";
712 N = strlen(complex_parameter);
717 char *out,*in_imag,*in_real;
728 int len=(strlen(in_real)+strlen(in_imag)+7+
N)*
sizeof(
char);
732 sprintf(out,
"(%s%s%s*%s)",in_real,c.
imag().
sign()>=0?
"+":
"-",complex_parameter,in_imag);
736 sprintf(out,
"%s", complex_parameter);
738 sprintf(out,
"-%s", complex_parameter);
740 sprintf(out,
"(%s%s*%s)",c.
imag().
sign()>=0?
"":
"-", complex_parameter,in_imag);
745 int len=(strlen(in_real)+strlen(in_imag)+9) *
sizeof(
char);
749 sprintf(out,
"(%s%s%s)",in_real,c.
imag().
sign()>=0?
"+I*":
"-I*",in_imag);
751 sprintf(out,
"(%s%s)",c.
imag().
sign()>=0?
"I*":
"-I*",in_imag);
753 omFree( (
void *) in_real );
754 omFree( (
void *) in_imag );
769 if ( digits < 1 )
return true;
771 eps=
pow(10.0,(
int)digits);
779 return (c->
real() < eps && (c->
imag() < eps && c->
imag() > epsm));
781 return (c->
real() > epsm && (c->
imag() < eps && c->
imag() > epsm));
791 mpf_set_prec(*ar.
_mpfp(), 32);
792 mpf_set_prec(*ai.
_mpfp(), 32);
Rational pow(const Rational &a, int e)
const CanonicalForm CFMap CFMap & N
gmp_complex numbers based on
gmp_complex & operator*=(const gmp_complex &a)
gmp_complex & operator/=(const gmp_complex &a)
gmp_complex & operator+=(const gmp_complex &a)
gmp_complex & operator-=(const gmp_complex &a)
void setFromStr(const char *in)
gmp_float & operator-=(const gmp_float &a)
gmp_float & operator+=(const gmp_float &a)
const mpf_t * mpfp() const
Coefficient rings, fields and other domains suitable for Singular polynomials.
static FORCE_INLINE BOOLEAN nCoeff_is_long_R(const coeffs r)
static FORCE_INLINE char const ** n_ParameterNames(const coeffs r)
Returns a (const!) pointer to (const char*) names of parameters.
static FORCE_INLINE BOOLEAN nCoeff_is_Q(const coeffs r)
static FORCE_INLINE BOOLEAN nCoeff_is_R(const coeffs r)
static FORCE_INLINE BOOLEAN nCoeff_is_long_C(const coeffs r)
const CanonicalForm int s
void WerrorS(const char *s)
void nlNormalize(number &x, const coeffs r)
gmp_float sin(const gmp_float &a)
gmp_float operator*(const gmp_float &a, const gmp_float &b)
char * complexToStr(gmp_complex &c, const unsigned int oprec, const coeffs src)
bool operator<(const gmp_float &a, const gmp_float &b)
bool operator<=(const gmp_float &a, const gmp_float &b)
gmp_float abs(const gmp_float &a)
gmp_float max(const gmp_float &a, const gmp_float &b)
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)
bool complexNearZero(gmp_complex *c, int digits)
gmp_float sqrt(const gmp_float &a)
gmp_float exp(const gmp_float &a)
gmp_float operator-(const gmp_float &a, const gmp_float &b)
gmp_float operator+(const gmp_float &a, const gmp_float &b)
gmp_float cos(const gmp_float &a)
bool operator==(const gmp_float &a, const gmp_float &b)
gmp_float numberToFloat(number num, const coeffs src)
gmp_float hypot(const gmp_float &a, const gmp_float &b)
gmp_float numberFieldToFloat(number num, int cf)
gmp_float log(const gmp_float &a)
STATIC_VAR gmp_float * gmpRel
gmp_float operator/(const gmp_float &a, const gmp_float &b)
STATIC_VAR gmp_float * diff
bool operator>=(const gmp_float &a, const gmp_float &b)
bool operator>(const gmp_float &a, const gmp_float &b)
VAR size_t gmp_output_digits
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...
The main handler for Singular numbers which are suitable for Singular polynomials.
#define omFreeSize(addr, size)