OpenWalnut  1.2.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public 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 >:

Public Member Functions

 WMatrix (size_t n)
 Produces a square matrix with the given number of components.
 WMatrix (size_t nbRows, size_t nbCols)
 Produces a matrix with the given number of components.
 WMatrix (const WMatrix &newMatrix)
 Produces a matrix as copy of the one given as parameter.
 WMatrix (const WMatrix4d &newMatrix)
 Copies the specified 4x4 matrix.
 WMatrix (const Eigen::MatrixXd &newMatrix)
 Copies the specified Eigen::MatrixXd.
WMatrixmakeIdentity ()
 Makes the matrix contain the identity matrix, i.e.
size_t getNbRows () const
 Get number of rows.
size_t getNbCols () const
 Get number of columns.
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.
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.
 operator WMatrix4d () const
 Cast this matrix to an 4x matrix if it is a 4x4 matrix.
 operator osg::Matrixd () const
 Cast this matrix to an 4x4 osg matrix if it is a 4x4 matrix.
 operator Eigen::MatrixXd () const
 Cast this matrix to an Eigen::MatrixXd matrix.
bool operator== (const WMatrix &rhs) const
 Compares two matrices and returns true if they are equal.
bool operator!= (const WMatrix &rhs) const
 Compares two matrices and returns true if they are not equal.
WMatrixoperator= (const WMatrix &rhs)
 Assigns the argument WMatrix to this WMatrix.
WMatrix operator* (const WMatrix &rhs) const
 Multiplication of the current matrix with andother matrix.
WValue< T > operator* (const WValue< T > &rhs) const
 Multiplication with a vector.
WVector3d operator* (const WVector3d &rhs) const
 Multiplication with a vector.
WMatrix transposed () const
 Returns the transposed matrix.
void setZero ()
 Resets the matrix components to zero.
- Public Member Functions inherited from WValue< T >
 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.
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

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

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 42 of file WMatrix.h.

Constructor & Destructor Documentation

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 203 of file WMatrix.h.

References WMatrix< T >::m_nbCols.

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 209 of file WMatrix.h.

References WMatrix< T >::m_nbCols.

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 219 of file WMatrix.h.

References WMatrix< T >::m_nbCols.

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

Copies the specified 4x4 matrix.

Parameters
newMatrixthe matrix to copy

Definition at line 225 of file WMatrix.h.

References WMatrix< T >::m_nbCols.

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 238 of file WMatrix.h.

References WMatrix< T >::m_nbCols.

Member Function Documentation

template<typename T >
size_t WMatrix< T >::getNbCols ( ) const
template<typename T >
size_t WMatrix< T >::getNbRows ( ) const
template<typename T >
WMatrix< T > & WMatrix< T >::makeIdentity ( )
template<typename T >
WMatrix< T >::operator Eigen::MatrixXd ( ) const

Cast this matrix to an Eigen::MatrixXd matrix.

Returns
casted matrix.

Definition at line 291 of file WMatrix.h.

template<typename T >
WMatrix< T >::operator osg::Matrixd ( ) const

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

Returns
casted matrix.

Definition at line 267 of file WMatrix.h.

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

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

Returns
casted matrix

Definition at line 252 of file WMatrix.h.

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?
Parameters
rhsThe right hand side of the comparison

Definition at line 380 of file WMatrix.h.

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

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)
Parameters
irow
jcolumn

Definition at line 349 of file WMatrix.h.

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)
Parameters
irow
jcolumn

Definition at line 361 of file WMatrix.h.

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 409 of file WMatrix.h.

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

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.

Reimplemented from WValue< T >.

Definition at line 427 of file WMatrix.h.

References WValue< T >::size().

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 442 of file WMatrix.h.

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

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).
Parameters
rhsThe right hand side of the assignment

Definition at line 389 of file WMatrix.h.

References WMatrix< T >::m_nbCols, and WValue< T >::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?
Parameters
rhsThe right hand side of the comparison

Definition at line 371 of file WMatrix.h.

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

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

Resets the matrix components to zero.

Definition at line 190 of file WMatrix.h.

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

template<typename T >
WMatrix< T > WMatrix< T >::transposed ( ) const

Returns the transposed matrix.

Returns
Transposed version of the current matrix.

Definition at line 399 of file WMatrix.h.

Referenced by WSymmetricSphericalHarmonic::getSHFittingMatrix(), WOSSIMHelperTest::testComputeSVD(), and WMatrixTest::testTransposed().

Member Data Documentation

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 200 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 file: