50 static mpfr_record* newMpfr(
unsigned int Precision);
53 static gmp_randstate_t* getRandState();
55 static mpfr_record_ptr&
getList(
unsigned int Precision);
72 mpfr_srcptr getReadPtr()
const;
73 mpfr_ptr getWritePtr();
81 template<
unsigned int Precision>
91 if( rval->refCount==0 )
98 ampf () { InitializeAsZero(); }
101 ampf (
long double v) { InitializeAsDouble(v); }
102 ampf (
double v) { InitializeAsDouble(v); }
103 ampf (
float v) { InitializeAsDouble(v); }
104 ampf (
signed long v) { InitializeAsSLong(v); }
105 ampf (
unsigned long v) { InitializeAsULong(v); }
106 ampf (
signed int v) { InitializeAsSLong(v); }
107 ampf (
unsigned int v) { InitializeAsULong(v); }
108 ampf (
signed short v) { InitializeAsSLong(v); }
109 ampf (
unsigned short v) { InitializeAsULong(v); }
110 ampf (
signed char v) { InitializeAsSLong(v); }
111 ampf (
unsigned char v) { InitializeAsULong(v); }
118 ampf (
const char *
s) { InitializeAsString(s); }
128 #ifndef _AMP_NO_TEMPLATE_CONSTRUCTORS 129 template<
unsigned int Precision2>
134 mpfr_set(getWritePtr(), r.
getReadPtr(), GMP_RNDN);
141 ampf& operator= (
long double v) { mpfr_set_ld(getWritePtr(), v, GMP_RNDN);
return *
this; }
142 ampf& operator= (
double v) { mpfr_set_ld(getWritePtr(), v, GMP_RNDN);
return *
this; }
143 ampf& operator= (
float v) { mpfr_set_ld(getWritePtr(), v, GMP_RNDN);
return *
this; }
144 ampf& operator= (
signed long v) { mpfr_set_si(getWritePtr(), v, GMP_RNDN);
return *
this; }
145 ampf& operator= (
unsigned long v) { mpfr_set_ui(getWritePtr(), v, GMP_RNDN);
return *
this; }
146 ampf& operator= (
signed int v) { mpfr_set_si(getWritePtr(), v, GMP_RNDN);
return *
this; }
147 ampf& operator= (
unsigned int v) { mpfr_set_ui(getWritePtr(), v, GMP_RNDN);
return *
this; }
148 ampf& operator= (
signed short v) { mpfr_set_si(getWritePtr(), v, GMP_RNDN);
return *
this; }
149 ampf& operator= (
unsigned short v) { mpfr_set_ui(getWritePtr(), v, GMP_RNDN);
return *
this; }
150 ampf& operator= (
signed char v) { mpfr_set_si(getWritePtr(), v, GMP_RNDN);
return *
this; }
151 ampf& operator= (
unsigned char v) { mpfr_set_ui(getWritePtr(), v, GMP_RNDN);
return *
this; }
152 ampf& operator= (
const char *
s) { mpfr_strtofr(getWritePtr(), s,
NULL, 0, GMP_RNDN);
return *
this; }
153 ampf& operator= (
const std::string &
s) { mpfr_strtofr(getWritePtr(), s.c_str(),
NULL, 0, GMP_RNDN);
return *
this; }
162 if( rval->refCount==0 )
169 #ifndef _AMP_NO_TEMPLATE_CONSTRUCTORS 170 template<
unsigned int Precision2>
173 if( (
void*)
this==(
void*)(&r) )
175 mpfr_set(getWritePtr(), r.
getReadPtr(), GMP_RNDN);
192 mpfr_srcptr getReadPtr()
const;
193 mpfr_ptr getWritePtr();
198 bool isFiniteNumber()
const;
199 bool isPositiveNumber()
const;
201 bool isNegativeNumber()
const;
202 const ampf getUlpOf();
207 double toDouble()
const;
216 static const ampf getUlpOf(
const ampf &
x);
217 static const ampf getUlp();
218 static const ampf getUlp256();
219 static const ampf getUlp512();
220 static const ampf getMaxNumber();
221 static const ampf getMinNumber();
222 static const ampf getAlgoPascalEpsilon();
223 static const ampf getAlgoPascalMaxNumber();
224 static const ampf getAlgoPascalMinNumber();
225 static const ampf getRandom();
227 void CheckPrecision();
228 void InitializeAsZero();
229 void InitializeAsSLong(
signed long v);
230 void InitializeAsULong(
unsigned long v);
231 void InitializeAsDouble(
long double v);
232 void InitializeAsString(
const char *
s);
244 template<
unsigned int Precision>
251 template<
unsigned int Precision>
256 mpfr_set_ui(getWritePtr(), 0, GMP_RNDN);
259 template<
unsigned int Precision>
264 mpfr_set_si(getWritePtr(), sv, GMP_RNDN);
267 template<
unsigned int Precision>
272 mpfr_set_ui(getWritePtr(), v, GMP_RNDN);
275 template<
unsigned int Precision>
280 mpfr_set_ld(getWritePtr(), v, GMP_RNDN);
283 template<
unsigned int Precision>
288 mpfr_strtofr(getWritePtr(), s,
NULL, 0, GMP_RNDN);
291 template<
unsigned int Precision>
302 template<
unsigned int Precision>
305 if( rval->refCount==1 )
308 mpfr_set(newrval->
value, rval->value, GMP_RNDN);
314 template<
unsigned int Precision>
317 return mpfr_number_p(getReadPtr())!=0;
320 template<
unsigned int Precision>
323 if( !isFiniteNumber() )
325 return mpfr_sgn(getReadPtr())>0;
328 template<
unsigned int Precision>
331 return mpfr_zero_p(getReadPtr())!=0;
334 template<
unsigned int Precision>
337 if( !isFiniteNumber() )
339 return mpfr_sgn(getReadPtr())<0;
342 template<
unsigned int Precision>
345 return getUlpOf(*
this);
348 template<
unsigned int Precision>
351 return mpfr_get_d(getReadPtr(), GMP_RNDN);
354 template<
unsigned int Precision>
360 if( !isFiniteNumber() )
365 ptr = mpfr_get_str(
NULL, &_e, 16, 0, getReadPtr(), GMP_RNDN);
380 ptr = mpfr_get_str(
NULL, &expval, 16, 0, getReadPtr(), GMP_RNDN);
383 if( iexpval!=expval )
385 sprintf(buf_e,
"%ld",
long(iexpval));
399 template<
unsigned int Precision>
407 if( !isFiniteNumber() )
412 ptr = mpfr_get_str(
NULL, &_e, 10, 0, getReadPtr(), GMP_RNDN);
427 ptr = mpfr_get_str(
NULL, &expval, 10, 0, getReadPtr(), GMP_RNDN);
430 if( iexpval!=expval )
432 sprintf(buf_e,
"%ld",
long(iexpval));
445 template<
unsigned int Precision>
448 char *toString_Block=(
char *)
omAlloc(256);
452 if( !isFiniteNumber() )
456 ptr = mpfr_get_str(
NULL, &_e, 10, 0, getReadPtr(), GMP_RNDN);
457 strcpy(toString_Block, ptr);
459 return toString_Block;
471 ptr = mpfr_get_str(
NULL, &expval, 10, 0, getReadPtr(), GMP_RNDN);
474 if( iexpval!=expval )
476 sprintf(buf_e,
"%ld",
long(iexpval));
480 sprintf(toString_Block,
"-0.%sE%s",ptr,buf_e);
483 sprintf(toString_Block,
"0.%sE%s",ptr,buf_e);
485 return toString_Block;
488 template<
unsigned int Precision>
511 template<
unsigned int Precision>
520 template<
unsigned int Precision>
534 template<
unsigned int Precision>
548 template<
unsigned int Precision>
557 template<
unsigned int Precision>
565 template<
unsigned int Precision>
571 template<
unsigned int Precision>
575 mp_exp_t e1 = mpfr_get_emax();
576 mp_exp_t e2 = -mpfr_get_emin();
577 mp_exp_t e = e1>e2 ? e1 : e2;
582 template<
unsigned int Precision>
586 mp_exp_t e1 = mpfr_get_emax();
587 mp_exp_t e2 = -mpfr_get_emin();
588 mp_exp_t e = e1>e2 ? e1 : e2;
593 template<
unsigned int Precision>
604 template<
unsigned int Precision>
610 template<
unsigned int Precision>
616 template<
unsigned int Precision>
619 return mpfr_cmp(op1.getReadPtr(), op2.getReadPtr())<0;
622 template<
unsigned int Precision>
628 template<
unsigned int Precision>
631 return mpfr_cmp(op1.getReadPtr(), op2.getReadPtr())<=0;
634 template<
unsigned int Precision>
643 template<
unsigned int Precision>
649 template<
unsigned int Precision>
657 template<
unsigned int Precision>
665 template<
unsigned int Precision>
674 template<
unsigned int Precision>
682 template<
unsigned int Precision>
693 template<
unsigned int Precision>
702 template<
unsigned int Precision>
713 template<
unsigned int Precision>
722 template<
unsigned int Precision>
731 template<
unsigned int Precision>
740 template<
unsigned int Precision>
749 template<
unsigned int Precision>
757 mpfr_clear_erangeflag();
759 if( mpfr_erangeflag_p()!=0 )
764 template<
unsigned int Precision>
773 template<
unsigned int Precision>
781 mpfr_clear_erangeflag();
783 if( mpfr_erangeflag_p()!=0 )
788 template<
unsigned int Precision>
796 mpfr_clear_erangeflag();
798 if( mpfr_erangeflag_p()!=0 )
803 template<
unsigned int Precision>
811 mpfr_clear_erangeflag();
813 if( mpfr_erangeflag_p()!=0 )
818 template<
unsigned int Precision>
837 template<
unsigned int Precision>
849 #define __AMP_BINARY_OPI(type) \ 850 template<unsigned int Precision> const ampf<Precision> operator+(const signed type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)+op2; } \ 851 template<unsigned int Precision> const ampf<Precision> operator+(const unsigned type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)+op2; } \ 852 template<unsigned int Precision> const ampf<Precision> operator+(const ampf<Precision>& op1, const signed type& op2) { return op1+ampf<Precision>(op2); } \ 853 template<unsigned int Precision> const ampf<Precision> operator+(const ampf<Precision>& op1, const unsigned type& op2) { return op1+ampf<Precision>(op2); } \ 854 template<unsigned int Precision> const ampf<Precision> operator-(const signed type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)-op2; } \ 855 template<unsigned int Precision> const ampf<Precision> operator-(const unsigned type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)-op2; } \ 856 template<unsigned int Precision> const ampf<Precision> operator-(const ampf<Precision>& op1, const signed type& op2) { return op1-ampf<Precision>(op2); } \ 857 template<unsigned int Precision> const ampf<Precision> operator-(const ampf<Precision>& op1, const unsigned type& op2) { return op1-ampf<Precision>(op2); } \ 858 template<unsigned int Precision> const ampf<Precision> operator*(const signed type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)*op2; } \ 859 template<unsigned int Precision> const ampf<Precision> operator*(const unsigned type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)*op2; } \ 860 template<unsigned int Precision> const ampf<Precision> operator*(const ampf<Precision>& op1, const signed type& op2) { return op1*ampf<Precision>(op2); } \ 861 template<unsigned int Precision> const ampf<Precision> operator*(const ampf<Precision>& op1, const unsigned type& op2) { return op1*ampf<Precision>(op2); } \ 862 template<unsigned int Precision> const ampf<Precision> operator/(const signed type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)/op2; } \ 863 template<unsigned int Precision> const ampf<Precision> operator/(const unsigned type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)/op2; } \ 864 template<unsigned int Precision> const ampf<Precision> operator/(const ampf<Precision>& op1, const signed type& op2) { return op1/ampf<Precision>(op2); } \ 865 template<unsigned int Precision> const ampf<Precision> operator/(const ampf<Precision>& op1, const unsigned type& op2) { return op1/ampf<Precision>(op2); } \ 866 template<unsigned int Precision> const bool operator==(const signed type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)==op2; } \ 867 template<unsigned int Precision> const bool operator==(const unsigned type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)==op2; } \ 868 template<unsigned int Precision> const bool operator==(const ampf<Precision>& op1, const signed type& op2) { return op1==ampf<Precision>(op2); } \ 869 template<unsigned int Precision> const bool operator==(const ampf<Precision>& op1, const unsigned type& op2) { return op1==ampf<Precision>(op2); } \ 870 template<unsigned int Precision> const bool operator!=(const signed type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)!=op2; } \ 871 template<unsigned int Precision> const bool operator!=(const unsigned type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)!=op2; } \ 872 template<unsigned int Precision> const bool operator!=(const ampf<Precision>& op1, const signed type& op2) { return op1!=ampf<Precision>(op2); } \ 873 template<unsigned int Precision> const bool operator!=(const ampf<Precision>& op1, const unsigned type& op2) { return op1!=ampf<Precision>(op2); } \ 874 template<unsigned int Precision> const bool operator<=(const signed type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)<=op2; } \ 875 template<unsigned int Precision> const bool operator<=(const unsigned type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)<=op2; } \ 876 template<unsigned int Precision> const bool operator<=(const ampf<Precision>& op1, const signed type& op2) { return op1<=ampf<Precision>(op2); } \ 877 template<unsigned int Precision> const bool operator<=(const ampf<Precision>& op1, const unsigned type& op2) { return op1<=ampf<Precision>(op2); } \ 878 template<unsigned int Precision> const bool operator>=(const signed type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)>=op2; } \ 879 template<unsigned int Precision> const bool operator>=(const unsigned type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)>=op2; } \ 880 template<unsigned int Precision> const bool operator>=(const ampf<Precision>& op1, const signed type& op2) { return op1>=ampf<Precision>(op2); } \ 881 template<unsigned int Precision> const bool operator>=(const ampf<Precision>& op1, const unsigned type& op2) { return op1>=ampf<Precision>(op2); } \ 882 template<unsigned int Precision> const bool operator<(const signed type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)<op2; } \ 883 template<unsigned int Precision> const bool operator<(const unsigned type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)<op2; } \ 884 template<unsigned int Precision> const bool operator<(const ampf<Precision>& op1, const signed type& op2) { return op1<ampf<Precision>(op2); } \ 885 template<unsigned int Precision> const bool operator<(const ampf<Precision>& op1, const unsigned type& op2) { return op1<ampf<Precision>(op2); } \ 886 template<unsigned int Precision> const bool operator>(const signed type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)>op2; } \ 887 template<unsigned int Precision> const bool operator>(const unsigned type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)>op2; } \ 888 template<unsigned int Precision> const bool operator>(const ampf<Precision>& op1, const signed type& op2) { return op1>ampf<Precision>(op2); } \ 889 template<unsigned int Precision> const bool operator>(const ampf<Precision>& op1, const unsigned type& op2) { return op1>ampf<Precision>(op2); } 894 #undef __AMP_BINARY_OPI 895 #define __AMP_BINARY_OPF(type) \ 896 template<unsigned int Precision> const ampf<Precision> operator+(const type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)+op2; } \ 897 template<unsigned int Precision> const ampf<Precision> operator+(const ampf<Precision>& op1, const type& op2) { return op1+ampf<Precision>(op2); } \ 898 template<unsigned int Precision> const ampf<Precision> operator-(const type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)-op2; } \ 899 template<unsigned int Precision> const ampf<Precision> operator-(const ampf<Precision>& op1, const type& op2) { return op1-ampf<Precision>(op2); } \ 900 template<unsigned int Precision> const ampf<Precision> operator*(const type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)*op2; } \ 901 template<unsigned int Precision> const ampf<Precision> operator*(const ampf<Precision>& op1, const type& op2) { return op1*ampf<Precision>(op2); } \ 902 template<unsigned int Precision> const ampf<Precision> operator/(const type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)/op2; } \ 903 template<unsigned int Precision> const ampf<Precision> operator/(const ampf<Precision>& op1, const type& op2) { return op1/ampf<Precision>(op2); } \ 904 template<unsigned int Precision> bool operator==(const type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)==op2; } \ 905 template<unsigned int Precision> bool operator==(const ampf<Precision>& op1, const type& op2) { return op1==ampf<Precision>(op2); } \ 906 template<unsigned int Precision> bool operator!=(const type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)!=op2; } \ 907 template<unsigned int Precision> bool operator!=(const ampf<Precision>& op1, const type& op2) { return op1!=ampf<Precision>(op2); } \ 908 template<unsigned int Precision> bool operator<=(const type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)<=op2; } \ 909 template<unsigned int Precision> bool operator<=(const ampf<Precision>& op1, const type& op2) { return op1<=ampf<Precision>(op2); } \ 910 template<unsigned int Precision> bool operator>=(const type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)>=op2; } \ 911 template<unsigned int Precision> bool operator>=(const ampf<Precision>& op1, const type& op2) { return op1>=ampf<Precision>(op2); } \ 912 template<unsigned int Precision> bool operator<(const type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)<op2; } \ 913 template<unsigned int Precision> bool operator<(const ampf<Precision>& op1, const type& op2) { return op1<ampf<Precision>(op2); } \ 914 template<unsigned int Precision> bool operator>(const type& op1, const ampf<Precision>& op2) { return ampf<Precision>(op1)>op2; } \ 915 template<unsigned int Precision> bool operator>(const ampf<Precision>& op1, const type& op2) { return op1>ampf<Precision>(op2); } 919 #undef __AMP_BINARY_OPF 924 template<
unsigned int Precision>
928 mpfr_const_pi(v->
value, GMP_RNDN);
932 template<
unsigned int Precision>
936 mpfr_const_pi(v->
value, GMP_RNDN);
937 mpfr_mul_2si(v->
value, v->
value, -1, GMP_RNDN);
941 template<
unsigned int Precision>
945 mpfr_const_pi(v->
value, GMP_RNDN);
946 mpfr_mul_2si(v->
value, v->
value, +1, GMP_RNDN);
950 template<
unsigned int Precision>
958 template<
unsigned int Precision>
966 template<
unsigned int Precision>
974 template<
unsigned int Precision>
982 template<
unsigned int Precision>
990 template<
unsigned int Precision>
998 template<
unsigned int Precision>
1006 template<
unsigned int Precision>
1014 template<
unsigned int Precision>
1022 template<
unsigned int Precision>
1030 template<
unsigned int Precision>
1038 template<
unsigned int Precision>
1046 template<
unsigned int Precision>
1054 template<
unsigned int Precision>
1062 template<
unsigned int Precision>
1073 template<
unsigned int Precision>
1092 #ifndef _AMP_NO_TEMPLATE_CONSTRUCTORS 1093 template<
unsigned int Prec2>
1097 campf& operator= (
long double v) {
x=
v;
y=0;
return *
this; }
1100 campf& operator= (
signed long v) {
x=
v;
y=0;
return *
this; }
1101 campf& operator= (
unsigned long v) {
x=
v;
y=0;
return *
this; }
1103 campf& operator= (
unsigned int v) {
x=
v;
y=0;
return *
this; }
1104 campf& operator= (
signed short v) {
x=
v;
y=0;
return *
this; }
1105 campf& operator= (
unsigned short v) {
x=
v;
y=0;
return *
this; }
1106 campf& operator= (
signed char v) {
x=
v;
y=0;
return *
this; }
1107 campf& operator= (
unsigned char v) {
x=
v;
y=0;
return *
this; }
1108 campf& operator= (
const char *
s) {
x=
s;
y=0;
return *
this; }
1116 #ifndef _AMP_NO_TEMPLATE_CONSTRUCTORS 1117 template<
unsigned int Precision2>
1132 template<
unsigned int Precision>
1134 {
return lhs.
x==rhs.
x && lhs.
y==rhs.
y; }
1136 template<
unsigned int Precision>
1138 {
return lhs.
x!=rhs.
x || lhs.
y!=rhs.
y; }
1140 template<
unsigned int Precision>
1144 template<
unsigned int Precision>
1146 { lhs.
x += rhs.
x; lhs.
y += rhs.
y;
return lhs; }
1148 template<
unsigned int Precision>
1152 template<
unsigned int Precision>
1156 template<
unsigned int Precision>
1158 { lhs.
x -= rhs.
x; lhs.
y -= rhs.
y;
return lhs; }
1160 template<
unsigned int Precision>
1164 template<
unsigned int Precision>
1173 template<
unsigned int Precision>
1177 template<
unsigned int Precision>
1187 result.
x = (lhs.
x+lhs.
y*e)/f;
1188 result.
y = (lhs.
y-lhs.
x*e)/f;
1194 result.
x = (lhs.
y+lhs.
x*e)/f;
1195 result.
y = (-lhs.
x+lhs.
y*e)/f;
1200 template<
unsigned int Precision>
1207 template<
unsigned int Precision>
1214 w = xabs>yabs ? xabs : yabs;
1215 v = xabs<yabs ? xabs : yabs;
1225 template<
unsigned int Precision>
1231 template<
unsigned int Precision>
1241 #define __AMP_BINARY_OPI(type) \ 1242 template<unsigned int Precision> const campf<Precision> operator+ (const signed type& op1, const campf<Precision>& op2) { return campf<Precision>(op1+op2.x, op2.y); } \ 1243 template<unsigned int Precision> const campf<Precision> operator+ (const unsigned type& op1, const campf<Precision>& op2) { return campf<Precision>(op1+op2.x, op2.y); } \ 1244 template<unsigned int Precision> const campf<Precision> operator+ (const campf<Precision>& op1, const signed type& op2) { return campf<Precision>(op1.x+op2, op1.y); } \ 1245 template<unsigned int Precision> const campf<Precision> operator+ (const campf<Precision>& op1, const unsigned type& op2) { return campf<Precision>(op1.x+op2, op1.y); } \ 1246 template<unsigned int Precision> const campf<Precision> operator- (const signed type& op1, const campf<Precision>& op2) { return campf<Precision>(op1-op2.x, -op2.y); } \ 1247 template<unsigned int Precision> const campf<Precision> operator- (const unsigned type& op1, const campf<Precision>& op2) { return campf<Precision>(op1-op2.x, -op2.y); } \ 1248 template<unsigned int Precision> const campf<Precision> operator- (const campf<Precision>& op1, const signed type& op2) { return campf<Precision>(op1.x-op2, op1.y); } \ 1249 template<unsigned int Precision> const campf<Precision> operator- (const campf<Precision>& op1, const unsigned type& op2) { return campf<Precision>(op1.x-op2, op1.y); } \ 1250 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); } \ 1251 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); } \ 1252 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); } \ 1253 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); } \ 1254 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; } \ 1255 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; } \ 1256 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); } \ 1257 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); } \ 1258 template<unsigned int Precision> bool operator==(const signed type& op1, const campf<Precision>& op2) { return op1==op2.x && op2.y==0; } \ 1259 template<unsigned int Precision> bool operator==(const unsigned type& op1, const campf<Precision>& op2) { return op1==op2.x && op2.y==0; } \ 1260 template<unsigned int Precision> bool operator==(const campf<Precision>& op1, const signed type& op2) { return op1.x==op2 && op1.y==0; } \ 1261 template<unsigned int Precision> bool operator==(const campf<Precision>& op1, const unsigned type& op2) { return op1.x==op2 && op1.y==0; } \ 1262 template<unsigned int Precision> bool operator!=(const campf<Precision>& op1, const signed type& op2) { return op1.x!=op2 || op1.y!=0; } \ 1263 template<unsigned int Precision> bool operator!=(const campf<Precision>& op1, const unsigned type& op2) { return op1.x!=op2 || op1.y!=0; } \ 1264 template<unsigned int Precision> bool operator!=(const signed type& op1, const campf<Precision>& op2) { return op1!=op2.x || op2.y!=0; } \ 1265 template<unsigned int Precision> bool operator!=(const unsigned type& op1, const campf<Precision>& op2) { return op1!=op2.x || op2.y!=0; } 1270 #undef __AMP_BINARY_OPI 1271 #define __AMP_BINARY_OPF(type) \ 1272 template<unsigned int Precision> const campf<Precision> operator+ (const type& op1, const campf<Precision>& op2) { return campf<Precision>(op1+op2.x, op2.y); } \ 1273 template<unsigned int Precision> const campf<Precision> operator+ (const campf<Precision>& op1, const type& op2) { return campf<Precision>(op1.x+op2, op1.y); } \ 1274 template<unsigned int Precision> const campf<Precision> operator- (const type& op1, const campf<Precision>& op2) { return campf<Precision>(op1-op2.x, -op2.y); } \ 1275 template<unsigned int Precision> const campf<Precision> operator- (const campf<Precision>& op1, const type& op2) { return campf<Precision>(op1.x-op2, op1.y); } \ 1276 template<unsigned int Precision> const campf<Precision> operator* (const type& op1, const campf<Precision>& op2) { return campf<Precision>(op1*op2.x, op1*op2.y); } \ 1277 template<unsigned int Precision> const campf<Precision> operator* (const campf<Precision>& op1, const type& op2) { return campf<Precision>(op2*op1.x, op2*op1.y); } \ 1278 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; } \ 1279 template<unsigned int Precision> const campf<Precision> operator/ (const campf<Precision>& op1, const type& op2) { return campf<Precision>(op1.x/op2, op1.y/op2); } \ 1280 template<unsigned int Precision> bool operator==(const type& op1, const campf<Precision>& op2) { return op1==op2.x && op2.y==0; } \ 1281 template<unsigned int Precision> bool operator==(const campf<Precision>& op1, const type& op2) { return op1.x==op2 && op1.y==0; } \ 1282 template<unsigned int Precision> bool operator!=(const type& op1, const campf<Precision>& op2) { return op1!=op2.x || op2.y!=0; } \ 1283 template<unsigned int Precision> bool operator!=(const campf<Precision>& op1, const type& op2) { return op1.x!=op2 || op1.y!=0; } 1288 #undef __AMP_BINARY_OPF 1293 template<
unsigned int Precision>
1297 int i, cnt = v1.GetLength();
1298 const ampf<Precision> *p1 = v1.GetData();
1299 const ampf<Precision> *p2 = v2.GetData();
1300 mpfr_record *r =
NULL;
1301 mpfr_record *t =
NULL;
1306 mpfr_set_ui(r->value, 0, GMP_RNDN);
1307 for(i=0; i<cnt; i++)
1309 mpfr_mul(t->value, p1->getReadPtr(), p2->getReadPtr(), GMP_RNDN);
1310 mpfr_add(r->value, r->value, t->value, GMP_RNDN);
1327 template<
unsigned int Precision>
1331 int i, cnt = vDst.GetLength();
1336 for(i=0; i<cnt; i++)
1339 pDst += vDst.GetStep();
1340 pSrc += vSrc.GetStep();
1344 template<
unsigned int Precision>
1348 int i, cnt = vDst.GetLength();
1351 for(i=0; i<cnt; i++)
1355 mpfr_neg(v, v, GMP_RNDN);
1356 pDst += vDst.GetStep();
1357 pSrc += vSrc.GetStep();
1361 template<
unsigned int Precision,
class T2>
1365 int i, cnt = vDst.GetLength();
1369 for(i=0; i<cnt; i++)
1374 pDst += vDst.GetStep();
1375 pSrc += vSrc.GetStep();
1379 template<
unsigned int Precision>
1383 int i, cnt = vDst.GetLength();
1386 for(i=0; i<cnt; i++)
1390 mpfr_add(v, v, vs, GMP_RNDN);
1391 pDst += vDst.GetStep();
1392 pSrc += vSrc.GetStep();
1396 template<
unsigned int Precision,
class T2>
1400 int i, cnt = vDst.GetLength();
1404 for(i=0; i<cnt; i++)
1408 mpfr_mul(tmp.
getWritePtr(), a.getReadPtr(), vs, GMP_RNDN);
1410 pDst += vDst.GetStep();
1411 pSrc += vSrc.GetStep();
1415 template<
unsigned int Precision>
1419 int i, cnt = vDst.GetLength();
1422 for(i=0; i<cnt; i++)
1426 mpfr_sub(v, v, vs, GMP_RNDN);
1427 pDst += vDst.GetStep();
1428 pSrc += vSrc.GetStep();
1432 template<
unsigned int Precision,
class T2>
1435 vAdd(vDst, vSrc, -alpha);
1438 template<
unsigned int Precision,
class T2>
1441 int i, cnt = vDst.GetLength();
1444 for(i=0; i<cnt; i++)
1448 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)