# VectorNav C++ Library: vn::math::mat< m, n, T > Struct Template Reference

vn::math::mat< m, n, T > Struct Template Reference

Template for a matrix. More...

`#include <matrix.h>`

## Public Member Functions

| mat ()
| Creates a new matrix with uninitialized elements.
| mat (T val)
| Creates a new matrix with ints elements initialized to val. More...
T & | operator() (size_t row, size_t col)
| Indexing into the matrix's elements. More...
const T & | operator() (size_t row, size_t col) const
| Indexing into the matrix's elements. More...
mat | operator- () const
| Negates the matrix. More...
template<typename S >
mat & | operator*= (const S &rhs)
| Multiplies the matrix by a scalar. More...
template<size_t r, size_t s, typename S >
mat & | operator* (const mat< r, s, S > &rhs)
| Multiplies the matrix by another matrix. More...
template<typename S >
mat & | operator/= (const T &rhs)
| Divides the matrix by a scalar. More...
template<typename S >
mat & | operator+= (const mat< m, n, S > &rhs)
| Adds a matrix to this matrix. More...
template<typename S >
mat & | operator-= (const mat< m, n, S > &rhs)
| Subtracts a matrix from this matrix. More...
size_t | dimRow () const
| The matrix's row dimension. More...
size_t | dimCol () const
| The matrix's column dimension. More...
mat | neg () const
| Negates the matrix. More...
mat | mult (const double &scalar) const
| Multiplies the matrix by a scalar. More...
mat | div (const double &scalar) const
| Divides the matrix by a scalar. More...
mat | add (const mat &toAdd) const
| Adds a matrix to this matrix. More...
mat | sub (const mat &toSub) const
| Subtracts a matrix from this matrix. More...
mat< n, m, T > | transpose () const
| Transposes the matrix. More...

## Static Public Member Functions

static mat | zero ()
| Matrix with all of its elements set to 0. More...
static mat | one ()
| Matrix with all of its elements set to 1. More...
static mat< m, m, T > | identity ()
| Identity matrix with its diagonal elements set to 1. More...

## Public Attributes

union {
T e [m *n]
}; |
| The matrix's elements.

## Detailed Description

### template<size_t m, size_t n = m, typename T = float>
struct vn::math::mat< m, n, T >

Template for a matrix.

Examples:
  math/main.cpp.

## Constructor & Destructor Documentation

template<size_t m, size_t n = m, typename T = float>

vn::math::mat< m, n, T >::mat | ( | T | val | ) |

inlineexplicit

Creates a new matrix with ints elements initialized to val.

Parameters

  [in] | val | The initialization value.

## Member Function Documentation

template<size_t m, size_t n = m, typename T = float>

mat vn::math::mat< m, n, T >::add | ( | const mat< m, n, T > & | toAdd | ) | const

inline

Adds a matrix to this matrix.

Parameters

  [in] | toAdd | The matrix to add.

Returns
  The resulting matrix.

template<size_t m, size_t n = m, typename T = float>

size_t vn::math::mat< m, n, T >::dimCol | ( |  | ) | const

inline

The matrix's column dimension.

Returns
  The matrix's column dimension.

template<size_t m, size_t n = m, typename T = float>

size_t vn::math::mat< m, n, T >::dimRow | ( |  | ) | const

inline

The matrix's row dimension.

Returns
  The matrix's row dimension.

template<size_t m, size_t n = m, typename T = float>

mat vn::math::mat< m, n, T >::div | ( | const double & | scalar | ) | const

inline

Divides the matrix by a scalar.

Parameters

  [in] | scalar | The scalar value.

Returns
  The divided matrix.

template<size_t m, size_t n = m, typename T = float>

static mat<m, m, T> vn::math::mat< m, n, T >::identity | ( |  | ) |

inlinestatic

Identity matrix with its diagonal elements set to 1.

Returns
  The identity matrix.

template<size_t m, size_t n = m, typename T = float>

mat vn::math::mat< m, n, T >::mult | ( | const double & | scalar | ) | const

inline

Multiplies the matrix by a scalar.

Parameters

  [in] | scalar | The scalar value.

Returns
  The multiplied matrix.

template<size_t m, size_t n = m, typename T = float>

mat vn::math::mat< m, n, T >::neg | ( |  | ) | const

inline

Negates the matrix.

Returns
  The negated matrix.

template<size_t m, size_t n = m, typename T = float>

static mat vn::math::mat< m, n, T >::one | ( |  | ) |

inlinestatic

Matrix with all of its elements set to 1.

Returns
  The 1 matrix.

template<size_t m, size_t n = m, typename T = float>

T& vn::math::mat< m, n, T >::operator() | ( | size_t | row,
|  | size_t | col
| ) |  |

inline

Indexing into the matrix's elements.

Parameters

  [in] | row | The 0-based index row.
  [in] | col | The 0-based index column.

Returns
  The requested element.

template<size_t m, size_t n = m, typename T = float>

const T& vn::math::mat< m, n, T >::operator() | ( | size_t | row,
|  | size_t | col
| ) |  | const

inline

Indexing into the matrix's elements.

Parameters

  [in] | row | The 0-based index row.
  [in] | col | The 0-based index column.

Returns
  The requested element.

template<size_t m, size_t n = m, typename T = float>
template<size_t r, size_t s, typename S >

mat& vn::math::mat< m, n, T >::operator* | ( | const mat< r, s, S > & | rhs | ) |

inline

Multiplies the matrix by another matrix.

Parameters

  [in] | rhs | The other matrix.

Returns
  The multiplied matrix.

template<size_t m, size_t n = m, typename T = float>
template<typename S >

mat& vn::math::mat< m, n, T >::operator*= | ( | const S & | rhs | ) |

inline

Multiplies the matrix by a scalar.

Parameters

  [in] | rhs | The scalar.

Returns
  The multiplied matrix.

template<size_t m, size_t n = m, typename T = float>
template<typename S >

mat& vn::math::mat< m, n, T >::operator+= | ( | const mat< m, n, S > & | rhs | ) |

inline

Adds a matrix to this matrix.

Parameters

  [in] | rhs | The right-side vector.

Returns
  The resulting vector.

template<size_t m, size_t n = m, typename T = float>

mat vn::math::mat< m, n, T >::operator- | ( |  | ) | const

inline

Negates the matrix.

Returns
  The negated matrix.

template<size_t m, size_t n = m, typename T = float>
template<typename S >

mat& vn::math::mat< m, n, T >::operator-= | ( | const mat< m, n, S > & | rhs | ) |

inline

Subtracts a matrix from this matrix.

Parameters

  [in] | rhs | The right-side matrix.

Returns
  The resulting matrix.

template<size_t m, size_t n = m, typename T = float>
template<typename S >

mat& vn::math::mat< m, n, T >::operator/= | ( | const T & | rhs | ) |

inline

Divides the matrix by a scalar.

Parameters

  [in] | rhs | The scalar.

Returns
  The divided matrix.

template<size_t m, size_t n = m, typename T = float>

mat vn::math::mat< m, n, T >::sub | ( | const mat< m, n, T > & | toSub | ) | const

inline

Subtracts a matrix from this matrix.

Parameters

  [in] | toSub | The matrix to subtract from this.

Returns
  The resulting matrix.

template<size_t m, size_t n = m, typename T = float>

mat<n, m, T> vn::math::mat< m, n, T >::transpose | ( |  | ) | const

inline

Transposes the matrix.

Returns
  The computed transpose.

Examples:
  math/main.cpp.

template<size_t m, size_t n = m, typename T = float>

static mat vn::math::mat< m, n, T >::zero | ( |  | ) |

inlinestatic

Matrix with all of its elements set to 0.

Returns
  The 0 matrix.

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

- include/vn/matrix.h