Antkeeper  0.0.1
Public Types | Public Attributes | Static Public Attributes | List of all members
math::matrix< T, N, M > Struct Template Reference

n by m column-major matrix. More...

#include <matrix.hpp>

Public Types

using element_type = T
 Element type. More...
 
using column_vector_type = vector< element_type, row_count >
 Matrix column vector data type. More...
 
using row_vector_type = vector< element_type, column_count >
 Matrix row vector data type. More...
 

Public Member Functions

Column access
constexpr column_vector_typeoperator[] (std::size_t i) noexcept
 Returns a reference to the column vector at a given index. More...
 
constexpr const column_vector_typeoperator[] (std::size_t i) const noexcept
 Returns a reference to the column vector at a given index. More...
 
constexpr column_vector_typecolumn (std::size_t i) noexcept
 Returns a reference to the column vector at a given index. More...
 
constexpr const column_vector_typecolumn (std::size_t i) const noexcept
 Returns a reference to the column vector at a given index. More...
 
constexpr column_vector_typefront () noexcept
 Returns a reference to the first column vector. More...
 
constexpr const column_vector_typefront () const noexcept
 Returns a reference to the first column vector. More...
 
constexpr column_vector_typeback () noexcept
 Returns a reference to the last column vector. More...
 
constexpr const column_vector_typeback () const noexcept
 Returns a reference to the last column vector. More...
 
Element access
constexpr T & element (std::size_t i) noexcept
 Returns a reference to the element at a given column-major index. More...
 
constexpr const T & element (std::size_t i) const noexcept
 Returns a reference to the element at a given column-major index. More...
 
constexpr element_typedata () noexcept
 Returns a pointer to the first element. More...
 
constexpr const element_typedata () const noexcept
 Returns a pointer to the first element. More...
 
Iterators
constexpr column_vector_typebegin () noexcept
 Returns an iterator to the first column vector. More...
 
constexpr const column_vector_typebegin () const noexcept
 Returns an iterator to the first column vector. More...
 
constexpr const column_vector_typecbegin () const noexcept
 Returns an iterator to the first column vector. More...
 
constexpr column_vector_typeend () noexcept
 Returns an iterator to the column vector following the last column vector. More...
 
constexpr const column_vector_typeend () const noexcept
 Returns an iterator to the column vector following the last column vector. More...
 
constexpr const column_vector_typecend () const noexcept
 Returns an iterator to the column vector following the last column vector. More...
 
constexpr std::reverse_iterator< column_vector_type * > rbegin () noexcept
 Returns a reverse iterator to the first column vector of the reversed matrix. More...
 
constexpr std::reverse_iterator< const column_vector_type * > rbegin () const noexcept
 Returns a reverse iterator to the first column vector of the reversed matrix. More...
 
constexpr std::reverse_iterator< const column_vector_type * > crbegin () const noexcept
 Returns a reverse iterator to the first column vector of the reversed matrix. More...
 
constexpr std::reverse_iterator< column_vector_type * > rend () noexcept
 Returns a reverse iterator to the column vector following the last column vector of the reversed matrix. More...
 
constexpr std::reverse_iterator< const column_vector_type * > rend () const noexcept
 Returns a reverse iterator to the column vector following the last column vector of the reversed matrix. More...
 
constexpr std::reverse_iterator< const column_vector_type * > crend () const noexcept
 Returns a reverse iterator to the column vector following the last column vector of the reversed matrix. More...
 
Capacity
constexpr std::size_t size () const noexcept
 Returns the number of elements in the matrix. More...
 

Public Attributes

column_vector_type columns [column_count]
 Array of matrix column vectors. More...
 

Static Public Attributes

static constexpr std::size_t column_count = N
 Number of columns. More...
 
static constexpr std::size_t row_count = M
 Number of rows. More...
 
static constexpr std::size_t element_count = column_count * row_count
 Number of elements. More...
 

Conversion

template<class U >
constexpr operator matrix< U, N, M > () const noexcept
 Type-casts the elements of this matrix using static_cast. More...
 
template<std::size_t P, std::size_t O>
constexpr operator matrix< T, P, O > () const noexcept
 Size-casts this matrix to a matrix with different dimensions. More...
 

Constants

static constexpr matrix zero () noexcept
 Returns a zero matrix, where every element is equal to zero. More...
 
static constexpr matrix one () noexcept
 Returns a matrix of ones, where every element is equal to one. More...
 
static constexpr matrix identity () noexcept
 Returns an identity matrix, with ones on the main diagonal and zeros elsewhere. More...
 

Detailed Description

template<class T, std::size_t N, std::size_t M>
struct math::matrix< T, N, M >

n by m column-major matrix.

Template Parameters
TElement type.
NNumber of columns.
MNumber of rows.
See also
https://en.wikipedia.org/wiki/Row-_and_column-major_order

Definition at line 43 of file math/matrix.hpp.

Member Typedef Documentation

◆ column_vector_type

template<class T , std::size_t N, std::size_t M>
using math::matrix< T, N, M >::column_vector_type = vector<element_type, row_count>

Matrix column vector data type.

Definition at line 58 of file math/matrix.hpp.

◆ element_type

template<class T , std::size_t N, std::size_t M>
using math::matrix< T, N, M >::element_type = T

Element type.

Definition at line 46 of file math/matrix.hpp.

◆ row_vector_type

template<class T , std::size_t N, std::size_t M>
using math::matrix< T, N, M >::row_vector_type = vector<element_type, column_count>

Matrix row vector data type.

Definition at line 61 of file math/matrix.hpp.

Member Function Documentation

◆ back() [1/2]

template<class T , std::size_t N, std::size_t M>
constexpr const column_vector_type& math::matrix< T, N, M >::back ( ) const
inlineconstexprnoexcept

Returns a reference to the last column vector.

Definition at line 170 of file math/matrix.hpp.

◆ back() [2/2]

template<class T , std::size_t N, std::size_t M>
constexpr column_vector_type& math::matrix< T, N, M >::back ( )
inlineconstexprnoexcept

Returns a reference to the last column vector.

Definition at line 166 of file math/matrix.hpp.

◆ begin() [1/2]

template<class T , std::size_t N, std::size_t M>
constexpr const column_vector_type* math::matrix< T, N, M >::begin ( ) const
inlineconstexprnoexcept

Returns an iterator to the first column vector.

Definition at line 228 of file math/matrix.hpp.

◆ begin() [2/2]

template<class T , std::size_t N, std::size_t M>
constexpr column_vector_type* math::matrix< T, N, M >::begin ( )
inlineconstexprnoexcept

Returns an iterator to the first column vector.

Definition at line 224 of file math/matrix.hpp.

◆ cbegin()

template<class T , std::size_t N, std::size_t M>
constexpr const column_vector_type* math::matrix< T, N, M >::cbegin ( ) const
inlineconstexprnoexcept

Returns an iterator to the first column vector.

Definition at line 232 of file math/matrix.hpp.

◆ cend()

template<class T , std::size_t N, std::size_t M>
constexpr const column_vector_type* math::matrix< T, N, M >::cend ( ) const
inlineconstexprnoexcept

Returns an iterator to the column vector following the last column vector.

Definition at line 250 of file math/matrix.hpp.

◆ column() [1/2]

template<class T , std::size_t N, std::size_t M>
constexpr const column_vector_type& math::matrix< T, N, M >::column ( std::size_t  i) const
inlineconstexprnoexcept

Returns a reference to the column vector at a given index.

Parameters
iIndex of a column vector.
Returns
Reference to the column vector at index i.

Definition at line 142 of file math/matrix.hpp.

◆ column() [2/2]

template<class T , std::size_t N, std::size_t M>
constexpr column_vector_type& math::matrix< T, N, M >::column ( std::size_t  i)
inlineconstexprnoexcept

Returns a reference to the column vector at a given index.

Parameters
iIndex of a column vector.
Returns
Reference to the column vector at index i.

Definition at line 138 of file math/matrix.hpp.

◆ crbegin()

template<class T , std::size_t N, std::size_t M>
constexpr std::reverse_iterator<const column_vector_type*> math::matrix< T, N, M >::crbegin ( ) const
inlineconstexprnoexcept

Returns a reverse iterator to the first column vector of the reversed matrix.

Definition at line 268 of file math/matrix.hpp.

◆ crend()

template<class T , std::size_t N, std::size_t M>
constexpr std::reverse_iterator<const column_vector_type*> math::matrix< T, N, M >::crend ( ) const
inlineconstexprnoexcept

Returns a reverse iterator to the column vector following the last column vector of the reversed matrix.

Definition at line 286 of file math/matrix.hpp.

◆ data() [1/2]

template<class T , std::size_t N, std::size_t M>
constexpr const element_type* math::matrix< T, N, M >::data ( ) const
inlineconstexprnoexcept

Returns a pointer to the first element.

Warning
If matrix::element_type is not a POD type, elements may not be stored contiguously.

Definition at line 209 of file math/matrix.hpp.

◆ data() [2/2]

template<class T , std::size_t N, std::size_t M>
constexpr element_type* math::matrix< T, N, M >::data ( )
inlineconstexprnoexcept

Returns a pointer to the first element.

Warning
If matrix::element_type is not a POD type, elements may not be stored contiguously.

Definition at line 205 of file math/matrix.hpp.

◆ element() [1/2]

template<class T , std::size_t N, std::size_t M>
constexpr const T& math::matrix< T, N, M >::element ( std::size_t  i) const
inlineconstexprnoexcept

Returns a reference to the element at a given column-major index.

Parameters
iColumn-major index of a matrix element.
Returns
Reference to the element at column-major index i.

Definition at line 193 of file math/matrix.hpp.

◆ element() [2/2]

template<class T , std::size_t N, std::size_t M>
constexpr T& math::matrix< T, N, M >::element ( std::size_t  i)
inlineconstexprnoexcept

Returns a reference to the element at a given column-major index.

Parameters
iColumn-major index of a matrix element.
Returns
Reference to the element at column-major index i.

Definition at line 189 of file math/matrix.hpp.

◆ end() [1/2]

template<class T , std::size_t N, std::size_t M>
constexpr const column_vector_type* math::matrix< T, N, M >::end ( ) const
inlineconstexprnoexcept

Returns an iterator to the column vector following the last column vector.

Definition at line 246 of file math/matrix.hpp.

◆ end() [2/2]

template<class T , std::size_t N, std::size_t M>
constexpr column_vector_type* math::matrix< T, N, M >::end ( )
inlineconstexprnoexcept

Returns an iterator to the column vector following the last column vector.

Definition at line 242 of file math/matrix.hpp.

◆ front() [1/2]

template<class T , std::size_t N, std::size_t M>
constexpr const column_vector_type& math::matrix< T, N, M >::front ( ) const
inlineconstexprnoexcept

Returns a reference to the first column vector.

Definition at line 156 of file math/matrix.hpp.

◆ front() [2/2]

template<class T , std::size_t N, std::size_t M>
constexpr column_vector_type& math::matrix< T, N, M >::front ( )
inlineconstexprnoexcept

Returns a reference to the first column vector.

Definition at line 152 of file math/matrix.hpp.

◆ identity()

template<class T , std::size_t N, std::size_t M>
static constexpr matrix math::matrix< T, N, M >::identity ( )
inlinestaticconstexprnoexcept

Returns an identity matrix, with ones on the main diagonal and zeros elsewhere.

Definition at line 353 of file math/matrix.hpp.

◆ one()

template<class T , std::size_t N, std::size_t M>
static constexpr matrix math::matrix< T, N, M >::one ( )
inlinestaticconstexprnoexcept

Returns a matrix of ones, where every element is equal to one.

Definition at line 331 of file math/matrix.hpp.

◆ operator matrix< T, P, O >()

template<class T , std::size_t N, std::size_t M>
template<std::size_t P, std::size_t O>
constexpr math::matrix< T, N, M >::operator matrix< T, P, O > ( ) const
inlineexplicitconstexprnoexcept

Size-casts this matrix to a matrix with different dimensions.

Casting to greater dimensions causes new elements to be set to identity matrix elements.

Template Parameters
PTarget number of columns.
OTarget number of rows.
Returns
p by o matrix.

Definition at line 112 of file math/matrix.hpp.

◆ operator matrix< U, N, M >()

template<class T , std::size_t N, std::size_t M>
template<class U >
constexpr math::matrix< T, N, M >::operator matrix< U, N, M > ( ) const
inlineexplicitconstexprnoexcept

Type-casts the elements of this matrix using static_cast.

Template Parameters
UTarget element type.
Returns
Matrix containing the type-casted elements.

Definition at line 84 of file math/matrix.hpp.

◆ operator[]() [1/2]

template<class T , std::size_t N, std::size_t M>
constexpr const column_vector_type& math::matrix< T, N, M >::operator[] ( std::size_t  i) const
inlineconstexprnoexcept

Returns a reference to the column vector at a given index.

Parameters
iIndex of a column vector.
Returns
Reference to the column vector at index i.

Definition at line 134 of file math/matrix.hpp.

◆ operator[]() [2/2]

template<class T , std::size_t N, std::size_t M>
constexpr column_vector_type& math::matrix< T, N, M >::operator[] ( std::size_t  i)
inlineconstexprnoexcept

Returns a reference to the column vector at a given index.

Parameters
iIndex of a column vector.
Returns
Reference to the column vector at index i.

Definition at line 130 of file math/matrix.hpp.

◆ rbegin() [1/2]

template<class T , std::size_t N, std::size_t M>
constexpr std::reverse_iterator<const column_vector_type*> math::matrix< T, N, M >::rbegin ( ) const
inlineconstexprnoexcept

Returns a reverse iterator to the first column vector of the reversed matrix.

Definition at line 264 of file math/matrix.hpp.

◆ rbegin() [2/2]

template<class T , std::size_t N, std::size_t M>
constexpr std::reverse_iterator<column_vector_type*> math::matrix< T, N, M >::rbegin ( )
inlineconstexprnoexcept

Returns a reverse iterator to the first column vector of the reversed matrix.

Definition at line 260 of file math/matrix.hpp.

◆ rend() [1/2]

template<class T , std::size_t N, std::size_t M>
constexpr std::reverse_iterator<const column_vector_type*> math::matrix< T, N, M >::rend ( ) const
inlineconstexprnoexcept

Returns a reverse iterator to the column vector following the last column vector of the reversed matrix.

Definition at line 282 of file math/matrix.hpp.

◆ rend() [2/2]

template<class T , std::size_t N, std::size_t M>
constexpr std::reverse_iterator<column_vector_type*> math::matrix< T, N, M >::rend ( )
inlineconstexprnoexcept

Returns a reverse iterator to the column vector following the last column vector of the reversed matrix.

Definition at line 278 of file math/matrix.hpp.

◆ size()

template<class T , std::size_t N, std::size_t M>
constexpr std::size_t math::matrix< T, N, M >::size ( ) const
inlineconstexprnoexcept

Returns the number of elements in the matrix.

Definition at line 300 of file math/matrix.hpp.

◆ zero()

template<class T , std::size_t N, std::size_t M>
static constexpr matrix math::matrix< T, N, M >::zero ( )
inlinestaticconstexprnoexcept

Returns a zero matrix, where every element is equal to zero.

Definition at line 313 of file math/matrix.hpp.

Member Data Documentation

◆ column_count

template<class T , std::size_t N, std::size_t M>
constexpr std::size_t math::matrix< T, N, M >::column_count = N
staticconstexpr

Number of columns.

Definition at line 49 of file math/matrix.hpp.

◆ columns

template<class T , std::size_t N, std::size_t M>
column_vector_type math::matrix< T, N, M >::columns[column_count]

Array of matrix column vectors.

Definition at line 64 of file math/matrix.hpp.

◆ element_count

template<class T , std::size_t N, std::size_t M>
constexpr std::size_t math::matrix< T, N, M >::element_count = column_count * row_count
staticconstexpr

Number of elements.

Definition at line 55 of file math/matrix.hpp.

◆ row_count

template<class T , std::size_t N, std::size_t M>
constexpr std::size_t math::matrix< T, N, M >::row_count = M
staticconstexpr

Number of rows.

Definition at line 52 of file math/matrix.hpp.


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