49 static mpfr_record* newMpfr(
unsigned int Precision);
52 static gmp_randstate_t* getRandState();
54 static mpfr_record_ptr&
getList(
unsigned int Precision);
71 mpfr_srcptr getReadPtr()
const;
72 mpfr_ptr getWritePtr();
80 template<
unsigned int Precision>
90 if( rval->refCount==0 )
97 ampf () { InitializeAsZero(); }
100 ampf (
long double v) { InitializeAsDouble(v); }
101 ampf (
double v) { InitializeAsDouble(v); }
102 ampf (
float v) { InitializeAsDouble(v); }
103 ampf (
signed long v) { InitializeAsSLong(v); }
104 ampf (
unsigned long v) { InitializeAsULong(v); }
105 ampf (
signed int v) { InitializeAsSLong(v); }
106 ampf (
unsigned int v) { InitializeAsULong(v); }
107 ampf (
signed short v) { InitializeAsSLong(v); }
108 ampf (
unsigned short v) { InitializeAsULong(v); }
109 ampf (
signed char v) { InitializeAsSLong(v); }
110 ampf (
unsigned char v) { InitializeAsULong(v); }
117 ampf (
const char *
s) { InitializeAsString(s); }
127 #ifndef _AMP_NO_TEMPLATE_CONSTRUCTORS 128 template<
unsigned int Precision2>
133 mpfr_set(getWritePtr(), r.
getReadPtr(), GMP_RNDN);
140 ampf& operator= (
long double v) { mpfr_set_ld(getWritePtr(), v, GMP_RNDN);
return *
this; }
141 ampf& operator= (
double v) { mpfr_set_ld(getWritePtr(), v, GMP_RNDN);
return *
this; }
142 ampf& operator= (
float v) { mpfr_set_ld(getWritePtr(), v, GMP_RNDN);
return *
this; }
143 ampf& operator= (
signed long v) { mpfr_set_si(getWritePtr(), v, GMP_RNDN);
return *
this; }
144 ampf& operator= (
unsigned long v) { mpfr_set_ui(getWritePtr(), v, GMP_RNDN);
return *
this; }
145 ampf& operator= (
signed int v) { mpfr_set_si(getWritePtr(), v, GMP_RNDN);
return *
this; }
146 ampf& operator= (
unsigned int v) { mpfr_set_ui(getWritePtr(), v, GMP_RNDN);
return *
this; }
147 ampf& operator= (
signed short v) { mpfr_set_si(getWritePtr(), v, GMP_RNDN);
return *
this; }
148 ampf& operator= (
unsigned short v) { mpfr_set_ui(getWritePtr(), v, GMP_RNDN);
return *
this; }
149 ampf& operator= (
signed char v) { mpfr_set_si(getWritePtr(), v, GMP_RNDN);
return *
this; }
150 ampf& operator= (
unsigned char v) { mpfr_set_ui(getWritePtr(), v, GMP_RNDN);
return *
this; }
151 ampf& operator= (
const char *
s) { mpfr_strtofr(getWritePtr(), s,
NULL, 0, GMP_RNDN);
return *
this; }
152 ampf& operator= (
const std::string &
s) { mpfr_strtofr(getWritePtr(), s.c_str(),
NULL, 0, GMP_RNDN);
return *
this; }
161 if( rval->refCount==0 )
168 #ifndef _AMP_NO_TEMPLATE_CONSTRUCTORS 169 template<
unsigned int Precision2>
172 if( (
void*)
this==(
void*)(&r) )
174 mpfr_set(getWritePtr(), r.
getReadPtr(), GMP_RNDN);
191 mpfr_srcptr getReadPtr()
const;
192 mpfr_ptr getWritePtr();
197 bool isFiniteNumber()
const;
198 bool isPositiveNumber()
const;
200 bool isNegativeNumber()
const;
201 const ampf getUlpOf();
206 double toDouble()
const;
215 static const ampf getUlpOf(
const ampf &
x);
216 static const ampf getUlp();
217 static const ampf getUlp256();
218 static const ampf getUlp512();
219 static const ampf getMaxNumber();
220 static const ampf getMinNumber();
221 static const ampf getAlgoPascalEpsilon();
222 static const ampf getAlgoPascalMaxNumber();
223 static const ampf getAlgoPascalMinNumber();
224 static const ampf getRandom();
226 void CheckPrecision();
227 void InitializeAsZero();
228 void InitializeAsSLong(
signed long v);
229 void InitializeAsULong(
unsigned long v);
230 void InitializeAsDouble(
long double v);
231 void InitializeAsString(
const char *
s);
243 template<
unsigned int Precision>
250 template<
unsigned int Precision>
255 mpfr_set_ui(getWritePtr(), 0, GMP_RNDN);
258 template<
unsigned int Precision>
263 mpfr_set_si(getWritePtr(), sv, GMP_RNDN);
266 template<
unsigned int Precision>
271 mpfr_set_ui(getWritePtr(), v, GMP_RNDN);
274 template<
unsigned int Precision>
279 mpfr_set_ld(getWritePtr(), v, GMP_RNDN);
282 template<
unsigned int Precision>
287 mpfr_strtofr(getWritePtr(), s,
NULL, 0, GMP_RNDN);
290 template<
unsigned int Precision>
301 template<
unsigned int Precision>
304 if( rval->refCount==1 )
307 mpfr_set(newrval->
value, rval->value, GMP_RNDN);
313 template<
unsigned int Precision>
316 return mpfr_number_p(getReadPtr())!=0;
319 template<
unsigned int Precision>
322 if( !isFiniteNumber() )
324 return mpfr_sgn(getReadPtr())>0;
327 template<
unsigned int Precision>
330 return mpfr_zero_p(getReadPtr())!=0;
333 template<
unsigned int Precision>
336 if( !isFiniteNumber() )
338 return mpfr_sgn(getReadPtr())<0;
341 template<
unsigned int Precision>
344 return getUlpOf(*
this);
347 template<
unsigned int Precision>
350 return mpfr_get_d(getReadPtr(), GMP_RNDN);
353 template<
unsigned int Precision>
359 if( !isFiniteNumber() )
364 ptr = mpfr_get_str(
NULL, &_e, 16, 0, getReadPtr(), GMP_RNDN);
379 ptr = mpfr_get_str(
NULL, &expval, 16, 0, getReadPtr(), GMP_RNDN);
382 if( iexpval!=expval )
384 sprintf(buf_e,
"%ld",
long(iexpval));
398 template<
unsigned int Precision>
406 if( !isFiniteNumber() )
411 ptr = mpfr_get_str(
NULL, &_e, 10, 0, getReadPtr(), GMP_RNDN);
426 ptr = mpfr_get_str(
NULL, &expval, 10, 0, getReadPtr(), GMP_RNDN);
429 if( iexpval!=expval )
431 sprintf(buf_e,
"%ld",
long(iexpval));
444 template<
unsigned int Precision>
447 char *toString_Block=(
char *)
omAlloc(256);
451 if( !isFiniteNumber() )
455 ptr = mpfr_get_str(
NULL, &_e, 10, 0, getReadPtr(), GMP_RNDN);
456 strcpy(toString_Block, ptr);
458 return toString_Block;
470 ptr = mpfr_get_str(
NULL, &expval, 10, 0, getReadPtr(), GMP_RNDN);
473 if( iexpval!=expval )
475 sprintf(buf_e,
"%ld",
long(iexpval));
479 sprintf(toString_Block,
"-0.%sE%s",ptr,buf_e);
482 sprintf(toString_Block,
"0.%sE%s",ptr,buf_e);
484 return toString_Block;
487 template<
unsigned int Precision>
510 template<
unsigned int Precision>
519 template<
unsigned int Precision>
533 template<
unsigned int Precision>
547 template<
unsigned int Precision>
556 template<
unsigned int Precision>
564 template<
unsigned int Precision>
570 template<
unsigned int Precision>
574 mp_exp_t e1 = mpfr_get_emax();
575 mp_exp_t e2 = -mpfr_get_emin();
576 mp_exp_t e = e1>e2 ? e1 : e2;
581 template<
unsigned int Precision>
585 mp_exp_t e1 = mpfr_get_emax();
586 mp_exp_t e2 = -mpfr_get_emin();
587 mp_exp_t e = e1>e2 ? e1 : e2;
592 template<
unsigned int Precision>
603 template<
unsigned int Precision>
609 template<
unsigned int Precision>
615 template<
unsigned int Precision>
618 return mpfr_cmp(op1.getReadPtr(), op2.getReadPtr())<0;
621 template<
unsigned int Precision>
627 template<
unsigned int Precision>
630 return mpfr_cmp(op1.getReadPtr(), op2.getReadPtr())<=0;
633 template<
unsigned int Precision>
642 template<
unsigned int Precision>
648 template<
unsigned int Precision>
656 template<
unsigned int Precision>
664 template<
unsigned int Precision>
673 template<
unsigned int Precision>
681 template<
unsigned int Precision>
692 template<
unsigned int Precision>
701 template<
unsigned int Precision>
712 template<
unsigned int Precision>
721 template<
unsigned int Precision>
730 template<
unsigned int Precision>
739 template<
unsigned int Precision>
748 template<
unsigned int Precision>
756 mpfr_clear_erangeflag();
758 if( mpfr_erangeflag_p()!=0 )
763 template<
unsigned int Precision>
772 template<
unsigned int Precision>
780 mpfr_clear_erangeflag();
782 if( mpfr_erangeflag_p()!=0 )
787 template<
unsigned int Precision>
795 mpfr_clear_erangeflag();
797 if( mpfr_erangeflag_p()!=0 )
802 template<
unsigned int Precision>
810 mpfr_clear_erangeflag();
812 if( mpfr_erangeflag_p()!=0 )
817 template<
unsigned int Precision>
836 template<
unsigned int Precision>
848 #define __AMP_BINARY_OPI(type) \ 849 template<unsigned int Precision> const ampf<Precision> operator+(const signed type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)+op2; } \ 850 template<unsigned int Precision> const ampf<Precision> operator+(const unsigned type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)+op2; } \ 851 template<unsigned int Precision> const ampf<Precision> operator+(const ampf<Precision>& op1, const signed type& op2) { return op1+ampf<Precision>(op2); } \ 852 template<unsigned int Precision> const ampf<Precision> operator+(const ampf<Precision>& op1, const unsigned type& op2) { return op1+ampf<Precision>(op2); } \ 853 template<unsigned int Precision> const ampf<Precision> operator-(const signed type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)-op2; } \ 854 template<unsigned int Precision> const ampf<Precision> operator-(const unsigned type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)-op2; } \ 855 template<unsigned int Precision> const ampf<Precision> operator-(const ampf<Precision>& op1, const signed type& op2) { return op1-ampf<Precision>(op2); } \ 856 template<unsigned int Precision> const ampf<Precision> operator-(const ampf<Precision>& op1, const unsigned type& op2) { return op1-ampf<Precision>(op2); } \ 857 template<unsigned int Precision> const ampf<Precision> operator*(const signed type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)*op2; } \ 858 template<unsigned int Precision> const ampf<Precision> operator*(const unsigned type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)*op2; } \ 859 template<unsigned int Precision> const ampf<Precision> operator*(const ampf<Precision>& op1, const signed type& op2) { return op1*ampf<Precision>(op2); } \ 860 template<unsigned int Precision> const ampf<Precision> operator*(const ampf<Precision>& op1, const unsigned type& op2) { return op1*ampf<Precision>(op2); } \ 861 template<unsigned int Precision> const ampf<Precision> operator/(const signed type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)/op2; } \ 862 template<unsigned int Precision> const ampf<Precision> operator/(const unsigned type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)/op2; } \ 863 template<unsigned int Precision> const ampf<Precision> operator/(const ampf<Precision>& op1, const signed type& op2) { return op1/ampf<Precision>(op2); } \ 864 template<unsigned int Precision> const ampf<Precision> operator/(const ampf<Precision>& op1, const unsigned type& op2) { return op1/ampf<Precision>(op2); } \ 865 template<unsigned int Precision> const bool operator==(const signed type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)==op2; } \ 866 template<unsigned int Precision> const bool operator==(const unsigned type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)==op2; } \ 867 template<unsigned int Precision> const bool operator==(const ampf<Precision>& op1, const signed type& op2) { return op1==ampf<Precision>(op2); } \ 868 template<unsigned int Precision> const bool operator==(const ampf<Precision>& op1, const unsigned type& op2) { return op1==ampf<Precision>(op2); } \ 869 template<unsigned int Precision> const bool operator!=(const signed type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)!=op2; } \ 870 template<unsigned int Precision> const bool operator!=(const unsigned type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)!=op2; } \ 871 template<unsigned int Precision> const bool operator!=(const ampf<Precision>& op1, const signed type& op2) { return op1!=ampf<Precision>(op2); } \ 872 template<unsigned int Precision> const bool operator!=(const ampf<Precision>& op1, const unsigned type& op2) { return op1!=ampf<Precision>(op2); } \ 873 template<unsigned int Precision> const bool operator<=(const signed type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)<=op2; } \ 874 template<unsigned int Precision> const bool operator<=(const unsigned type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)<=op2; } \ 875 template<unsigned int Precision> const bool operator<=(const ampf<Precision>& op1, const signed type& op2) { return op1<=ampf<Precision>(op2); } \ 876 template<unsigned int Precision> const bool operator<=(const ampf<Precision>& op1, const unsigned type& op2) { return op1<=ampf<Precision>(op2); } \ 877 template<unsigned int Precision> const bool operator>=(const signed type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)>=op2; } \ 878 template<unsigned int Precision> const bool operator>=(const unsigned type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)>=op2; } \ 879 template<unsigned int Precision> const bool operator>=(const ampf<Precision>& op1, const signed type& op2) { return op1>=ampf<Precision>(op2); } \ 880 template<unsigned int Precision> const bool operator>=(const ampf<Precision>& op1, const unsigned type& op2) { return op1>=ampf<Precision>(op2); } \ 881 template<unsigned int Precision> const bool operator<(const signed type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)<op2; } \ 882 template<unsigned int Precision> const bool operator<(const unsigned type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)<op2; } \ 883 template<unsigned int Precision> const bool operator<(const ampf<Precision>& op1, const signed type& op2) { return op1<ampf<Precision>(op2); } \ 884 template<unsigned int Precision> const bool operator<(const ampf<Precision>& op1, const unsigned type& op2) { return op1<ampf<Precision>(op2); } \ 885 template<unsigned int Precision> const bool operator>(const signed type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)>op2; } \ 886 template<unsigned int Precision> const bool operator>(const unsigned type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)>op2; } \ 887 template<unsigned int Precision> const bool operator>(const ampf<Precision>& op1, const signed type& op2) { return op1>ampf<Precision>(op2); } \ 888 template<unsigned int Precision> const bool operator>(const ampf<Precision>& op1, const unsigned type& op2) { return op1>ampf<Precision>(op2); } 893 #undef __AMP_BINARY_OPI 894 #define __AMP_BINARY_OPF(type) \ 895 template<unsigned int Precision> const ampf<Precision> operator+(const type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)+op2; } \ 896 template<unsigned int Precision> const ampf<Precision> operator+(const ampf<Precision>& op1, const type& op2) { return op1+ampf<Precision>(op2); } \ 897 template<unsigned int Precision> const ampf<Precision> operator-(const type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)-op2; } \ 898 template<unsigned int Precision> const ampf<Precision> operator-(const ampf<Precision>& op1, const type& op2) { return op1-ampf<Precision>(op2); } \ 899 template<unsigned int Precision> const ampf<Precision> operator*(const type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)*op2; } \ 900 template<unsigned int Precision> const ampf<Precision> operator*(const ampf<Precision>& op1, const type& op2) { return op1*ampf<Precision>(op2); } \ 901 template<unsigned int Precision> const ampf<Precision> operator/(const type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)/op2; } \ 902 template<unsigned int Precision> const ampf<Precision> operator/(const ampf<Precision>& op1, const type& op2) { return op1/ampf<Precision>(op2); } \ 903 template<unsigned int Precision> bool operator==(const type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)==op2; } \ 904 template<unsigned int Precision> bool operator==(const ampf<Precision>& op1, const type& op2) { return op1==ampf<Precision>(op2); } \ 905 template<unsigned int Precision> bool operator!=(const type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)!=op2; } \ 906 template<unsigned int Precision> bool operator!=(const ampf<Precision>& op1, const type& op2) { return op1!=ampf<Precision>(op2); } \ 907 template<unsigned int Precision> bool operator<=(const type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)<=op2; } \ 908 template<unsigned int Precision> bool operator<=(const ampf<Precision>& op1, const type& op2) { return op1<=ampf<Precision>(op2); } \ 909 template<unsigned int Precision> bool operator>=(const type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)>=op2; } \ 910 template<unsigned int Precision> bool operator>=(const ampf<Precision>& op1, const type& op2) { return op1>=ampf<Precision>(op2); } \ 911 template<unsigned int Precision> bool operator<(const type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)<op2; } \ 912 template<unsigned int Precision> bool operator<(const ampf<Precision>& op1, const type& op2) { return op1<ampf<Precision>(op2); } \ 913 template<unsigned int Precision> bool operator>(const type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)>op2; } \ 914 template<unsigned int Precision> bool operator>(const ampf<Precision>& op1, const type& op2) { return op1>ampf<Precision>(op2); } 918 #undef __AMP_BINARY_OPF 923 template<
unsigned int Precision>
927 mpfr_const_pi(v->
value, GMP_RNDN);
931 template<
unsigned int Precision>
935 mpfr_const_pi(v->
value, GMP_RNDN);
936 mpfr_mul_2si(v->
value, v->
value, -1, GMP_RNDN);
940 template<
unsigned int Precision>
944 mpfr_const_pi(v->
value, GMP_RNDN);
945 mpfr_mul_2si(v->
value, v->
value, +1, GMP_RNDN);
949 template<
unsigned int Precision>
957 template<
unsigned int Precision>
965 template<
unsigned int Precision>
973 template<
unsigned int Precision>
981 template<
unsigned int Precision>
989 template<
unsigned int Precision>
997 template<
unsigned int Precision>
1005 template<
unsigned int Precision>
1013 template<
unsigned int Precision>
1021 template<
unsigned int Precision>
1029 template<
unsigned int Precision>
1037 template<
unsigned int Precision>
1045 template<
unsigned int Precision>
1053 template<
unsigned int Precision>
1061 template<
unsigned int Precision>
1072 template<
unsigned int Precision>
1091 #ifndef _AMP_NO_TEMPLATE_CONSTRUCTORS 1092 template<
unsigned int Prec2>
1096 campf& operator= (
long double v) {
x=
v;
y=0;
return *
this; }
1099 campf& operator= (
signed long v) {
x=
v;
y=0;
return *
this; }
1100 campf& operator= (
unsigned long v) {
x=
v;
y=0;
return *
this; }
1102 campf& operator= (
unsigned int v) {
x=
v;
y=0;
return *
this; }
1103 campf& operator= (
signed short v) {
x=
v;
y=0;
return *
this; }
1104 campf& operator= (
unsigned short v) {
x=
v;
y=0;
return *
this; }
1105 campf& operator= (
signed char v) {
x=
v;
y=0;
return *
this; }
1106 campf& operator= (
unsigned char v) {
x=
v;
y=0;
return *
this; }
1107 campf& operator= (
const char *
s) {
x=
s;
y=0;
return *
this; }
1115 #ifndef _AMP_NO_TEMPLATE_CONSTRUCTORS 1116 template<
unsigned int Precision2>
1131 template<
unsigned int Precision>
1133 {
return lhs.
x==rhs.
x && lhs.
y==rhs.
y; }
1135 template<
unsigned int Precision>
1137 {
return lhs.
x!=rhs.
x || lhs.
y!=rhs.
y; }
1139 template<
unsigned int Precision>
1143 template<
unsigned int Precision>
1145 { lhs.
x += rhs.
x; lhs.
y += rhs.
y;
return lhs; }
1147 template<
unsigned int Precision>
1151 template<
unsigned int Precision>
1155 template<
unsigned int Precision>
1157 { lhs.
x -= rhs.
x; lhs.
y -= rhs.
y;
return lhs; }
1159 template<
unsigned int Precision>
1163 template<
unsigned int Precision>
1172 template<
unsigned int Precision>
1176 template<
unsigned int Precision>
1186 result.
x = (lhs.
x+lhs.
y*e)/f;
1187 result.
y = (lhs.
y-lhs.
x*e)/f;
1193 result.
x = (lhs.
y+lhs.
x*e)/f;
1194 result.
y = (-lhs.
x+lhs.
y*e)/f;
1199 template<
unsigned int Precision>
1206 template<
unsigned int Precision>
1213 w = xabs>yabs ? xabs : yabs;
1214 v = xabs<yabs ? xabs : yabs;
1224 template<
unsigned int Precision>
1230 template<
unsigned int Precision>
1240 #define __AMP_BINARY_OPI(type) \ 1241 template<unsigned int Precision> const campf<Precision> operator+ (const signed type& op1, const campf<Precision>& op2) { return campf<Precision>(op1+op2.x, op2.y); } \ 1242 template<unsigned int Precision> const campf<Precision> operator+ (const unsigned type& op1, const campf<Precision>& op2) { return campf<Precision>(op1+op2.x, op2.y); } \ 1243 template<unsigned int Precision> const campf<Precision> operator+ (const campf<Precision>& op1, const signed type& op2) { return campf<Precision>(op1.x+op2, op1.y); } \ 1244 template<unsigned int Precision> const campf<Precision> operator+ (const campf<Precision>& op1, const unsigned type& op2) { return campf<Precision>(op1.x+op2, op1.y); } \ 1245 template<unsigned int Precision> const campf<Precision> operator- (const signed type& op1, const campf<Precision>& op2) { return campf<Precision>(op1-op2.x, -op2.y); } \ 1246 template<unsigned int Precision> const campf<Precision> operator- (const unsigned type& op1, const campf<Precision>& op2) { return campf<Precision>(op1-op2.x, -op2.y); } \ 1247 template<unsigned int Precision> const campf<Precision> operator- (const campf<Precision>& op1, const signed type& op2) { return campf<Precision>(op1.x-op2, op1.y); } \ 1248 template<unsigned int Precision> const campf<Precision> operator- (const campf<Precision>& op1, const unsigned type& op2) { return campf<Precision>(op1.x-op2, op1.y); } \ 1249 template<unsigned int Precision> const campf<Precision> operator* (const signed type& op1, const campf<Precision>& op2) { return campf<Precision>(op1*op2.x, op1*op2.y); } \ 1250 template<unsigned int Precision> const campf<Precision> operator* (const unsigned type& op1, const campf<Precision>& op2) { return campf<Precision>(op1*op2.x, op1*op2.y); } \ 1251 template<unsigned int Precision> const campf<Precision> operator* (const campf<Precision>& op1, const signed type& op2) { return campf<Precision>(op2*op1.x, op2*op1.y); } \ 1252 template<unsigned int Precision> const campf<Precision> operator* (const campf<Precision>& op1, const unsigned type& op2) { return campf<Precision>(op2*op1.x, op2*op1.y); } \ 1253 template<unsigned int Precision> const campf<Precision> operator/ (const signed type& op1, const campf<Precision>& op2) { return campf<Precision>(ampf<Precision>(op1),ampf<Precision>(0))/op2; } \ 1254 template<unsigned int Precision> const campf<Precision> operator/ (const unsigned type& op1, const campf<Precision>& op2) { return campf<Precision>(ampf<Precision>(op1),ampf<Precision>(0))/op2; } \ 1255 template<unsigned int Precision> const campf<Precision> operator/ (const campf<Precision>& op1, const signed type& op2) { return campf<Precision>(op1.x/op2, op1.y/op2); } \ 1256 template<unsigned int Precision> const campf<Precision> operator/ (const campf<Precision>& op1, const unsigned type& op2) { return campf<Precision>(op1.x/op2, op1.y/op2); } \ 1257 template<unsigned int Precision> bool operator==(const signed type& op1, const campf<Precision>& op2) { return op1==op2.x && op2.y==0; } \ 1258 template<unsigned int Precision> bool operator==(const unsigned type& op1, const campf<Precision>& op2) { return op1==op2.x && op2.y==0; } \ 1259 template<unsigned int Precision> bool operator==(const campf<Precision>& op1, const signed type& op2) { return op1.x==op2 && op1.y==0; } \ 1260 template<unsigned int Precision> bool operator==(const campf<Precision>& op1, const unsigned type& op2) { return op1.x==op2 && op1.y==0; } \ 1261 template<unsigned int Precision> bool operator!=(const campf<Precision>& op1, const signed type& op2) { return op1.x!=op2 || op1.y!=0; } \ 1262 template<unsigned int Precision> bool operator!=(const campf<Precision>& op1, const unsigned type& op2) { return op1.x!=op2 || op1.y!=0; } \ 1263 template<unsigned int Precision> bool operator!=(const signed type& op1, const campf<Precision>& op2) { return op1!=op2.x || op2.y!=0; } \ 1264 template<unsigned int Precision> bool operator!=(const unsigned type& op1, const campf<Precision>& op2) { return op1!=op2.x || op2.y!=0; } 1269 #undef __AMP_BINARY_OPI 1270 #define __AMP_BINARY_OPF(type) \ 1271 template<unsigned int Precision> const campf<Precision> operator+ (const type& op1, const campf<Precision>& op2) { return campf<Precision>(op1+op2.x, op2.y); } \ 1272 template<unsigned int Precision> const campf<Precision> operator+ (const campf<Precision>& op1, const type& op2) { return campf<Precision>(op1.x+op2, op1.y); } \ 1273 template<unsigned int Precision> const campf<Precision> operator- (const type& op1, const campf<Precision>& op2) { return campf<Precision>(op1-op2.x, -op2.y); } \ 1274 template<unsigned int Precision> const campf<Precision> operator- (const campf<Precision>& op1, const type& op2) { return campf<Precision>(op1.x-op2, op1.y); } \ 1275 template<unsigned int Precision> const campf<Precision> operator* (const type& op1, const campf<Precision>& op2) { return campf<Precision>(op1*op2.x, op1*op2.y); } \ 1276 template<unsigned int Precision> const campf<Precision> operator* (const campf<Precision>& op1, const type& op2) { return campf<Precision>(op2*op1.x, op2*op1.y); } \ 1277 template<unsigned int Precision> const campf<Precision> operator/ (const type& op1, const campf<Precision>& op2) { return campf<Precision>(ampf<Precision>(op1),ampf<Precision>(0))/op2; } \ 1278 template<unsigned int Precision> const campf<Precision> operator/ (const campf<Precision>& op1, const type& op2) { return campf<Precision>(op1.x/op2, op1.y/op2); } \ 1279 template<unsigned int Precision> bool operator==(const type& op1, const campf<Precision>& op2) { return op1==op2.x && op2.y==0; } \ 1280 template<unsigned int Precision> bool operator==(const campf<Precision>& op1, const type& op2) { return op1.x==op2 && op1.y==0; } \ 1281 template<unsigned int Precision> bool operator!=(const type& op1, const campf<Precision>& op2) { return op1!=op2.x || op2.y!=0; } \ 1282 template<unsigned int Precision> bool operator!=(const campf<Precision>& op1, const type& op2) { return op1.x!=op2 || op1.y!=0; } 1287 #undef __AMP_BINARY_OPF 1292 template<
unsigned int Precision>
1296 int i, cnt = v1.GetLength();
1297 const ampf<Precision> *p1 = v1.GetData();
1298 const ampf<Precision> *p2 = v2.GetData();
1299 mpfr_record *r =
NULL;
1300 mpfr_record *t =
NULL;
1305 mpfr_set_ui(r->value, 0, GMP_RNDN);
1306 for(i=0; i<cnt; i++)
1308 mpfr_mul(t->value, p1->getReadPtr(), p2->getReadPtr(), GMP_RNDN);
1309 mpfr_add(r->value, r->value, t->value, GMP_RNDN);
1326 template<
unsigned int Precision>
1330 int i, cnt = vDst.GetLength();
1335 for(i=0; i<cnt; i++)
1338 pDst += vDst.GetStep();
1339 pSrc += vSrc.GetStep();
1343 template<
unsigned int Precision>
1347 int i, cnt = vDst.GetLength();
1350 for(i=0; i<cnt; i++)
1354 mpfr_neg(v, v, GMP_RNDN);
1355 pDst += vDst.GetStep();
1356 pSrc += vSrc.GetStep();
1360 template<
unsigned int Precision,
class T2>
1364 int i, cnt = vDst.GetLength();
1368 for(i=0; i<cnt; i++)
1373 pDst += vDst.GetStep();
1374 pSrc += vSrc.GetStep();
1378 template<
unsigned int Precision>
1382 int i, cnt = vDst.GetLength();
1385 for(i=0; i<cnt; i++)
1389 mpfr_add(v, v, vs, GMP_RNDN);
1390 pDst += vDst.GetStep();
1391 pSrc += vSrc.GetStep();
1395 template<
unsigned int Precision,
class T2>
1399 int i, cnt = vDst.GetLength();
1403 for(i=0; i<cnt; i++)
1407 mpfr_mul(tmp.
getWritePtr(), a.getReadPtr(), vs, GMP_RNDN);
1409 pDst += vDst.GetStep();
1410 pSrc += vSrc.GetStep();
1414 template<
unsigned int Precision>
1418 int i, cnt = vDst.GetLength();
1421 for(i=0; i<cnt; i++)
1425 mpfr_sub(v, v, vs, GMP_RNDN);
1426 pDst += vDst.GetStep();
1427 pSrc += vSrc.GetStep();
1431 template<
unsigned int Precision,
class T2>
1434 vAdd(vDst, vSrc, -alpha);
1437 template<
unsigned int Precision,
class T2>
1440 int i, cnt = vDst.GetLength();
1443 for(i=0; i<cnt; i++)
1447 pDst += vDst.GetStep();
const ampf< Precision > halfpi()
static const ampf getUlp256()
const CanonicalForm int s
const CanonicalForm int const CFList const Variable & y
const ampf< Precision > operator/(const ampf< Precision > &op1, const ampf< Precision > &op2)
static const ampf getAlgoPascalMinNumber()
void InitializeAsULong(unsigned long v)
void InitializeAsDouble(long double v)
static const ampf getRandom()
mpfr_srcptr getReadPtr() const
ampf & operator*=(const T &v)
const bool operator==(const ampf< Precision > &op1, const ampf< Precision > &op2)
static const ampf getAlgoPascalEpsilon()
const ampf< Precision > log2(const ampf< Precision > &x)
const ampf< Precision > acos(const ampf< Precision > &x)
void vAdd(ap::raw_vector< ampf< Precision > > vDst, ap::const_raw_vector< ampf< Precision > > vSrc)
campf(const ampf< Precision > &_x)
ampf & operator/=(const T &v)
campf(const ampf< Precision > &_x, const ampf< Precision > &_y)
const ampf< Precision > atan2(const ampf< Precision > &y, const ampf< Precision > &x)
static mpfr_record * newMpfr(unsigned int Precision)
const ampf< Precision > minimum(const ampf< Precision > &x, const ampf< Precision > &y)
const ampf< Precision > cos(const ampf< Precision > &x)
static const ampf getAlgoPascalMaxNumber()
const ampf< Precision > exp(const ampf< Precision > &x)
const signed long trunc(const ampf< Precision > &x)
static void make_assertion(bool bClause)
campf< Precision > & operator/=(campf< Precision > &lhs, const campf< Precision > &rhs)
__AMP_BINARY_OPI(char) __AMP_BINARY_OPI(short) __AMP_BINARY_OPI(long) __AMP_BINARY_OPI(int) __AMP_BINARY_OPF(float) __AMP_BINARY_OPF(double) __AMP_BINARY_OPF(long double) template< unsigned int Precision > const ampf< Precision > pi()
const ampf< Precision > operator*(const ampf< Precision > &op1, const ampf< Precision > &op2)
ampf & operator+=(const T &v)
const bool operator>=(const ampf< Precision > &op1, const ampf< Precision > &op2)
static const ampf getUlp()
mpfr_record * mpfr_record_ptr
const ampf< Precision > log(const ampf< Precision > &x)
const signed long round(const ampf< Precision > &x)
lists getList(spectrum &spec)
const signed long floor(const ampf< Precision > &x)
const ampf< Precision > sinh(const ampf< Precision > &x)
static void deleteMpfr(mpfr_record *ref)
bool isFiniteNumber() const
bool isNegativeNumber() const
const ampf< Precision > operator+(const ampf< Precision > &op1)
const bool operator!=(const ampf< Precision > &op1, const ampf< Precision > &op2)
void vMul(ap::raw_vector< ampf< Precision > > vDst, T2 alpha)
const ampf< Precision > abscomplex(const campf< Precision > &z)
std::string toDec() const
const signed long ceil(const ampf< Precision > &x)
static const ampf getMinNumber()
bool isPositiveNumber() const
const ampf< Precision > sqrt(const ampf< Precision > &x)
const ampf< Precision > pow(const ampf< Precision > &x, const ampf< Precision > &y)
const campf< Precision > csqr(const campf< Precision > &z)
const bool operator>(const ampf< Precision > &op1, const ampf< Precision > &op2)
campf< Precision > & operator+=(campf< Precision > &lhs, const campf< Precision > &rhs)
void vMoveNeg(ap::raw_vector< ampf< Precision > > vDst, ap::const_raw_vector< ampf< Precision > > vSrc)
void vSub(ap::raw_vector< ampf< Precision > > vDst, ap::const_raw_vector< ampf< Precision > > vSrc)
void InitializeAsString(const char *s)
campf< Precision > & operator-=(campf< Precision > &lhs, const campf< Precision > &rhs)
ampf(const ampf< Precision2 > &r)
campf(const campf< Prec2 > &z)
ampf(const std::string &s)
static const ampf getMaxNumber()
campf< Precision > & operator*=(campf< Precision > &lhs, const campf< Precision > &rhs)
const ampf< Precision > ldexp2(const ampf< Precision > &x, mp_exp_t exponent)
const ampf< Precision > tan(const ampf< Precision > &x)
const campf< Precision > conj(const campf< Precision > &z)
const Variable & v
< [in] a sqrfree bivariate poly
#define __AMP_BINARY_OPF(type)
const ampf< Precision > twopi()
const ampf< Precision > frac(const ampf< Precision > &x)
ampf & operator-=(const T &v)
const ampf< Precision > operator-(const ampf< Precision > &op1)
const ampf< Precision > asin(const ampf< Precision > &x)
const ampf< Precision > tanh(const ampf< Precision > &x)
bool isZero(const CFArray &A)
checks if entries of A are zero
void InitializeAsSLong(signed long v)
void vMove(ap::raw_vector< ampf< Precision > > vDst, ap::const_raw_vector< ampf< Precision > > vSrc)
const int sign(const ampf< Precision > &x)
std::string toString(const gfan::ZCone *const c)
int exponent(const CanonicalForm &f, int q)
int exponent ( const CanonicalForm & f, int q )
static gmp_randstate_t * getRandState()
const ampf< Precision > sqr(const ampf< Precision > &x)
const ampf< Precision > frexp2(const ampf< Precision > &x, mp_exp_t *exponent)
const ampf< Precision > maximum(const ampf< Precision > &x, const ampf< Precision > &y)
std::string toHex() const
const ampf< Precision > sin(const ampf< Precision > &x)
const ampf< Precision > log10(const ampf< Precision > &x)
const ampf< Precision > atan(const ampf< Precision > &x)
static const ampf getUlp512()
const ampf< Precision > abs(const ampf< Precision > &x)
const ampf< Precision > cosh(const ampf< Precision > &x)