OpenWalnut  1.5.0dev
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
WValue< T > Class Template Reference

Base class for all higher level values like tensors, vectors, matrices and so on. More...

#include <WValue.h>

+ Inheritance diagram for WValue< T >:
+ Collaboration diagram for WValue< T >:

Public Member Functions

 WValue (size_t nbComponents)
 Create a WValue with the given number of components. More...
 
 WValue (const WValue &newValue)
 Create a WValue as copy of the one given as parameter. More...
 
template<typename S >
 WValue (const WValue< S > &newValue)
 Create a WValue as copy of the one given as parameter but with another template type. More...
 
 WValue (const Eigen::VectorXd &newValues)
 Create a WValue from the given Eigen::VectorXd. More...
 
 WValue (const Eigen::VectorXf &newValues)
 Create a WValue from the given Eigen::VectorXf. More...
 
 WValue (const Eigen::VectorXi &newValues)
 Create a WValue from the given Eigen::VectorXi. More...
 
size_t size () const
 Get number of components the value consists of. More...
 
T & operator[] (size_t i)
 Returns a reference to the i-th component in order to provide access to the component. More...
 
const T & operator[] (size_t i) const
 Returns a CONST reference to the i-th component in order to provide read-only access to the component. More...
 
bool operator== (const WValue &rhs) const
 Compares two WValues and returns true if they contain the same data. More...
 
bool operator!= (const WValue &rhs) const
 Compares two WValues and returns true if they contain the different data. More...
 
WValueoperator= (const WValue &rhs)
 Assigns the contents of its argument to the contents of this WValue. More...
 
WValueoperator+= (const WValue &rhs)
 Adds a the argument component-wise to the components of this WValue. More...
 
WValueoperator-= (const WValue &rhs)
 Subtracts the argument component-wise from the components of this WValue. More...
 
WValueoperator*= (double rhs)
 Scales each component of this WValue with the given scalar argument. More...
 
WValueoperator*= (const WValue &rhs)
 Scales each component of this WValue with the corresponding component of the given argument WValue. More...
 
WValueoperator/= (const double rhs)
 Scales each component of this WValue with the given scalar argument. More...
 
const WValue operator+ (const WValue &summand2) const
 Component-wise addition. More...
 
const WValue operator- (const WValue &subtrahend) const
 Component-wise subtraction. More...
 
const WValue operator* (const WValue &factor2) const
 Component-wise multiplication. More...
 
double norm () const
 Square root of sum of squares of elements. More...
 
double normSquare () const
 Sum of squares of elements. More...
 
void normalize ()
 Make the norm of this WValue be 1 by dividing by WValue::norm() More...
 
WValue normalized () const
 Return a normalized version of the current WValue without modifying it. More...
 
mean () const
 Returns the mean value of all values stored in this WValue. More...
 
median () const
 Returns the median of all values stored in this WValue. More...
 
void resize (size_t size)
 Changes the number of scalars held by this WValue. More...
 

Private Member Functions

template<typename EigenDataType >
void copyFromEigenVector (const Eigen::Matrix< EigenDataType, Eigen::Dynamic, 1 > &newValues)
 This function is used by the constructors that have the different Eigen::MatrixX types as parameter. More...
 

Private Attributes

std::vector< T > m_components
 The components the value is composed of. More...
 

Friends

template<typename S >
class WValue
 All WValues are friends of each other. More...
 

Detailed Description

template<typename T>
class WValue< T >

Base class for all higher level values like tensors, vectors, matrices and so on.

Definition at line 40 of file WValue.h.

Constructor & Destructor Documentation

◆ WValue() [1/6]

template<typename T >
WValue< T >::WValue ( size_t  nbComponents)
inlineexplicit

Create a WValue with the given number of components.

The components will be set to zero if T is a type representing numbers.

Parameters
nbComponentsNumber of elements the WValue consists of.

Definition at line 55 of file WValue.h.

◆ WValue() [2/6]

template<typename T >
WValue< T >::WValue ( const WValue< T > &  newValue)
inline

Create a WValue as copy of the one given as parameter.

Parameters
newValueThe WValue to be copied.

Definition at line 64 of file WValue.h.

◆ WValue() [3/6]

template<typename T >
template<typename S >
WValue< T >::WValue ( const WValue< S > &  newValue)
inlineexplicit

Create a WValue as copy of the one given as parameter but with another template type.

Parameters
newValueThe WValue to be copied.

Definition at line 73 of file WValue.h.

References WValue< T >::m_components.

◆ WValue() [4/6]

template<typename T >
WValue< T >::WValue ( const Eigen::VectorXd &  newValues)
inlineexplicit

Create a WValue from the given Eigen::VectorXd.

Parameters
newValuesThe Eigen::VectorXd with the values.

Definition at line 86 of file WValue.h.

References WValue< T >::copyFromEigenVector().

+ Here is the call graph for this function:

◆ WValue() [5/6]

template<typename T >
WValue< T >::WValue ( const Eigen::VectorXf &  newValues)
inlineexplicit

Create a WValue from the given Eigen::VectorXf.

Parameters
newValuesThe Eigen::VectorXf with the values.

Definition at line 96 of file WValue.h.

References WValue< T >::copyFromEigenVector().

+ Here is the call graph for this function:

◆ WValue() [6/6]

template<typename T >
WValue< T >::WValue ( const Eigen::VectorXi &  newValues)
inlineexplicit

Create a WValue from the given Eigen::VectorXi.

Parameters
newValuesThe Eigen::VectorXi with the values.

Definition at line 106 of file WValue.h.

References WValue< T >::copyFromEigenVector().

+ Here is the call graph for this function:

Member Function Documentation

◆ copyFromEigenVector()

template<typename T >
template<typename EigenDataType >
void WValue< T >::copyFromEigenVector ( const Eigen::Matrix< EigenDataType, Eigen::Dynamic, 1 > &  newValues)
inlineprivate

This function is used by the constructors that have the different Eigen::MatrixX types as parameter.

Template Parameters
EigenDataTypeThe data type which is used by the Eigen::VectorX.
Parameters
newValuesThe source Eigen::VectorX.

Definition at line 382 of file WValue.h.

References WValue< T >::m_components.

Referenced by WValue< T >::WValue().

+ Here is the caller graph for this function:

◆ mean()

template<typename T >
T WValue< T >::mean ( ) const
inline

Returns the mean value of all values stored in this WValue.

Returns
Mean of the WValues components.

Definition at line 342 of file WValue.h.

References WValue< T >::m_components.

Referenced by WValueTest::testMean(), and WValueTest::testMedian().

+ Here is the caller graph for this function:

◆ median()

template<typename T >
T WValue< T >::median ( ) const
inline

Returns the median of all values stored in this WValue.

Returns
Median of the WValues components.

Definition at line 357 of file WValue.h.

References WValue< T >::m_components.

◆ norm()

template<typename T >
double WValue< T >::norm ( ) const
inline

Square root of sum of squares of elements.

This function returns double instead of T because norm includes a square root and thus its computation automatically results in a floating point number.

Returns
Double-precision norm of the WValue.

Definition at line 288 of file WValue.h.

References WValue< T >::normSquare().

Referenced by WValue< T >::normalize(), WValueTest::testNormalize(), WValueTest::testNormalized(), WValueTest::testNormDouble(), and WValueTest::testNormInt().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ normalize()

template<typename T >
void WValue< T >::normalize ( )
inline

Make the norm of this WValue be 1 by dividing by WValue::norm()

Definition at line 317 of file WValue.h.

References WValue< T >::m_components, and WValue< T >::norm().

Referenced by WValue< T >::normalized(), and WValueTest::testNormalize().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ normalized()

template<typename T >
WValue WValue< T >::normalized ( ) const
inline

Return a normalized version of the current WValue without modifying it.

Returns
Normalized version of the current WValue object.

Definition at line 331 of file WValue.h.

References WValue< T >::normalize().

Referenced by WValueTest::testNormalized().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ normSquare()

template<typename T >
double WValue< T >::normSquare ( ) const
inline

Sum of squares of elements.

This function returns double instead of T because normSquare includes many squares and thus might return large values that might not fit into T's range of values. Double prevents an overflow. Additionally this is consistent with norm().

Returns
Double-precision squared norm of the WValue.

Definition at line 302 of file WValue.h.

References WValue< T >::m_components.

Referenced by WValue< T >::norm(), and WValueTest::testNormSquare().

+ Here is the caller graph for this function:

◆ operator!=()

template<typename T >
bool WValue< T >::operator!= ( const WValue< T > &  rhs) const
inline

Compares two WValues and returns true if they contain the different data.

Parameters
rhsThe right hand side of the comparison
Returns
The answer to whether both WValues do NOT contain the same data.

Definition at line 160 of file WValue.h.

References WValue< T >::m_components.

Referenced by WMatrix< T >::operator!=().

+ Here is the caller graph for this function:

◆ operator*()

template<typename T >
const WValue WValue< T >::operator* ( const WValue< T > &  factor2) const
inline

Component-wise multiplication.

Parameters
factor2The right hand side of the product
Returns
The vector of the product of the components.

Definition at line 272 of file WValue.h.

References WValue< T >::m_components.

◆ operator*=() [1/2]

template<typename T >
WValue& WValue< T >::operator*= ( const WValue< T > &  rhs)
inline

Scales each component of this WValue with the corresponding component of the given argument WValue.

Parameters
rhsThe right hand side of the assignment
Returns
A reference to the left hand side of the assignment (i.e. the current (scaled) object).

Definition at line 220 of file WValue.h.

References WValue< T >::m_components.

◆ operator*=() [2/2]

template<typename T >
WValue& WValue< T >::operator*= ( double  rhs)
inline

Scales each component of this WValue with the given scalar argument.

Parameters
rhsThe right hand side of the assignment
Returns
A reference to the left hand side of the assignment (i.e. the (scaled) current object).

Definition at line 207 of file WValue.h.

References WValue< T >::m_components.

◆ operator+()

template<typename T >
const WValue WValue< T >::operator+ ( const WValue< T > &  summand2) const
inline

Component-wise addition.

Parameters
summand2The right hand side of the summation
Returns
The sum of the WValues.

Definition at line 246 of file WValue.h.

References WValue< T >::m_components.

◆ operator+=()

template<typename T >
WValue& WValue< T >::operator+= ( const WValue< T > &  rhs)
inline

Adds a the argument component-wise to the components of this WValue.

Parameters
rhsThe right hand side of the assignment
Returns
A reference to the left hand side of the assignment (i.e. the current object).

Definition at line 181 of file WValue.h.

References WValue< T >::m_components.

◆ operator-()

template<typename T >
const WValue WValue< T >::operator- ( const WValue< T > &  subtrahend) const
inline

Component-wise subtraction.

Parameters
subtrahendThe right hand side of the subtraction
Returns
The difference of the WValues.

Definition at line 259 of file WValue.h.

References WValue< T >::m_components.

◆ operator-=()

template<typename T >
WValue& WValue< T >::operator-= ( const WValue< T > &  rhs)
inline

Subtracts the argument component-wise from the components of this WValue.

Parameters
rhsThe right hand side of the assignment
Returns
A reference to the left hand side of the assignment (i.e. the current object).

Definition at line 194 of file WValue.h.

References WValue< T >::m_components.

◆ operator/=()

template<typename T >
WValue& WValue< T >::operator/= ( const double  rhs)
inline

Scales each component of this WValue with the given scalar argument.

Parameters
rhsThe right hand side of the assignment
Returns
A reference to the left hand side of the assignment (i.e. the current (scaled) object).

Definition at line 233 of file WValue.h.

References WValue< T >::m_components.

◆ operator=()

template<typename T >
WValue& WValue< T >::operator= ( const WValue< T > &  rhs)
inline

Assigns the contents of its argument to the contents of this WValue.

Parameters
rhsThe right hand side of the assignment
Returns
A reference to the left hand side of the assignment (i.e. the current object).

Definition at line 170 of file WValue.h.

References WValue< T >::m_components.

Referenced by WMatrix< T >::operator=().

+ Here is the caller graph for this function:

◆ operator==()

template<typename T >
bool WValue< T >::operator== ( const WValue< T > &  rhs) const
inline

Compares two WValues and returns true if they contain the same data.

Parameters
rhsThe right hand side of the comparison
Returns
The answer to whether both WValues contain the same data.

Definition at line 150 of file WValue.h.

References WValue< T >::m_components.

Referenced by WMatrix< T >::operator==().

+ Here is the caller graph for this function:

◆ operator[]() [1/2]

template<typename T >
T& WValue< T >::operator[] ( size_t  i)
inline

Returns a reference to the i-th component in order to provide access to the component.

Parameters
ielement id
Returns
A reference to the desired component.

Definition at line 127 of file WValue.h.

References WValue< T >::m_components.

◆ operator[]() [2/2]

template<typename T >
const T& WValue< T >::operator[] ( size_t  i) const
inline

Returns a CONST reference to the i-th component in order to provide read-only access to the component.

Parameters
ielement id
Returns
A CONST reference to the desired component

Definition at line 139 of file WValue.h.

References WValue< T >::m_components.

◆ resize()

template<typename T >
void WValue< T >::resize ( size_t  size)
inline

Changes the number of scalars held by this WValue.

Parameters
sizeThe number of scalars stored in the WValue.

Definition at line 369 of file WValue.h.

References WValue< T >::m_components, and WValue< T >::size().

+ Here is the call graph for this function:

◆ size()

template<typename T >
size_t WValue< T >::size ( ) const
inline

Friends And Related Function Documentation

◆ WValue

template<typename T >
template<typename S >
friend class WValue
friend

All WValues are friends of each other.

Definition at line 42 of file WValue.h.

Member Data Documentation

◆ m_components

template<typename T >
std::vector< T > WValue< T >::m_components
private

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