Chi-Tech
chi_math::DynamicVector< NumberFormat > Class Template Reference

#include <dynamic_vector.h>

Public Member Functions

 DynamicVector ()
 
 DynamicVector (size_t N)
 
 DynamicVector (size_t N, NumberFormat value)
 
 DynamicVector (const DynamicVector &other)
 
DynamicVectoroperator= (const DynamicVector &other)
 
 DynamicVector (DynamicVector &&other) noexcept
 
DynamicVectoroperator= (DynamicVector &&other) noexcept
 
 DynamicVector (const std::vector< double > &in)
 
DynamicVectoroperator= (const std::vector< double > &in)
 
 DynamicVector (std::initializer_list< NumberFormat > in)
 
DynamicVectoroperator= (std::initializer_list< NumberFormat > in)
 
NumberFormat & operator[] (size_t i)
 
const NumberFormat & operator[] (size_t i) const
 
NumberFormat & at (size_t i)
 
NumberFormat & back ()
 
NumberFormat & front ()
 
NumberFormat * data ()
 
void clear ()
 
void resize (size_t dim)
 
void resize (size_t dim, const NumberFormat &val)
 
void reserve (size_t dim)
 
void push_back (const NumberFormat &val)
 
void pop_back ()
 
bool empty () const noexcept
 
std::vector< NumberFormat >::iterator begin ()
 
std::vector< NumberFormat >::iterator end ()
 
size_t size () const
 
void bounds_check (const size_t a, const size_t b) const
 
DynamicVector operator+ (const DynamicVector &rhs) const
 
DynamicVectoroperator+= (const DynamicVector &rhs)
 
DynamicVector operator- (const DynamicVector &rhs) const
 
DynamicVectoroperator-= (const DynamicVector &rhs)
 
DynamicVector operator* (const NumberFormat value) const
 
DynamicVectoroperator*= (const NumberFormat value)
 
DynamicVector operator* (const DynamicVector &rhs) const
 
DynamicVectoroperator*= (const DynamicVector &rhs)
 
DynamicVector operator/ (const NumberFormat value) const
 
DynamicVectoroperator/= (const NumberFormat value)
 
DynamicVector operator/ (const DynamicVector &rhs) const
 
DynamicVectoroperator/= (const DynamicVector &rhs)
 
NumberFormat Dot (const DynamicVector &rhs) const
 
NumberFormat Norm () const
 
NumberFormat NormSquare () const
 
void Normalize ()
 
DynamicVector Normalized () const
 
void Set (NumberFormat value)
 
std::string PrintStr () const
 

Data Fields

std::vector< NumberFormat > elements_
 

Detailed Description

template<class NumberFormat>
class chi_math::DynamicVector< NumberFormat >

General dynamic vector utility.

Definition at line 22 of file dynamic_vector.h.

Constructor & Destructor Documentation

◆ DynamicVector() [1/7]

template<class NumberFormat >
chi_math::DynamicVector< NumberFormat >::DynamicVector ( )
inline

Default constructor. Does nothing.

Definition at line 28 of file dynamic_vector.h.

◆ DynamicVector() [2/7]

template<class NumberFormat >
chi_math::DynamicVector< NumberFormat >::DynamicVector ( size_t  N)
inlineexplicit

Constructor with number of entries. Value defaults.

Definition at line 36 of file dynamic_vector.h.

◆ DynamicVector() [3/7]

template<class NumberFormat >
chi_math::DynamicVector< NumberFormat >::DynamicVector ( size_t  N,
NumberFormat  value 
)
inline

Constructor with number of entries and default value.

Definition at line 44 of file dynamic_vector.h.

◆ DynamicVector() [4/7]

template<class NumberFormat >
chi_math::DynamicVector< NumberFormat >::DynamicVector ( const DynamicVector< NumberFormat > &  other)
inline

Copy constructor.

Definition at line 52 of file dynamic_vector.h.

◆ DynamicVector() [5/7]

template<class NumberFormat >
chi_math::DynamicVector< NumberFormat >::DynamicVector ( DynamicVector< NumberFormat > &&  other)
inlinenoexcept

Move constructor.

Definition at line 62 of file dynamic_vector.h.

◆ DynamicVector() [6/7]

template<class NumberFormat >
chi_math::DynamicVector< NumberFormat >::DynamicVector ( const std::vector< double > &  in)
inlineexplicit

Constructor with vector.

Definition at line 75 of file dynamic_vector.h.

◆ DynamicVector() [7/7]

template<class NumberFormat >
chi_math::DynamicVector< NumberFormat >::DynamicVector ( std::initializer_list< NumberFormat >  in)
inline

Constructor with vector.

Definition at line 85 of file dynamic_vector.h.

Member Function Documentation

◆ at()

template<class NumberFormat >
NumberFormat & chi_math::DynamicVector< NumberFormat >::at ( size_t  i)
inline

Definition at line 98 of file dynamic_vector.h.

◆ back()

template<class NumberFormat >
NumberFormat & chi_math::DynamicVector< NumberFormat >::back ( )
inline

Definition at line 100 of file dynamic_vector.h.

◆ begin()

template<class NumberFormat >
std::vector< NumberFormat >::iterator chi_math::DynamicVector< NumberFormat >::begin ( )
inline

Definition at line 124 of file dynamic_vector.h.

◆ bounds_check()

template<class NumberFormat >
void chi_math::DynamicVector< NumberFormat >::bounds_check ( const size_t  a,
const size_t  b 
) const
inline

Definition at line 133 of file dynamic_vector.h.

◆ clear()

template<class NumberFormat >
void chi_math::DynamicVector< NumberFormat >::clear ( )
inline

Definition at line 106 of file dynamic_vector.h.

◆ data()

template<class NumberFormat >
NumberFormat * chi_math::DynamicVector< NumberFormat >::data ( )
inline

Definition at line 104 of file dynamic_vector.h.

◆ Dot()

template<class NumberFormat >
NumberFormat chi_math::DynamicVector< NumberFormat >::Dot ( const DynamicVector< NumberFormat > &  rhs) const
inline

Vector dot-product. $ \vec{w} = \vec{x} \bullet \vec{y} $

Definition at line 279 of file dynamic_vector.h.

◆ empty()

template<class NumberFormat >
bool chi_math::DynamicVector< NumberFormat >::empty ( ) const
inlinenoexcept

Definition at line 121 of file dynamic_vector.h.

◆ end()

template<class NumberFormat >
std::vector< NumberFormat >::iterator chi_math::DynamicVector< NumberFormat >::end ( )
inline

Definition at line 129 of file dynamic_vector.h.

◆ front()

template<class NumberFormat >
NumberFormat & chi_math::DynamicVector< NumberFormat >::front ( )
inline

Definition at line 102 of file dynamic_vector.h.

◆ Norm()

template<class NumberFormat >
NumberFormat chi_math::DynamicVector< NumberFormat >::Norm ( ) const
inline

Computes the L2-norm of the vector. Otherwise known as the length of a 3D vector.

Definition at line 291 of file dynamic_vector.h.

◆ Normalize()

template<class NumberFormat >
void chi_math::DynamicVector< NumberFormat >::Normalize ( )
inline

Normalizes the vector in-place.

Definition at line 314 of file dynamic_vector.h.

◆ Normalized()

template<class NumberFormat >
DynamicVector chi_math::DynamicVector< NumberFormat >::Normalized ( ) const
inline

Returns a normalized version of the vector.

Definition at line 322 of file dynamic_vector.h.

◆ NormSquare()

template<class NumberFormat >
NumberFormat chi_math::DynamicVector< NumberFormat >::NormSquare ( ) const
inline

Computes the square of the L2-norm of the vector. This eliminates the usage of the square root and is therefore less expensive that a proper L2-norm. Useful if only comparing distances.

Definition at line 304 of file dynamic_vector.h.

◆ operator*() [1/2]

template<class NumberFormat >
DynamicVector chi_math::DynamicVector< NumberFormat >::operator* ( const DynamicVector< NumberFormat > &  rhs) const
inline

Vector component-wise multiplication. $ w_i = x_i y_i $

Definition at line 210 of file dynamic_vector.h.

◆ operator*() [2/2]

template<class NumberFormat >
DynamicVector chi_math::DynamicVector< NumberFormat >::operator* ( const NumberFormat  value) const
inline

Vector component-wise multiplication by scalar. $ \vec{w} = \vec{x} \alpha $

Definition at line 189 of file dynamic_vector.h.

◆ operator*=() [1/2]

template<class NumberFormat >
DynamicVector & chi_math::DynamicVector< NumberFormat >::operator*= ( const DynamicVector< NumberFormat > &  rhs)
inline

Vector in-place component-wise multiplication. $ x_i = x_i y_i $

Definition at line 222 of file dynamic_vector.h.

◆ operator*=() [2/2]

template<class NumberFormat >
DynamicVector & chi_math::DynamicVector< NumberFormat >::operator*= ( const NumberFormat  value)
inline

Vector in-place component-wise multiplication by scalar. $ \vec{x} = \vec{x} \alpha $

Definition at line 200 of file dynamic_vector.h.

◆ operator+()

template<class NumberFormat >
DynamicVector chi_math::DynamicVector< NumberFormat >::operator+ ( const DynamicVector< NumberFormat > &  rhs) const
inline

Component-wise addition of two vectors. $ \vec{w} = \vec{x} + \vec{y} $

Definition at line 141 of file dynamic_vector.h.

◆ operator+=()

template<class NumberFormat >
DynamicVector & chi_math::DynamicVector< NumberFormat >::operator+= ( const DynamicVector< NumberFormat > &  rhs)
inline

In-place component-wise addition of two vectors. $ \vec{x} = \vec{x} + \vec{y} $

Definition at line 153 of file dynamic_vector.h.

◆ operator-()

template<class NumberFormat >
DynamicVector chi_math::DynamicVector< NumberFormat >::operator- ( const DynamicVector< NumberFormat > &  rhs) const
inline

Component-wise subtraction. $ \vec{w} = \vec{x} - \vec{y} $

Definition at line 165 of file dynamic_vector.h.

◆ operator-=()

template<class NumberFormat >
DynamicVector & chi_math::DynamicVector< NumberFormat >::operator-= ( const DynamicVector< NumberFormat > &  rhs)
inline

In-place component-wise subtraction. $ \vec{x} = \vec{x} - \vec{y} $

Definition at line 177 of file dynamic_vector.h.

◆ operator/() [1/2]

template<class NumberFormat >
DynamicVector chi_math::DynamicVector< NumberFormat >::operator/ ( const DynamicVector< NumberFormat > &  rhs) const
inline

Vector component-wise division. $ w_i = \frac{x_i}{y_i} $

Definition at line 255 of file dynamic_vector.h.

◆ operator/() [2/2]

template<class NumberFormat >
DynamicVector chi_math::DynamicVector< NumberFormat >::operator/ ( const NumberFormat  value) const
inline

Vector component-wise division by scalar. $ w_i = \frac{x_i}{\alpha} $

Definition at line 234 of file dynamic_vector.h.

◆ operator/=() [1/2]

template<class NumberFormat >
DynamicVector & chi_math::DynamicVector< NumberFormat >::operator/= ( const DynamicVector< NumberFormat > &  rhs)
inline

Vector in-place component-wise division. $ x_i = \frac{x_i}{y_i} $

Definition at line 267 of file dynamic_vector.h.

◆ operator/=() [2/2]

template<class NumberFormat >
DynamicVector & chi_math::DynamicVector< NumberFormat >::operator/= ( const NumberFormat  value)
inline

Vector in-place component-wise division by scalar. $ x_i = \frac{x_i}{\alpha} $

Definition at line 245 of file dynamic_vector.h.

◆ operator=() [1/4]

template<class NumberFormat >
DynamicVector & chi_math::DynamicVector< NumberFormat >::operator= ( const DynamicVector< NumberFormat > &  other)
inline

Assignment operator.

Definition at line 55 of file dynamic_vector.h.

◆ operator=() [2/4]

template<class NumberFormat >
DynamicVector & chi_math::DynamicVector< NumberFormat >::operator= ( const std::vector< double > &  in)
inline

Copy constructor with vector.

Definition at line 78 of file dynamic_vector.h.

◆ operator=() [3/4]

template<class NumberFormat >
DynamicVector & chi_math::DynamicVector< NumberFormat >::operator= ( DynamicVector< NumberFormat > &&  other)
inlinenoexcept

Move assignment operator.

Definition at line 68 of file dynamic_vector.h.

◆ operator=() [4/4]

template<class NumberFormat >
DynamicVector & chi_math::DynamicVector< NumberFormat >::operator= ( std::initializer_list< NumberFormat >  in)
inline

Copy constructor with vector.

Definition at line 88 of file dynamic_vector.h.

◆ operator[]() [1/2]

template<class NumberFormat >
NumberFormat & chi_math::DynamicVector< NumberFormat >::operator[] ( size_t  i)
inline

Definition at line 95 of file dynamic_vector.h.

◆ operator[]() [2/2]

template<class NumberFormat >
const NumberFormat & chi_math::DynamicVector< NumberFormat >::operator[] ( size_t  i) const
inline

Definition at line 96 of file dynamic_vector.h.

◆ pop_back()

template<class NumberFormat >
void chi_math::DynamicVector< NumberFormat >::pop_back ( )
inline

Definition at line 119 of file dynamic_vector.h.

◆ PrintStr()

template<class NumberFormat >
std::string chi_math::DynamicVector< NumberFormat >::PrintStr ( ) const
inline

Prints the vector to a string and then returns the string.

Definition at line 340 of file dynamic_vector.h.

◆ push_back()

template<class NumberFormat >
void chi_math::DynamicVector< NumberFormat >::push_back ( const NumberFormat &  val)
inline

Definition at line 118 of file dynamic_vector.h.

◆ reserve()

template<class NumberFormat >
void chi_math::DynamicVector< NumberFormat >::reserve ( size_t  dim)
inline

Definition at line 116 of file dynamic_vector.h.

◆ resize() [1/2]

template<class NumberFormat >
void chi_math::DynamicVector< NumberFormat >::resize ( size_t  dim)
inline

Definition at line 108 of file dynamic_vector.h.

◆ resize() [2/2]

template<class NumberFormat >
void chi_math::DynamicVector< NumberFormat >::resize ( size_t  dim,
const NumberFormat &  val 
)
inline

Definition at line 109 of file dynamic_vector.h.

◆ Set()

template<class NumberFormat >
void chi_math::DynamicVector< NumberFormat >::Set ( NumberFormat  value)
inline

Sets all the elements of the vector to the specified value.

Definition at line 333 of file dynamic_vector.h.

◆ size()

template<class NumberFormat >
size_t chi_math::DynamicVector< NumberFormat >::size ( ) const
inline

Definition at line 131 of file dynamic_vector.h.

Field Documentation

◆ elements_

template<class NumberFormat >
std::vector<NumberFormat> chi_math::DynamicVector< NumberFormat >::elements_

Definition at line 25 of file dynamic_vector.h.


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