#include <Magnum/Math/RectangularMatrix.h>
          template<std::
        Rectangular matrix.
| Template parameters | |
|---|---|
| cols | Column count | 
| rows | Row count | 
| T | Underlying data type | 
See Operations with matrices and vectors for brief introduction. See also Matrix (square), Matrix3, Matrix4 and Vector.
The data are stored in column-major order, to reflect that, all indices in math formulas are in reverse order (i.e. instead of ).
Public types
- 
              enum (anonymous): std::size_t { Cols = cols, Rows = rows, DiagonalSize = (cols < rows ? cols : rows) } 
- using Type = T
- Underlying data type.
Public static functions
- static auto from(T* data) -> RectangularMatrix<cols, rows, T>&
- Matrix from an array.
- static auto from(const T* data) -> const RectangularMatrix<cols, rows, T>&
- static auto fromVector(const Vector<cols*rows, T>& vector) -> RectangularMatrix<cols, rows, T>
- Construct a matrix from a vector.
- static auto fromDiagonal(const Vector<DiagonalSize, T>& diagonal) -> RectangularMatrix<cols, rows, T> constexpr noexcept
- Construct a diagonal matrix.
Constructors, destructors, conversion operators
- RectangularMatrix() constexpr noexcept
- Default constructor.
- RectangularMatrix(ZeroInitT) explicit constexpr noexcept
- Construct a zero-filled matrix.
- RectangularMatrix(IdentityInitT, T value = T(1)) explicit constexpr noexcept new in Git master
- Construct an identity matrix.
- 
              RectangularMatrix(Magnum::NoInitT) explicit noexcept 
- Construct without initializing the contents.
- 
              template<class ... U>RectangularMatrix(const Vector<rows, T>& first, const U&... next) constexpr noexcept
- Construct from column vectors.
- RectangularMatrix(T value) explicit constexpr noexcept
- Construct with one value for all components.
- 
              template<std::RectangularMatrix(const T(&data)[cols_][rows_]) explicit constexpr noexcept new in Git mastersize_t cols_, std:: size_t rows_> 
- Construct from a fixed-size array.
- 
              template<class U>RectangularMatrix(const RectangularMatrix<cols, rows, U>& other) explicit constexpr noexcept
- Construct from a matrix of a different type.
- 
              template<std::RectangularMatrix(ZeroInitT, const RectangularMatrix<otherCols, otherRows, T>& other) explicit constexpr noexcept new in Git mastersize_t otherCols, std:: size_t otherRows> 
- Construct by slicing or expanding a matrix of different size, leaving the rest at zero.
- 
              template<std::RectangularMatrix(IdentityInitT, const RectangularMatrix<otherCols, otherRows, T>& other, T value = T(1)) explicit constexpr noexcept new in Git mastersize_t otherCols, std:: size_t otherRows> 
- Construct by slicing or expanding a matrix of different size, leaving the rest at identity.
- 
              template<std::RectangularMatrix(const RectangularMatrix<otherCols, otherRows, T>& other) explicit constexpr noexcept new in Git mastersize_t otherCols, std:: size_t otherRows> 
- Construct by slicing or expanding a matrix of different size.
- 
              template<class U, class = decltype(Implementation::RectangularMatrixConverter<cols, rows, T, U>::from(std::RectangularMatrix(const U& other) explicit constexprdeclval<U>()))> 
- Construct a matrix from external representation.
- 
              template<class U, class = decltype(Implementation::RectangularMatrixConverter<cols, rows, T, U>::to(std::operator U() const explicit constexprdeclval<RectangularMatrix<cols, rows, T>>()))> 
- Convert the matrix to external representation.
Public functions
- auto data() -> T*
- Raw data.
- auto data() const -> const T*
- 
              auto operator[](std::size_t col) -> Vector<rows, T>& constexpr 
- Column at given position.
- 
              auto operator[](std::size_t col) const -> const Vector<rows, T>& constexpr 
- 
              auto row(std::size_t row) const -> Vector<cols, T> 
- Row at given position.
- 
              void setRow(std::size_t row, const Vector<cols, T>& data) 
- Set matrix row.
- auto operator==(const RectangularMatrix<cols, rows, T>& other) const -> bool
- Equality comparison.
- auto operator!=(const RectangularMatrix<cols, rows, T>& other) const -> bool
- Non-equality comparison.
- auto operator<(const RectangularMatrix<cols, rows, T>& other) const -> BitVector<cols*rows>
- Component-wise less than.
- auto operator<=(const RectangularMatrix<cols, rows, T>& other) const -> BitVector<cols*rows>
- Component-wise less than or equal.
- auto operator>=(const RectangularMatrix<cols, rows, T>& other) const -> BitVector<cols*rows>
- Component-wise greater than or equal.
- auto operator>(const RectangularMatrix<cols, rows, T>& other) const -> BitVector<cols*rows>
- Component-wise greater than.
- auto operator+() const -> RectangularMatrix<cols, rows, T> new in Git master
- Promotion.
- auto operator-() const -> RectangularMatrix<cols, rows, T>
- Negated matrix.
- auto operator+=(const RectangularMatrix<cols, rows, T>& other) -> RectangularMatrix<cols, rows, T>&
- Add and assign a matrix.
- auto operator+(const RectangularMatrix<cols, rows, T>& other) const -> RectangularMatrix<cols, rows, T>
- Add a matrix.
- auto operator-=(const RectangularMatrix<cols, rows, T>& other) -> RectangularMatrix<cols, rows, T>&
- Subtract and assign a matrix.
- auto operator-(const RectangularMatrix<cols, rows, T>& other) const -> RectangularMatrix<cols, rows, T>
- Subtract a matrix.
- auto operator*=(T scalar) -> RectangularMatrix<cols, rows, T>&
- Multiply with a scalar and assign.
- auto operator*(T scalar) const -> RectangularMatrix<cols, rows, T>
- Multiply with a scalar.
- auto operator/=(T scalar) -> RectangularMatrix<cols, rows, T>&
- Divide with a scalar and assign.
- auto operator/(T scalar) const -> RectangularMatrix<cols, rows, T>
- Divide with a scalar.
- 
              template<std::auto operator*(const RectangularMatrix<size, cols, T>& other) const -> RectangularMatrix<size, rows, T>size_t size> 
- Multiply a matrix.
- auto operator*(const Vector<cols, T>& other) const -> Vector<rows, T>
- Multiply a vector.
- auto transposed() const -> RectangularMatrix<rows, cols, T>
- Transposed matrix.
- auto flippedCols() const -> RectangularMatrix<cols, rows, T> constexpr
- Matrix with flipped cols.
- auto flippedRows() const -> RectangularMatrix<cols, rows, T> constexpr
- Matrix with flipped rows.
- auto diagonal() const -> Vector<DiagonalSize, T> constexpr
- Values on diagonal.
- auto toVector() const -> Vector<rows*cols, T>
- Convert matrix to vector.
Friends
- auto operator*(T scalar, const RectangularMatrix<cols, rows, T>& matrix) -> RectangularMatrix<cols, rows, T>
- Multiply a scalar with a matrix.
- auto operator/(T scalar, const RectangularMatrix<cols, rows, T>& matrix) -> RectangularMatrix<cols, rows, T>
- Divide a matrix with a scalar and invert.
Enum documentation
              
                template<std::
            | Enumerators | |
|---|---|
| Cols | Matrix column count | 
| Rows | Matrix row count | 
| DiagonalSize | Size of matrix diagonal | 
Function documentation
              
                template<std::
            Matrix from an array.
| Returns | Reference to the data as if it was matrix, thus doesn't perform any copying. | 
|---|
Use with caution, the function doesn't check whether the array is long enough. If possible, prefer to use the RectangularMatrix(const T(&)[cols_
              
                template<std::
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
              
                template<std::
            Construct a matrix from a vector.
Rolls the vector into matrix, i.e. first rows elements of the vector will make first column of resulting matrix.
              
                template<std::
            Construct a diagonal matrix.
              
                template<std::
            Default constructor.
Equivalent to RectangularMatrix(ZeroInitT).
              
                template<std::
            Construct a zero-filled matrix.
              
                template<std::
            Construct an identity matrix.
For non-square matrices, the diagonal has DiagonalSize elements. The value allows you to specify a value on diagonal.
              
                template<std::
            Construct from a fixed-size array.
Use from(const T*) to reinterpret an arbitrary pointer to a matrix.
              
                template<std::
            Construct from a matrix of a different type.
Performs only default casting on the values, no rounding or anything else. Example usage:
Math::RectangularMatrix<4, 1, Float> floatingPoint{1.3f, 2.7f, -15.0f, 7.0f}; Math::RectangularMatrix<4, 1, Byte> integral{floatingPoint}; // {1, 2, -15, 7}
              
                template<std::
            Construct by slicing or expanding a matrix of different size, leaving the rest at zero.
If the other matrix has less columns or rows, the corresponding vectors and components are set to zeros.
              
                template<std::
            Construct by slicing or expanding a matrix of different size, leaving the rest at identity.
If the other matrix has less columns or rows, the corresponding vectors and components are set to either zeros or value on the diagonal.
              
                template<std::
            Construct by slicing or expanding a matrix of different size.
Equivalent to RectangularMatrix(ZeroInitT, const RectangularMatrix<otherCols, otherRows, T>&). Note that this default is different from Matrix, where it's equivalent to the IdentityInit variant instead.
              
                template<std::
            Raw data.
Contrary to what Doxygen shows, returns reference to an one-dimensional fixed-size array of cols*rows elements, i.e. T(&)[cols*rows].
              
                template<std::
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
              
                template<std::
            Column at given position.
Particular elements can be accessed using Vector::
Matrix4x3 m; Float a = m[2][1];
              
                template<std::
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
              
                template<std::
            Row at given position.
Consider using transposed() when accessing rows frequently, as this is slower than accessing columns due to the way the matrix is stored.
              
                template<std::
            Set matrix row.
Consider using transposed() when accessing rows frequently, as this is slower than accessing columns due to the way the matrix is stored.
              
                template<std::
            Equality comparison.
Done by comparing the underlying vectors, which internally uses TypeTraits::
              
                template<std::
            Non-equality comparison.
Done by comparing the underlying vectors, which internally uses TypeTraits::
              
                template<std::
            Component-wise less than.
Calls Vector::
              
                template<std::
            Component-wise less than or equal.
Calls Vector::
              
                template<std::
            Component-wise greater than or equal.
Calls Vector::
              
                template<std::
            Component-wise greater than.
Calls Vector::
              
                template<std::
            Promotion.
Returns the value as-is.
              
                template<std::
            Negated matrix.
The computation is done column-wise.
              
                template<std::
            Add and assign a matrix.
The computation is done column-wise in-place.
              
                template<std::
            Add a matrix.
              
                template<std::
            Subtract and assign a matrix.
The computation is done column-wise in-place.
              
                template<std::
            Subtract a matrix.
              
                template<std::
            Multiply with a scalar and assign.
The computation is done column-wise in-place.
              
                template<std::
            Multiply with a scalar.
              
                template<std::
            Divide with a scalar and assign.
The computation is done column-wise in-place.
              
                template<std::
            Divide with a scalar.
              
              RectangularMatrix<size, rows, T> Magnum::
            Multiply a matrix.
              
                template<std::
            Multiply a vector.
Internally the same as multiplying with a one-column matrix, but returns a vector instead of a one-column matrix.
Vectors are treated as columns. An equivalent operation is multiplying a transposed matrix with an one-row matrix from the left side instead:
Matrix3x4 m = …; Vector3 v = …; /* a1 and a2 contain the same data, just transposed */ Vector4 a1 = m*v; Matrix4x1 a2 = Matrix3x1::fromVector(v)*m.transposed();
              
                template<std::
            Transposed matrix.
              
                template<std::
            Matrix with flipped cols.
The order of columns is reversed.
              
                template<std::
            Matrix with flipped rows.
The order of rows is reversed.
              
                template<std::
            Values on diagonal.
              
                template<std::
            Convert matrix to vector.
Returns the matrix unrolled into one large vector, i.e. first column of the matrix will make first rows elements of resulting vector. Useful for performing vector operations with the matrix (e.g. summing the elements etc.).
              
                template<std::
            Multiply a scalar with a matrix.
Same as operator*(T) const.
              
                template<std::
            Divide a matrix with a scalar and invert.
The computation is done column-wise.
              
                template<std::
            Multiply a vector with a rectangular matrix.
Internally the same as multiplying one-column matrix with one-row matrix.
              
                template<std::
            Debug output operator.