Matrix template implemented in C++