Sandia Home

APPSPACK::BasePoint class Reference

APPSPACK::BasePoint Class Reference

#include <APPSPACK_BasePoint.H>

Inheritance diagram for APPSPACK::BasePoint:

APPSPACK::CachePoint APPSPACK::Point APPSPACK::SearchElement List of all members.

Detailed Description

Basic point representation.

BasePoint is the base for Point and SearchElement.

For comparing BasePoints (or derived objects), we must be careful about precision so that we get the same results on all hosts, even if their architectures differ. The static epsilon is used to indicate the precision to which function values should be compared.

Definition at line 54 of file APPSPACK_BasePoint.H.

Public Member Functions

 BasePoint ()
 Default constructor.

 BasePoint (const BasePoint &source)
 Copy constructor.

virtual ~BasePoint ()
 Destructor.

virtual bool isSet () const
 Returns true if x.size() and step are nonzero.

BasePointoperator= (const BasePoint &source)
 Copy.

void pack (bool isInitSend) const
 Pack.

void unpack (int msgTag)
 Receive the message with the specified tag and then unpack the BasePoint (without epsilon).

void unpack (bool isInitRecv)
 Unpack.

double & operator[] (int i)
 Return reference to x[i].

const double & operator[] (int i) const
 Return const reference to x[i].

bool operator< (const BasePoint &b) const
 Compare two BasePoint objects.

bool operator> (const BasePoint &b) const
 Returns b. BasePoint::operator< (*this).

bool operator== (const vector< double > &y) const
 Compare a point and a double array numerically.

bool operator== (const BasePoint &b) const
 Compare x of this and b.

void setX (int len)
 Set the length of x to len, and initialize x to zeroes.

void setX (const vector< double > &xvec)
 Set x to xvec.

void setX (int len, const vector< double > &xvec)
 Set the length of x to len. If xvec.size() == 0, initialize x to zeroes. Otherwise, copy xvec to x.

void setF (bool isFval, double fval=0)
 If isFval is true, copy fval to f and set isF to true. Otherwise, just set isF to false.

bool getIsF () const
 Return true if there is a valid function value (i.e., isF is true).

double getF () const
 Return the function value.

void setStep (double stepval)
 Set the step length.

double getStep () const
 Return the step length.

vector< double > & getX ()
 Return a reference to x.

const vector< double > & getX () const
 Return a const reference to x.

int getN () const
 Get the size of x.

void newGuid ()
 Generate a new GUID for this point.

const GUIDgetGuid () const
 Return a const reference to guid.

virtual ostream & leftshift (ostream &stream) const
 Print the basepoint to the given stream.


Static Public Member Functions

void setEpsilon (double d)
 Set the epsilon.


Static Public Attributes

double epsilon = 0.0

Static Protected Member Functions

bool eq (double alpha, double beta)
 Determine if == within the specified epsilon.

double fabsmax (double alpha, double beta)
 Return $\max\{|\alpha|,|\beta|\}$.


Protected Attributes

vector< double > x
 Contains the point.

bool isF
 True if there a valid function value, f.

double f
 f(x)

double step
 Step length.

GUID guid
 Unique identifier.


Constructor & Destructor Documentation

BasePoint::BasePoint  ) 
 

Default constructor.

The point will actually be initialized by calls to BasePoint::setX or BasePoint::setF or by a later copy.

Definition at line 41 of file APPSPACK_BasePoint.C.

References f, isF, and step.

BasePoint::BasePoint const BasePoint source  ) 
 

Copy constructor.

Does not copy the GUID

Definition at line 52 of file APPSPACK_BasePoint.C.

References f, isF, step, and x.

BasePoint::~BasePoint  )  [virtual]
 

Destructor.

Definition at line 61 of file APPSPACK_BasePoint.C.


Member Function Documentation

bool BasePoint::isSet  )  const [virtual]
 

Returns true if x.size() and step are nonzero.

Reimplemented in APPSPACK::Point, and APPSPACK::CachePoint.

Definition at line 65 of file APPSPACK_BasePoint.C.

References step, and x.

Referenced by setX().

BasePoint & BasePoint::operator= const BasePoint source  ) 
 

Copy.

Copy includes the GUID, unlike copy constructor.

Reimplemented in APPSPACK::Point.

Definition at line 92 of file APPSPACK_BasePoint.C.

References f, guid, isF, step, and x.

void BasePoint::pack bool  isInitSend  )  const
 

Pack.

If isInitSend it true, pass the static epsilon as well.

Reimplemented in APPSPACK::Point.

Definition at line 305 of file APPSPACK_BasePoint.C.

References epsilon, f, guid, isF, APPSPACK::GUID::pack(), step, and x.

Referenced by APPSPACK::CacheMgr::addToCache(), APPSPACK::ModelMgr::addToModel(), and APPSPACK::CacheWkr::recvCheck().

void BasePoint::unpack int  msgTag  ) 
 

Receive the message with the specified tag and then unpack the BasePoint (without epsilon).

Definition at line 325 of file APPSPACK_BasePoint.C.

Referenced by APPSPACK::CacheMgr::isCached(), and APPSPACK::CacheWkr::recvAdd().

void BasePoint::unpack bool  isInitRecv  ) 
 

Unpack.

If isInitRecv it true, unpack the static epsilon as well.

Reimplemented in APPSPACK::Point.

Definition at line 331 of file APPSPACK_BasePoint.C.

References epsilon, f, guid, isF, step, APPSPACK::GUID::unpack(), and x.

double & BasePoint::operator[] int  i  ) 
 

Return reference to x[i].

Definition at line 81 of file APPSPACK_BasePoint.C.

References x.

const double & BasePoint::operator[] int  i  )  const
 

Return const reference to x[i].

Definition at line 70 of file APPSPACK_BasePoint.C.

References x.

bool BasePoint::operator< const BasePoint b  )  const
 

Compare two BasePoint objects.

Let a represent this object. We say $a < b$ if one of the following holds.

  • Both isF and b.isF are true, and BasePoint::eq(f, b.f) is false, and f < b.f.
  • Both isF and b.isF are true, and BasePoint::eq(f, b.f) is true, and guid < b.guid (see GUID::operator<).
  • We have isF is true and b.isF is false

Definition at line 106 of file APPSPACK_BasePoint.C.

References eq(), f, guid, and isF.

bool APPSPACK::BasePoint::operator> const BasePoint b  )  const [inline]
 

Returns b. BasePoint::operator< (*this).

Definition at line 114 of file APPSPACK_BasePoint.H.

bool BasePoint::operator== const vector< double > &  y  )  const
 

Compare a point and a double array numerically.

Return true only if BasePoint::eq(x[i],y[i]) is true for every entry.

Definition at line 140 of file APPSPACK_BasePoint.C.

References eq(), and x.

Referenced by operator==().

bool BasePoint::operator== const BasePoint b  )  const
 

Compare x of this and b.

Return true only if BasePoint::eq(x[i],b.x[i]) is true for every entry.

Definition at line 158 of file APPSPACK_BasePoint.C.

References getX(), and operator==().

void BasePoint::setX int  len  ) 
 

Set the length of x to len, and initialize x to zeroes.

Definition at line 163 of file APPSPACK_BasePoint.C.

References x.

Referenced by APPSPACK::apps(), APPSPACK::CacheWkr::isCached(), and APPSPACK::SearchElement::setSearchElement().

void BasePoint::setX const vector< double > &  xvec  ) 
 

Set x to xvec.

Definition at line 170 of file APPSPACK_BasePoint.C.

References isSet(), and x.

void BasePoint::setX int  len,
const vector< double > &  xvec
 

Set the length of x to len. If xvec.size() == 0, initialize x to zeroes. Otherwise, copy xvec to x.

Definition at line 190 of file APPSPACK_BasePoint.C.

References isSet(), and x.

void BasePoint::setF bool  isFval,
double  fval = 0
 

If isFval is true, copy fval to f and set isF to true. Otherwise, just set isF to false.

Definition at line 226 of file APPSPACK_BasePoint.C.

References f, and isF.

Referenced by APPSPACK::apps(), and APPSPACK::SearchElement::setSearchElement().

bool BasePoint::getIsF  )  const
 

Return true if there is a valid function value (i.e., isF is true).

Definition at line 235 of file APPSPACK_BasePoint.C.

References isF.

Referenced by APPSPACK::SearchElement::fevalStart().

double BasePoint::getF  )  const
 

Return the function value.

Warning:
Should call isF first to verify that the function value is indeed defined.

Definition at line 240 of file APPSPACK_BasePoint.C.

References f.

Referenced by APPSPACK::SearchElement::fevalStart().

void BasePoint::setStep double  stepval  ) 
 

Set the step length.

Definition at line 246 of file APPSPACK_BasePoint.C.

References step.

Referenced by APPSPACK::apps(), and APPSPACK::SearchElement::setSearchElement().

double BasePoint::getStep  )  const
 

Return the step length.

Definition at line 257 of file APPSPACK_BasePoint.C.

References step.

vector< double > & BasePoint::getX  ) 
 

Return a reference to x.

Definition at line 267 of file APPSPACK_BasePoint.C.

References x.

Referenced by APPSPACK::SearchElement::fevalStart(), APPSPACK::Search::isConverged(), and operator==().

const vector< double > & BasePoint::getX  )  const
 

Return a const reference to x.

Definition at line 262 of file APPSPACK_BasePoint.C.

References x.

int BasePoint::getN  )  const
 

Get the size of x.

Definition at line 272 of file APPSPACK_BasePoint.C.

References x.

void BasePoint::newGuid  ) 
 

Generate a new GUID for this point.

See GUID::next.

Definition at line 320 of file APPSPACK_BasePoint.C.

References guid, and APPSPACK::GUID::next().

const GUID& APPSPACK::BasePoint::getGuid  )  const [inline]
 

Return a const reference to guid.

Definition at line 174 of file APPSPACK_BasePoint.H.

References guid.

ostream & BasePoint::leftshift ostream &  stream  )  const [virtual]
 

Print the basepoint to the given stream.

Uses scientific notation, where the precision is defined by Utils::precision. Prints the function value if it is known and otherwise prints "<null>". Then prints x, the step, and the guid. For example:

 f= 0.00e+00 x=[ 0.00e+00  0.00e+00 ] step=1.00e+00 tag=000_075

Reimplemented in APPSPACK::Point, and APPSPACK::SearchElement.

Definition at line 277 of file APPSPACK_BasePoint.C.

References f, guid, isF, step, and x.

void BasePoint::setEpsilon double  d  )  [static]
 

Set the epsilon.

Definition at line 347 of file APPSPACK_BasePoint.C.

References epsilon.

bool BasePoint::eq double  alpha,
double  beta
[static, protected]
 

Determine if == within the specified epsilon.

Return true if $|\alpha| \leq \epsilon$ and $|\beta| \leq \epsilon$, or if

\[ \frac{|\alpha-\beta|}{\max\{|\alpha|,|\beta|\}} \leq \epsilon. \]

Otherwise, return false.

Definition at line 358 of file APPSPACK_BasePoint.C.

References epsilon, and fabsmax().

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

double BasePoint::fabsmax double  alpha,
double  beta
[static, protected]
 

Return $\max\{|\alpha|,|\beta|\}$.

Definition at line 370 of file APPSPACK_BasePoint.C.

Referenced by eq().


Member Data Documentation

double BasePoint::epsilon = 0.0 [static]
 

See BasePoint::eq

Definition at line 39 of file APPSPACK_BasePoint.C.

Referenced by eq(), pack(), setEpsilon(), and unpack().

vector<double> APPSPACK::BasePoint::x [protected]
 

Contains the point.

Definition at line 200 of file APPSPACK_BasePoint.H.

Referenced by BasePoint(), APPSPACK::SearchElement::fevalStart(), getN(), getX(), APPSPACK::CachePoint::isSet(), isSet(), leftshift(), APPSPACK::CachePoint::operator<(), operator=(), APPSPACK::CachePoint::operator==(), operator==(), operator[](), pack(), setX(), and unpack().

bool APPSPACK::BasePoint::isF [protected]
 

True if there a valid function value, f.

Definition at line 203 of file APPSPACK_BasePoint.H.

Referenced by BasePoint(), APPSPACK::SearchElement::checkSufficientDecrease(), APPSPACK::SearchElement::fevalReturn(), APPSPACK::SearchElement::fevalStart(), getIsF(), leftshift(), operator<(), operator=(), pack(), setF(), and unpack().

double APPSPACK::BasePoint::f [protected]
 

f(x)

Definition at line 206 of file APPSPACK_BasePoint.H.

Referenced by BasePoint(), APPSPACK::SearchElement::checkSufficientDecrease(), APPSPACK::SearchElement::fevalReturn(), APPSPACK::SearchElement::fevalStart(), getF(), leftshift(), operator<(), operator=(), pack(), setF(), and unpack().

double APPSPACK::BasePoint::step [protected]
 

Step length.

Definition at line 209 of file APPSPACK_BasePoint.H.

Referenced by BasePoint(), APPSPACK::SearchElement::decreaseStep(), APPSPACK::SearchElement::fevalStart(), getStep(), APPSPACK::SearchElement::increaseStep(), APPSPACK::SearchElement::isConverged(), isSet(), leftshift(), APPSPACK::SearchElement::newMin(), operator=(), pack(), setStep(), and unpack().

GUID APPSPACK::BasePoint::guid [protected]
 

Unique identifier.

Definition at line 212 of file APPSPACK_BasePoint.H.

Referenced by APPSPACK::SearchElement::fevalStart(), getGuid(), leftshift(), newGuid(), operator<(), operator=(), APPSPACK::Point::operator|=(), pack(), and unpack().


The documentation for this class was generated from the following files:
Generated on Mon Oct 27 15:14:48 2003 for APPSPACK by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2002


© Sandia Corporation | Site Contact | Privacy and Security