QMCDouble Class Reference

Either the numerator or the denominator of a Greens function ratio. More...

#include <QMCDouble.h>

List of all members.

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.
QMCDoubledivideBy (const QMCDouble &denom)
 Divides this QMCDouble by another one and returns a double.
QMCDoublemultiplyBy (const QMCDouble &rhs)
 Multiplies two QMCDoubles together.
QMCDoubleadd (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)


Detailed Description

Either the numerator or the denominator of a Greens function ratio.

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.


Constructor & Destructor Documentation

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.

'

Parameters:
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.

Parameters:
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.

Parameters:
rhs object to set this equal to.

Definition at line 25 of file QMCDouble.cpp.

QMCDouble::~QMCDouble (  ) 

Deallocates the memory allocated by this object.

Definition at line 30 of file QMCDouble.cpp.


Member Function Documentation

QMCDouble & QMCDouble::divideBy ( const QMCDouble denom  ) 

Divides this QMCDouble by another one and returns a double.

Parameters:
denom object to divide this object by
Returns:
*this

Definition at line 202 of file QMCDouble.cpp.

References a, b, c, isNotValid(), isZero(), k, and SimplifyRatioPowers().

Referenced by operator/(), and operator/=().

QMCDouble & QMCDouble::multiplyBy ( const QMCDouble rhs  ) 

Multiplies two QMCDoubles together.

Parameters:
*this 

Definition at line 253 of file QMCDouble.cpp.

References a, b, c, isNotValid(), and k.

Referenced by operator*(), operator*=(), and QMCSCFJastrow::update_SCF().

QMCDouble & QMCDouble::add ( const QMCDouble rhs  ) 

Adds two QMCDoubles together.

Parameters:
*this 

Definition at line 403 of file QMCDouble.cpp.

References a, b, c, IeeeMath::isNaN(), isNotValid(), and k.

Referenced by operator+(), and operator-().

QMCDouble QMCDouble::operator+ ( const QMCDouble rhs  )  const

Definition at line 583 of file QMCDouble.cpp.

References add().

QMCDouble QMCDouble::operator- ( const QMCDouble rhs  )  const

Definition at line 588 of file QMCDouble.cpp.

References add().

QMCDouble QMCDouble::operator* ( const QMCDouble rhs  )  const

Definition at line 593 of file QMCDouble.cpp.

References multiplyBy().

QMCDouble QMCDouble::operator/ ( const QMCDouble rhs  )  const

Definition at line 598 of file QMCDouble.cpp.

References divideBy().

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  ) 

Definition at line 611 of file QMCDouble.cpp.

References multiplyBy().

void QMCDouble::operator/= ( const QMCDouble rhs  ) 

Definition at line 615 of file QMCDouble.cpp.

References divideBy().

void QMCDouble::operator= ( const QMCDouble rhs  ) 

Definition at line 619 of file QMCDouble.cpp.

References a, b, c, and k.

Referenced by operator=().

QMCDouble QMCDouble::operator+ ( const double &  rhs  )  const

Definition at line 626 of file QMCDouble.cpp.

References add(), and QMCDouble().

QMCDouble QMCDouble::operator- ( const double &  rhs  )  const

Definition at line 631 of file QMCDouble.cpp.

References add(), and QMCDouble().

QMCDouble QMCDouble::operator* ( const double &  rhs  )  const

Definition at line 636 of file QMCDouble.cpp.

References multiplyBy(), and QMCDouble().

QMCDouble QMCDouble::operator/ ( const double &  rhs  )  const

Definition at line 641 of file QMCDouble.cpp.

References divideBy(), and QMCDouble().

void QMCDouble::operator+= ( const double &  rhs  ) 

Definition at line 646 of file QMCDouble.cpp.

References QMCDouble().

void QMCDouble::operator-= ( const double &  rhs  ) 

Definition at line 650 of file QMCDouble.cpp.

References QMCDouble().

void QMCDouble::operator*= ( const double &  rhs  ) 

Definition at line 654 of file QMCDouble.cpp.

References multiplyBy(), and QMCDouble().

void QMCDouble::operator/= ( const double &  rhs  ) 

Definition at line 658 of file QMCDouble.cpp.

References divideBy(), and QMCDouble().

void QMCDouble::operator= ( double  rhs  ) 

Definition at line 662 of file QMCDouble.cpp.

References operator=(), and QMCDouble().

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  ) 

Writes the state of this object to an XML stream.

Parameters:
strm XML stream.

Definition at line 62 of file QMCDouble.cpp.

References a, b, c, and k.

double QMCDouble::getValue (  )  const

Gets the overall value of the object.

Returns:
total value of this object.

Definition at line 153 of file QMCDouble.cpp.

References a, b, c, and k.

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.

References c, and k.

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.

References a, b, c, and k.

Referenced by QMCDouble().

void QMCDouble::SimplifyRatioPowers ( double  na,
double  nb,
double  da,
double  db,
double &  ra,
double &  rb 
) [private]

na^nb/da^db = ra^rb

Definition at line 73 of file QMCDouble.cpp.

Referenced by divideBy().


Friends And Related Function Documentation

ostream& operator<< ( ostream &  strm,
const QMCDouble rhs 
) [friend]

Definition at line 43 of file QMCDouble.cpp.


Member Data Documentation

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]

double QMCDouble::b [private]

double QMCDouble::c [private]


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

Generated on Sat Jul 5 16:14:03 2008 for QMcBeaver by  doxygen 1.5.6