#ifndef MATRIX_PROXY_H #define MATRIX_PROXY_H #include "matrix_expression.h" #include "matrix.h" /***************************************************** * matrix_proxy class ****************************************************/ class matrix_proxy : public matrix_expression { private: matrix_expression& _src; // reference to the underlying source (which may be matrix or proxy) matrix _rows; // copy of matrix expression describing extent of rows matrix _cols; // copy of matrix expression describing extent of columns public: // use inherited assignment operator (rather than default) using matrix_expression::operator=; matrix_proxy& operator=(const matrix_proxy& other); // we need following declaration to properly inherit the version of // operator() for submatrices. Then we can define our additional ones. using matrix_expression::operator(); // constructor matrix_proxy(matrix_expression& src, const matrix_expression& rows, const matrix_expression& ccols); int numRows() const; int numColumns() const; // Determine source of underlying storage const matrix_expression& underlyingStorage() const; // read-only version of indexing operator double operator()(int r, int c) const; // write-access version of indexing operator double& operator()(int r, int c); }; #endif