#ifndef _matrix_h_ #define _matrix_h_ #include using namespace std; template class Matrix; template ostream & operator << (ostream & os, Matrix & mat); template class Matrix { public: Matrix(int nrows, int ncols); int num_rows(); int num_cols(); virtual ValType & operator()(int i, int j) = 0; protected: int _nrows, _ncols; }; template int Matrix::num_rows() { return _nrows; } template int Matrix::num_cols() { return _ncols; } template Matrix::Matrix(int nrows, int ncols) { _nrows = nrows; _ncols = ncols; } template ostream & operator << (ostream & os, Matrix & mat) { for (int i = 0; i < mat.num_rows(); i++) { for (int j = 0; j < mat.num_cols(); j++) os << mat(i, j) << '\t'; os << endl; } return os; } #endif