#include <QMCDouble.h>
Public Member Functions | |
QMCDouble () | |
Creates a new uninitialized instance of this class. | |
QMCDouble (double k) | |
Creates a new instance of this class with a total value of 'k. | |
QMCDouble (double k, double a, double b, double c) | |
Creates a new instance of this class of the form k*a^b*c. | |
QMCDouble (const QMCDouble &rhs) | |
Creates new instance of this class and makes it equivalent to another instance of this class. | |
~QMCDouble () | |
Deallocates the memory allocated by this object. | |
QMCDouble & | divideBy (const QMCDouble &denom) |
Divides this QMCDouble by another one and returns a double. | |
QMCDouble & | multiplyBy (const QMCDouble &rhs) |
Multiplies two QMCDoubles together. | |
QMCDouble & | add (const QMCDouble &rhs) |
Adds two QMCDoubles together. | |
QMCDouble | operator+ (const QMCDouble &rhs) const |
QMCDouble | operator- (const QMCDouble &rhs) const |
QMCDouble | operator* (const QMCDouble &rhs) const |
QMCDouble | operator/ (const QMCDouble &rhs) const |
void | operator+= (const QMCDouble &rhs) |
void | operator-= (const QMCDouble &rhs) |
void | operator*= (const QMCDouble &rhs) |
void | operator/= (const QMCDouble &rhs) |
void | operator= (const QMCDouble &rhs) |
QMCDouble | operator+ (const double &rhs) const |
QMCDouble | operator- (const double &rhs) const |
QMCDouble | operator* (const double &rhs) const |
QMCDouble | operator/ (const double &rhs) const |
void | operator+= (const double &rhs) |
void | operator-= (const double &rhs) |
void | operator*= (const double &rhs) |
void | operator/= (const double &rhs) |
void | operator= (double rhs) |
operator double () const | |
A typecasting function. | |
void | toXML (ostream &strm) |
Writes the state of this object to an XML stream. | |
double | getValue () const |
Gets the overall value of the object. | |
bool | isNotValid () const |
If the QMCDouble is bad (e.g. | |
bool | isZero () const |
To test whether we can divide by this number. | |
Private Member Functions | |
void | initialize () |
Initializes all of the data members. | |
void | SimplifyRatioPowers (double na, double nb, double da, double db, double &ra, double &rb) |
na^nb/da^db = ra^rb | |
Private Attributes | |
double | k |
This class has the form k*a^b*c. | |
double | a |
double | b |
double | c |
Friends | |
ostream & | operator<< (ostream &strm, const QMCDouble &rhs) |
The purpose of this is to make the evaluation of ratios of very large or very small numbers more stable. This object has the form k*a^b*exp(c)
Notes from Amos: This class has been extended a bit from its Green's function only usage. This is now intended to be a general purpose class to hold and handle super large or super small numbers. In particular, it is now used in QMCFunctions to handle super small psi multiplied by super huge jastrow term.
The full set of math operators have been defined including a cast to double operator. One word of warning, if GRC is a QMCDouble object, then -1.0*GRC is not necessarily equal to GRC*-1.0. This is because the latter calls the QMCDouble operator * (double) function, while the former casts GRC to a double (which *might* be a problem), then multiplies by -1.0.
Perhaps in the future we will want to make this class even better. Specifically, include a "balancing" function to shift large exponents out of the k degree of freedom and into the c degree of freedom. Also maybe add checks in the divideBy function.
Some class philosophy: I sort of intend this class to be a data type... an ExtendedDouble type, with all the appropriate overloaded operators. It now has 3 different classes of math operators: 1) Ones that return by reference the object operated on (divideBy, multiplyBy, add) 2) Ones that return nothing (the +=, *=, /=, etc) 3) Ones that return a new QMCDouble, leaving the operands unaffected (*, +, /, etc)
Definition at line 45 of file QMCDouble.h.
QMCDouble::QMCDouble | ( | ) |
Creates a new uninitialized instance of this class.
Definition at line 4 of file QMCDouble.cpp.
References initialize().
Referenced by operator*(), operator*=(), operator+(), operator+=(), operator-(), operator-=(), operator/(), operator/=(), and operator=().
QMCDouble::QMCDouble | ( | double | k | ) |
Creates a new instance of this class with a total value of 'k.
'
k | total value for the new object. |
Definition at line 9 of file QMCDouble.cpp.
References initialize(), and k.
QMCDouble::QMCDouble | ( | double | k, | |
double | a, | |||
double | b, | |||
double | c | |||
) |
Creates a new instance of this class of the form k*a^b*c.
k | coefficient | |
a | base | |
b | power | |
c | exponent |
Definition at line 15 of file QMCDouble.cpp.
References a, b, c, initialize(), and k.
QMCDouble::QMCDouble | ( | const QMCDouble & | rhs | ) |
Creates new instance of this class and makes it equivalent to another instance of this class.
rhs | object to set this equal to. |
Definition at line 25 of file QMCDouble.cpp.
QMCDouble::~QMCDouble | ( | ) |
Divides this QMCDouble by another one and returns a double.
denom | object to divide this object by |
Definition at line 202 of file QMCDouble.cpp.
References a, b, c, isNotValid(), isZero(), k, and SimplifyRatioPowers().
Referenced by operator/(), and operator/=().
Multiplies two QMCDoubles together.
*this |
Definition at line 253 of file QMCDouble.cpp.
References a, b, c, isNotValid(), and k.
Referenced by operator*(), operator*=(), and QMCSCFJastrow::update_SCF().
Adds two QMCDoubles together.
*this |
Definition at line 403 of file QMCDouble.cpp.
References a, b, c, IeeeMath::isNaN(), isNotValid(), and k.
Referenced by operator+(), and operator-().
void QMCDouble::operator+= | ( | const QMCDouble & | rhs | ) |
Definition at line 603 of file QMCDouble.cpp.
void QMCDouble::operator-= | ( | const QMCDouble & | rhs | ) |
Definition at line 607 of file QMCDouble.cpp.
void QMCDouble::operator*= | ( | const QMCDouble & | rhs | ) |
void QMCDouble::operator/= | ( | const QMCDouble & | rhs | ) |
void QMCDouble::operator= | ( | const QMCDouble & | rhs | ) |
QMCDouble QMCDouble::operator+ | ( | const double & | rhs | ) | const |
QMCDouble QMCDouble::operator- | ( | const double & | rhs | ) | const |
QMCDouble QMCDouble::operator* | ( | const double & | rhs | ) | const |
QMCDouble QMCDouble::operator/ | ( | const double & | rhs | ) | const |
void QMCDouble::operator+= | ( | const double & | rhs | ) |
void QMCDouble::operator-= | ( | const double & | rhs | ) |
void QMCDouble::operator*= | ( | const double & | rhs | ) |
void QMCDouble::operator/= | ( | const double & | rhs | ) |
void QMCDouble::operator= | ( | double | rhs | ) |
QMCDouble::operator double | ( | ) | const |
A typecasting function.
Obviously, care must be taken for unintended casting (see comments for the class, above), but this is quite a convenience I think. It just calls the getValue() function.
Definition at line 666 of file QMCDouble.cpp.
References getValue().
void QMCDouble::toXML | ( | ostream & | strm | ) |
double QMCDouble::getValue | ( | ) | const |
Gets the overall value of the object.
Definition at line 153 of file QMCDouble.cpp.
Referenced by operator double().
bool QMCDouble::isNotValid | ( | ) | const |
If the QMCDouble is bad (e.g.
inf, nan, etc) then this will return false.
Definition at line 172 of file QMCDouble.cpp.
References a, b, c, IeeeMath::isNaN(), and k.
Referenced by add(), QMCWalker::calculateReverseGreensFunctionUmrigar93AcceleratedSampling(), divideBy(), QMCWalker::moveElectronsUmrigar93AcceleratedSampling(), and multiplyBy().
bool QMCDouble::isZero | ( | ) | const |
To test whether we can divide by this number.
Definition at line 193 of file QMCDouble.cpp.
Referenced by divideBy(), and QMCSCFJastrow::update_SCF().
void QMCDouble::initialize | ( | ) | [private] |
Initializes all of the data members.
Definition at line 35 of file QMCDouble.cpp.
Referenced by QMCDouble().
void QMCDouble::SimplifyRatioPowers | ( | double | na, | |
double | nb, | |||
double | da, | |||
double | db, | |||
double & | ra, | |||
double & | rb | |||
) | [private] |
ostream& operator<< | ( | ostream & | strm, | |
const QMCDouble & | rhs | |||
) | [friend] |
Definition at line 43 of file QMCDouble.cpp.
double QMCDouble::k [private] |
This class has the form k*a^b*c.
Definition at line 161 of file QMCDouble.h.
Referenced by add(), divideBy(), getValue(), initialize(), isNotValid(), isZero(), multiplyBy(), operator<<(), operator=(), QMCDouble(), and toXML().
double QMCDouble::a [private] |
Definition at line 161 of file QMCDouble.h.
Referenced by add(), divideBy(), getValue(), initialize(), isNotValid(), multiplyBy(), operator<<(), operator=(), QMCDouble(), and toXML().
double QMCDouble::b [private] |
Definition at line 161 of file QMCDouble.h.
Referenced by add(), divideBy(), getValue(), initialize(), isNotValid(), multiplyBy(), operator<<(), operator=(), QMCDouble(), and toXML().
double QMCDouble::c [private] |
Definition at line 161 of file QMCDouble.h.
Referenced by add(), divideBy(), getValue(), initialize(), isNotValid(), isZero(), multiplyBy(), operator<<(), operator=(), QMCDouble(), and toXML().