Manipulating Matrices in C++