Loading...
Searching...
No Matches
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)
ampf & | operator= (long double v)
ampf & | operator= (double v)
ampf & | operator= (float v)
ampf & | operator= (signed long v)
ampf & | operator= (unsigned long v)
ampf & | operator= (signed int v)
ampf & | operator= (unsigned int v)
ampf & | operator= (signed short v)
ampf & | operator= (unsigned short v)
ampf & | operator= (signed char v)
ampf & | operator= (unsigned char v)
ampf & | operator= (const char *s)
ampf & | operator= (const std::string &s)
ampf & | operator= (const ampf &r)
template<unsigned int Precision2>
ampf & | operator= (const ampf< Precision2 > &r)
template<class T>
ampf & | operator+= (const T &v)
template<class T>
ampf & | operator-= (const T &v)
template<class T>
ampf & | operator*= (const T &v)
template<class T>
ampf & | operator/= (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)
ampf & | operator= (long double v)
ampf & | operator= (double v)
ampf & | operator= (float v)
ampf & | operator= (signed long v)
ampf & | operator= (unsigned long v)
ampf & | operator= (signed int v)
ampf & | operator= (unsigned int v)
ampf & | operator= (signed short v)
ampf & | operator= (unsigned short v)
ampf & | operator= (signed char v)
ampf & | operator= (unsigned char v)
ampf & | operator= (const char *s)
ampf & | operator= (const std::string &s)
ampf & | operator= (const ampf &r)
template<unsigned int Precision2>
ampf & | operator= (const ampf< Precision2 > &r)
template<class T>
ampf & | operator+= (const T &v)
template<class T>
ampf & | operator-= (const T &v)
template<class T>
ampf & | operator*= (const T &v)
template<class T>
ampf & | operator/= (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_record * | rval

## 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.

{
rval->refCount--;
if( rval->refCount==0 )
mpfr_storage::deleteMpfr(rval);
}
amp::ampf::rval
mpfr_record * rval
Definition amp.h:234
amp::mpfr_storage::deleteMpfr
static void deleteMpfr(mpfr_record *ref)
Definition amp.cpp:30

## ampf() [1/34]

template<unsigned int Precision>

amp::ampf< Precision >::ampf | ( |  | ) |

inline

Definition at line 97 of file amp.h.

{ InitializeAsZero(); }
amp::ampf::InitializeAsZero
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.

{ rval = v; }
amp::ampf
Definition amp.h:82

## ampf() [3/34]

template<unsigned int Precision>

amp::ampf< Precision >::ampf | ( | long double | v | ) |

inline

Definition at line 100 of file amp.h.

{ InitializeAsDouble(v); }
amp::ampf::InitializeAsDouble
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.

{ InitializeAsDouble(v); }

## ampf() [5/34]

template<unsigned int Precision>

amp::ampf< Precision >::ampf | ( | float | v | ) |

inline

Definition at line 102 of file amp.h.

{ InitializeAsDouble(v); }

## ampf() [6/34]

template<unsigned int Precision>

amp::ampf< Precision >::ampf | ( | signed long | v | ) |

inline

Definition at line 103 of file amp.h.

{ InitializeAsSLong(v); }
amp::ampf::InitializeAsSLong
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.

{ InitializeAsULong(v); }
amp::ampf::InitializeAsULong
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.

{ InitializeAsSLong(v); }

## ampf() [9/34]

template<unsigned int Precision>

amp::ampf< Precision >::ampf | ( | unsigned int | v | ) |

inline

Definition at line 106 of file amp.h.

{ InitializeAsULong(v); }

## ampf() [10/34]

template<unsigned int Precision>

amp::ampf< Precision >::ampf | ( | signed short | v | ) |

inline

Definition at line 107 of file amp.h.

{ InitializeAsSLong(v); }

## ampf() [11/34]

template<unsigned int Precision>

amp::ampf< Precision >::ampf | ( | unsigned short | v | ) |

inline

Definition at line 108 of file amp.h.

{ InitializeAsULong(v); }

## ampf() [12/34]

template<unsigned int Precision>

amp::ampf< Precision >::ampf | ( | signed char | v | ) |

inline

Definition at line 109 of file amp.h.

{ InitializeAsSLong(v); }

## ampf() [13/34]

template<unsigned int Precision>

amp::ampf< Precision >::ampf | ( | unsigned char | v | ) |

inline

Definition at line 110 of file amp.h.

{ InitializeAsULong(v); }

## ampf() [14/34]

template<unsigned int Precision>

amp::ampf< Precision >::ampf | ( | const std::string & | s | ) |

inline

Definition at line 116 of file amp.h.

{ InitializeAsString(s.c_str()); }
amp::ampf::InitializeAsString
void InitializeAsString(const char *s)
Definition amp.h:283

## ampf() [15/34]

template<unsigned int Precision>

amp::ampf< Precision >::ampf | ( | const char * | s | ) |

inline

Definition at line 117 of file amp.h.

{ InitializeAsString(s); }

## ampf() [16/34]

template<unsigned int Precision>

amp::ampf< Precision >::ampf | ( | const ampf< Precision > & | r | ) |

inline

Definition at line 122 of file amp.h.

{
rval = r.rval;
rval->refCount++;
}

## 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.

{
CheckPrecision();
rval = mpfr_storage::newMpfr(Precision);
mpfr_set(getWritePtr(), r.getReadPtr(), GMP_RNDN);
}
amp::ampf::getWritePtr
mpfr_ptr getWritePtr()
Definition amp.h:302
amp::ampf::CheckPrecision
void CheckPrecision()
Definition amp.h:244
amp::ampf::getReadPtr
mpfr_srcptr getReadPtr() const
Definition amp.h:291
amp::mpfr_storage::newMpfr
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.

{
rval->refCount--;
if( rval->refCount==0 )
mpfr_storage::deleteMpfr(rval);
}

## ampf() [18/34]

template<unsigned int Precision>

amp::ampf< Precision >::ampf | ( |  | ) |

inline

Definition at line 1112 of file svd_si.h.

{ 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.

{ 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.

{ InitializeAsDouble(v); }

## ampf() [21/34]

template<unsigned int Precision>

amp::ampf< Precision >::ampf | ( | double | v | ) |

inline

Definition at line 1116 of file svd_si.h.

{ InitializeAsDouble(v); }

## ampf() [22/34]

template<unsigned int Precision>

amp::ampf< Precision >::ampf | ( | float | v | ) |

inline

Definition at line 1117 of file svd_si.h.

{ InitializeAsDouble(v); }

## ampf() [23/34]

template<unsigned int Precision>

amp::ampf< Precision >::ampf | ( | signed long | v | ) |

inline

Definition at line 1118 of file svd_si.h.

{ 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.

{ 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.

{ 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.

{ 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.

{ 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.

{ 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.

{ 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.

{ 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.

{ 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.

{ InitializeAsString(s); }

## 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.

{
rval = r.rval;
rval->refCount++;
}

## 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.

{
CheckPrecision();
rval = mpfr_storage::newMpfr(Precision);
mpfr_set(getWritePtr(), r.getReadPtr(), GMP_RNDN);
}

## Member Function Documentation

## CheckPrecision() [1/2]

template<unsigned int Precision>

void amp::ampf< Precision >::CheckPrecision | ( |  | ) |

private

Definition at line 244 of file amp.h.

{
if( Precision<32 )
throw incorrectPrecision();
}

## 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.

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

## getAlgoPascalEpsilon() [2/2]

template<unsigned int Precision>

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.

{
ampf<Precision> r(1);
mp_exp_t e1 = mpfr_get_emax();
mp_exp_t e2 = -mpfr_get_emin();
mp_exp_t e = e1>e2 ? e1 : e2;
mpfr_set_exp(r.getWritePtr(), e-5);
return r;
}
amp::ampf::ampf
ampf()
Definition amp.h:97

## getAlgoPascalMaxNumber() [2/2]

template<unsigned int Precision>

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.

{
ampf<Precision> r(1);
mp_exp_t e1 = mpfr_get_emax();
mp_exp_t e2 = -mpfr_get_emin();
mp_exp_t e = e1>e2 ? e1 : e2;
mpfr_set_exp(r.getWritePtr(), 2-(e-5));
return r;
}

## getAlgoPascalMinNumber() [2/2]

template<unsigned int Precision>

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.

{
ampf<Precision> r(1);
mpfr_nextbelow(r.getWritePtr());
mpfr_set_exp(r.getWritePtr(),mpfr_get_emax());
return r;
}

## getMaxNumber() [2/2]

template<unsigned int Precision>

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.

{
ampf<Precision> r(1);
mpfr_set_exp(r.getWritePtr(),mpfr_get_emin());
return r;
}

## getMinNumber() [2/2]

template<unsigned int Precision>

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.

{
ampf<Precision> r;
while(mpfr_urandomb(r.getWritePtr(), *amp::mpfr_storage::getRandState()));
return r;
}

## getRandom() [2/2]

template<unsigned int Precision>

const ampf amp::ampf< Precision >::getRandom | ( |  | ) |

static

## getReadPtr() [1/2]

template<unsigned int Precision>

mpfr_srcptr amp::ampf< Precision >::getReadPtr | ( |  | ) | const

Definition at line 291 of file amp.h.

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

## 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.

{
ampf<Precision> r(1);
mpfr_nextabove(r.getWritePtr());
mpfr_sub_ui(r.getWritePtr(), r.getWritePtr(), 1, GMP_RNDN);
return r;
}

## getUlp() [2/2]

template<unsigned int Precision>

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.

{
ampf<Precision> r(1);
mpfr_nextabove(r.getWritePtr());
mpfr_sub_ui(r.getWritePtr(), r.getWritePtr(), 1, GMP_RNDN);
mpfr_mul_2si(
r.getWritePtr(),
r.getWritePtr(),
8,
GMP_RNDN);
return r;
}

## getUlp256() [2/2]

template<unsigned int Precision>

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.

{
ampf<Precision> r(1);
mpfr_nextabove(r.getWritePtr());
mpfr_sub_ui(r.getWritePtr(), r.getWritePtr(), 1, GMP_RNDN);
mpfr_mul_2si(
r.getWritePtr(),
r.getWritePtr(),
9,
GMP_RNDN);
return r;
}

## getUlp512() [2/2]

template<unsigned int Precision>

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.

{
return getUlpOf(*this);
}
amp::ampf::getUlpOf
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.

{
if( !x.isFiniteNumber() )
return x;
if( x.isZero() )
return x;
ampf<Precision> r(1);
mpfr_nextabove(r.getWritePtr());
mpfr_sub_ui(r.getWritePtr(), r.getWritePtr(), 1, GMP_RNDN);
mpfr_mul_2si(
r.getWritePtr(),
r.getWritePtr(),
mpfr_get_exp(x.getReadPtr()),
GMP_RNDN);
mpfr_div_2si(
r.getWritePtr(),
r.getWritePtr(),
1,
GMP_RNDN);
return r;
}
amp::ampf::isZero
bool isZero() const
Definition amp.h:328
amp::ampf::isFiniteNumber
bool isFiniteNumber() const
Definition amp.h:314

## getUlpOf() [4/4]

template<unsigned int Precision>

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.

{
if( rval->refCount==1 )
return rval->value;
mpfr_record *newrval = mpfr_storage::newMpfr(Precision);
mpfr_set(newrval->value, rval->value, GMP_RNDN);
rval->refCount--;
rval = newrval;
return rval->value;
}

## 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.

{
CheckPrecision();
rval = mpfr_storage::newMpfr(Precision);
mpfr_set_ld(getWritePtr(), v, GMP_RNDN);
}

## 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.

{
CheckPrecision();
rval = mpfr_storage::newMpfr(Precision);
mpfr_set_si(getWritePtr(), sv, GMP_RNDN);
}

## 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.

{
CheckPrecision();
rval = mpfr_storage::newMpfr(Precision);
mpfr_strtofr(getWritePtr(), s, NULL, 0, GMP_RNDN);
}

## 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.

{
CheckPrecision();
rval = mpfr_storage::newMpfr(Precision);
mpfr_set_ui(getWritePtr(), v, GMP_RNDN);
}

## 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.

{
CheckPrecision();
rval = mpfr_storage::newMpfr(Precision);
mpfr_set_ui(getWritePtr(), 0, GMP_RNDN);
}

## 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 | ( |  | ) | const

Definition at line 314 of file amp.h.

{
return mpfr_number_p(getReadPtr())!=0;
}

## 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 | ( |  | ) | const

Definition at line 334 of file amp.h.

{
if( !isFiniteNumber() )
return false;
return mpfr_sgn(getReadPtr())<0;
}

## 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 | ( |  | ) | const

Definition at line 320 of file amp.h.

{
if( !isFiniteNumber() )
return false;
return mpfr_sgn(getReadPtr())>0;
}

## 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 | ( |  | ) | const

Definition at line 328 of file amp.h.

{
return mpfr_zero_p(getReadPtr())!=0;
}

## 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.

{ *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.

{ *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.

{ *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.

{ *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.

{ *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.

{ *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.

{ *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.

{ *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.

{
// TODO: may be copy ref
if( this==&r )
return *this;
if( rval==r.rval )
return *this;
rval->refCount--;
if( rval->refCount==0 )
mpfr_storage::deleteMpfr(rval);
rval = r.rval;
rval->refCount++;
//mpfr_set(getWritePtr(), r.getReadPtr(), GMP_RNDN);
return *this;
}

## 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.

{
// TODO: may be copy ref
if( this==&r )
return *this;
if( rval==r.rval )
return *this;
rval->refCount--;
if( rval->refCount==0 )
mpfr_storage::deleteMpfr(rval);
rval = r.rval;
rval->refCount++;
//mpfr_set(getWritePtr(), r.getReadPtr(), GMP_RNDN);
return *this;
}

## 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.

{
if( (void*)this==(void*)(&r) )
return *this;
mpfr_set(getWritePtr(), r.getReadPtr(), GMP_RNDN);
return *this;
}

## 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.

{
if( (void*)this==(void*)(&r) )
return *this;
mpfr_set(getWritePtr(), r.getReadPtr(), GMP_RNDN);
return *this;
}

## operator=() [5/30]

template<unsigned int Precision>

ampf & amp::ampf< Precision >::operator= | ( | const char * | s | ) |

inline

Definition at line 151 of file amp.h.

{ 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.

{ 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.

{ 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.

{ 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.

{ 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.

{ 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.

{ 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.

{ 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.

{ 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.

{ 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.

{ 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.

{ 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.

{ 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.

{ 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.

{ 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.

{ 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.

{ 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.

{ 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.

{ 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.

{ 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.

{ 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.

{ 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.

{ 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.

{ 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.

{ 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.

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

## toDec() [1/2]

template<unsigned int Precision>

std::string amp::ampf< Precision >::toDec | ( |  | ) | const

Definition at line 399 of file amp.h.

{
// TODO: advanced output formatting (zero, integers)
//
// some special cases
//
if( !isFiniteNumber() )
{
std::string r;
mp_exp_t _e;
char *ptr;
ptr = mpfr_get_str(NULL, &_e, 10, 0, getReadPtr(), GMP_RNDN);
r = ptr;
mpfr_free_str(ptr);
return r;
}
//
// general case
//
std::string r;
char buf_e[128];
signed long iexpval;
mp_exp_t expval;
char *ptr;
char *ptr2;
ptr = mpfr_get_str(NULL, &expval, 10, 0, getReadPtr(), GMP_RNDN);
ptr2 = ptr;
iexpval = expval;
if( iexpval!=expval )
throw internalError();
sprintf(buf_e, "%ld", long(iexpval));
if( *ptr=='-' )
{
r = "-";
ptr++;
}
r += "0.";
r += ptr;
r += "E";
r += buf_e;
mpfr_free_str(ptr2);
return r;
}

## 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 | ( |  | ) | const

Definition at line 348 of file amp.h.

{
return mpfr_get_d(getReadPtr(), GMP_RNDN);
}

## 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 | ( |  | ) | const

Definition at line 354 of file amp.h.

{
//
// some special cases
//
if( !isFiniteNumber() )
{
std::string r;
mp_exp_t _e;
char *ptr;
ptr = mpfr_get_str(NULL, &_e, 16, 0, getReadPtr(), GMP_RNDN);
r = ptr;
mpfr_free_str(ptr);
return r;
}
//
// general case
//
std::string r;
char buf_e[128];
signed long iexpval;
mp_exp_t expval;
char *ptr;
char *ptr2;
ptr = mpfr_get_str(NULL, &expval, 16, 0, getReadPtr(), GMP_RNDN);
ptr2 = ptr;
iexpval = expval;
if( iexpval!=expval )
throw internalError();
sprintf(buf_e, "%ld", long(iexpval));
if( *ptr=='-' )
{
r = "-";
ptr++;
}
r += "0x0.";
r += ptr;
r += "@";
r += buf_e;
mpfr_free_str(ptr2);
return r;
}

## 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 | ( |  | ) | const

Definition at line 445 of file amp.h.

{
char *toString_Block=(char *)omAlloc(256);
//
// some special cases
//
if( !isFiniteNumber() )
{
mp_exp_t _e;
char *ptr;
ptr = mpfr_get_str(NULL, &_e, 10, 0, getReadPtr(), GMP_RNDN);
strcpy(toString_Block, ptr);
mpfr_free_str(ptr);
return toString_Block;
}
//
// general case
//
char buf_e[128];
signed long iexpval;
mp_exp_t expval;
char *ptr;
char *ptr2;
ptr = mpfr_get_str(NULL, &expval, 10, 0, getReadPtr(), GMP_RNDN);
ptr2 = ptr;
iexpval = expval;
if( iexpval!=expval )
throw internalError();
sprintf(buf_e, "%ld", long(iexpval));
if( *ptr=='-' )
{
ptr++;
sprintf(toString_Block,"-0.%sE%s",ptr,buf_e);
}
else
sprintf(toString_Block,"0.%sE%s",ptr,buf_e);
mpfr_free_str(ptr2);
return toString_Block;
}
omAlloc
#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:

- Singular/svd/libs/amp.h
- Singular/svd_si.h