template<std:: size_t size, class T>
Matrix class
Square matrix.
Template parameters | |
---|---|
size | Matrix size |
T | Data type |
Contents
See Operations with matrices and vectors for brief introduction.
Base classes
-
template<std::class RectangularMatrix
size_t cols, std:: size_t rows, class T> - Rectangular matrix.
Derived classes
Public types
-
enum (anonymous): std::
size_t { Size = size }
Constructors, destructors, conversion operators
- Matrix(IdentityInitT = IdentityInit, T value = T(1)) constexpr noexcept
- Default constructor.
- Matrix(ZeroInitT) explicit constexpr noexcept
- Construct zero-filled matrix.
- Matrix(NoInitT) explicit constexpr noexcept
- Construct matrix without initializing the contents.
-
template<class ... U>Matrix(const Vector<size, T>& first, const U&... next) constexpr noexcept
- Construct matrix from column vectors.
- Matrix(T value) explicit constexpr noexcept
- Construct matrix with one value for all elements.
-
template<class U>Matrix(const RectangularMatrix<size, size, U>& other) explicit constexpr noexcept
- Construct matrix from another of different type.
-
template<class U, class V = decltype(Implementation::RectangularMatrixConverter<size, size, T, U>::from(std::Matrix(const U& other) explicit constexpr
declval<U>()))> - Construct matrix from external representation.
- Matrix(const RectangularMatrix<size, size, T>& other) constexpr noexcept
- Copy constructor.
Public functions
- auto isOrthogonal() const -> bool
- Whether the matrix is orthogonal.
- auto trace() const -> T
- Trace of the matrix.
-
auto ij(std::
size_t skipCol, std:: size_t skipRow) const -> Matrix<size-1, T> - Matrix without given column and row.
- auto determinant() const -> T
- Determinant.
- auto inverted() const -> Matrix<size, T>
- Inverted matrix.
- auto invertedOrthogonal() const -> Matrix<size, T>
- Inverted orthogonal matrix.
Enum documentation
template<std:: size_t size, class T>
enum Magnum:: Math:: Matrix<size, T>:: (anonymous): std:: size_t
Enumerators | |
---|---|
Size |
Matrix size |
Function documentation
template<std:: size_t size, class T>
Magnum:: Math:: Matrix<size, T>:: Matrix(IdentityInitT = IdentityInit,
T value = T(1)) constexpr noexcept
Default constructor.
Creates identity matrix. value
allows you to specify value on diagonal.
template<std:: size_t size, class T>
template<class U>
Magnum:: Math:: Matrix<size, T>:: Matrix(const RectangularMatrix<size, size, U>& other) explicit constexpr noexcept
Construct matrix from another of different type.
Performs only default casting on the values, no rounding or anything else. Example usage:
Matrix2x2<Float> floatingPoint({1.3f, 2.7f}, {-15.0f, 7.0f}); Matrix2x2<Byte> integral(floatingPoint); // integral == {{1, 2}, {-15, 7}}
template<std:: size_t size, class T>
bool Magnum:: Math:: Matrix<size, T>:: isOrthogonal() const
Whether the matrix is orthogonal.
The matrix is orthogonal if its transpose is equal to its inverse:
template<std:: size_t size, class T>
T Magnum:: Math:: Matrix<size, T>:: trace() const
Trace of the matrix.
template<std:: size_t size, class T>
T Magnum:: Math:: Matrix<size, T>:: determinant() const
Determinant.
Returns 0
if the matrix is noninvertible and 1
if the matrix is orthogonal. Computed recursively using Laplace's formula:
is matrix without i-th row and j-th column, see ij(). The formula is expanded down to 2x2 matrix, where the determinant is computed directly:
template<std:: size_t size, class T>
Matrix<size, T> Magnum:: Math:: Matrix<size, T>:: inverted() const
Inverted matrix.
Computed using Cramer's rule:
See invertedOrthogonal(), Matrix3::
template<std:: size_t size, class T>
Matrix<size, T> Magnum:: Math:: Matrix<size, T>:: invertedOrthogonal() const
Inverted orthogonal matrix.
Equivalent to transposed(), expects that the matrix is orthogonal.