I would not recommend doing this from a code design standpoint, as a linear algebra library is not something you are likely to replace. So encapsulating it will most likely not be beneficial and will make your code more complicated. However if you really want to do this, you would use template specialization. Something along the lines of the following:
template< typename InternalMatrixType>
class Matrix
{
private:
InternalMatrixType _matrix;
public:
// Example function
float operator[](unsigned index)
{
return _matrix[index];
}
};
For a particular linear algebra library:
template<>
class Matrix<EigenMatrixType>
{
private:
EigenMatrixType _matrix;
public:
// Example function
float operator[](unsigned index)
{
return _matrix.get(index);
}
};
Edit: Added information on typedefs to clarify usage. Based on below comment from moodle.
Throughout the library you could then typedef the template class. This will allow you to use something like cMatrix
vs Matrix<InternalMatrixType>
.
typedef Matrix<InternalMatrixType> cMatrix;