// Matrix class template #ifndef MATRIX #define MATRIX const Matrix #include "NumVec.hpp" template class Matrix : public NumVec {int lbRows; size_t extentRows; int lbCols; size_t extentCols; public: // Constructors and accessors // -------------------------- Matrix (SIZET m, SIZET n) : NumVec(m*n), lbRows(0), extentRows(m), lbCols(0), extentCols(n) {} Matrix (SIZET lb1, SIZET hb1, SIZET lb2, SIZET hb2) : NumVec((hb1-lb1+1)*(hb2-lb2+1)), lbRows(lb1), extentRows(hb1-lb1+1), lbCols(lb2), extentCols(hb2-lb2+1) {} int lboundRows() {return lbRows;} int hboundRows() {return lbRows + extentRows - 1;} int dimRows() {return extentRows;}; int lboundCols() {return lbCols;} int hboundCols() {return lbRows + extentCols - 1;} int dimCols() {return extentCols;}; // Subscript operator // ------------------ T& operator() (INT j, INT k) {assert(lbRows <= j && j <= lbRows + extentRows-1 && lbCols <= k && k <= lbCols + extentCols-1); return (*this)[(j-lbRows)*extentCols + (k-lbCols)]; } const T& operator() (INT j, INT k) const {assert(lbRows <= j && j <= lbRows + extentRows-1 && lbCols <= k && k <= lbCols + extentCols-1); return (*this)[(j-lbRows)*extentCols + (k-lbCols)]; } }; #endif