Loading...
Searching...
No Matches
libcamera::Matrix< T, Rows, Cols > Class Template Reference

Matrix class. More...

## Public Member Functions

constexpr | Matrix ()
| Construct a zero matrix.
| Matrix (const std::array< T, Rows *Cols > &data)
| Construct a matrix from supplied data.
| Matrix (const Span< const T, Rows *Cols > data)
| Construct a matrix from supplied data.
std::string | toString () const
| Assemble and return a string describing the matrix.
constexpr Span< const T, Rows *Cols > | data () const
| Access the matrix data as a linear array.
constexpr Span< const T, Cols > | operator[] (size_t i) const
| Index to a row in the matrix.
constexpr Span< T, Cols > | operator[] (size_t i)
| Index to a row in the matrix.
template<typename U>
Matrix< T, Rows, Cols > & | operator*= (U d)
| Multiply the matrix by a scalar in-place.
Matrix< T, Rows, Cols > | inverse (bool *ok=nullptr) const
| Compute the inverse of the matrix.

## Static Public Member Functions

static constexpr Matrix | identity ()
| Construct an identity matrix.

## Detailed Description

template<typename T, unsigned int Rows, unsigned int Cols>
class libcamera::Matrix< T, Rows, Cols >

Matrix class.

Template Parameters

  T | Type of numerical values to be stored in the matrix
  Rows | Number of rows in the matrix
  Cols | Number of columns in the matrix

## Constructor & Destructor Documentation

## Matrix() [1/2]

template<typename T, unsigned int Rows, unsigned int Cols>

libcamera::Matrix< T, Rows, Cols >::Matrix | ( | const std::array< T, Rows *Cols > & | data | ) |

inline

Construct a matrix from supplied data.

Parameters

  [in] | data | Data from which to construct a matrix

data is a one-dimensional vector and will be turned into a matrix in row-major order. The size of data must be equal to the product of the number of rows and columns of the matrix (Rows x Cols).

## Matrix() [2/2]

template<typename T, unsigned int Rows, unsigned int Cols>

libcamera::Matrix< T, Rows, Cols >::Matrix | ( | const Span< const T, Rows *Cols > | data | ) |

inline

Construct a matrix from supplied data.

Parameters

  [in] | data | Data from which to construct a matrix

data is a one-dimensional Span and will be turned into a matrix in row-major order. The size of data must be equal to the product of the number of rows and columns of the matrix (Rows x Cols).

## Member Function Documentation

## data()

template<typename T, unsigned int Rows, unsigned int Cols>

Span< const T, Rows *Cols > libcamera::Matrix< T, Rows, Cols >::data | ( |  | ) | const

inline constexpr

Access the matrix data as a linear array.

Access the contents of the matrix as a one-dimensional linear array of values in row-major order. The size of the array is equal to the product of the number of rows and columns of the matrix (Rows x Cols).

Returns
  A span referencing the matrix data as a linear array

## inverse()

template<typename T, unsigned int Rows, unsigned int Cols>

Matrix< T, Rows, Cols > libcamera::Matrix< T, Rows, Cols >::inverse | ( | bool * | ok = nullptr | ) | const

inline

Compute the inverse of the matrix.

Parameters

  [out] | ok | Indicate if the matrix was successfully inverted

This function computes the inverse of the matrix. It is only implemented for matrices of float and double types. If ok is provided it will be set to a boolean value to indicate of the inversion was successful. This can be used to check if the matrix is singular, in which case the function will return an identity matrix.

Returns
  The inverse of the matrix

## operator*=()

template<typename T, unsigned int Rows, unsigned int Cols>
template<typename U>

Matrix< T, Rows, Cols > & libcamera::Matrix< T, Rows, Cols >::operator*= | ( | U | d | ) |

inline

Multiply the matrix by a scalar in-place.

Template Parameters

  U | Type of the numerical scalar value

Parameters

  d | The scalar multiplier

Returns
  Product of this matrix and scalar d

## operator[]() [1/2]

template<typename T, unsigned int Rows, unsigned int Cols>

Span< T, Cols > libcamera::Matrix< T, Rows, Cols >::operator[] | ( | size_t | i | ) |

inline constexpr

Index to a row in the matrix.

Parameters

  [in] | i | Index of row to retrieve

This operator[] returns a Span, which can then be indexed into again with another operator[], allowing a convenient m[i][j] to access elements of the matrix. Note that the lifetime of the Span returned by this first-level operator[] is bound to that of the Matrix itself, so it is not recommended to save the Span that is the result of this operator[].

Returns
  Row i from the matrix, as a Span

## operator[]() [2/2]

template<typename T, unsigned int Rows, unsigned int Cols>

Span< const T, Cols > libcamera::Matrix< T, Rows, Cols >::operator[] | ( | size_t | i | ) | const

inline constexpr

Index to a row in the matrix.

Parameters

  [in] | i | Index of row to retrieve

This operator[] returns a Span, which can then be indexed into again with another operator[], allowing a convenient m[i][j] to access elements of the matrix. Note that the lifetime of the Span returned by this first-level operator[] is bound to that of the Matrix itself, so it is not recommended to save the Span that is the result of this operator[].

Returns
  Row i from the matrix, as a Span

## toString()

template<typename T, unsigned int Rows, unsigned int Cols>

std::string libcamera::Matrix< T, Rows, Cols >::toString | ( |  | ) | const

inline

Assemble and return a string describing the matrix.

Returns
  A string describing the matrix

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

- include/libcamera/internal/matrix.h
- src/libcamera/matrix.cpp