Implemented the stack and concatenate methods of Matrix.