My Project
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
amp::ampf< Precision > Class Template Reference

#include <amp.h>

Public Member Functions

 ~ampf ()
 
 ampf ()
 
 ampf (mpfr_record *v)
 
 ampf (long double v)
 
 ampf (double v)
 
 ampf (float v)
 
 ampf (signed long v)
 
 ampf (unsigned long v)
 
 ampf (signed int v)
 
 ampf (unsigned int v)
 
 ampf (signed short v)
 
 ampf (unsigned short v)
 
 ampf (signed char v)
 
 ampf (unsigned char v)
 
 ampf (const std::string &s)
 
 ampf (const char *s)
 
 ampf (const ampf &r)
 
template<unsigned int Precision2>
 ampf (const ampf< Precision2 > &r)
 
ampfoperator= (long double v)
 
ampfoperator= (double v)
 
ampfoperator= (float v)
 
ampfoperator= (signed long v)
 
ampfoperator= (unsigned long v)
 
ampfoperator= (signed int v)
 
ampfoperator= (unsigned int v)
 
ampfoperator= (signed short v)
 
ampfoperator= (unsigned short v)
 
ampfoperator= (signed char v)
 
ampfoperator= (unsigned char v)
 
ampfoperator= (const char *s)
 
ampfoperator= (const std::string &s)
 
ampfoperator= (const ampf &r)
 
template<unsigned int Precision2>
ampfoperator= (const ampf< Precision2 > &r)
 
template<class T >
ampfoperator+= (const T &v)
 
template<class T >
ampfoperator-= (const T &v)
 
template<class T >
ampfoperator*= (const T &v)
 
template<class T >
ampfoperator/= (const T &v)
 
mpfr_srcptr getReadPtr () const
 
mpfr_ptr getWritePtr ()
 
bool isFiniteNumber () const
 
bool isPositiveNumber () const
 
bool isZero () const
 
bool isNegativeNumber () const
 
const ampf getUlpOf ()
 
double toDouble () const
 
std::string toHex () const
 
std::string toDec () const
 
char * toString () const
 
 ~ampf ()
 
 ampf ()
 
 ampf (mpfr_record *v)
 
 ampf (long double v)
 
 ampf (double v)
 
 ampf (float v)
 
 ampf (signed long v)
 
 ampf (unsigned long v)
 
 ampf (signed int v)
 
 ampf (unsigned int v)
 
 ampf (signed short v)
 
 ampf (unsigned short v)
 
 ampf (signed char v)
 
 ampf (unsigned char v)
 
 ampf (const std::string &s)
 
 ampf (const char *s)
 
 ampf (const ampf &r)
 
template<unsigned int Precision2>
 ampf (const ampf< Precision2 > &r)
 
ampfoperator= (long double v)
 
ampfoperator= (double v)
 
ampfoperator= (float v)
 
ampfoperator= (signed long v)
 
ampfoperator= (unsigned long v)
 
ampfoperator= (signed int v)
 
ampfoperator= (unsigned int v)
 
ampfoperator= (signed short v)
 
ampfoperator= (unsigned short v)
 
ampfoperator= (signed char v)
 
ampfoperator= (unsigned char v)
 
ampfoperator= (const char *s)
 
ampfoperator= (const std::string &s)
 
ampfoperator= (const ampf &r)
 
template<unsigned int Precision2>
ampfoperator= (const ampf< Precision2 > &r)
 
template<class T >
ampfoperator+= (const T &v)
 
template<class T >
ampfoperator-= (const T &v)
 
template<class T >
ampfoperator*= (const T &v)
 
template<class T >
ampfoperator/= (const T &v)
 
mpfr_srcptr getReadPtr () const
 
mpfr_ptr getWritePtr ()
 
bool isFiniteNumber () const
 
bool isPositiveNumber () const
 
bool isZero () const
 
bool isNegativeNumber () const
 
const ampf getUlpOf ()
 
double toDouble () const
 
std::string toHex () const
 
std::string toDec () const
 
char * toString () const
 

Static Public Member Functions

static const ampf getUlpOf (const ampf &x)
 
static const ampf getUlp ()
 
static const ampf getUlp256 ()
 
static const ampf getUlp512 ()
 
static const ampf getMaxNumber ()
 
static const ampf getMinNumber ()
 
static const ampf getAlgoPascalEpsilon ()
 
static const ampf getAlgoPascalMaxNumber ()
 
static const ampf getAlgoPascalMinNumber ()
 
static const ampf getRandom ()
 
static const ampf getUlpOf (const ampf &x)
 
static const ampf getUlp ()
 
static const ampf getUlp256 ()
 
static const ampf getUlp512 ()
 
static const ampf getMaxNumber ()
 
static const ampf getMinNumber ()
 
static const ampf getAlgoPascalEpsilon ()
 
static const ampf getAlgoPascalMaxNumber ()
 
static const ampf getAlgoPascalMinNumber ()
 
static const ampf getRandom ()
 

Private Member Functions

void CheckPrecision ()
 
void InitializeAsZero ()
 
void InitializeAsSLong (signed long v)
 
void InitializeAsULong (unsigned long v)
 
void InitializeAsDouble (long double v)
 
void InitializeAsString (const char *s)
 
void CheckPrecision ()
 
void InitializeAsZero ()
 
void InitializeAsSLong (signed long v)
 
void InitializeAsULong (unsigned long v)
 
void InitializeAsDouble (long double v)
 
void InitializeAsString (const char *s)
 

Private Attributes

mpfr_recordrval
 

Detailed Description

template<unsigned int Precision>
class amp::ampf< Precision >

Definition at line 81 of file amp.h.

Constructor & Destructor Documentation

◆ ~ampf() [1/2]

template<unsigned int Precision>
amp::ampf< Precision >::~ampf ( )
inline

Definition at line 87 of file amp.h.

88 {
89 rval->refCount--;
90 if( rval->refCount==0 )
92 }
mpfr_record * rval
Definition: amp.h:234
static void deleteMpfr(mpfr_record *ref)
Definition: amp.cpp:30
unsigned int refCount
Definition: amp.h:35

◆ ampf() [1/34]

template<unsigned int Precision>
amp::ampf< Precision >::ampf ( )
inline

Definition at line 97 of file amp.h.

void InitializeAsZero()
Definition: amp.h:251

◆ ampf() [2/34]

template<unsigned int Precision>
amp::ampf< Precision >::ampf ( mpfr_record v)
inline

Definition at line 98 of file amp.h.

98{ rval = v; }
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:39

◆ ampf() [3/34]

template<unsigned int Precision>
amp::ampf< Precision >::ampf ( long double  v)
inline

Definition at line 100 of file amp.h.

void InitializeAsDouble(long double v)
Definition: amp.h:275

◆ ampf() [4/34]

template<unsigned int Precision>
amp::ampf< Precision >::ampf ( double  v)
inline

Definition at line 101 of file amp.h.

◆ ampf() [5/34]

template<unsigned int Precision>
amp::ampf< Precision >::ampf ( float  v)
inline

Definition at line 102 of file amp.h.

◆ ampf() [6/34]

template<unsigned int Precision>
amp::ampf< Precision >::ampf ( signed long  v)
inline

Definition at line 103 of file amp.h.

void InitializeAsSLong(signed long v)
Definition: amp.h:259

◆ ampf() [7/34]

template<unsigned int Precision>
amp::ampf< Precision >::ampf ( unsigned long  v)
inline

Definition at line 104 of file amp.h.

void InitializeAsULong(unsigned long v)
Definition: amp.h:267

◆ ampf() [8/34]

template<unsigned int Precision>
amp::ampf< Precision >::ampf ( signed int  v)
inline

Definition at line 105 of file amp.h.

◆ ampf() [9/34]

template<unsigned int Precision>
amp::ampf< Precision >::ampf ( unsigned int  v)
inline

Definition at line 106 of file amp.h.

◆ ampf() [10/34]

template<unsigned int Precision>
amp::ampf< Precision >::ampf ( signed short  v)
inline

Definition at line 107 of file amp.h.

◆ ampf() [11/34]

template<unsigned int Precision>
amp::ampf< Precision >::ampf ( unsigned short  v)
inline

Definition at line 108 of file amp.h.

◆ ampf() [12/34]

template<unsigned int Precision>
amp::ampf< Precision >::ampf ( signed char  v)
inline

Definition at line 109 of file amp.h.

◆ ampf() [13/34]

template<unsigned int Precision>
amp::ampf< Precision >::ampf ( unsigned char  v)
inline

Definition at line 110 of file amp.h.

◆ ampf() [14/34]

template<unsigned int Precision>
amp::ampf< Precision >::ampf ( const std::string &  s)
inline

Definition at line 116 of file amp.h.

116{ InitializeAsString(s.c_str()); }
void InitializeAsString(const char *s)
Definition: amp.h:283
const CanonicalForm int s
Definition: facAbsFact.cc:51

◆ ampf() [15/34]

template<unsigned int Precision>
amp::ampf< Precision >::ampf ( const char *  s)
inline

Definition at line 117 of file amp.h.

◆ ampf() [16/34]

template<unsigned int Precision>
amp::ampf< Precision >::ampf ( const ampf< Precision > &  r)
inline

Definition at line 122 of file amp.h.

123 {
124 rval = r.rval;
125 rval->refCount++;
126 }

◆ ampf() [17/34]

template<unsigned int Precision>
template<unsigned int Precision2>
amp::ampf< Precision >::ampf ( const ampf< Precision2 > &  r)
inline

Definition at line 129 of file amp.h.

130 {
132 rval = mpfr_storage::newMpfr(Precision);
133 mpfr_set(getWritePtr(), r.getReadPtr(), GMP_RNDN);
134 }
mpfr_ptr getWritePtr()
Definition: amp.h:302
void CheckPrecision()
Definition: amp.h:244
static mpfr_record * newMpfr(unsigned int Precision)
Definition: amp.cpp:11

◆ ~ampf() [2/2]

template<unsigned int Precision>
amp::ampf< Precision >::~ampf ( )
inline

Definition at line 1102 of file svd_si.h.

1103 {
1104 rval->refCount--;
1105 if( rval->refCount==0 )
1107 }

◆ ampf() [18/34]

template<unsigned int Precision>
amp::ampf< Precision >::ampf ( )
inline

Definition at line 1112 of file svd_si.h.

1112{ InitializeAsZero(); }

◆ ampf() [19/34]

template<unsigned int Precision>
amp::ampf< Precision >::ampf ( mpfr_record v)
inline

Definition at line 1113 of file svd_si.h.

1113{ rval = v; }

◆ ampf() [20/34]

template<unsigned int Precision>
amp::ampf< Precision >::ampf ( long double  v)
inline

Definition at line 1115 of file svd_si.h.

◆ ampf() [21/34]

template<unsigned int Precision>
amp::ampf< Precision >::ampf ( double  v)
inline

Definition at line 1116 of file svd_si.h.

◆ ampf() [22/34]

template<unsigned int Precision>
amp::ampf< Precision >::ampf ( float  v)
inline

Definition at line 1117 of file svd_si.h.

◆ ampf() [23/34]

template<unsigned int Precision>
amp::ampf< Precision >::ampf ( signed long  v)
inline

Definition at line 1118 of file svd_si.h.

1118{ InitializeAsSLong(v); }

◆ ampf() [24/34]

template<unsigned int Precision>
amp::ampf< Precision >::ampf ( unsigned long  v)
inline

Definition at line 1119 of file svd_si.h.

1119{ InitializeAsULong(v); }

◆ ampf() [25/34]

template<unsigned int Precision>
amp::ampf< Precision >::ampf ( signed int  v)
inline

Definition at line 1120 of file svd_si.h.

1120{ InitializeAsSLong(v); }

◆ ampf() [26/34]

template<unsigned int Precision>
amp::ampf< Precision >::ampf ( unsigned int  v)
inline

Definition at line 1121 of file svd_si.h.

1121{ InitializeAsULong(v); }

◆ ampf() [27/34]

template<unsigned int Precision>
amp::ampf< Precision >::ampf ( signed short  v)
inline

Definition at line 1122 of file svd_si.h.

1122{ InitializeAsSLong(v); }

◆ ampf() [28/34]

template<unsigned int Precision>
amp::ampf< Precision >::ampf ( unsigned short  v)
inline

Definition at line 1123 of file svd_si.h.

1123{ InitializeAsULong(v); }

◆ ampf() [29/34]

template<unsigned int Precision>
amp::ampf< Precision >::ampf ( signed char  v)
inline

Definition at line 1124 of file svd_si.h.

1124{ InitializeAsSLong(v); }

◆ ampf() [30/34]

template<unsigned int Precision>
amp::ampf< Precision >::ampf ( unsigned char  v)
inline

Definition at line 1125 of file svd_si.h.

1125{ InitializeAsULong(v); }

◆ ampf() [31/34]

template<unsigned int Precision>
amp::ampf< Precision >::ampf ( const std::string &  s)
inline

Definition at line 1131 of file svd_si.h.

1131{ InitializeAsString(s.c_str()); }

◆ ampf() [32/34]

template<unsigned int Precision>
amp::ampf< Precision >::ampf ( const char *  s)
inline

Definition at line 1132 of file svd_si.h.

◆ ampf() [33/34]

template<unsigned int Precision>
amp::ampf< Precision >::ampf ( const ampf< Precision > &  r)
inline

Definition at line 1137 of file svd_si.h.

1138 {
1139 rval = r.rval;
1140 rval->refCount++;
1141 }

◆ ampf() [34/34]

template<unsigned int Precision>
template<unsigned int Precision2>
amp::ampf< Precision >::ampf ( const ampf< Precision2 > &  r)
inline

Definition at line 1144 of file svd_si.h.

1145 {
1147 rval = mpfr_storage::newMpfr(Precision);
1148 mpfr_set(getWritePtr(), r.getReadPtr(), GMP_RNDN);
1149 }

Member Function Documentation

◆ CheckPrecision() [1/2]

template<unsigned int Precision>
void amp::ampf< Precision >::CheckPrecision
private

Definition at line 244 of file amp.h.

245 {
246 if( Precision<32 )
247 throw incorrectPrecision();
248 }

◆ CheckPrecision() [2/2]

template<unsigned int Precision>
void amp::ampf< Precision >::CheckPrecision ( )
private

◆ getAlgoPascalEpsilon() [1/2]

template<unsigned int Precision>
const ampf< Precision > amp::ampf< Precision >::getAlgoPascalEpsilon
static

Definition at line 565 of file amp.h.

566 {
567 return getUlp256();
568 }
static const ampf getUlp256()
Definition: amp.h:520

◆ getAlgoPascalEpsilon() [2/2]

template<unsigned int Precision>
static const ampf amp::ampf< Precision >::getAlgoPascalEpsilon ( )
static

◆ getAlgoPascalMaxNumber() [1/2]

template<unsigned int Precision>
const ampf< Precision > amp::ampf< Precision >::getAlgoPascalMaxNumber
static

Definition at line 571 of file amp.h.

572 {
573 ampf<Precision> r(1);
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;
577 mpfr_set_exp(r.getWritePtr(), e-5);
578 return r;
579 }

◆ getAlgoPascalMaxNumber() [2/2]

template<unsigned int Precision>
static const ampf amp::ampf< Precision >::getAlgoPascalMaxNumber ( )
static

◆ getAlgoPascalMinNumber() [1/2]

template<unsigned int Precision>
const ampf< Precision > amp::ampf< Precision >::getAlgoPascalMinNumber
static

Definition at line 582 of file amp.h.

583 {
584 ampf<Precision> r(1);
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;
588 mpfr_set_exp(r.getWritePtr(), 2-(e-5));
589 return r;
590 }

◆ getAlgoPascalMinNumber() [2/2]

template<unsigned int Precision>
static const ampf amp::ampf< Precision >::getAlgoPascalMinNumber ( )
static

◆ getMaxNumber() [1/2]

template<unsigned int Precision>
const ampf< Precision > amp::ampf< Precision >::getMaxNumber
static

Definition at line 548 of file amp.h.

549 {
550 ampf<Precision> r(1);
551 mpfr_nextbelow(r.getWritePtr());
552 mpfr_set_exp(r.getWritePtr(),mpfr_get_emax());
553 return r;
554 }

◆ getMaxNumber() [2/2]

template<unsigned int Precision>
static const ampf amp::ampf< Precision >::getMaxNumber ( )
static

◆ getMinNumber() [1/2]

template<unsigned int Precision>
const ampf< Precision > amp::ampf< Precision >::getMinNumber
static

Definition at line 557 of file amp.h.

558 {
559 ampf<Precision> r(1);
560 mpfr_set_exp(r.getWritePtr(),mpfr_get_emin());
561 return r;
562 }

◆ getMinNumber() [2/2]

template<unsigned int Precision>
static const ampf amp::ampf< Precision >::getMinNumber ( )
static

◆ getRandom() [1/2]

template<unsigned int Precision>
const ampf< Precision > amp::ampf< Precision >::getRandom
static

Definition at line 593 of file amp.h.

594 {
595 ampf<Precision> r;
596 while(mpfr_urandomb(r.getWritePtr(), *amp::mpfr_storage::getRandState()));
597 return r;
598 }
static gmp_randstate_t * getRandState()
Definition: amp.cpp:37

◆ getRandom() [2/2]

template<unsigned int Precision>
static const ampf amp::ampf< Precision >::getRandom ( )
static

◆ getReadPtr() [1/2]

template<unsigned int Precision>
mpfr_srcptr amp::ampf< Precision >::getReadPtr

Definition at line 291 of file amp.h.

292 {
293 // TODO: подумать, нужно ли сделать, чтобы и при getRead, и при
294 // getWrite создавалась новая instance mpfr_t.
295 // это может быть нужно для корректной обработки ситуаций вида
296 // mpfr_чего_то_там( a.getWritePtr(), a.getReadPtr())
297 // вроде бы нужно, а то если там завязано на side-effects...
298 return rval->value;
299 }
mpfr_t value
Definition: amp.h:37

◆ getReadPtr() [2/2]

template<unsigned int Precision>
mpfr_srcptr amp::ampf< Precision >::getReadPtr ( ) const

◆ getUlp() [1/2]

template<unsigned int Precision>
const ampf< Precision > amp::ampf< Precision >::getUlp
static

Definition at line 511 of file amp.h.

512 {
513 ampf<Precision> r(1);
514 mpfr_nextabove(r.getWritePtr());
515 mpfr_sub_ui(r.getWritePtr(), r.getWritePtr(), 1, GMP_RNDN);
516 return r;
517 }

◆ getUlp() [2/2]

template<unsigned int Precision>
static const ampf amp::ampf< Precision >::getUlp ( )
static

◆ getUlp256() [1/2]

template<unsigned int Precision>
const ampf< Precision > amp::ampf< Precision >::getUlp256
static

Definition at line 520 of file amp.h.

521 {
522 ampf<Precision> r(1);
523 mpfr_nextabove(r.getWritePtr());
524 mpfr_sub_ui(r.getWritePtr(), r.getWritePtr(), 1, GMP_RNDN);
525 mpfr_mul_2si(
526 r.getWritePtr(),
527 r.getWritePtr(),
528 8,
529 GMP_RNDN);
530 return r;
531 }

◆ getUlp256() [2/2]

template<unsigned int Precision>
static const ampf amp::ampf< Precision >::getUlp256 ( )
static

◆ getUlp512() [1/2]

template<unsigned int Precision>
const ampf< Precision > amp::ampf< Precision >::getUlp512
static

Definition at line 534 of file amp.h.

535 {
536 ampf<Precision> r(1);
537 mpfr_nextabove(r.getWritePtr());
538 mpfr_sub_ui(r.getWritePtr(), r.getWritePtr(), 1, GMP_RNDN);
539 mpfr_mul_2si(
540 r.getWritePtr(),
541 r.getWritePtr(),
542 9,
543 GMP_RNDN);
544 return r;
545 }

◆ getUlp512() [2/2]

template<unsigned int Precision>
static const ampf amp::ampf< Precision >::getUlp512 ( )
static

◆ getUlpOf() [1/4]

template<unsigned int Precision>
const ampf< Precision > amp::ampf< Precision >::getUlpOf

Definition at line 342 of file amp.h.

343 {
344 return getUlpOf(*this);
345 }
const ampf getUlpOf()
Definition: amp.h:342

◆ getUlpOf() [2/4]

template<unsigned int Precision>
const ampf amp::ampf< Precision >::getUlpOf ( )

◆ getUlpOf() [3/4]

template<unsigned int Precision>
const ampf< Precision > amp::ampf< Precision >::getUlpOf ( const ampf< Precision > &  x)
static

Definition at line 488 of file amp.h.

489 {
490 if( !x.isFiniteNumber() )
491 return x;
492 if( x.isZero() )
493 return x;
494 ampf<Precision> r(1);
495 mpfr_nextabove(r.getWritePtr());
496 mpfr_sub_ui(r.getWritePtr(), r.getWritePtr(), 1, GMP_RNDN);
497 mpfr_mul_2si(
498 r.getWritePtr(),
499 r.getWritePtr(),
500 mpfr_get_exp(x.getReadPtr()),
501 GMP_RNDN);
502 mpfr_div_2si(
503 r.getWritePtr(),
504 r.getWritePtr(),
505 1,
506 GMP_RNDN);
507 return r;
508 }
Variable x
Definition: cfModGcd.cc:4082

◆ getUlpOf() [4/4]

template<unsigned int Precision>
static const ampf amp::ampf< Precision >::getUlpOf ( const ampf< Precision > &  x)
static

◆ getWritePtr() [1/2]

template<unsigned int Precision>
mpfr_ptr amp::ampf< Precision >::getWritePtr

Definition at line 302 of file amp.h.

303 {
304 if( rval->refCount==1 )
305 return rval->value;
306 mpfr_record *newrval = mpfr_storage::newMpfr(Precision);
307 mpfr_set(newrval->value, rval->value, GMP_RNDN);
308 rval->refCount--;
309 rval = newrval;
310 return rval->value;
311 }

◆ getWritePtr() [2/2]

template<unsigned int Precision>
mpfr_ptr amp::ampf< Precision >::getWritePtr ( )

◆ InitializeAsDouble() [1/2]

template<unsigned int Precision>
void amp::ampf< Precision >::InitializeAsDouble ( long double  v)
private

Definition at line 275 of file amp.h.

276 {
278 rval = mpfr_storage::newMpfr(Precision);
279 mpfr_set_ld(getWritePtr(), v, GMP_RNDN);
280 }

◆ InitializeAsDouble() [2/2]

template<unsigned int Precision>
void amp::ampf< Precision >::InitializeAsDouble ( long double  v)
private

◆ InitializeAsSLong() [1/2]

template<unsigned int Precision>
void amp::ampf< Precision >::InitializeAsSLong ( signed long  v)
private

Definition at line 259 of file amp.h.

260 {
262 rval = mpfr_storage::newMpfr(Precision);
263 mpfr_set_si(getWritePtr(), sv, GMP_RNDN);
264 }

◆ InitializeAsSLong() [2/2]

template<unsigned int Precision>
void amp::ampf< Precision >::InitializeAsSLong ( signed long  v)
private

◆ InitializeAsString() [1/2]

template<unsigned int Precision>
void amp::ampf< Precision >::InitializeAsString ( const char *  s)
private

Definition at line 283 of file amp.h.

284 {
286 rval = mpfr_storage::newMpfr(Precision);
287 mpfr_strtofr(getWritePtr(), s, NULL, 0, GMP_RNDN);
288 }
#define NULL
Definition: omList.c:12

◆ InitializeAsString() [2/2]

template<unsigned int Precision>
void amp::ampf< Precision >::InitializeAsString ( const char *  s)
private

◆ InitializeAsULong() [1/2]

template<unsigned int Precision>
void amp::ampf< Precision >::InitializeAsULong ( unsigned long  v)
private

Definition at line 267 of file amp.h.

268 {
270 rval = mpfr_storage::newMpfr(Precision);
271 mpfr_set_ui(getWritePtr(), v, GMP_RNDN);
272 }

◆ InitializeAsULong() [2/2]

template<unsigned int Precision>
void amp::ampf< Precision >::InitializeAsULong ( unsigned long  v)
private

◆ InitializeAsZero() [1/2]

template<unsigned int Precision>
void amp::ampf< Precision >::InitializeAsZero
private

Definition at line 251 of file amp.h.

252 {
254 rval = mpfr_storage::newMpfr(Precision);
255 mpfr_set_ui(getWritePtr(), 0, GMP_RNDN);
256 }

◆ InitializeAsZero() [2/2]

template<unsigned int Precision>
void amp::ampf< Precision >::InitializeAsZero ( )
private

◆ isFiniteNumber() [1/2]

template<unsigned int Precision>
bool amp::ampf< Precision >::isFiniteNumber

Definition at line 314 of file amp.h.

315 {
316 return mpfr_number_p(getReadPtr())!=0;
317 }
mpfr_srcptr getReadPtr() const
Definition: amp.h:291

◆ isFiniteNumber() [2/2]

template<unsigned int Precision>
bool amp::ampf< Precision >::isFiniteNumber ( ) const

◆ isNegativeNumber() [1/2]

template<unsigned int Precision>
bool amp::ampf< Precision >::isNegativeNumber

Definition at line 334 of file amp.h.

335 {
336 if( !isFiniteNumber() )
337 return false;
338 return mpfr_sgn(getReadPtr())<0;
339 }
bool isFiniteNumber() const
Definition: amp.h:314

◆ isNegativeNumber() [2/2]

template<unsigned int Precision>
bool amp::ampf< Precision >::isNegativeNumber ( ) const

◆ isPositiveNumber() [1/2]

template<unsigned int Precision>
bool amp::ampf< Precision >::isPositiveNumber

Definition at line 320 of file amp.h.

321 {
322 if( !isFiniteNumber() )
323 return false;
324 return mpfr_sgn(getReadPtr())>0;
325 }

◆ isPositiveNumber() [2/2]

template<unsigned int Precision>
bool amp::ampf< Precision >::isPositiveNumber ( ) const

◆ isZero() [1/2]

template<unsigned int Precision>
bool amp::ampf< Precision >::isZero

Definition at line 328 of file amp.h.

329 {
330 return mpfr_zero_p(getReadPtr())!=0;
331 }

◆ isZero() [2/2]

template<unsigned int Precision>
bool amp::ampf< Precision >::isZero ( ) const

◆ operator*=() [1/2]

template<unsigned int Precision>
template<class T >
ampf & amp::ampf< Precision >::operator*= ( const T v)
inline

Definition at line 185 of file amp.h.

185{ *this = *this * v; return *this; };

◆ operator*=() [2/2]

template<unsigned int Precision>
template<class T >
ampf & amp::ampf< Precision >::operator*= ( const T v)
inline

Definition at line 1200 of file svd_si.h.

1200{ *this = *this * v; return *this; };

◆ operator+=() [1/2]

template<unsigned int Precision>
template<class T >
ampf & amp::ampf< Precision >::operator+= ( const T v)
inline

Definition at line 183 of file amp.h.

183{ *this = *this + v; return *this; };

◆ operator+=() [2/2]

template<unsigned int Precision>
template<class T >
ampf & amp::ampf< Precision >::operator+= ( const T v)
inline

Definition at line 1198 of file svd_si.h.

1198{ *this = *this + v; return *this; };

◆ operator-=() [1/2]

template<unsigned int Precision>
template<class T >
ampf & amp::ampf< Precision >::operator-= ( const T v)
inline

Definition at line 184 of file amp.h.

184{ *this = *this - v; return *this; };

◆ operator-=() [2/2]

template<unsigned int Precision>
template<class T >
ampf & amp::ampf< Precision >::operator-= ( const T v)
inline

Definition at line 1199 of file svd_si.h.

1199{ *this = *this - v; return *this; };

◆ operator/=() [1/2]

template<unsigned int Precision>
template<class T >
ampf & amp::ampf< Precision >::operator/= ( const T v)
inline

Definition at line 186 of file amp.h.

186{ *this = *this / v; return *this; };

◆ operator/=() [2/2]

template<unsigned int Precision>
template<class T >
ampf & amp::ampf< Precision >::operator/= ( const T v)
inline

Definition at line 1201 of file svd_si.h.

1201{ *this = *this / v; return *this; };

◆ operator=() [1/30]

template<unsigned int Precision>
ampf & amp::ampf< Precision >::operator= ( const ampf< Precision > &  r)
inline

Definition at line 153 of file amp.h.

154 {
155 // TODO: may be copy ref
156 if( this==&r )
157 return *this;
158 if( rval==r.rval )
159 return *this;
160 rval->refCount--;
161 if( rval->refCount==0 )
163 rval = r.rval;
164 rval->refCount++;
165 //mpfr_set(getWritePtr(), r.getReadPtr(), GMP_RNDN);
166 return *this;
167 }

◆ operator=() [2/30]

template<unsigned int Precision>
ampf & amp::ampf< Precision >::operator= ( const ampf< Precision > &  r)
inline

Definition at line 1168 of file svd_si.h.

1169 {
1170 // TODO: may be copy ref
1171 if( this==&r )
1172 return *this;
1173 if( rval==r.rval )
1174 return *this;
1175 rval->refCount--;
1176 if( rval->refCount==0 )
1178 rval = r.rval;
1179 rval->refCount++;
1180 //mpfr_set(getWritePtr(), r.getReadPtr(), GMP_RNDN);
1181 return *this;
1182 }

◆ operator=() [3/30]

template<unsigned int Precision>
template<unsigned int Precision2>
ampf & amp::ampf< Precision >::operator= ( const ampf< Precision2 > &  r)
inline

Definition at line 170 of file amp.h.

171 {
172 if( (void*)this==(void*)(&r) )
173 return *this;
174 mpfr_set(getWritePtr(), r.getReadPtr(), GMP_RNDN);
175 return *this;
176 }

◆ operator=() [4/30]

template<unsigned int Precision>
template<unsigned int Precision2>
ampf & amp::ampf< Precision >::operator= ( const ampf< Precision2 > &  r)
inline

Definition at line 1185 of file svd_si.h.

1186 {
1187 if( (void*)this==(void*)(&r) )
1188 return *this;
1189 mpfr_set(getWritePtr(), r.getReadPtr(), GMP_RNDN);
1190 return *this;
1191 }

◆ operator=() [5/30]

template<unsigned int Precision>
ampf & amp::ampf< Precision >::operator= ( const char *  s)
inline

Definition at line 151 of file amp.h.

151{ mpfr_strtofr(getWritePtr(), s, NULL, 0, GMP_RNDN); return *this; }

◆ operator=() [6/30]

template<unsigned int Precision>
ampf & amp::ampf< Precision >::operator= ( const char *  s)
inline

Definition at line 1166 of file svd_si.h.

1166{ mpfr_strtofr(getWritePtr(), s, NULL, 0, GMP_RNDN); return *this; }

◆ operator=() [7/30]

template<unsigned int Precision>
ampf & amp::ampf< Precision >::operator= ( const std::string &  s)
inline

Definition at line 152 of file amp.h.

152{ mpfr_strtofr(getWritePtr(), s.c_str(), NULL, 0, GMP_RNDN); return *this; }

◆ operator=() [8/30]

template<unsigned int Precision>
ampf & amp::ampf< Precision >::operator= ( const std::string &  s)
inline

Definition at line 1167 of file svd_si.h.

1167{ mpfr_strtofr(getWritePtr(), s.c_str(), NULL, 0, GMP_RNDN); return *this; }

◆ operator=() [9/30]

template<unsigned int Precision>
ampf & amp::ampf< Precision >::operator= ( double  v)
inline

Definition at line 141 of file amp.h.

141{ mpfr_set_ld(getWritePtr(), v, GMP_RNDN); return *this; }

◆ operator=() [10/30]

template<unsigned int Precision>
ampf & amp::ampf< Precision >::operator= ( double  v)
inline

Definition at line 1156 of file svd_si.h.

1156{ mpfr_set_ld(getWritePtr(), v, GMP_RNDN); return *this; }

◆ operator=() [11/30]

template<unsigned int Precision>
ampf & amp::ampf< Precision >::operator= ( float  v)
inline

Definition at line 142 of file amp.h.

142{ mpfr_set_ld(getWritePtr(), v, GMP_RNDN); return *this; }

◆ operator=() [12/30]

template<unsigned int Precision>
ampf & amp::ampf< Precision >::operator= ( float  v)
inline

Definition at line 1157 of file svd_si.h.

1157{ mpfr_set_ld(getWritePtr(), v, GMP_RNDN); return *this; }

◆ operator=() [13/30]

template<unsigned int Precision>
ampf & amp::ampf< Precision >::operator= ( long double  v)
inline

Definition at line 140 of file amp.h.

140{ mpfr_set_ld(getWritePtr(), v, GMP_RNDN); return *this; }

◆ operator=() [14/30]

template<unsigned int Precision>
ampf & amp::ampf< Precision >::operator= ( long double  v)
inline

Definition at line 1155 of file svd_si.h.

1155{ mpfr_set_ld(getWritePtr(), v, GMP_RNDN); return *this; }

◆ operator=() [15/30]

template<unsigned int Precision>
ampf & amp::ampf< Precision >::operator= ( signed char  v)
inline

Definition at line 149 of file amp.h.

149{ mpfr_set_si(getWritePtr(), v, GMP_RNDN); return *this; }

◆ operator=() [16/30]

template<unsigned int Precision>
ampf & amp::ampf< Precision >::operator= ( signed char  v)
inline

Definition at line 1164 of file svd_si.h.

1164{ mpfr_set_si(getWritePtr(), v, GMP_RNDN); return *this; }

◆ operator=() [17/30]

template<unsigned int Precision>
ampf & amp::ampf< Precision >::operator= ( signed int  v)
inline

Definition at line 145 of file amp.h.

145{ mpfr_set_si(getWritePtr(), v, GMP_RNDN); return *this; }

◆ operator=() [18/30]

template<unsigned int Precision>
ampf & amp::ampf< Precision >::operator= ( signed int  v)
inline

Definition at line 1160 of file svd_si.h.

1160{ mpfr_set_si(getWritePtr(), v, GMP_RNDN); return *this; }

◆ operator=() [19/30]

template<unsigned int Precision>
ampf & amp::ampf< Precision >::operator= ( signed long  v)
inline

Definition at line 143 of file amp.h.

143{ mpfr_set_si(getWritePtr(), v, GMP_RNDN); return *this; }

◆ operator=() [20/30]

template<unsigned int Precision>
ampf & amp::ampf< Precision >::operator= ( signed long  v)
inline

Definition at line 1158 of file svd_si.h.

1158{ mpfr_set_si(getWritePtr(), v, GMP_RNDN); return *this; }

◆ operator=() [21/30]

template<unsigned int Precision>
ampf & amp::ampf< Precision >::operator= ( signed short  v)
inline

Definition at line 147 of file amp.h.

147{ mpfr_set_si(getWritePtr(), v, GMP_RNDN); return *this; }

◆ operator=() [22/30]

template<unsigned int Precision>
ampf & amp::ampf< Precision >::operator= ( signed short  v)
inline

Definition at line 1162 of file svd_si.h.

1162{ mpfr_set_si(getWritePtr(), v, GMP_RNDN); return *this; }

◆ operator=() [23/30]

template<unsigned int Precision>
ampf & amp::ampf< Precision >::operator= ( unsigned char  v)
inline

Definition at line 150 of file amp.h.

150{ mpfr_set_ui(getWritePtr(), v, GMP_RNDN); return *this; }

◆ operator=() [24/30]

template<unsigned int Precision>
ampf & amp::ampf< Precision >::operator= ( unsigned char  v)
inline

Definition at line 1165 of file svd_si.h.

1165{ mpfr_set_ui(getWritePtr(), v, GMP_RNDN); return *this; }

◆ operator=() [25/30]

template<unsigned int Precision>
ampf & amp::ampf< Precision >::operator= ( unsigned int  v)
inline

Definition at line 146 of file amp.h.

146{ mpfr_set_ui(getWritePtr(), v, GMP_RNDN); return *this; }

◆ operator=() [26/30]

template<unsigned int Precision>
ampf & amp::ampf< Precision >::operator= ( unsigned int  v)
inline

Definition at line 1161 of file svd_si.h.

1161{ mpfr_set_ui(getWritePtr(), v, GMP_RNDN); return *this; }

◆ operator=() [27/30]

template<unsigned int Precision>
ampf & amp::ampf< Precision >::operator= ( unsigned long  v)
inline

Definition at line 144 of file amp.h.

144{ mpfr_set_ui(getWritePtr(), v, GMP_RNDN); return *this; }

◆ operator=() [28/30]

template<unsigned int Precision>
ampf & amp::ampf< Precision >::operator= ( unsigned long  v)
inline

Definition at line 1159 of file svd_si.h.

1159{ mpfr_set_ui(getWritePtr(), v, GMP_RNDN); return *this; }

◆ operator=() [29/30]

template<unsigned int Precision>
ampf & amp::ampf< Precision >::operator= ( unsigned short  v)
inline

Definition at line 148 of file amp.h.

148{ mpfr_set_ui(getWritePtr(), v, GMP_RNDN); return *this; }

◆ operator=() [30/30]

template<unsigned int Precision>
ampf & amp::ampf< Precision >::operator= ( unsigned short  v)
inline

Definition at line 1163 of file svd_si.h.

1163{ mpfr_set_ui(getWritePtr(), v, GMP_RNDN); return *this; }

◆ toDec() [1/2]

template<unsigned int Precision>
std::string amp::ampf< Precision >::toDec

Definition at line 399 of file amp.h.

400 {
401 // TODO: advanced output formatting (zero, integers)
402
403 //
404 // some special cases
405 //
406 if( !isFiniteNumber() )
407 {
408 std::string r;
409 mp_exp_t _e;
410 char *ptr;
411 ptr = mpfr_get_str(NULL, &_e, 10, 0, getReadPtr(), GMP_RNDN);
412 r = ptr;
413 mpfr_free_str(ptr);
414 return r;
415 }
416
417 //
418 // general case
419 //
420 std::string r;
421 char buf_e[128];
422 signed long iexpval;
423 mp_exp_t expval;
424 char *ptr;
425 char *ptr2;
426 ptr = mpfr_get_str(NULL, &expval, 10, 0, getReadPtr(), GMP_RNDN);
427 ptr2 = ptr;
428 iexpval = expval;
429 if( iexpval!=expval )
430 throw internalError();
431 sprintf(buf_e, "%ld", long(iexpval));
432 if( *ptr=='-' )
433 {
434 r = "-";
435 ptr++;
436 }
437 r += "0.";
438 r += ptr;
439 r += "E";
440 r += buf_e;
441 mpfr_free_str(ptr2);
442 return r;
443 }

◆ toDec() [2/2]

template<unsigned int Precision>
std::string amp::ampf< Precision >::toDec ( ) const

◆ toDouble() [1/2]

template<unsigned int Precision>
double amp::ampf< Precision >::toDouble

Definition at line 348 of file amp.h.

349 {
350 return mpfr_get_d(getReadPtr(), GMP_RNDN);
351 }

◆ toDouble() [2/2]

template<unsigned int Precision>
double amp::ampf< Precision >::toDouble ( ) const

◆ toHex() [1/2]

template<unsigned int Precision>
std::string amp::ampf< Precision >::toHex

Definition at line 354 of file amp.h.

355 {
356 //
357 // some special cases
358 //
359 if( !isFiniteNumber() )
360 {
361 std::string r;
362 mp_exp_t _e;
363 char *ptr;
364 ptr = mpfr_get_str(NULL, &_e, 16, 0, getReadPtr(), GMP_RNDN);
365 r = ptr;
366 mpfr_free_str(ptr);
367 return r;
368 }
369
370 //
371 // general case
372 //
373 std::string r;
374 char buf_e[128];
375 signed long iexpval;
376 mp_exp_t expval;
377 char *ptr;
378 char *ptr2;
379 ptr = mpfr_get_str(NULL, &expval, 16, 0, getReadPtr(), GMP_RNDN);
380 ptr2 = ptr;
381 iexpval = expval;
382 if( iexpval!=expval )
383 throw internalError();
384 sprintf(buf_e, "%ld", long(iexpval));
385 if( *ptr=='-' )
386 {
387 r = "-";
388 ptr++;
389 }
390 r += "0x0.";
391 r += ptr;
392 r += "@";
393 r += buf_e;
394 mpfr_free_str(ptr2);
395 return r;
396 }

◆ toHex() [2/2]

template<unsigned int Precision>
std::string amp::ampf< Precision >::toHex ( ) const

◆ toString() [1/2]

template<unsigned int Precision>
char * amp::ampf< Precision >::toString

Definition at line 445 of file amp.h.

446 {
447 char *toString_Block=(char *)omAlloc(256);
448 //
449 // some special cases
450 //
451 if( !isFiniteNumber() )
452 {
453 mp_exp_t _e;
454 char *ptr;
455 ptr = mpfr_get_str(NULL, &_e, 10, 0, getReadPtr(), GMP_RNDN);
456 strcpy(toString_Block, ptr);
457 mpfr_free_str(ptr);
458 return toString_Block;
459 }
460
461 //
462 // general case
463 //
464
465 char buf_e[128];
466 signed long iexpval;
467 mp_exp_t expval;
468 char *ptr;
469 char *ptr2;
470 ptr = mpfr_get_str(NULL, &expval, 10, 0, getReadPtr(), GMP_RNDN);
471 ptr2 = ptr;
472 iexpval = expval;
473 if( iexpval!=expval )
474 throw internalError();
475 sprintf(buf_e, "%ld", long(iexpval));
476 if( *ptr=='-' )
477 {
478 ptr++;
479 sprintf(toString_Block,"-0.%sE%s",ptr,buf_e);
480 }
481 else
482 sprintf(toString_Block,"0.%sE%s",ptr,buf_e);
483 mpfr_free_str(ptr2);
484 return toString_Block;
485 }
#define omAlloc(size)
Definition: omAllocDecl.h:210

◆ toString() [2/2]

template<unsigned int Precision>
char * amp::ampf< Precision >::toString ( ) const

Field Documentation

◆ rval

template<unsigned int Precision>
mpfr_record * amp::ampf< Precision >::rval
private

Definition at line 234 of file amp.h.


The documentation for this class was generated from the following files: