Peano
Loading...
Searching...
No Matches
tarch::la::ShallowMatrix< Rows, Cols, Scalar > Class Template Reference

Shallow matrix wrapping an existing array. More...

#include <ShallowMatrix.h>

Public Member Functions

 ShallowMatrix (Scalar *values)
 Constructs a non-initialized matrix.
 ShallowMatrix (const ShallowMatrix &copy)
 Shallow copy.
ShallowMatrix & operator= (const ShallowMatrix &copy)
 Shallow copy.
int rows () const
 Returns the number of rows in the matrix.
int cols () const
 Returns the number of columns in the matrix.
int size () const
 Returns the number of total elements in the matrix.
Scalar & operator() (int rowIndex, int colIndex)
 Returns element at given row and column index (from 0..size-1).
const Scalar & operator() (int rowIndex, int colIndex) const
 Returns const element at given row and column index (from 0..size-1).
std::string toString () const
std::string toPrettyString (int numberOfDigits=4) const
template<typename NewScalarType>
tarch::la::Matrix< Rows, Cols, NewScalarType > convertScalar () const
 Convert the scalar type.
Scalar * data ()
 Return pointer back to original data.
const Scalar * data () const

Private Attributes

Scalar * _values
 Values of the matrix components.

Detailed Description

template<int Rows, int Cols, typename Scalar>
class tarch::la::ShallowMatrix< Rows, Cols, Scalar >

Shallow matrix wrapping an existing array.

You are in charge of handling the underlying memory, i.e. the class does neither allocate anything nor destroy anything

Definition at line 29 of file ShallowMatrix.h.

Constructor & Destructor Documentation

◆ ShallowMatrix() [1/2]

template<int Rows, int Cols, typename Scalar>
tarch::la::ShallowMatrix< Rows, Cols, Scalar >::ShallowMatrix ( Scalar * values)

Constructs a non-initialized matrix.

Referenced by operator=(), and ShallowMatrix().

Here is the caller graph for this function:

◆ ShallowMatrix() [2/2]

template<int Rows, int Cols, typename Scalar>
tarch::la::ShallowMatrix< Rows, Cols, Scalar >::ShallowMatrix ( const ShallowMatrix< Rows, Cols, Scalar > & copy)

Shallow copy.

References ShallowMatrix().

Here is the call graph for this function:

Member Function Documentation

◆ cols()

template<int Rows, int Cols, typename Scalar>
int tarch::la::ShallowMatrix< Rows, Cols, Scalar >::cols ( ) const

Returns the number of columns in the matrix.

◆ convertScalar()

template<int Rows, int Cols, typename Scalar>
template<typename NewScalarType>
tarch::la::Matrix< Rows, Cols, NewScalarType > tarch::la::ShallowMatrix< Rows, Cols, Scalar >::convertScalar ( ) const

Convert the scalar type.

Can also be used to convert a shallow matrix into a proper one, i.e. to deep copy.

◆ data() [1/2]

template<int Rows, int Cols, typename Scalar>
Scalar * tarch::la::ShallowMatrix< Rows, Cols, Scalar >::data ( )

Return pointer back to original data.

Definition at line 121 of file ShallowMatrix.h.

References _values.

◆ data() [2/2]

template<int Rows, int Cols, typename Scalar>
const Scalar * tarch::la::ShallowMatrix< Rows, Cols, Scalar >::data ( ) const

Definition at line 125 of file ShallowMatrix.h.

References _values.

◆ operator()() [1/2]

template<int Rows, int Cols, typename Scalar>
Scalar & tarch::la::ShallowMatrix< Rows, Cols, Scalar >::operator() ( int rowIndex,
int colIndex )

Returns element at given row and column index (from 0..size-1).

See also
Vector::operator[] for remarks on SSE efficiency

Definition at line 72 of file ShallowMatrix.h.

References _values, assertion5, and toString().

Here is the call graph for this function:

◆ operator()() [2/2]

template<int Rows, int Cols, typename Scalar>
const Scalar & tarch::la::ShallowMatrix< Rows, Cols, Scalar >::operator() ( int rowIndex,
int colIndex ) const

Returns const element at given row and column index (from 0..size-1).

Definition at line 90 of file ShallowMatrix.h.

References _values, assertion5, and toString().

Here is the call graph for this function:

◆ operator=()

template<int Rows, int Cols, typename Scalar>
ShallowMatrix & tarch::la::ShallowMatrix< Rows, Cols, Scalar >::operator= ( const ShallowMatrix< Rows, Cols, Scalar > & copy)

Shallow copy.

References ShallowMatrix().

Here is the call graph for this function:

◆ rows()

template<int Rows, int Cols, typename Scalar>
int tarch::la::ShallowMatrix< Rows, Cols, Scalar >::rows ( ) const

Returns the number of rows in the matrix.

◆ size()

template<int Rows, int Cols, typename Scalar>
int tarch::la::ShallowMatrix< Rows, Cols, Scalar >::size ( ) const

Returns the number of total elements in the matrix.

◆ toPrettyString()

template<int Rows, int Cols, typename Scalar>
std::string tarch::la::ShallowMatrix< Rows, Cols, Scalar >::toPrettyString ( int numberOfDigits = 4) const

◆ toString()

template<int Rows, int Cols, typename Scalar>
std::string tarch::la::ShallowMatrix< Rows, Cols, Scalar >::toString ( ) const

Referenced by operator()(), and operator()().

Here is the caller graph for this function:

Field Documentation

◆ _values

template<int Rows, int Cols, typename Scalar>
Scalar* tarch::la::ShallowMatrix< Rows, Cols, Scalar >::_values
private

Values of the matrix components.

Definition at line 34 of file ShallowMatrix.h.

Referenced by data(), data(), operator()(), and operator()().


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