Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

QVM: Quaternions, Vectors, Matrices

Accessing Matrix Elements

#include <boost/qvm/mat_access.hpp>

namespace boost
{
    namespace qvm
    {
        //Only enabled if:
        //  is_quat<Q>::value
        
        template <int R,int C,class M> -unspecified-return-type- A( M & m );
        
        template <class M> -unspecified-return-type- A00( M & m );
        template <class M> -unspecified-return-type- A01( M & m );
        ...
        template <class M> -unspecified-return-type- A09( M & m );
        template <class M> -unspecified-return-type- A10( M & m );
        ...
        template <class M> -unspecified-return-type- A99( M & m );
    }
}

An expression of the form A<R,C>(m) can be used to access the element at row R and column C of a matrix object m. For example, the expression:

A<4,2>(m) *= 42;

can be used to multiply the element at row 4 and column 2 of a matrix m by 42.

For convenience, there are also non-template overloads for R from 0 to 9 and C from 0 to 9; an alternative way to write the above expression is:

A42(m) *= 42;