OpenMD  2.5
Molecular Dynamics in the Open
OpenMD::DynamicVector< Real, Alloc > Class Template Reference

Fix length vector class. More...

#include "math/DynamicVector.hpp"

Inheritance diagram for OpenMD::DynamicVector< Real, Alloc >:

Public Types

typedef Real value_type
 
typedef std::vector< Real, Alloc > VectorType
 
typedef VectorType::pointer pointer
 
typedef VectorType::const_pointer const_pointer
 
typedef VectorType::reference reference
 
typedef VectorType::const_reference const_reference
 
typedef VectorType::iterator iterator
 
typedef VectorType::const_iterator const_iterator
 
typedef VectorType::const_reverse_iterator const_reverse_iterator
 
typedef VectorType::reverse_iterator reverse_iterator
 
typedef VectorType::size_type size_type
 
typedef VectorType::difference_type difference_type
 
typedef VectorType::allocator_type allocator_type
 

Public Member Functions

 DynamicVector (const allocator_type &alloc=allocator_type())
 Default constructor creates no elements. More...
 
 DynamicVector (size_type n, const value_type &value, const allocator_type &alloc=allocator_type())
 Create a DynamicVector with copies of an exemplar element. More...
 
 DynamicVector (size_type n)
 Create a DynamicVector with default elements. More...
 
 DynamicVector (const DynamicVector &x)
 Vector copy constructor. More...
 
template<typename _InputIterator >
 DynamicVector (_InputIterator first, _InputIterator last, const allocator_type &alloc=allocator_type())
 
Real operator() (unsigned int i) const
 
Real & operator() (unsigned int i)
 
bool operator== (const DynamicVector< Real > &v)
 
bool operator!= (const DynamicVector< Real > &v)
 
void negate ()
 
void negate (const DynamicVector< Real > &v1)
 
void add (const DynamicVector< Real > &v1)
 
void add (const DynamicVector< Real > &v1, const DynamicVector< Real > &v2)
 
void sub (const DynamicVector< Real > &v1)
 
void sub (const DynamicVector< Real > &v1, const DynamicVector &v2)
 
void mul (Real s)
 
void mul (const DynamicVector< Real > &v1, Real s)
 
void div (Real s)
 
void div (const DynamicVector< Real > &v1, Real s)
 
DynamicVector< Real > & operator+= (const DynamicVector< Real > &v1)
 
DynamicVector< Real > & operator-= (const DynamicVector< Real > &v1)
 
DynamicVector< Real > & operator*= (Real s)
 
DynamicVector< Real > & operator/= (Real s)
 
void setZero ()
 
Real length ()
 
Real lengthSquare ()
 
void normalize ()
 
bool isNormalized ()
 
template<class VectorType >
void getSubVector (unsigned int beginning, VectorType &v)
 

Detailed Description

template<typename Real, typename Alloc = std::allocator<Real>>
class OpenMD::DynamicVector< Real, Alloc >

Fix length vector class.

Definition at line 66 of file DynamicVector.hpp.

Member Typedef Documentation

◆ allocator_type

template<typename Real, typename Alloc = std::allocator<Real>>
typedef VectorType::allocator_type OpenMD::DynamicVector< Real, Alloc >::allocator_type

Definition at line 81 of file DynamicVector.hpp.

◆ const_iterator

template<typename Real, typename Alloc = std::allocator<Real>>
typedef VectorType::const_iterator OpenMD::DynamicVector< Real, Alloc >::const_iterator

Definition at line 76 of file DynamicVector.hpp.

◆ const_pointer

template<typename Real, typename Alloc = std::allocator<Real>>
typedef VectorType::const_pointer OpenMD::DynamicVector< Real, Alloc >::const_pointer

Definition at line 72 of file DynamicVector.hpp.

◆ const_reference

template<typename Real, typename Alloc = std::allocator<Real>>
typedef VectorType::const_reference OpenMD::DynamicVector< Real, Alloc >::const_reference

Definition at line 74 of file DynamicVector.hpp.

◆ const_reverse_iterator

template<typename Real, typename Alloc = std::allocator<Real>>
typedef VectorType::const_reverse_iterator OpenMD::DynamicVector< Real, Alloc >::const_reverse_iterator

Definition at line 77 of file DynamicVector.hpp.

◆ difference_type

template<typename Real, typename Alloc = std::allocator<Real>>
typedef VectorType::difference_type OpenMD::DynamicVector< Real, Alloc >::difference_type

Definition at line 80 of file DynamicVector.hpp.

◆ iterator

template<typename Real, typename Alloc = std::allocator<Real>>
typedef VectorType::iterator OpenMD::DynamicVector< Real, Alloc >::iterator

Definition at line 75 of file DynamicVector.hpp.

◆ pointer

template<typename Real, typename Alloc = std::allocator<Real>>
typedef VectorType::pointer OpenMD::DynamicVector< Real, Alloc >::pointer

Definition at line 71 of file DynamicVector.hpp.

◆ reference

template<typename Real, typename Alloc = std::allocator<Real>>
typedef VectorType::reference OpenMD::DynamicVector< Real, Alloc >::reference

Definition at line 73 of file DynamicVector.hpp.

◆ reverse_iterator

template<typename Real, typename Alloc = std::allocator<Real>>
typedef VectorType::reverse_iterator OpenMD::DynamicVector< Real, Alloc >::reverse_iterator

Definition at line 78 of file DynamicVector.hpp.

◆ size_type

template<typename Real, typename Alloc = std::allocator<Real>>
typedef VectorType::size_type OpenMD::DynamicVector< Real, Alloc >::size_type

Definition at line 79 of file DynamicVector.hpp.

◆ value_type

template<typename Real, typename Alloc = std::allocator<Real>>
typedef Real OpenMD::DynamicVector< Real, Alloc >::value_type

Definition at line 69 of file DynamicVector.hpp.

◆ VectorType

template<typename Real, typename Alloc = std::allocator<Real>>
typedef std::vector<Real, Alloc> OpenMD::DynamicVector< Real, Alloc >::VectorType

Definition at line 70 of file DynamicVector.hpp.

Constructor & Destructor Documentation

◆ DynamicVector() [1/5]

template<typename Real, typename Alloc = std::allocator<Real>>
OpenMD::DynamicVector< Real, Alloc >::DynamicVector ( const allocator_type alloc = allocator_type())
inlineexplicit

Default constructor creates no elements.

Definition at line 89 of file DynamicVector.hpp.

◆ DynamicVector() [2/5]

template<typename Real, typename Alloc = std::allocator<Real>>
OpenMD::DynamicVector< Real, Alloc >::DynamicVector ( size_type  n,
const value_type value,
const allocator_type alloc = allocator_type() 
)
inline

Create a DynamicVector with copies of an exemplar element.

Parameters
nThe number of elements to initially create.
valueAn element to copy.
allocThe allocator_type to use

This constructor fills the DynamicVector with n copies of value.

Definition at line 100 of file DynamicVector.hpp.

◆ DynamicVector() [3/5]

template<typename Real, typename Alloc = std::allocator<Real>>
OpenMD::DynamicVector< Real, Alloc >::DynamicVector ( size_type  n)
inlineexplicit

Create a DynamicVector with default elements.

Parameters
nThe number of elements to initially create.

This constructor fills the DynamicVector with n copies of a default-constructed element.

Definition at line 112 of file DynamicVector.hpp.

◆ DynamicVector() [4/5]

template<typename Real, typename Alloc = std::allocator<Real>>
OpenMD::DynamicVector< Real, Alloc >::DynamicVector ( const DynamicVector< Real, Alloc > &  x)
inline

Vector copy constructor.

Parameters
xA DynamicVector of identical element and allocator types.

The newly-created DynamicVector uses a copy of the allocation object used by x. All the elements of x are copied, but any extra memory in x (for fast expansion) will not be copied.

Definition at line 123 of file DynamicVector.hpp.

◆ DynamicVector() [5/5]

template<typename Real, typename Alloc = std::allocator<Real>>
template<typename _InputIterator >
OpenMD::DynamicVector< Real, Alloc >::DynamicVector ( _InputIterator  first,
_InputIterator  last,
const allocator_type alloc = allocator_type() 
)
inline

Definition at line 127 of file DynamicVector.hpp.

Member Function Documentation

◆ add() [1/2]

template<typename Real, typename Alloc = std::allocator<Real>>
void OpenMD::DynamicVector< Real, Alloc >::add ( const DynamicVector< Real > &  v1)
inline

Sets the value of this vector to the sum of itself and v1 (*this += v1).

Parameters
v1the other vector

Definition at line 183 of file DynamicVector.hpp.

Referenced by OpenMD::operator+(), and OpenMD::DynamicVector< Real >::operator+=().

◆ add() [2/2]

template<typename Real, typename Alloc = std::allocator<Real>>
void OpenMD::DynamicVector< Real, Alloc >::add ( const DynamicVector< Real > &  v1,
const DynamicVector< Real > &  v2 
)
inline

Sets the value of this vector to the sum of v1 and v2 (*this = v1 + v2).

Parameters
v1the first vector
v2the second vector

Definition at line 192 of file DynamicVector.hpp.

◆ div() [1/2]

template<typename Real, typename Alloc = std::allocator<Real>>
void OpenMD::DynamicVector< Real, Alloc >::div ( Real  s)
inline

Sets the value of this vector to the scalar division of itself (*this /= s ).

Parameters
sthe scalar value

Definition at line 238 of file DynamicVector.hpp.

Referenced by OpenMD::operator/(), and OpenMD::DynamicVector< Real >::operator/=().

◆ div() [2/2]

template<typename Real, typename Alloc = std::allocator<Real>>
void OpenMD::DynamicVector< Real, Alloc >::div ( const DynamicVector< Real > &  v1,
Real  s 
)
inline

Sets the value of this vector to the scalar division of vector v1 (*this = v1 / s ).

Parameters
v1the source vector
sthe scalar value

Definition at line 248 of file DynamicVector.hpp.

◆ getSubVector()

template<typename Real, typename Alloc = std::allocator<Real>>
template<class VectorType >
void OpenMD::DynamicVector< Real, Alloc >::getSubVector ( unsigned int  beginning,
VectorType v 
)
inline

◆ isNormalized()

template<typename Real, typename Alloc = std::allocator<Real>>
bool OpenMD::DynamicVector< Real, Alloc >::isNormalized ( )
inline

Tests if this vector is normalized

Returns
true if this vector is normalized, otherwise return false

Definition at line 315 of file DynamicVector.hpp.

◆ length()

template<typename Real, typename Alloc = std::allocator<Real>>
Real OpenMD::DynamicVector< Real, Alloc >::length ( )
inline

Returns the length of this vector.

Returns
the length of this vector

Definition at line 287 of file DynamicVector.hpp.

Referenced by OpenMD::distance(), and OpenMD::DynamicVector< Real >::normalize().

◆ lengthSquare()

template<typename Real, typename Alloc = std::allocator<Real>>
Real OpenMD::DynamicVector< Real, Alloc >::lengthSquare ( )
inline

Returns the squared length of this vector.

Returns
the squared length of this vector

Definition at line 295 of file DynamicVector.hpp.

Referenced by QuantLib::Problem::computeGradientNormValue(), OpenMD::distanceSquare(), OpenMD::DynamicVector< Real >::isNormalized(), and OpenMD::DynamicVector< Real >::length().

◆ mul() [1/2]

template<typename Real, typename Alloc = std::allocator<Real>>
void OpenMD::DynamicVector< Real, Alloc >::mul ( Real  s)
inline

Sets the value of this vector to the scalar multiplication of itself (*this *= s).

Parameters
sthe scalar value

Definition at line 217 of file DynamicVector.hpp.

Referenced by OpenMD::operator*(), and OpenMD::DynamicVector< Real >::operator*=().

◆ mul() [2/2]

template<typename Real, typename Alloc = std::allocator<Real>>
void OpenMD::DynamicVector< Real, Alloc >::mul ( const DynamicVector< Real > &  v1,
Real  s 
)
inline

Sets the value of this vector to the scalar multiplication of vector v1 (*this = s * v1).

Parameters
v1the vector
sthe scalar value

Definition at line 228 of file DynamicVector.hpp.

◆ negate() [1/2]

template<typename Real, typename Alloc = std::allocator<Real>>
void OpenMD::DynamicVector< Real, Alloc >::negate ( )
inline

Negates the value of this vector in place.

Definition at line 164 of file DynamicVector.hpp.

Referenced by OpenMD::operator-().

◆ negate() [2/2]

template<typename Real, typename Alloc = std::allocator<Real>>
void OpenMD::DynamicVector< Real, Alloc >::negate ( const DynamicVector< Real > &  v1)
inline

Sets the value of this vector to the negation of vector v1.

Parameters
v1the source vector

Definition at line 173 of file DynamicVector.hpp.

◆ normalize()

template<typename Real, typename Alloc = std::allocator<Real>>
void OpenMD::DynamicVector< Real, Alloc >::normalize ( )
inline

Normalizes this vector in place

Definition at line 300 of file DynamicVector.hpp.

◆ operator!=()

template<typename Real, typename Alloc = std::allocator<Real>>
bool OpenMD::DynamicVector< Real, Alloc >::operator!= ( const DynamicVector< Real > &  v)
inline

Tests if this vetor is not equal to other vector

Returns
true if equal, otherwise return false
Parameters
vvector to be compared

Definition at line 159 of file DynamicVector.hpp.

◆ operator()() [1/2]

template<typename Real, typename Alloc = std::allocator<Real>>
Real OpenMD::DynamicVector< Real, Alloc >::operator() ( unsigned int  i) const
inline

Definition at line 131 of file DynamicVector.hpp.

◆ operator()() [2/2]

template<typename Real, typename Alloc = std::allocator<Real>>
Real& OpenMD::DynamicVector< Real, Alloc >::operator() ( unsigned int  i)
inline

Definition at line 135 of file DynamicVector.hpp.

◆ operator*=()

template<typename Real, typename Alloc = std::allocator<Real>>
DynamicVector<Real>& OpenMD::DynamicVector< Real, Alloc >::operator*= ( Real  s)
inline
See also
mul

Definition at line 266 of file DynamicVector.hpp.

◆ operator+=()

template<typename Real, typename Alloc = std::allocator<Real>>
DynamicVector<Real>& OpenMD::DynamicVector< Real, Alloc >::operator+= ( const DynamicVector< Real > &  v1)
inline
See also
add

Definition at line 254 of file DynamicVector.hpp.

◆ operator-=()

template<typename Real, typename Alloc = std::allocator<Real>>
DynamicVector<Real>& OpenMD::DynamicVector< Real, Alloc >::operator-= ( const DynamicVector< Real > &  v1)
inline
See also
sub

Definition at line 260 of file DynamicVector.hpp.

◆ operator/=()

template<typename Real, typename Alloc = std::allocator<Real>>
DynamicVector<Real>& OpenMD::DynamicVector< Real, Alloc >::operator/= ( Real  s)
inline
See also
div

Definition at line 272 of file DynamicVector.hpp.

◆ operator==()

template<typename Real, typename Alloc = std::allocator<Real>>
bool OpenMD::DynamicVector< Real, Alloc >::operator== ( const DynamicVector< Real > &  v)
inline

Tests if this vetor is equal to other vector

Returns
true if equal, otherwise return false
Parameters
vvector to be compared

Definition at line 143 of file DynamicVector.hpp.

◆ setZero()

template<typename Real, typename Alloc = std::allocator<Real>>
void OpenMD::DynamicVector< Real, Alloc >::setZero ( )
inline

zero out the vector

Definition at line 278 of file DynamicVector.hpp.

◆ sub() [1/2]

template<typename Real, typename Alloc = std::allocator<Real>>
void OpenMD::DynamicVector< Real, Alloc >::sub ( const DynamicVector< Real > &  v1)
inline

Sets the value of this vector to the difference of itself and v1 (*this -= v1).

Parameters
v1the other vector

Definition at line 200 of file DynamicVector.hpp.

Referenced by OpenMD::operator-(), and OpenMD::DynamicVector< Real >::operator-=().

◆ sub() [2/2]

template<typename Real, typename Alloc = std::allocator<Real>>
void OpenMD::DynamicVector< Real, Alloc >::sub ( const DynamicVector< Real > &  v1,
const DynamicVector< Real, Alloc > &  v2 
)
inline

Sets the value of this vector to the difference of vector v1 and v2 (*this = v1 - v2).

Parameters
v1the first vector
v2the second vector

Definition at line 209 of file DynamicVector.hpp.


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