This template represents 2x2 matrix. It uses row major order of data.
You can find more information in comments below.
template<class TYPE>
union TMat2
{
    struct
    {
        TYPE _11, _12; // First row
        TYPE _21, _22; // Second row
    };
    TVec2<TYPE> Rows[2]; // Rows as vectors
    TYPE Data[4]; // Elements as array
    TMatrix<TYPE, 2, 2> M; // As TMatrix
    TMat2() = default;
    TMat2(const TMat2 &other) = default;
    TMat2(TMat2 &&other) = default;
    // Create with specified elements
    TMat2(
        const TYPE m11, const TYPE m12,
        const TYPE m21, const TYPE m22);
    // Create with specified rows
    TMat2(const TVec2<TYPE> &row1, const TVec2<TYPE> &row2);
    // Create diagonal matrix
    TMat2(const TYPE diagonal, const TYPE other);
    // Create from TMatrix
    TMat2(const TMatrix<TYPE, 2, 2> &m);
    TMat2 &operator=(const TMat2 &other) = default;
    TMat2 &operator=(TMat2 &&other) = default;
    TVec2<TYPE> operator[](const size_t row) const; // Return specified row. Used when matrix is a constant
    TVec2<TYPE> &operator[](const size_t row); // Return specified row
};Additionally following operators exists.
template<class TYPE>
bool operator==(const TMat2<TYPE> &a, const TMat2<TYPE> &b); // Check whether matrices are equal. Can be used for non-float data types onlytemplate<class TYPE>
bool operator!=(const TMat2<TYPE> &a, const TMat2<TYPE> &b); // Check whether matrices aren't equal. Can be used for non-float data types onlytemplate<class TYPE>
TMat2<TYPE> operator+(const TMat2<TYPE> &m, const TYPE val); // Add matrix and scalartemplate<class TYPE>
TMat2<TYPE> operator-(const TMat2<TYPE> &m, const TYPE val); // Subtruct matrix and scalartemplate<class TYPE>
TMat2<TYPE> operator*(const TMat2<TYPE> &m, const TYPE val); // Multiply matrix and scalartemplate<class TYPE>
TMat2<TYPE> operator/(const TMat2<TYPE> &m, const TYPE val); // Divide matrix and scalartemplate<class TYPE>
TMat2<TYPE> operator+(const TYPE val, const TMat2<TYPE> &m); // Add scalar and matrixtemplate<class TYPE>
TMat2<TYPE> operator-(const TYPE val, const TMat2<TYPE> &m); // Subtruct scalar and matrixtemplate<class TYPE>
TMat2<TYPE> operator*(const TYPE val, const TMat2<TYPE> &m); // Multiply scalar and matrixtemplate<class TYPE>
TMat2<TYPE> operator/(const TYPE val, const TMat2<TYPE> &m); // Divide scalar and matrixtemplate<class TYPE>
TMat2<TYPE> &operator+=(TMat2<TYPE> &m, const TYPE val); // Add scalar to matrixtemplate<class TYPE>
TMat2<TYPE> &operator-=(TMat2<TYPE> &m, const TYPE val); // Subtract scalar from matrixtemplate<class TYPE>
TMat2<TYPE> &operator*=(TMat2<TYPE> &m, const TYPE val); // Multiply matrix by scalartemplate<class TYPE>
TMat2<TYPE> &operator/=(TMat2<TYPE> &m, const TYPE val); // Divide matrix by scalartemplate<class TYPE>
TVec2<TYPE> operator*(const TVec2<TYPE> &v, const TMat2<TYPE> &m); // Multiply vector and matrixtemplate<class TYPE>
TVec2<TYPE> operator*(const TMat2<TYPE> &m, const TVec2<TYPE> &v); // Multiply matrix and vectortemplate<class TYPE>
TVec2<TYPE> &operator*=(TVec2<TYPE> &v, const TMat2<TYPE> &m); // Multiply vector by matrixtemplate<class TYPE>
TMat2<TYPE> operator+(const TMat2<TYPE> &a, const TMat2<TYPE> &b); // Add matricestemplate<class TYPE>
TMat2<TYPE> operator-(const TMat2<TYPE> &a, const TMat2<TYPE> &b); // Subtract matricestemplate<class TYPE>
TMat2<TYPE> operator*(const TMat2<TYPE> &a, const TMat2<TYPE> &b); // Multiply matricestemplate<class TYPE>
TMat2<TYPE> &operator+=(TMat2<TYPE> &a, const TMat2<TYPE> &b); // Add matrix to matrixtemplate<class TYPE>
TMat2<TYPE> &operator-=(TMat2<TYPE> &a, const TMat2<TYPE> &b); // Subtract matrix from matrixtemplate<class TYPE>
TMat2<TYPE> &operator*=(TMat2<TYPE> &a, const TMat2<TYPE> &b); // Multiply matrix by matrixAlso there are some functions which can be used with TMat2 template. Here they are.
| Namespace: | ntl | 
| Include: | NTL/Core/Mat2.h |