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

Symmetric square matrix, storing only the elements of the triangular matrix without the main diagonal. More...

#include <WMatrixSym.h>

+ Collaboration diagram for WMatrixSym< T >:

Public Types

typedef T value_type
 Type of stored elements. More...
 
typedef std::shared_ptr< WMatrixSym< T > > SPtr
 Shorthand for shared pointers. More...
 

Public Member Functions

 WMatrixSym (size_t n)
 Generates new symmetric matrix. More...
 
 WMatrixSym ()
 Default constructor leaving all empty. More...
 
T & operator() (size_t i, size_t j)
 Element acces operator as if the elements where stored as a normal matrix. More...
 
const T & operator() (size_t i, size_t j) const
 Const version of the element access. More...
 
size_t numElements () const
 Returns the number of elements stored in this matrix. More...
 
size_t size () const
 Returns the number of rows and cols of the matrix. More...
 
const std::vector< T > & getData () const
 Returns the elements stored inside of this container. More...
 
void setData (const std::vector< T > &data)
 Resets the internal data to the given vector of elements. More...
 
std::string toString (void) const
 Renders the matrix to a full nxn matrix, where the main diagonal is set to 0.0 and the m(i,j) == m(j,i). More...
 

Private Attributes

std::vector< T > m_data
 Internal data structure to store the elements. More...
 
size_t m_n
 Number of rows and cols. More...
 

Friends

class WMatrixSymTest
 Access for test class. More...
 

Detailed Description

template<typename T>
class WMatrixSym< T >

Symmetric square matrix, storing only the elements of the triangular matrix without the main diagonal.

So in case of a NxN matrix there are only (N^2-N)/2 elements stored.

Note
There exists also a WWriter and WReader for storing/reading the matrix in VTK file format.

Definition at line 46 of file WMatrixSym.h.

Member Typedef Documentation

◆ SPtr

template<typename T >
typedef std::shared_ptr< WMatrixSym < T > > WMatrixSym< T >::SPtr

Shorthand for shared pointers.

Definition at line 58 of file WMatrixSym.h.

◆ value_type

template<typename T >
typedef T WMatrixSym< T >::value_type

Type of stored elements.

Definition at line 53 of file WMatrixSym.h.

Constructor & Destructor Documentation

◆ WMatrixSym() [1/2]

template<typename T >
WMatrixSym< T >::WMatrixSym ( size_t  n)
inlineexplicit

Generates new symmetric matrix.

Parameters
nnumber of rows and cols

Definition at line 143 of file WMatrixSym.h.

◆ WMatrixSym() [2/2]

template<typename T >
WMatrixSym< T >::WMatrixSym
inline

Default constructor leaving all empty.

Definition at line 150 of file WMatrixSym.h.

Member Function Documentation

◆ getData()

template<typename T >
const std::vector< T > & WMatrixSym< T >::getData
inline

Returns the elements stored inside of this container.

Returns
Read-only reference to the elements stored inside this container.

Definition at line 310 of file WMatrixSym.h.

◆ numElements()

template<typename T >
size_t WMatrixSym< T >::numElements
inline

Returns the number of elements stored in this matrix.

Returns
the number of elements stored in this matrix.

Definition at line 298 of file WMatrixSym.h.

◆ operator()() [1/2]

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

Element acces operator as if the elements where stored as a normal matrix.

Warning
Acessing elements of the main diagonal is forbidden!
Parameters
iThe i'th row
jThe j'th column
Returns
reference to the (i,j) element of the table

Definition at line 173 of file WMatrixSym.h.

◆ operator()() [2/2]

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

Const version of the element access.

Warning
Acessing elements of the main diagonal is forbidden!
Parameters
iThe i'th row
jThe j'th column
Returns
Const reference to the (i,j) element of the table

Definition at line 156 of file WMatrixSym.h.

◆ setData()

template<typename T >
void WMatrixSym< T >::setData ( const std::vector< T > &  data)
inline

Resets the internal data to the given vector of elements.

Parameters
datanew data in row major arrangement

Definition at line 316 of file WMatrixSym.h.

Referenced by WMatrixSymTest::testAccessOn3x3Matrix(), WMatrixSymTest::testInputStream(), WMatrixSymTest::testOutputStream(), WMatrixSymTest::testSetDataWithInvalidLengthForDimension(), and WMatrixSymTest::testToString().

+ Here is the caller graph for this function:

◆ size()

template<typename T >
size_t WMatrixSym< T >::size
inline

Returns the number of rows and cols of the matrix.

Returns
The number of rows and cols of the matrix.

Definition at line 304 of file WMatrixSym.h.

◆ toString()

template<typename T >
std::string WMatrixSym< T >::toString ( void  ) const
inline

Renders the matrix to a full nxn matrix, where the main diagonal is set to 0.0 and the m(i,j) == m(j,i).

Each column is separated by exactly one space and each row is separated by a newline.

Returns
Multiline string containing the nxn symmetric matrix.

Definition at line 190 of file WMatrixSym.h.

Referenced by WMatrixSymTest::testToString().

+ Here is the caller graph for this function:

Friends And Related Function Documentation

◆ WMatrixSymTest

template<typename T >
friend class WMatrixSymTest
friend

Access for test class.

Definition at line 48 of file WMatrixSym.h.

Member Data Documentation

◆ m_data

template<typename T >
std::vector< T > WMatrixSym< T >::m_data
private

Internal data structure to store the elements.

The order is row major.

Definition at line 134 of file WMatrixSym.h.

Referenced by WMatrixSymTest::testOperatorOn3x3Matrix().

◆ m_n

template<typename T >
size_t WMatrixSym< T >::m_n
private

Number of rows and cols.

Definition at line 139 of file WMatrixSym.h.


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