Ginger 1.1.5; VERSION ${PROJECT_VERSION}
Loading...
Searching...
No Matches
Public Member Functions | List of all members
ginger::Matrix2< T1, T2 > Class Template Reference

Matrix2. More...

#include <matrix2.hpp>

Public Member Functions

constexpr Matrix2 (T1 x, T2 y) noexcept
 Construct a new Matrix2 object.
 
constexpr auto x () const -> const T1 &
 Get the first column vector.
 
constexpr auto y () const -> const T2 &
 Get the second column vector.
 

Arithmetic operators

definie +, -, *, /, +=, -=, *=, /=, etc.

constexpr auto operator- () const -> Matrix2< T1, T2 >
 Negate the matrix.
 
template<typename U1 , typename U2 >
CONSTEXPR14 auto operator+= (const Matrix2< U1, U2 > &other) -> Matrix2< T1, T2 > &
 Add another matrix to this one.
 
template<typename U1 , typename U2 >
CONSTEXPR14 auto operator-= (const Matrix2< U1, U2 > &other) -> Matrix2< T1, T2 > &
 Subtract another matrix from this one.
 
template<typename R >
CONSTEXPR14 auto operator*= (const R &alpha) -> Matrix2< T1, T2 > &
 Multiply.
 
template<typename R >
CONSTEXPR14 auto operator/= (const R &alpha) -> Matrix2< T1, T2 > &
 Divide matrix by a scalar.
 
template<typename U1 , typename U2 >
constexpr auto mdot (const Vector2< U1, U2 > &other) const -> T1
 Multiply matrix with vector.
 
constexpr auto det () const -> double
 Calculate the determinant.
 
template<typename U1 , typename U2 >
constexpr auto operator+ (Matrix2< T1, T2 > x, const Matrix2< U1, U2 > &y) -> Matrix2< T1, T2 >
 Add two matrices.
 
template<typename U1 , typename U2 >
constexpr auto operator- (Matrix2< T1, T2 > x, const Matrix2< U1, U2 > &y) -> Matrix2< T1, T2 >
 Subtract two matrices.
 
template<typename R >
constexpr auto operator* (Matrix2< T1, T2 > x, const R &alpha) -> Matrix2< T1, T2 >
 Multiply matrix by a scalar.
 
template<typename R >
constexpr auto operator* (const R &alpha, Matrix2< T1, T2 > x) -> Matrix2< T1, T2 >
 Multiply a scalar by a matrix.
 
template<typename R >
constexpr auto operator/ (Matrix2< T1, T2 > x, const R &alpha) -> Matrix2< T1, T2 >
 Divide matrix by a scalar.
 

Detailed Description

template<typename T1, typename T2 = T1>
class ginger::Matrix2< T1, T2 >

Matrix2.

A template class representing a 2x2 matrix with column vectors. The matrix is stored as two column vectors (x and y).

Template Parameters
T1The type of the first column vector
T2The type of the second column vector (defaults to T1)

Constructor & Destructor Documentation

◆ Matrix2()

template<typename T1 , typename T2 = T1>
constexpr ginger::Matrix2< T1, T2 >::Matrix2 ( T1  x,
T2  y 
)
inlineconstexprnoexcept

Construct a new Matrix2 object.

Parameters
[in]xThe first column vector
[in]yThe second column vector

Member Function Documentation

◆ det()

template<typename T1 , typename T2 = T1>
constexpr auto ginger::Matrix2< T1, T2 >::det ( ) const -> double
inlineconstexpr

Calculate the determinant.

Computes the determinant of the 2x2 matrix:

\[ \det\begin{bmatrix} a & b \\ c & d \end{bmatrix} = ad - bc \]

Returns
double The determinant value

◆ mdot()

template<typename T1 , typename T2 = T1>
template<typename U1 , typename U2 >
constexpr auto ginger::Matrix2< T1, T2 >::mdot ( const Vector2< U1, U2 > &  other) const -> T1
inlineconstexpr

Multiply matrix with vector.

Performs matrix-vector multiplication:

\[ \begin{bmatrix} a & b \\ c & d \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix} = \begin{bmatrix} ax + by \\ cx + dy \end{bmatrix} \]

Template Parameters
U1Type of the first component of the vector
U2Type of the second component of the vector
Parameters
[in]otherThe vector to multiply
Returns
T1 The resulting vector (as column vector type)

◆ operator*=()

template<typename T1 , typename T2 = T1>
template<typename R >
CONSTEXPR14 auto ginger::Matrix2< T1, T2 >::operator*= ( const R &  alpha) -> Matrix2<T1, T2>&
inline

Multiply.

Template Parameters
R
Parameters
[in]alpha
Returns
Matrix2<T1, T2>&

◆ operator+=()

template<typename T1 , typename T2 = T1>
template<typename U1 , typename U2 >
CONSTEXPR14 auto ginger::Matrix2< T1, T2 >::operator+= ( const Matrix2< U1, U2 > &  other) -> Matrix2<T1, T2>&
inline

Add another matrix to this one.

Template Parameters
U1Type of the first column of the other matrix
U2Type of the second column of the other matrix
Parameters
[in]otherThe matrix to add
Returns
Matrix2<T1, T2>& Reference to this matrix

◆ operator-()

template<typename T1 , typename T2 = T1>
constexpr auto ginger::Matrix2< T1, T2 >::operator- ( ) const -> Matrix2<T1, T2>
inlineconstexpr

Negate the matrix.

Returns
Matrix2<T1, T2> A new matrix with negated column vectors

◆ operator-=()

template<typename T1 , typename T2 = T1>
template<typename U1 , typename U2 >
CONSTEXPR14 auto ginger::Matrix2< T1, T2 >::operator-= ( const Matrix2< U1, U2 > &  other) -> Matrix2<T1, T2>&
inline

Subtract another matrix from this one.

Template Parameters
U1Type of the first column of the other matrix
U2Type of the second column of the other matrix
Parameters
[in]otherThe matrix to subtract
Returns
Matrix2<T1, T2>& Reference to this matrix

◆ operator/=()

template<typename T1 , typename T2 = T1>
template<typename R >
CONSTEXPR14 auto ginger::Matrix2< T1, T2 >::operator/= ( const R &  alpha) -> Matrix2<T1, T2>&
inline

Divide matrix by a scalar.

Template Parameters
RThe scalar type
Parameters
[in]alphaThe scalar value
Returns
Matrix2<T1, T2>& Reference to this matrix

◆ x()

template<typename T1 , typename T2 = T1>
constexpr auto ginger::Matrix2< T1, T2 >::x ( ) const -> const T1&
inlineconstexpr

Get the first column vector.

Returns
constexpr const T1& Reference to the first column vector

◆ y()

template<typename T1 , typename T2 = T1>
constexpr auto ginger::Matrix2< T1, T2 >::y ( ) const -> const T2&
inlineconstexpr

Get the second column vector.

Returns
constexpr const T2& Reference to the second column vector

Friends And Related Symbol Documentation

◆ operator* [1/2]

template<typename T1 , typename T2 = T1>
template<typename R >
constexpr auto operator* ( const R &  alpha,
Matrix2< T1, T2 >  x 
) -> Matrix2<T1, T2>
friend

Multiply a scalar by a matrix.

Template Parameters
RThe scalar type
Parameters
[in]alphaThe scalar value
[in]xThe matrix
Returns
Matrix2<T1, T2> The result matrix

◆ operator* [2/2]

template<typename T1 , typename T2 = T1>
template<typename R >
constexpr auto operator* ( Matrix2< T1, T2 >  x,
const R &  alpha 
) -> Matrix2<T1, T2>
friend

Multiply matrix by a scalar.

Template Parameters
RThe scalar type
Parameters
[in]xThe matrix
[in]alphaThe scalar value
Returns
Matrix2<T1, T2> The result matrix

◆ operator+

template<typename T1 , typename T2 = T1>
template<typename U1 , typename U2 >
constexpr auto operator+ ( Matrix2< T1, T2 >  x,
const Matrix2< U1, U2 > &  y 
) -> Matrix2<T1, T2>
friend

Add two matrices.

Template Parameters
U1Type of the first column of the first matrix
U2Type of the second column of the first matrix
Parameters
[in]xThe first matrix
[in]yThe second matrix
Returns
Matrix2<T1, T2> The result matrix

◆ operator-

template<typename T1 , typename T2 = T1>
template<typename U1 , typename U2 >
constexpr auto operator- ( Matrix2< T1, T2 >  x,
const Matrix2< U1, U2 > &  y 
) -> Matrix2<T1, T2>
friend

Subtract two matrices.

Template Parameters
U1Type of the first column of the first matrix
U2Type of the second column of the first matrix
Parameters
[in]xThe first matrix
[in]yThe second matrix
Returns
Matrix2<T1, T2> The result matrix

◆ operator/

template<typename T1 , typename T2 = T1>
template<typename R >
constexpr auto operator/ ( Matrix2< T1, T2 >  x,
const R &  alpha 
) -> Matrix2<T1, T2>
friend

Divide matrix by a scalar.

Template Parameters
RThe scalar type
Parameters
[in]xThe matrix
[in]alphaThe scalar value
Returns
Matrix2<T1, T2> The result matrix

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