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

Matrix template class with variable number of rows and columns. More...

#include <WMatrix.h>

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

Public Member Functions

 WMatrix (size_t n)
 Produces a square matrix with the given number of components. More...
 
 WMatrix (size_t nbRows, size_t nbCols)
 Produces a matrix with the given number of components. More...
 
 WMatrix (const WMatrix &newMatrix)
 Produces a matrix as copy of the one given as parameter. More...
 
 WMatrix (const WMatrix4d &newMatrix)
 Copies the specified 4x4 matrix. More...
 
 WMatrix (const Eigen::MatrixXd &newMatrix)
 Copies the specified Eigen::MatrixXd. More...
 
 WMatrix (const Eigen::MatrixXf &newMatrix)
 Copies the specified Eigen::MatrixXf. More...
 
 WMatrix (const Eigen::MatrixXi &newMatrix)
 Copies the specified Eigen::MatrixXi. More...
 
WMatrixmakeIdentity ()
 Makes the matrix contain the identity matrix, i.e. More...
 
size_t getNbRows () const
 Get number of rows. More...
 
size_t getNbCols () const
 Get number of columns. More...
 
T & operator() (size_t i, size_t j)
 Returns a reference to the component an row i, columns j in order to provide access to the component. More...
 
const T & operator() (size_t i, size_t j) const
 Returns a const reference to the component an row i, columns j in order to provide read-only access to the component. More...
 
 operator WMatrix4d () const
 Cast this matrix to an 4x matrix if it is a 4x4 matrix. More...
 
 operator osg::Matrixd () const
 Cast this matrix to an 4x4 osg matrix if it is a 4x4 matrix. More...
 
template<typename EigenDataType >
 operator Eigen::Matrix< EigenDataType, Eigen::Dynamic, Eigen::Dynamic > () const
 Cast this matrix to an Eigen::Matrix< EigenDataType, Eigen::Dynamic, Eigen::Dynamic >() matrix. More...
 
bool operator== (const WMatrix &rhs) const
 Compares two matrices and returns true if they are equal. More...
 
bool operator!= (const WMatrix &rhs) const
 Compares two matrices and returns true if they are not equal. More...
 
WMatrixoperator= (const WMatrix &rhs)
 Assigns the argument WMatrix to this WMatrix. More...
 
WMatrix operator* (const WMatrix &rhs) const
 Multiplication of the current matrix with andother matrix. More...
 
WValue< T > operator* (const WValue< T > &rhs) const
 Multiplication with a vector. More...
 
WVector3d operator* (const WVector3d &rhs) const
 Multiplication with a vector. More...
 
WMatrix transposed () const
 Returns the transposed matrix. More...
 
void setZero ()
 Resets the matrix components to zero. More...
 
bool isSquare () const
 Returns true if the matrix is a square matrix. More...
 
bool isIdentity (T delta=T(0.0)) const
 Returns true if the matrix is a identity matrix. More...
 
- Public Member Functions inherited from WValue< T >
 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 copyFromEigenMatrix (const Eigen::Matrix< EigenDataType, Eigen::Dynamic, Eigen::Dynamic > &newMatrix)
 This function is used by the constructors that have the different Eigen::MatrixX types as parameter. More...
 

Private Attributes

size_t m_nbCols
 Number of columns of the matrix. The number of rows will be computed by (size/m_nbCols). More...
 

Detailed Description

template<typename T>
class WMatrix< T >

Matrix template class with variable number of rows and columns.

The access function are row-major, which means that the rows are the first parameter or index.

Definition at line 43 of file WMatrix.h.

Constructor & Destructor Documentation

◆ WMatrix() [1/7]

template<typename T >
WMatrix< T >::WMatrix ( size_t  n)
explicit

Produces a square matrix with the given number of components.

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

Parameters
nNumber of cols and rows in the matrix

Definition at line 242 of file WMatrix.h.

References WMatrix< T >::m_nbCols.

◆ WMatrix() [2/7]

template<typename T >
WMatrix< T >::WMatrix ( size_t  nbRows,
size_t  nbCols 
)

Produces a matrix with the given number of components.

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

Parameters
nbRowsnumber of rows in the matrix
nbColsnumber of columns in the matrix

Definition at line 248 of file WMatrix.h.

References WMatrix< T >::m_nbCols.

◆ WMatrix() [3/7]

template<typename T >
WMatrix< T >::WMatrix ( const WMatrix< T > &  newMatrix)

Produces a matrix as copy of the one given as parameter.

Parameters
newMatrixThe matrix to be copied.

Definition at line 258 of file WMatrix.h.

References WMatrix< T >::m_nbCols.

◆ WMatrix() [4/7]

template<typename T >
WMatrix< T >::WMatrix ( const WMatrix4d newMatrix)

Copies the specified 4x4 matrix.

Parameters
newMatrixthe matrix to copy

Definition at line 264 of file WMatrix.h.

References WMatrix< T >::m_nbCols.

◆ WMatrix() [5/7]

template<typename T >
WMatrix< T >::WMatrix ( const Eigen::MatrixXd &  newMatrix)

Copies the specified Eigen::MatrixXd.

Parameters
newMatrixthe Eigen::MatrixXd matrix to copy

Definition at line 277 of file WMatrix.h.

◆ WMatrix() [6/7]

template<typename T >
WMatrix< T >::WMatrix ( const Eigen::MatrixXf &  newMatrix)

Copies the specified Eigen::MatrixXf.

Parameters
newMatrixthe Eigen::MatrixXf matrix to copy

Definition at line 283 of file WMatrix.h.

◆ WMatrix() [7/7]

template<typename T >
WMatrix< T >::WMatrix ( const Eigen::MatrixXi &  newMatrix)

Copies the specified Eigen::MatrixXi.

Parameters
newMatrixthe Eigen::MatrixXi matrix to copy

Definition at line 289 of file WMatrix.h.

Member Function Documentation

◆ copyFromEigenMatrix()

template<typename T >
template<typename EigenDataType >
void WMatrix< T >::copyFromEigenMatrix ( const Eigen::Matrix< EigenDataType, Eigen::Dynamic, Eigen::Dynamic > &  newMatrix)
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 matrix.
Parameters
newMatrixThe source matrix.

Definition at line 534 of file WMatrix.h.

◆ getNbCols()

template<typename T >
size_t WMatrix< T >::getNbCols

◆ getNbRows()

template<typename T >
size_t WMatrix< T >::getNbRows

◆ isIdentity()

template<typename T >
bool WMatrix< T >::isIdentity ( delta = T( 0.0 )) const

Returns true if the matrix is a identity matrix.

Parameters
delta- tolerance parameter when checking the values.
Returns
true for identity matrixes, otherwise false.

Definition at line 510 of file WMatrix.h.

Referenced by WMatrixTest::testIsIdentity().

+ Here is the caller graph for this function:

◆ isSquare()

template<typename T >
bool WMatrix< T >::isSquare

Returns true if the matrix is a square matrix.

Returns
true for square matrixes, otherwise false.

Definition at line 505 of file WMatrix.h.

◆ makeIdentity()

template<typename T >
WMatrix< T > & WMatrix< T >::makeIdentity

◆ operator Eigen::Matrix< EigenDataType, Eigen::Dynamic, Eigen::Dynamic >()

template<typename T >
template<typename EigenDataType >
WMatrix< T >::operator Eigen::Matrix< EigenDataType, Eigen::Dynamic, Eigen::Dynamic >

Cast this matrix to an Eigen::Matrix< EigenDataType, Eigen::Dynamic, Eigen::Dynamic >() matrix.

Template Parameters
EigenDataTypeData type of Eigen matrix.
Returns
casted matrix.

Definition at line 335 of file WMatrix.h.

◆ operator osg::Matrixd()

template<typename T >
WMatrix< T >::operator osg::Matrixd

Cast this matrix to an 4x4 osg matrix if it is a 4x4 matrix.

Returns
casted matrix.

Definition at line 310 of file WMatrix.h.

◆ operator WMatrix4d()

template<typename T >
WMatrix< T >::operator WMatrix4d

Cast this matrix to an 4x matrix if it is a 4x4 matrix.

Returns
casted matrix

Definition at line 295 of file WMatrix.h.

◆ operator!=()

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

Compares two matrices and returns true if they are not equal.

Parameters
rhsThe right hand side of the comparison
Returns
Are the matrices NOT equal?

For parameter documentations see overloaded function.

Definition at line 427 of file WMatrix.h.

References WMatrix< T >::m_nbCols, and WValue< T >::operator!=().

+ Here is the call graph for this function:

◆ operator()() [1/2]

template<typename T >
T & WMatrix< T >::operator() ( size_t  i,
size_t  j 
)

Returns a reference to the component an row i, columns j in order to provide access to the component.

Parameters
irow
jcolumn
Returns
A reference to the component (i,j)

For parameter documentations see overloaded function.

Definition at line 394 of file WMatrix.h.

◆ operator()() [2/2]

template<typename T >
const T & WMatrix< T >::operator() ( size_t  i,
size_t  j 
) const

Returns a const reference to the component an row i, columns j in order to provide read-only access to the component.

Parameters
irow
jcolumn *
Returns
A const reference to the component (i,j)

For parameter documentations see overloaded function.

Definition at line 406 of file WMatrix.h.

◆ operator*() [1/3]

template<typename T >
WMatrix< T > WMatrix< T >::operator* ( const WMatrix< T > &  rhs) const

Multiplication of the current matrix with andother matrix.

Parameters
rhsThe right hand side of the multiplication
Returns
The product of the two matrices.

Definition at line 457 of file WMatrix.h.

References WMatrix< T >::getNbCols(), and WMatrix< T >::getNbRows().

+ Here is the call graph for this function:

◆ operator*() [2/3]

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

Multiplication with a vector.

Parameters
rhsThe right hand side of the multiplication
Returns
The product of the matrix and the vector.

Definition at line 475 of file WMatrix.h.

References WValue< T >::size().

+ Here is the call graph for this function:

◆ operator*() [3/3]

template<typename T >
WVector3d WMatrix< T >::operator* ( const WVector3d rhs) const

Multiplication with a vector.

Parameters
rhsThe right hand side of the multiplication
Returns
The product of the matrix and the 3D vector.

Definition at line 490 of file WMatrix.h.

References WMatrixFixed< ValueT, Rows, Cols, ValueStoreT >::getRows().

+ Here is the call graph for this function:

◆ operator=()

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

Assigns the argument WMatrix to this WMatrix.

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

For parameter documentations see overloaded function.

Definition at line 437 of file WMatrix.h.

References WMatrix< T >::m_nbCols, and WValue< T >::operator=().

+ Here is the call graph for this function:

◆ operator==()

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

Compares two matrices and returns true if they are equal.

Parameters
rhsThe right hand side of the comparison
Returns
Are the matrices equal?

For parameter documentations see overloaded function.

Definition at line 417 of file WMatrix.h.

References WMatrix< T >::m_nbCols, and WValue< T >::operator==().

+ Here is the call graph for this function:

◆ setZero()

template<typename T >
void WMatrix< T >::setZero ( )
inline

Resets the matrix components to zero.

Definition at line 208 of file WMatrix.h.

References WValue< T >::size().

Referenced by WSymmetricSphericalHarmonicTest::testCalcFRTMatrix(), WSymmetricSphericalHarmonicTest::testCalcSmoothingMatrix(), and WLinearAlgebraFunctionsTest::testComputeSVD().

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

◆ transposed()

template<typename T >
WMatrix< T > WMatrix< T >::transposed

Returns the transposed matrix.

Returns
Transposed version of the current matrix.

Definition at line 447 of file WMatrix.h.

Referenced by WSymmetricSphericalHarmonic< T >::getSHFittingMatrix(), WSymmetricSphericalHarmonic< T >::getSHFittingMatrixForConstantSolidAngle(), WLinearAlgebraFunctionsTest::testComputeSVD(), WOSSIMHelperTest::testComputeSVD(), and WMatrixTest::testTransposed().

+ Here is the caller graph for this function:

Member Data Documentation

◆ m_nbCols

template<typename T >
size_t WMatrix< T >::m_nbCols
private

Number of columns of the matrix. The number of rows will be computed by (size/m_nbCols).

Definition at line 239 of file WMatrix.h.

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


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