NTLib - Number Theory Library 0.9
Loading...
Searching...
No Matches
ntlib::matrix< ROWS, COLUMNS, T > Class Template Referenceexport
module matrix

Represents a matrix with a given number of rows and colums. More...

Public Member Functions

 matrix ()=default
 Creates new matrix.
 matrix (const std::initializer_list< std::initializer_list< T > > &elements)
 Constructs a new matrix from a given 2D initializer list.
decltype(auto) operator[] (this auto &self, std::size_t r, std::size_t c)
 Two dimensional array subscript operator.
matrixoperator+= (const matrix &rhs)
 Compound plus operator for matrix addition.
matrixoperator-= (const matrix &rhs)
 Compound minus operator for matrix subtraction.
matrixoperator*= (T rhs)
 Compound times operator for right scalar multiplication.
matrixoperator/= (T rhs)
 Compound divides operator for scalar division.
matrixoperator%= (T rhs)
 Compound modulo operator for elementwise modulo by a scalar.
matrixoperator*= (const matrix &rhs)
 Compound times operator for matrix multiplication.

Static Public Member Functions

static matrix get_zero ()
 Returns a zero matrix.
static matrix get_identity ()
 Returns a square identity matrix.

Friends

bool operator== (const matrix &, const matrix &)=default
 Default equality operator.

Detailed Description

template<std::size_t ROWS, std::size_t COLUMNS, Ring T>
class ntlib::matrix< ROWS, COLUMNS, T >

Represents a matrix with a given number of rows and colums.

Template Parameters
ROWSThe number of rows.
COLUMSThe number of colums.
TThe element type.

Constructor & Destructor Documentation

◆ matrix() [1/2]

template<std::size_t ROWS, std::size_t COLUMNS, Ring T>
ntlib::matrix< ROWS, COLUMNS, T >::matrix ( )
default

Creates new matrix.

Elements will be default initialized.

◆ matrix() [2/2]

template<std::size_t ROWS, std::size_t COLUMNS, Ring T>
ntlib::matrix< ROWS, COLUMNS, T >::matrix ( const std::initializer_list< std::initializer_list< T > > & elements)
inline

Constructs a new matrix from a given 2D initializer list.

The 2D initializer list shall be a list of lines.

Parameters
elementsThe elements of the matrix.

Member Function Documentation

◆ get_identity()

template<std::size_t ROWS, std::size_t COLUMNS, Ring T>
matrix ntlib::matrix< ROWS, COLUMNS, T >::get_identity ( )
inlinestatic

Returns a square identity matrix.

Returns
An identity matrix.

◆ get_zero()

template<std::size_t ROWS, std::size_t COLUMNS, Ring T>
matrix ntlib::matrix< ROWS, COLUMNS, T >::get_zero ( )
inlinestatic

Returns a zero matrix.

Returns
A zero matrix.

◆ operator%=()

template<std::size_t ROWS, std::size_t COLUMNS, Ring T>
matrix & ntlib::matrix< ROWS, COLUMNS, T >::operator%= ( T rhs)
inline

Compound modulo operator for elementwise modulo by a scalar.

Parameters
rhsThe divisor. A scalar.
Returns
Reference to the result.

◆ operator*=() [1/2]

template<std::size_t ROWS, std::size_t COLUMNS, Ring T>
matrix & ntlib::matrix< ROWS, COLUMNS, T >::operator*= ( const matrix< ROWS, COLUMNS, T > & rhs)
inline

Compound times operator for matrix multiplication.

Note
As this method returns a reference to the modified first factor, it can only be used on square matrices. For other dimensions the product would have different dimension.
Parameters
rhsThe second factor.
Returns
Reference to the result.

◆ operator*=() [2/2]

template<std::size_t ROWS, std::size_t COLUMNS, Ring T>
matrix & ntlib::matrix< ROWS, COLUMNS, T >::operator*= ( T rhs)
inline

Compound times operator for right scalar multiplication.

Parameters
rhsThe second factor. A scalar.
Returns
Reference to the result.

◆ operator+=()

template<std::size_t ROWS, std::size_t COLUMNS, Ring T>
matrix & ntlib::matrix< ROWS, COLUMNS, T >::operator+= ( const matrix< ROWS, COLUMNS, T > & rhs)
inline

Compound plus operator for matrix addition.

Parameters
rhsThe second summand.
Returns
Reference to the result.

◆ operator-=()

template<std::size_t ROWS, std::size_t COLUMNS, Ring T>
matrix & ntlib::matrix< ROWS, COLUMNS, T >::operator-= ( const matrix< ROWS, COLUMNS, T > & rhs)
inline

Compound minus operator for matrix subtraction.

Parameters
rhsThe subtrahend.
Returns
Reference to the result.

◆ operator/=()

template<std::size_t ROWS, std::size_t COLUMNS, Ring T>
matrix & ntlib::matrix< ROWS, COLUMNS, T >::operator/= ( T rhs)
inline

Compound divides operator for scalar division.

Parameters
rhsThe divisor. A scalar.
Returns
Reference to this matrix.

◆ operator[]()

template<std::size_t ROWS, std::size_t COLUMNS, Ring T>
decltype(auto) ntlib::matrix< ROWS, COLUMNS, T >::operator[] ( this auto & self,
std::size_t r,
std::size_t c )
inline

Two dimensional array subscript operator.

Parameters
selfExplicity object parameter.
rThe row.
cThe column.
Returns
(Constant) reference to the element at the given position.

◆ operator==

template<std::size_t ROWS, std::size_t COLUMNS, Ring T>
bool operator== ( const matrix< ROWS, COLUMNS, T > & ,
const matrix< ROWS, COLUMNS, T > &  )
friend

Default equality operator.

Returns
Whether two matrices are equal.

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