Correlation 4.10.0
An Analysis Tool for Liquids and for Amorphous Solids
Loading...
Searching...
No Matches
correlation::math::Matrix3< T > Class Template Reference

A lightweight, constexpr, stack-based 3x3 matrix. More...

#include <LinearAlgebra.hpp>

Inheritance diagram for correlation::math::Matrix3< T >:

Public Types

using value_type = T
 Scalar type.

Public Member Functions

constexpr Matrix3 () noexcept
 Default constructor. Initializes all elements to zero.
constexpr Matrix3 (const Vector3< T > &c_zero, const Vector3< T > &c_one, const Vector3< T > &c_two) noexcept
 Parameterized constructor from column vectors.
template<typename U>
constexpr Matrix3 (const Matrix3< U > &other) noexcept
constexpr const Vector3< T > & operator[] (std::size_t col_idx) const noexcept
 Access column vector by index.
constexpr Vector3< T > & operator[] (std::size_t col_idx) noexcept
 Access mutable column vector by index.
constexpr T operator() (std::size_t row_idx, std::size_t col_idx) const noexcept
 Access element by row and column.
constexpr T & operator() (std::size_t row_idx, std::size_t col_idx) noexcept
 Access mutable element by row and column.
constexpr std::array< std::array< T, 3 >, 3 > array () const noexcept
 Converts the matrix to a nested std::array.
constexpr T trace () const noexcept
 Computes the matrix trace.
constexpr Matrix3 operator* (T scalar) const noexcept
 Matrix-scalar multiplication.
constexpr Matrix3 & operator*= (T scalar) noexcept
 In-place scalar multiplication.
constexpr Matrix3 & operator+= (const Matrix3 &rhs) noexcept
 In-place matrix addition.
constexpr Matrix3 operator+ (const Matrix3 &rhs) const noexcept
 Matrix addition.
constexpr Matrix3 & operator-= (const Matrix3 &rhs) noexcept
 In-place matrix subtraction.
constexpr Matrix3 operator- (const Matrix3 &rhs) const noexcept
 Matrix subtraction.
constexpr Matrix3 & operator*= (const Matrix3 &rhs) noexcept
 In-place matrix-matrix multiplication.
constexpr bool operator== (const Matrix3 &rhs) const noexcept
 Equality comparison.
constexpr bool operator!= (const Matrix3 &rhs) const noexcept
 Inequality comparison.

Static Public Member Functions

static constexpr Matrix3 identity () noexcept
 Returns the 3×3 identity matrix.

Private Attributes

std::array< Vector3< T >, 3 > data_
 Column vectors of the matrix.

Detailed Description

template<typename T>
class correlation::math::Matrix3< T >

A lightweight, constexpr, stack-based 3x3 matrix.

Uses column-major storage format (standard for OpenGL and BLAS). This means data is stored as an array of three column vectors.

Template Parameters
TThe scalar type stored by the matrix.

Member Typedef Documentation

◆ value_type

template<typename T>
using correlation::math::Matrix3< T >::value_type = T

Scalar type.

Constructor & Destructor Documentation

◆ Matrix3() [1/3]

template<typename T>
correlation::math::Matrix3< T >::Matrix3 ( )
inlineconstexprnoexcept

Default constructor. Initializes all elements to zero.

Here is the caller graph for this function:

◆ Matrix3() [2/3]

template<typename T>
correlation::math::Matrix3< T >::Matrix3 ( const Vector3< T > & c_zero,
const Vector3< T > & c_one,
const Vector3< T > & c_two )
inlineconstexprnoexcept

Parameterized constructor from column vectors.

Parameters
c_zeroFirst column vector.
c_oneSecond column vector.
c_twoThird column vector.

◆ Matrix3() [3/3]

template<typename T>
template<typename U>
correlation::math::Matrix3< T >::Matrix3 ( const Matrix3< U > & other)
inlineconstexprnoexcept

Member Function Documentation

◆ array()

template<typename T>
std::array< std::array< T, 3 >, 3 > correlation::math::Matrix3< T >::array ( ) const
inlinenodiscardconstexprnoexcept

Converts the matrix to a nested std::array.

Returns
Row-major nested array representation.

◆ identity()

template<typename T>
constexpr Matrix3 correlation::math::Matrix3< T >::identity ( )
inlinestaticnodiscardconstexprnoexcept

Returns the 3×3 identity matrix.

Returns
Identity matrix with ones on the diagonal.

◆ operator!=()

template<typename T>
bool correlation::math::Matrix3< T >::operator!= ( const Matrix3< T > & rhs) const
inlinenodiscardconstexprnoexcept

Inequality comparison.

Parameters
rhsThe matrix to compare with.
Returns
True if any element differs.

◆ operator()() [1/2]

template<typename T>
T correlation::math::Matrix3< T >::operator() ( std::size_t row_idx,
std::size_t col_idx ) const
inlinenodiscardconstexprnoexcept

Access element by row and column.

Parameters
row_idxRow index.
col_idxColumn index.
Returns
The element value.

◆ operator()() [2/2]

template<typename T>
T & correlation::math::Matrix3< T >::operator() ( std::size_t row_idx,
std::size_t col_idx )
inlineconstexprnoexcept

Access mutable element by row and column.

Parameters
row_idxRow index.
col_idxColumn index.
Returns
Reference to the element.

◆ operator*()

template<typename T>
Matrix3 correlation::math::Matrix3< T >::operator* ( T scalar) const
inlinenodiscardconstexprnoexcept

Matrix-scalar multiplication.

Parameters
scalarScalar factor.
Returns
A scaled matrix object.

◆ operator*=() [1/2]

template<typename T>
Matrix3 & correlation::math::Matrix3< T >::operator*= ( const Matrix3< T > & rhs)
inlineconstexprnoexcept

In-place matrix-matrix multiplication.

Parameters
rhsThe matrix to multiply with (post-multiplication).
Returns
Reference to this matrix.

◆ operator*=() [2/2]

template<typename T>
Matrix3 & correlation::math::Matrix3< T >::operator*= ( T scalar)
inlineconstexprnoexcept

In-place scalar multiplication.

Parameters
scalarScalar factor.
Returns
Reference to this matrix.

◆ operator+()

template<typename T>
Matrix3 correlation::math::Matrix3< T >::operator+ ( const Matrix3< T > & rhs) const
inlinenodiscardconstexprnoexcept

Matrix addition.

Parameters
rhsThe matrix to add.
Returns
A new matrix representing the sum.

◆ operator+=()

template<typename T>
Matrix3 & correlation::math::Matrix3< T >::operator+= ( const Matrix3< T > & rhs)
inlineconstexprnoexcept

In-place matrix addition.

Parameters
rhsThe matrix to add.
Returns
Reference to this matrix.

◆ operator-()

template<typename T>
Matrix3 correlation::math::Matrix3< T >::operator- ( const Matrix3< T > & rhs) const
inlinenodiscardconstexprnoexcept

Matrix subtraction.

Parameters
rhsThe matrix to subtract.
Returns
A new matrix representing the difference.

◆ operator-=()

template<typename T>
Matrix3 & correlation::math::Matrix3< T >::operator-= ( const Matrix3< T > & rhs)
inlineconstexprnoexcept

In-place matrix subtraction.

Parameters
rhsThe matrix to subtract.
Returns
Reference to this matrix.

◆ operator==()

template<typename T>
bool correlation::math::Matrix3< T >::operator== ( const Matrix3< T > & rhs) const
inlinenodiscardconstexprnoexcept

Equality comparison.

Parameters
rhsThe matrix to compare with.
Returns
True if all elements are exactly equal.

◆ operator[]() [1/2]

template<typename T>
const Vector3< T > & correlation::math::Matrix3< T >::operator[] ( std::size_t col_idx) const
inlinenodiscardconstexprnoexcept

Access column vector by index.

Parameters
col_idxColumn index (0, 1, or 2).
Returns
Constant reference to the column vector.

◆ operator[]() [2/2]

template<typename T>
Vector3< T > & correlation::math::Matrix3< T >::operator[] ( std::size_t col_idx)
inlineconstexprnoexcept

Access mutable column vector by index.

Parameters
col_idxColumn index (0, 1, or 2).
Returns
Reference to the column vector.

◆ trace()

template<typename T>
T correlation::math::Matrix3< T >::trace ( ) const
inlinenodiscardconstexprnoexcept

Computes the matrix trace.

Returns
Sum of the diagonal elements.

Member Data Documentation

◆ data_

template<typename T>
std::array<Vector3<T>, 3> correlation::math::Matrix3< T >::data_
private

Column vectors of the matrix.


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