QVM: Quaternions, Vectors, Matrices

boost/qvm/mat.hpp

This header defines the struct mat template, which acts as a generic matrix type.

Synopsis:

#include <boost/qvm/mat.hpp>

namespace boost
{
    namespace qvm
    {
        template <class T,int Rows,int Cols>
        struct mat
        {
            T a[Rows][Cols];
        
            template <class R>
            operator R() const
                {
                R r;
                assign(r,*this);
                return r;
                }
        };
        
        template <class Matrix>
        struct mat_traits;
        
        template <class T,int Rows,int Cols>
        struct mat_traits< mat<T,Rows,Cols> >
        {
            typedef T scalar_type;
            static int const rows=Rows;
            static int const cols=Cols;
        
            template <int Row,int Col> static scalar_type read_element( mat<T,Rows,Cols> const & x ) { return x.a[Row][Col]; }
            template <int Row,int Col> static scalar_type & write_element( mat<T,Rows,Cols> & x ) { return x.a[Row][Col]; }
        
            static scalar_type read_element_idx( int row, int col, mat<T,Rows,Cols> const & x ) { return x.a[row][col]; }
            static scalar_type & write_element_idx( int row, int col, mat<T,Rows,Cols> & x ) { return x.a[row][col]; }
        };
    }
}

See also: mat