My Project  UNKNOWN_GIT_VERSION
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 82 of file amp.h.

Constructor & Destructor Documentation

◆ ~ampf() [1/2]

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

Definition at line 88 of file amp.h.

89  {
90  rval->refCount--;
91  if( rval->refCount==0 )
93  }

◆ ampf() [1/34]

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

Definition at line 98 of file amp.h.

98 { InitializeAsZero(); }

◆ ampf() [2/34]

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

Definition at line 99 of file amp.h.

99 { rval = v; }

◆ ampf() [3/34]

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

Definition at line 101 of file amp.h.

101 { InitializeAsDouble(v); }

◆ ampf() [4/34]

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

Definition at line 102 of file amp.h.

102 { InitializeAsDouble(v); }

◆ ampf() [5/34]

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

Definition at line 103 of file amp.h.

103 { InitializeAsDouble(v); }

◆ ampf() [6/34]

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

Definition at line 104 of file amp.h.

104 { InitializeAsSLong(v); }

◆ ampf() [7/34]

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

Definition at line 105 of file amp.h.

105 { InitializeAsULong(v); }

◆ ampf() [8/34]

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

Definition at line 106 of file amp.h.

106 { InitializeAsSLong(v); }

◆ ampf() [9/34]

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

Definition at line 107 of file amp.h.

107 { InitializeAsULong(v); }

◆ ampf() [10/34]

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

Definition at line 108 of file amp.h.

108 { InitializeAsSLong(v); }

◆ ampf() [11/34]

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

Definition at line 109 of file amp.h.

109 { InitializeAsULong(v); }

◆ ampf() [12/34]

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

Definition at line 110 of file amp.h.

110 { InitializeAsSLong(v); }

◆ ampf() [13/34]

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

Definition at line 111 of file amp.h.

111 { InitializeAsULong(v); }

◆ ampf() [14/34]

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

Definition at line 117 of file amp.h.

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

◆ ampf() [15/34]

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

Definition at line 118 of file amp.h.

118 { InitializeAsString(s); }

◆ ampf() [16/34]

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

Definition at line 123 of file amp.h.

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

◆ ampf() [17/34]

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

Definition at line 130 of file amp.h.

131  {
132  CheckPrecision();
133  rval = mpfr_storage::newMpfr(Precision);
134  mpfr_set(getWritePtr(), r.getReadPtr(), GMP_RNDN);
135  }

◆ ~ampf() [2/2]

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

Definition at line 1096 of file svd_si.h.

1096  :
1097  //
1098  // Destructor
1099  //
1100  ~ampf()
1101  {

◆ ampf() [18/34]

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

Definition at line 1106 of file svd_si.h.

1110 { InitializeAsZero(); }

◆ ampf() [19/34]

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

Definition at line 1107 of file svd_si.h.

1110 { InitializeAsZero(); }

◆ ampf() [20/34]

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

Definition at line 1109 of file svd_si.h.

1110 { InitializeAsZero(); }

◆ ampf() [21/34]

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

Definition at line 1110 of file svd_si.h.

1110 { InitializeAsZero(); }

◆ ampf() [22/34]

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

Definition at line 1111 of file svd_si.h.

1111 { rval = v; }

◆ ampf() [23/34]

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

Definition at line 1112 of file svd_si.h.

1113 { InitializeAsDouble(v); }

◆ ampf() [24/34]

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

Definition at line 1113 of file svd_si.h.

1113 { InitializeAsDouble(v); }

◆ ampf() [25/34]

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

Definition at line 1114 of file svd_si.h.

1114 { InitializeAsDouble(v); }

◆ ampf() [26/34]

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

Definition at line 1115 of file svd_si.h.

1115 { InitializeAsDouble(v); }

◆ ampf() [27/34]

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

Definition at line 1116 of file svd_si.h.

1116 { InitializeAsSLong(v); }

◆ ampf() [28/34]

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

Definition at line 1117 of file svd_si.h.

1117 { InitializeAsULong(v); }

◆ ampf() [29/34]

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

Definition at line 1118 of file svd_si.h.

1118 { InitializeAsSLong(v); }

◆ ampf() [30/34]

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

Definition at line 1119 of file svd_si.h.

1119 { InitializeAsULong(v); }

◆ ampf() [31/34]

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

Definition at line 1125 of file svd_si.h.

◆ ampf() [32/34]

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

Definition at line 1126 of file svd_si.h.

◆ ampf() [33/34]

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

Definition at line 1131 of file svd_si.h.

1136  {

◆ ampf() [34/34]

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

Definition at line 1138 of file svd_si.h.

1143  {

Member Function Documentation

◆ CheckPrecision() [1/2]

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

Definition at line 245 of file amp.h.

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

◆ 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 566 of file amp.h.

567  {
568  return getUlp256();
569  }

◆ 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 572 of file amp.h.

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

◆ 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 583 of file amp.h.

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

◆ 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 549 of file amp.h.

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

◆ 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 558 of file amp.h.

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

◆ 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 594 of file amp.h.

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

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

Definition at line 292 of file amp.h.

293  {
294  // TODO: ïîäóìàòü, íóæíî ëè ñäåëàòü, ÷òîáû è ïðè getRead, è ïðè
295  // getWrite ñîçäàâàëàñü íîâàÿ instance mpfr_t.
296  // ýòî ìîæåò áûòü íóæíî äëÿ êîððåêòíîé îáðàáîòêè ñèòóàöèé âèäà
297  // mpfr_÷åãî_òî_òàì( a.getWritePtr(), a.getReadPtr())
298  // âðîäå áû íóæíî, à òî åñëè òàì çàâÿçàíî íà side-effects...
299  return rval->value;
300  }

◆ 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 512 of file amp.h.

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

◆ 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 521 of file amp.h.

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

◆ 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 535 of file amp.h.

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

◆ 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 343 of file amp.h.

344  {
345  return getUlpOf(*this);
346  }

◆ 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 489 of file amp.h.

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

◆ 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 303 of file amp.h.

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

◆ 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 276 of file amp.h.

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

◆ 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 260 of file amp.h.

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

◆ 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 284 of file amp.h.

285  {
286  CheckPrecision();
287  rval = mpfr_storage::newMpfr(Precision);
288  mpfr_strtofr(getWritePtr(), s, NULL, 0, GMP_RNDN);
289  }

◆ 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 268 of file amp.h.

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

◆ 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 252 of file amp.h.

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

◆ 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 315 of file amp.h.

316  {
317  return mpfr_number_p(getReadPtr())!=0;
318  }

◆ 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 335 of file amp.h.

336  {
337  if( !isFiniteNumber() )
338  return false;
339  return mpfr_sgn(getReadPtr())<0;
340  }

◆ 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 321 of file amp.h.

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

◆ 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 329 of file amp.h.

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

◆ 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 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 1194 of file svd_si.h.

1196 { *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 1192 of file svd_si.h.

1196 { *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 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 1193 of file svd_si.h.

1196 { *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 187 of file amp.h.

187 { *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 1195 of file svd_si.h.

1196 { *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 154 of file amp.h.

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

◆ operator=() [2/30]

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

Definition at line 1162 of file svd_si.h.

1162  { mpfr_set_si(getWritePtr(), v, GMP_RNDN); return *this; }
1163  ampf& operator= (unsigned char v) { mpfr_set_ui(getWritePtr(), v, GMP_RNDN); return *this; }
1164  ampf& operator= (const char *s) { mpfr_strtofr(getWritePtr(), s, NULL, 0, GMP_RNDN); return *this; }
1165  ampf& operator= (const std::string &s) { mpfr_strtofr(getWritePtr(), s.c_str(), NULL, 0, GMP_RNDN); return *this; }
1166  ampf& operator= (const ampf& r)
1167  {
1168  // TODO: may be copy ref
1169  if( this==&r )
1170  return *this;
1171  if( rval==r.rval )
1172  return *this;
1173  rval->refCount--;
1174  if( rval->refCount==0 )
1176  rval = r.rval;

◆ operator=() [3/30]

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

Definition at line 171 of file amp.h.

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

◆ operator=() [4/30]

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

Definition at line 1179 of file svd_si.h.

1184  {
1185  if( (void*)this==(void*)(&r) )

◆ operator=() [5/30]

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

Definition at line 152 of file amp.h.

152 { 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 1160 of file svd_si.h.

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

◆ operator=() [7/30]

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

Definition at line 153 of file amp.h.

153 { 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 1161 of file svd_si.h.

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

◆ operator=() [9/30]

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

Definition at line 142 of file amp.h.

142 { 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 1150 of file svd_si.h.

1153 { 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 143 of file amp.h.

143 { 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 1151 of file svd_si.h.

1153 { 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 141 of file amp.h.

141 { 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 1149 of file svd_si.h.

1153 { 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 150 of file amp.h.

150 { 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 1158 of file svd_si.h.

1158 { 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 146 of file amp.h.

146 { 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 1154 of file svd_si.h.

1154 { mpfr_set_ld(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 144 of file amp.h.

144 { 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 1152 of file svd_si.h.

1153 { mpfr_set_ld(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 148 of file amp.h.

148 { 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 1156 of file svd_si.h.

1156 { 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 151 of file amp.h.

151 { 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 1159 of file svd_si.h.

1159 { 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 147 of file amp.h.

147 { 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 1155 of file svd_si.h.

1155 { mpfr_set_ld(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 145 of file amp.h.

145 { 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 1153 of file svd_si.h.

1153 { mpfr_set_ld(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 149 of file amp.h.

149 { 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 1157 of file svd_si.h.

1157 { 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 400 of file amp.h.

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

◆ 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 349 of file amp.h.

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

◆ 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 355 of file amp.h.

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

◆ 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 446 of file amp.h.

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

◆ 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 235 of file amp.h.


The documentation for this class was generated from the following files:
amp::ampf::InitializeAsDouble
void InitializeAsDouble(long double v)
Definition: amp.h:276
amp::ampf::rval
mpfr_record * rval
Definition: amp.h:235
x
Variable x
Definition: cfModGcd.cc:4023
amp::ampf::CheckPrecision
void CheckPrecision()
Definition: amp.h:245
amp::ampf::getReadPtr
mpfr_srcptr getReadPtr() const
Definition: amp.h:292
amp::ampf::isFiniteNumber
bool isFiniteNumber() const
Definition: amp.h:315
amp::mpfr_storage::getRandState
static gmp_randstate_t * getRandState()
Definition: amp.cpp:36
amp::ampf::operator=
ampf & operator=(long double v)
Definition: amp.h:141
amp::ampf::~ampf
~ampf()
Definition: amp.h:88
amp::mpfr_record::refCount
unsigned int refCount
Definition: amp.h:36
amp::ampf::getWritePtr
mpfr_ptr getWritePtr()
Definition: amp.h:303
omAlloc
#define omAlloc(size)
Definition: omAllocDecl.h:208
amp::ampf::InitializeAsString
void InitializeAsString(const char *s)
Definition: amp.h:284
amp::ampf::getUlpOf
const ampf getUlpOf()
Definition: amp.h:343
amp::ampf::InitializeAsSLong
void InitializeAsSLong(signed long v)
Definition: amp.h:260
NULL
#define NULL
Definition: omList.c:9
string
#define string
Definition: libparse.cc:1249
v
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
amp::mpfr_storage::newMpfr
static mpfr_record * newMpfr(unsigned int Precision)
Definition: amp.cpp:10
amp::ampf::ampf
ampf()
Definition: amp.h:98
s
const CanonicalForm int s
Definition: facAbsFact.cc:55
amp::mpfr_record::value
mpfr_t value
Definition: amp.h:38
amp::ampf::getUlp256
static const ampf getUlp256()
Definition: amp.h:521
amp::mpfr_storage::deleteMpfr
static void deleteMpfr(mpfr_record *ref)
Definition: amp.cpp:29
amp::ampf::InitializeAsULong
void InitializeAsULong(unsigned long v)
Definition: amp.h:268
amp::ampf::InitializeAsZero
void InitializeAsZero()
Definition: amp.h:252