OpenWalnut  1.4.0
Public Member Functions | Private Member Functions | Private Attributes | Friends
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 >:

List of all members.

Public Member Functions

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

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.

Private Attributes

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

Friends

class WValue
 All WValues are friends of each other.

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

template<typename T>
WValue< T >::WValue ( size_t  nbComponents) [inline, explicit]

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.

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.

template<typename T>
template<typename S >
WValue< T >::WValue ( const WValue< S > &  newValue) [inline, explicit]

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.

template<typename T>
WValue< T >::WValue ( const Eigen::VectorXd &  newValues) [inline, explicit]

Create a WValue from the given Eigen::VectorXd.

Parameters:
newValuesThe Eigen::VectorXd with the values..

Definition at line 86 of file WValue.h.

template<typename T>
WValue< T >::WValue ( const Eigen::VectorXf &  newValues) [inline, explicit]

Create a WValue from the given Eigen::VectorXf.

Parameters:
newValuesThe Eigen::VectorXf with the values..

Definition at line 96 of file WValue.h.

template<typename T>
WValue< T >::WValue ( const Eigen::VectorXi &  newValues) [inline, explicit]

Create a WValue from the given Eigen::VectorXi.

Parameters:
newValuesThe Eigen::VectorXi with the values..

Definition at line 106 of file WValue.h.


Member Function Documentation

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

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.

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

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.

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

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.

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.

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

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.

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

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.

Referenced by WValueTest::testNormalized().

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.

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

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.

Referenced by WMatrix< T >::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.

Reimplemented in WMatrix< T >.

Definition at line 272 of file WValue.h.

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.

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.

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.

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.

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.

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.

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.

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.

Referenced by WMatrix< T >::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.

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

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.

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.

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.

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

Friends And Related Function Documentation

template<typename T>
friend class WValue [friend]

All WValues are friends of each other.

Definition at line 42 of file WValue.h.


Member Data Documentation

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

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