Zivid C++ API 2.13.1+18e79e79-1
Zivid::Matrix< T, rowCount, colCount > Class Template Reference

A fixed size matrix in row major order. More...

#include <Zivid/Matrix.h>

Public Types

using ValueType = T
 The type stored in the matrix.
 
using Iterator = typename Storage::iterator
 The matrix iterator type for mutable access. It iterates over individual matrix elements in row major order.
 
using ConstIterator = typename Storage::const_iterator
 The matrix iterator type for immutable access. It iterates over individual matrix elements in row major order.
 

Public Member Functions

 Matrix ()=default
 Constructor.
 
 Matrix (const std::string &fileName)
 Load the matrix from a file.
 
 Matrix (const std::array< T, colCount *rowCount > &arrArr)
 Constructor.
 
template<typename U >
 Matrix (const Matrix< U, rowCount, colCount > &sourceMatrix)
 Constructor.
 
template<typename Iterator >
 Matrix (Iterator beginIt, Iterator endIt)
 Constructor.
 
 Matrix (std::initializer_list< T > values)
 Constructor.
 
 Matrix (std::initializer_list< std::initializer_list< T > > values)
 Constructor.
 
Iterator begin ()
 Iterator to the beginning of the matrix.
 
Iterator end ()
 Iterator to the end of the matrix.
 
ConstIterator begin () const
 Iterator to the beginning of the matrix.
 
ConstIterator end () const
 Iterator to the end of the matrix.
 
ConstIterator cbegin () const
 Iterator to the beginning of the matrix.
 
ConstIterator cend () const
 Iterator to the end of the matrix.
 
T & at (size_t row, size_t col)
 Access specified element with bounds checking.
 
const T & at (size_t row, size_t col) const
 Access specified element with bounds checking.
 
T & operator() (size_t row, size_t col)
 Access specified element without bounds checking.
 
const T & operator() (size_t row, size_t col) const
 Access specified element without bounds checking.
 
T * data ()
 Pointer to the underlying data.
 
const T * data () const
 Pointer to the underlying data.
 
void save (const std::string &fileName) const
 Save the matrix to the given file.
 
void load (const std::string &fileName)
 Load the matrix from the given file.
 
template<typename Q = T, typename = typename std::enable_if<invertSupported, Q>::type>
ZIVID_CORE_EXPORT Matrix inverse () const
 Get the inverse of this matrix.
 
std::string toString () const
 Get string representation of the Matrix.
 

Static Public Attributes

static constexpr size_t rows { rowCount }
 The number of rows in the matrix.
 
static constexpr size_t cols { colCount }
 The number of columns in the matrix.
 

Detailed Description

template<typename T, size_t rowCount, size_t colCount>
class Zivid::Matrix< T, rowCount, colCount >

A fixed size matrix in row major order.

Member Typedef Documentation

◆ ConstIterator

template<typename T , size_t rowCount, size_t colCount>
using Zivid::Matrix< T, rowCount, colCount >::ConstIterator = typename Storage::const_iterator

The matrix iterator type for immutable access. It iterates over individual matrix elements in row major order.

◆ Iterator

template<typename T , size_t rowCount, size_t colCount>
using Zivid::Matrix< T, rowCount, colCount >::Iterator = typename Storage::iterator

The matrix iterator type for mutable access. It iterates over individual matrix elements in row major order.

◆ ValueType

template<typename T , size_t rowCount, size_t colCount>
using Zivid::Matrix< T, rowCount, colCount >::ValueType = T

The type stored in the matrix.

Constructor & Destructor Documentation

◆ Matrix() [1/7]

template<typename T , size_t rowCount, size_t colCount>
Zivid::Matrix< T, rowCount, colCount >::Matrix ( )
default

Constructor.

◆ Matrix() [2/7]

template<typename T , size_t rowCount, size_t colCount>
Zivid::Matrix< T, rowCount, colCount >::Matrix ( const std::string & fileName)
inline

Load the matrix from a file.

◆ Matrix() [3/7]

template<typename T , size_t rowCount, size_t colCount>
Zivid::Matrix< T, rowCount, colCount >::Matrix ( const std::array< T, colCount *rowCount > & arrArr)
inlineexplicit

Constructor.

◆ Matrix() [4/7]

template<typename T , size_t rowCount, size_t colCount>
template<typename U >
Zivid::Matrix< T, rowCount, colCount >::Matrix ( const Matrix< U, rowCount, colCount > & sourceMatrix)
inlineexplicit

Constructor.

◆ Matrix() [5/7]

template<typename T , size_t rowCount, size_t colCount>
template<typename Iterator >
Zivid::Matrix< T, rowCount, colCount >::Matrix ( Iterator beginIt,
Iterator endIt )
inline

Constructor.

◆ Matrix() [6/7]

template<typename T , size_t rowCount, size_t colCount>
Zivid::Matrix< T, rowCount, colCount >::Matrix ( std::initializer_list< T > values)
inlineexplicit

Constructor.

◆ Matrix() [7/7]

template<typename T , size_t rowCount, size_t colCount>
Zivid::Matrix< T, rowCount, colCount >::Matrix ( std::initializer_list< std::initializer_list< T > > values)
inlineexplicit

Constructor.

Member Function Documentation

◆ at() [1/2]

template<typename T , size_t rowCount, size_t colCount>
T & Zivid::Matrix< T, rowCount, colCount >::at ( size_t row,
size_t col )
inline

Access specified element with bounds checking.

◆ at() [2/2]

template<typename T , size_t rowCount, size_t colCount>
const T & Zivid::Matrix< T, rowCount, colCount >::at ( size_t row,
size_t col ) const
inline

Access specified element with bounds checking.

◆ begin() [1/2]

template<typename T , size_t rowCount, size_t colCount>
Iterator Zivid::Matrix< T, rowCount, colCount >::begin ( )
inline

Iterator to the beginning of the matrix.

◆ begin() [2/2]

template<typename T , size_t rowCount, size_t colCount>
ConstIterator Zivid::Matrix< T, rowCount, colCount >::begin ( ) const
inline

Iterator to the beginning of the matrix.

◆ cbegin()

template<typename T , size_t rowCount, size_t colCount>
ConstIterator Zivid::Matrix< T, rowCount, colCount >::cbegin ( ) const
inline

Iterator to the beginning of the matrix.

◆ cend()

template<typename T , size_t rowCount, size_t colCount>
ConstIterator Zivid::Matrix< T, rowCount, colCount >::cend ( ) const
inline

Iterator to the end of the matrix.

◆ data() [1/2]

template<typename T , size_t rowCount, size_t colCount>
T * Zivid::Matrix< T, rowCount, colCount >::data ( )
inline

Pointer to the underlying data.

◆ data() [2/2]

template<typename T , size_t rowCount, size_t colCount>
const T * Zivid::Matrix< T, rowCount, colCount >::data ( ) const
inline

Pointer to the underlying data.

◆ end() [1/2]

template<typename T , size_t rowCount, size_t colCount>
Iterator Zivid::Matrix< T, rowCount, colCount >::end ( )
inline

Iterator to the end of the matrix.

◆ end() [2/2]

template<typename T , size_t rowCount, size_t colCount>
ConstIterator Zivid::Matrix< T, rowCount, colCount >::end ( ) const
inline

Iterator to the end of the matrix.

◆ inverse()

template<typename T , size_t rowCount, size_t colCount>
template<typename Q = T, typename = typename std::enable_if<invertSupported, Q>::type>
ZIVID_CORE_EXPORT Matrix Zivid::Matrix< T, rowCount, colCount >::inverse ( ) const

Get the inverse of this matrix.

An exception is thrown if the matrix is not invertible.

Returns
A new matrix, holding the inverse

◆ load()

template<typename T , size_t rowCount, size_t colCount>
void Zivid::Matrix< T, rowCount, colCount >::load ( const std::string & fileName)

Load the matrix from the given file.

Loads the matrix into the object it was invoked on, does not return a value.

◆ operator()() [1/2]

template<typename T , size_t rowCount, size_t colCount>
T & Zivid::Matrix< T, rowCount, colCount >::operator() ( size_t row,
size_t col )
inline

Access specified element without bounds checking.

◆ operator()() [2/2]

template<typename T , size_t rowCount, size_t colCount>
const T & Zivid::Matrix< T, rowCount, colCount >::operator() ( size_t row,
size_t col ) const
inline

Access specified element without bounds checking.

◆ save()

template<typename T , size_t rowCount, size_t colCount>
void Zivid::Matrix< T, rowCount, colCount >::save ( const std::string & fileName) const

Save the matrix to the given file.

The matrix is saved in YAML format.

◆ toString()

template<typename T , size_t rowCount, size_t colCount>
std::string Zivid::Matrix< T, rowCount, colCount >::toString ( ) const
inline

Get string representation of the Matrix.

Returns
Matrix as string

Member Data Documentation

◆ cols

template<typename T , size_t rowCount, size_t colCount>
size_t Zivid::Matrix< T, rowCount, colCount >::cols { colCount }
staticconstexpr

The number of columns in the matrix.

◆ rows

template<typename T , size_t rowCount, size_t colCount>
size_t Zivid::Matrix< T, rowCount, colCount >::rows { rowCount }
staticconstexpr

The number of rows in the matrix.


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