C++ class for matrix operations