Array1D< T > Class Template Reference

A 1-dimensional template for making arrays. More...

#include <Array1D.h>

List of all members.

Public Member Functions

int dim1 () const
 Gets the number of elements in the array's first dimension.
int size () const
 Gets the total number of elements in the array.
T * array ()
 Gets a pointer to an array containing the array elements.
void allocate (int i)
 Allocates memory for the array.
void resize (int i)
 This is for compatability with std::vector.
void clear ()
 This is for compatability with std::vector.
void deallocate ()
 Deallocates memory for the array.
operator* (const Array1D &rhs)
 Returns the dot product of two arrays.
Array1D operator+ (const Array1D &rhs)
 Returns the sum of two arrays.
void operator+= (const Array1D< T > &rhs)
void operator= (const Array1D &rhs)
 Sets two arrays equal.
void operator= (const T C)
 Sets all of the elements in an array equal to the same value.
Array1D operator* (const double rhs)
 Returns the product of an array and a double.
void operator*= (const T C)
 Sets this array equal to itself times a scalar value.
void operator/= (const T C)
 Sets this array equal to itself divided by a scalar value.
Array1D operator- (const Array1D &rhs)
 Returns the difference of two arrays.
void quaternion_conjugate ()
 Conjugates a quaternion.
Array1D quaternion_product (const Array1D &rhs)
 Returns the product of two quaternions.
void rotate (Array1D axis, double angle)
 Rotates a vector by an angle about a normalized axis.
void rotateQ (Array1D axis, double angle)
 Rotates a point by an angle about an axis, using a very general approach with quaternions.
Array1D< T > cross (Array1D< T > &rhs)
 Returns the cross product of two vectors.
mag ()
 Array1D ()
 Creates an array.
 Array1D (int i)
 Creates an array and allocates memory.
 Array1D (int i, double shift, double range, long &iseed)
 Create a random array.
 Array1D (const Array1D &rhs)
 Creates an array and sets it equal to another array.
 ~Array1D ()
 Destroys the array and cleans up the memory.
T & operator() (int i)
 Accesses element (i) of the array.
get (int i) const
 It's nice to have a const accessor.
T & operator[] (int i)
void printArray1D (ostream &strm, int numSigFig, int columnSpace, int maxI, char sep, bool sci) const
 This makes it easier to print out the Array1D for input into Mathematica.
int read (istream &strm, T initialization, string label)
 This function assumes that the Array1D was initialized to the expected number of parameters.

Private Attributes

int n_1
 Number of elements in the array's first dimension.
T * pArray
 Array containing the data.

Friends

ostream & operator<< (ostream &strm, const Array1D< T > &rhs)
 Prints the array to a stream.


Detailed Description

template<class T>
class Array1D< T >

A 1-dimensional template for making arrays.

All of the memory allocation and deallocation details are dealt with by the class.

Some of the methods can now be run with ATLAS. Some of the other methods (e.g. rotation) can also be sent to ATLAS, but these aren't bottlenecks...

Definition at line 32 of file Array1D.h.


Constructor & Destructor Documentation

template<class T>
Array1D< T >::Array1D (  )  [inline]

Creates an array.

Definition at line 509 of file Array1D.h.

template<class T>
Array1D< T >::Array1D ( int  i  )  [inline]

Creates an array and allocates memory.

Parameters:
i size of the array's first dimension.

Definition at line 519 of file Array1D.h.

template<class T>
Array1D< T >::Array1D ( int  i,
double  shift,
double  range,
long &  iseed 
) [inline]

Create a random array.

It uses the UNIX rand function, which will produce a uniform random number, [0,1)

Parameters:
shift will be added to the random value
range after adding shift, we'll multiply by range
iseed will be used to initialize srand, if iseed > 0

Definition at line 533 of file Array1D.h.

template<class T>
Array1D< T >::Array1D ( const Array1D< T > &  rhs  )  [inline]

Creates an array and sets it equal to another array.

Parameters:
rhs array to set this array equal to.

Definition at line 554 of file Array1D.h.

template<class T>
Array1D< T >::~Array1D (  )  [inline]

Destroys the array and cleans up the memory.

Definition at line 566 of file Array1D.h.


Member Function Documentation

template<class T>
int Array1D< T >::dim1 (  )  const [inline]

Gets the number of elements in the array's first dimension.

Returns:
number of elements in the array's first dimension.

Definition at line 55 of file Array1D.h.

Referenced by QMCBasisFunction::angularGrid(), QMCBasisFunction::basisFunctionsOnGrid(), QMCMikesBracketingStepLengthSelector::bracket(), QMCNuclearForces::calcCoefficients(), QMCSCFJastrow::calculate_CorrelatedSampling(), QMCSCFJastrow::calculate_OrbitalDerivatives(), QMCJastrowParameters::calculate_penalty_function(), QMCSCFJastrow::calculate_Psi_quantities(), QMCWalker::calculateDerivatives(), QMCWalker::calculateElectronDensities(), QMCWalker::calculateObservables(), QMCElectronNucleusCuspParameters::calculateSigmaSq(), QMCPsiPotential::CountGaussians(), Array1D< QMCProperty >::cross(), CKGeneticAlgorithm1::crossover(), AtomicOrbitalInverter::eval_gaussians(), QMCNuclearForces::evaluate(), QMCJastrowElectronNuclear::evaluate(), Polynomial::evaluate(), Polynomial::evaluateAll(), QMCManager::gatherExtraProperties(), QMCManager::gatherForces(), QMCManager::gatherHistograms(), Array2D< QMCProperty >::generalizedEigenvectors(), QMCEigenSearch::get_a_diag(), QMCDerivativeProperties::getCorrelatedSamples(), QMCJastrowParameters::getJWParameters(), Polynomial::getNumberCoefficients(), QMCWavefunction::getNumberOrbitals(), QMCDerivativeProperties::getParameterHamiltonian(), QMCDerivativeProperties::getParameterHessian(), QMCDerivativeProperties::getParameterOverlap(), QMCEigenSearch::getParameters(), QMCJastrowParameters::getPoles(), QMCSlater::getPsi(), Polynomial::getRoots(), QMCNuclearForces::getTemperTerm(), QMCPolynomial::hasNonNegativeZeroes(), QMCWalkerData::initialize(), QMCSlater::initialize(), QMCRun::initialize(), QMCNuclearForces::initialize(), QMCJastrowElectronNuclear::initialize(), QMCJastrowElectronElectron::initialize(), Polynomial::initialize(), AtomicOrbitalInverter::initialize(), QMCBasisFunction::initializeInterpolation(), QMCBasisFunction::initializeInterpolations(), Yukawa2CorrelationFunction::initializeParameters(), Williamson2CorrelationFunction::initializeParameters(), Umrigar2CorrelationFunction::initializeParameters(), PadeCorrelationFunction::initializeParameters(), JuliusCorrelationFunction::initializeParameters(), FixedCuspPadeCorrelationFunction::initializeParameters(), CambridgeThreeBodyCorrelationFunction::initializeParameters(), Cambridge2CorrelationFunction::initializeParameters(), Anderson2CorrelationFunction::initializeParameters(), CKGeneticAlgorithm1::initializePopulation(), QMCThreeBodyCorrelationFunctionParameters::initializeThreeBodyCorrelationFunctionParameters(), CubicSpline::initializeWithDerivativeValues(), LinearSpline::initializeWithFunctionValues(), CubicSpline::initializeWithFunctionValues(), AtomicOrbitalInverter::invert_gaussians(), QMCThreeBodyJastrow::jastrowOnGrid(), QMCJastrowElectronNuclear::jastrowOnGrid(), QMCJastrowElectronElectron::jastrowOnGrid(), QMCPsiPotential::LoadOrbitals(), QMCReadAndEvaluateConfigs::locally_CalculateProperties(), DistributionInverter::make_F_and_F_inverse(), QMCWavefunction::makeCoefficients(), QMCReadAndEvaluateConfigs::MPI_reduce(), CKGeneticAlgorithm1::mutate(), QMCPropertyArrays::newSample(), QMCObjectiveFunction::numerical_grad(), QMCPropertyArrays::operator+(), operator<<(), QMCWalker::operator=(), QMCLineSearch::optimize(), QMCEigenSearch::optimize(), QMCCorrelatedSamplingVMCOptimization::optimize(), QMCThreeBodyJastrow::packageDerivatives(), QMCJastrowParameters::print(), Polynomial::print(), QMCInput::printAIParameters(), QMCElectronNucleusCuspParameters::printParameters(), QMCRun::propagateWalkers(), QMCMikesBracketingStepLengthSelector::quadratic_rebracketer(), QMCWavefunction::read(), QMCThreeBodyCorrelationFunctionParameters::read(), QMCJastrowParameters::read(), QMCMolecule::readGeometry(), QMCMolecule::readPsuedoPotential(), QMCPropertyArrays::readXML(), QMCLinearizeStepLength::rescalingJCP(), QMCLinearizeStepLength::rescalingPRL(), QMCPropertyArrays::setCalcForces(), QMCThreeBodyCorrelationFunctionParameters::setFreeParameters(), QMCJastrowParameters::setJWParameters(), QMCWavefunction::setORParameters(), QMCCorrelationFunctionParameters::setParameters(), Array2D< QMCProperty >::setRow(), QMCPropertyArrays::toXML(), CubicSpline::toXML(), QMCSlater::update_Ds(), QMCSCFJastrow::update_SCF(), QMCThreeBodyJastrow::updateAll(), QMCJastrowElectronElectron::updateAll(), QMCThreeBodyJastrow::updateOne(), QMCPsiPotential::UseWavefunction(), QMCReadAndEvaluateConfigs::workerCalculateProperties(), QMCManager::writeElectronDensityHistograms(), QMCManager::writeForces(), QMCPropertyArrays::zeroOut(), QMCThreeBodyCorrelationFunctionParameters::zeroOutDerivatives(), Polynomial::zroots(), QMCJastrow::~QMCJastrow(), QMCJastrowElectronElectron::~QMCJastrowElectronElectron(), QMCJastrowElectronNuclear::~QMCJastrowElectronNuclear(), QMCNuclearForces::~QMCNuclearForces(), QMCPropertyArrays::~QMCPropertyArrays(), and QMCSlater::~QMCSlater().

template<class T>
int Array1D< T >::size (  )  const [inline]

template<class T>
T* Array1D< T >::array (  )  [inline]

template<class T>
void Array1D< T >::allocate ( int  i  )  [inline]

Allocates memory for the array.

Parameters:
i size of the array's first dimension.

Definition at line 85 of file Array1D.h.

Referenced by QMCSlater::allocate(), Array1D< QMCProperty >::Array1D(), QMCMikesBracketingStepLengthSelector::bracket(), QMCSCFJastrow::calculate_CorrelatedSampling(), QMCSCFJastrow::calculate_Psi_quantities(), QMCWalker::calculateObservables(), Array2D< QMCProperty >::determinant_and_inverse(), QMCElectronNucleusCusp::determineRc(), Array2D< QMCProperty >::eigenvaluesRS(), QMCHarmonicOscillator::evaluate(), QMCPotential_Energy::evaluatePsuedoPotential(), QMCElectronNucleusCuspParameters::fitReplacementOrbital(), QMCManager::gatherHistograms(), Array2D< QMCProperty >::generalizedEigenvectors(), QMCDerivativeProperties::getCorrelatedSamples(), QMCNuclearForces::getDensities(), QMCThreeBodyCorrelationFunctionParameters::getFree(), QMCDerivativeProperties::getParameterGradient(), QMCSlater::getPsi(), QMCWalkerData::initialize(), QMCRun::initialize(), QMCPotential_Energy::initialize(), QMCNuclearForces::initialize(), QMCJastrowElectronNuclear::initialize(), QMCJastrowElectronElectron::initialize(), QMCJastrow::initialize(), QMCBasisFunction::initialize(), Polynomial::initialize(), AtomicOrbitalInverter::initialize(), QMCDansWalkerInitialization::initializeArrays(), ZeroThreeBodyCorrelationFunction::initializeParameters(), Williamson2CorrelationFunction::initializeParameters(), CambridgeThreeBodyCorrelationFunction::initializeParameters(), Anderson2CorrelationFunction::initializeParameters(), QMCThreeBodyCorrelationFunctionParameters::initializeThreeBodyCorrelationFunctionParameters(), CubicSpline::initializeWithDerivativeValues(), LinearSpline::initializeWithFunctionValues(), CubicSpline::initializeWithFunctionValues(), QMCReadAndEvaluateConfigs::locally_CalculateProperties(), DistributionInverter::make_F_and_F_inverse(), QMCReadAndEvaluateConfigs::MPI_reduce(), QMCObjectiveFunction::numerical_grad(), QMCWalker::operator=(), Array1D< QMCProperty >::operator=(), operator>>(), QMCEigenSearch::optimize(), QMCCorrelatedSamplingVMCOptimization::optimize(), QMCThreeBodyJastrow::packageDerivatives(), QMCRun::propagateWalkers(), QMCCorrelationFunctionParameters::QMCCorrelationFunctionParameters(), QMCPropertyArrays::QMCPropertyArrays(), QMCThreeBodyCorrelationFunctionParameters::QMCThreeBodyCorrelationFunctionParameters(), QMCMikesBracketingStepLengthSelector::quadratic_rebracketer(), QMCWavefunction::read(), QMCThreeBodyCorrelationFunctionParameters::read(), QMCJastrowParameters::read(), QMCCorrelationFunctionParameters::read(), QMCMolecule::readGeometry(), QMCMolecule::readPsuedoPotential(), Array1D< QMCProperty >::resize(), QMCReadAndEvaluateConfigs::rootCalculateProperties(), QMCPropertyArrays::setCalcDensity(), QMCPropertyArrays::setCalcForces(), QMCThreeBodyCorrelationFunctionParameters::setFreeParameters(), QMCJastrowParameters::setJWParameters(), QMCThreeBodyCorrelationFunctionParameters::setTotalParameters(), QMCThreeBodyCorrelationFunctionParameters::totalToFree(), QMCSlater::update_Ds(), QMCSCFJastrow::update_SCF(), QMCNuclearForces::waveMemorization(), QMCReadAndEvaluateConfigs::workerCalculateProperties(), and QMCPropertyArrays::zeroOut().

template<class T>
void Array1D< T >::resize ( int  i  )  [inline]

This is for compatability with std::vector.

It just calls allocate(int i).

Definition at line 120 of file Array1D.h.

Referenced by QMCWalker::initialize().

template<class T>
void Array1D< T >::clear (  )  [inline]

This is for compatability with std::vector.

It just deallocates.

Definition at line 129 of file Array1D.h.

Referenced by QMCWalker::~QMCWalker().

template<class T>
void Array1D< T >::deallocate (  )  [inline]

Deallocates memory for the array.

Definition at line 138 of file Array1D.h.

Referenced by Array1D< QMCProperty >::allocate(), QMCWalker::calculateDerivatives(), QMCWalker::calculateObservables(), Array1D< QMCProperty >::clear(), Array2D< QMCProperty >::deallocate(), Array2D< QMCProperty >::eigenvaluesRS(), QMCNuclearForces::evaluate(), QMCElectronNucleusCuspParameters::fitReplacementOrbital(), QMCManager::gatherHistograms(), Array2D< QMCProperty >::generalizedEigenvectors(), QMCEigenSearch::optimize(), QMCCorrelatedSamplingVMCOptimization::optimize(), QMCRun::propagateWalkers(), QMCThreeBodyCorrelationFunctionParameters::read(), QMCCorrelationFunctionParameters::read(), QMCPropertyArrays::setCalcDensity(), QMCPropertyArrays::setCalcForces(), QMCSlater::update_Ds(), QMCSCFJastrow::update_SCF(), QMCThreeBodyJastrow::updateAll(), QMCThreeBodyJastrow::updateOne(), QMCNuclearForces::waveMemorization(), QMCManager::writeElectronDensityHistograms(), QMCPropertyArrays::zeroOut(), Array1D< QMCProperty >::~Array1D(), CambridgeThreeBodyCorrelationFunction::~CambridgeThreeBodyCorrelationFunction(), QMCCorrelationFunctionParameters::~QMCCorrelationFunctionParameters(), QMCDansWalkerInitialization::~QMCDansWalkerInitialization(), QMCJastrow::~QMCJastrow(), QMCJastrowElectronElectron::~QMCJastrowElectronElectron(), QMCJastrowElectronNuclear::~QMCJastrowElectronNuclear(), QMCNuclearForces::~QMCNuclearForces(), QMCPropertyArrays::~QMCPropertyArrays(), QMCSlater::~QMCSlater(), QMCThreeBodyCorrelationFunctionParameters::~QMCThreeBodyCorrelationFunctionParameters(), and QMCWalker::~QMCWalker().

template<class T>
T Array1D< T >::operator* ( const Array1D< T > &  rhs  )  [inline]

Returns the dot product of two arrays.

Definition at line 210 of file Array1D.h.

template<class T>
Array1D Array1D< T >::operator+ ( const Array1D< T > &  rhs  )  [inline]

Returns the sum of two arrays.

Definition at line 239 of file Array1D.h.

template<class T>
void Array1D< T >::operator+= ( const Array1D< T > &  rhs  )  [inline]

Definition at line 265 of file Array1D.h.

template<class T>
void Array1D< T >::operator= ( const Array1D< T > &  rhs  )  [inline]

Sets two arrays equal.

Definition at line 276 of file Array1D.h.

template<class T>
void Array1D< T >::operator= ( const T  C  )  [inline]

Sets all of the elements in an array equal to the same value.

Definition at line 288 of file Array1D.h.

template<class T>
Array1D Array1D< T >::operator* ( const double  rhs  )  [inline]

Returns the product of an array and a double.

Definition at line 303 of file Array1D.h.

template<class T>
void Array1D< T >::operator*= ( const T  C  )  [inline]

Sets this array equal to itself times a scalar value.

Definition at line 317 of file Array1D.h.

Referenced by Array1D< QMCProperty >::operator/=().

template<class T>
void Array1D< T >::operator/= ( const T  C  )  [inline]

Sets this array equal to itself divided by a scalar value.

Definition at line 329 of file Array1D.h.

template<class T>
Array1D Array1D< T >::operator- ( const Array1D< T > &  rhs  )  [inline]

Returns the difference of two arrays.

Definition at line 339 of file Array1D.h.

template<class T>
void Array1D< T >::quaternion_conjugate (  )  [inline]

Conjugates a quaternion.

Definition at line 365 of file Array1D.h.

template<class T>
Array1D Array1D< T >::quaternion_product ( const Array1D< T > &  rhs  )  [inline]

Returns the product of two quaternions.

Parameters:
rhs quaternion to multiply by this quaternion.
Returns:
product of these two quaternions.

Definition at line 384 of file Array1D.h.

Referenced by Array1D< QMCProperty >::rotateQ().

template<class T>
void Array1D< T >::rotate ( Array1D< T >  axis,
double  angle 
) [inline]

Rotates a vector by an angle about a normalized axis.

It uses a rotation matrix, and is ~6-7 times faster than rotateQ.

This procedure takes 9+12 = 21 multiplications and 1+15=16 additions, for a total of 37 operations, and 2 trig operations.

Parameters:
angle 
axis 3D coords of axis of unit length about which we are rotating.

Definition at line 413 of file Array1D.h.

Referenced by QMCDansWalkerInitialization::dist_energy_level(), and QMCWalker::moveElectronsUmrigar93AcceleratedSampling().

template<class T>
void Array1D< T >::rotateQ ( Array1D< T >  axis,
double  angle 
) [inline]

Rotates a point by an angle about an axis, using a very general approach with quaternions.

It is 6-7 times slower than rotate.

Parameters:
angle 
axis 3D coords of axis of unit length about which we are rotating.

Definition at line 453 of file Array1D.h.

template<class T>
Array1D<T> Array1D< T >::cross ( Array1D< T > &  rhs  )  [inline]

Returns the cross product of two vectors.

Definition at line 480 of file Array1D.h.

template<class T>
T Array1D< T >::mag (  )  [inline]

Definition at line 498 of file Array1D.h.

Referenced by QMCWavefunction::getCINorm(), and QMCWavefunction::normalizeCI().

template<class T>
T& Array1D< T >::operator() ( int  i  )  [inline]

Accesses element (i) of the array.

Definition at line 575 of file Array1D.h.

template<class T>
T Array1D< T >::get ( int  i  )  const [inline]

template<class T>
T& Array1D< T >::operator[] ( int  i  )  [inline]

Definition at line 601 of file Array1D.h.

template<class T>
void Array1D< T >::printArray1D ( ostream &  strm,
int  numSigFig,
int  columnSpace,
int  maxI,
char  sep,
bool  sci 
) const [inline]

This makes it easier to print out the Array1D for input into Mathematica.

In Mathematica, you will still have to replace all the scientific notational "e" with "*^".

Definition at line 625 of file Array1D.h.

Referenced by QMCThreeBodyCorrelationFunctionParameters::gaussianParamDepMatrix().

template<class T>
int Array1D< T >::read ( istream &  strm,
initialization,
string  label 
) [inline]

This function assumes that the Array1D was initialized to the expected number of parameters.

This function will read into Array1D a set of parameters, separated by whitespace. It will read in as many numbers as it can until it runs into a letter [a-zA-Z]. At that point, if too many parameters were entered, it will print a warning, using 'label' to help the user find the problem.

If too few parameters were entered, then it will initialize the rest to the provided initialization value.

Parameters:
strm the input stream where the parameters are ready to be read
initialization the value to use to fill in missing entries
label printed with the warning for loading too many variables
Returns:
the number of parameters that were available

Definition at line 664 of file Array1D.h.

Referenced by QMCThreeBodyCorrelationFunctionParameters::read(), and QMCCorrelationFunctionParameters::read().


Friends And Related Function Documentation

template<class T>
ostream& operator<< ( ostream &  strm,
const Array1D< T > &  rhs 
) [friend]

Prints the array to a stream.

Definition at line 614 of file Array1D.h.


Member Data Documentation

template<class T>
int Array1D< T >::n_1 [private]

template<class T>
T* Array1D< T >::pArray [private]


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

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