OpenWalnut 1.2.5
Public 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 WVector_2 &newValues)
 Create a WValue from the given WVector_2.
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.
WVector_2 toWVector ()
 Returns this WValue as WVector_2.

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 39 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 54 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 63 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 72 of file WValue.h.

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

Create a WValue from the given WVector_2.

Parameters:
newValuesThe WVector_2 with the values..

Definition at line 85 of file WValue.h.


Member Function Documentation

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 324 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 339 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 270 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 299 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 313 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 284 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 142 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 254 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 189 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 202 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 228 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 163 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 241 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 176 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 215 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 152 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 132 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 109 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 121 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 351 of file WValue.h.

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

Returns this WValue as WVector_2.

Returns:
The WValue as WVector_2.

Definition at line 360 of file WValue.h.


Friends And Related Function Documentation

template<typename T>
friend class WValue [friend]

All WValues are friends of each other.

Definition at line 41 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:
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends