#ifndef MATRIX_H #define MATRIX_H #include const int null = 0; /** Representa una matriz de reales de nxm **/ class Matrix { private: size_t n; size_t m; double* entries; public: Matrix(); Matrix(size_t rows, size_t cols); Matrix(const Matrix& other); const Matrix& operator=(const Matrix& other); ~Matrix(); inline operator bool() const { return entries; } inline bool operator!() const { return ! entries; } inline size_t rows() const { return n; } inline size_t cols() const { return m; } inline double& operator()(size_t i, size_t j) { return entries[i * m + j]; } inline const double& operator()(size_t i, size_t j) const { return entries[i * m + j]; } Matrix operator+(const Matrix& other) const; Matrix operator-(const Matrix& other) const; Matrix operator*(double r) const; Matrix operator*(const Matrix& other) const; inline const Matrix& operator+=(const Matrix& other) { return (*this) = (*this) + other; } inline const Matrix& operator-=(const Matrix& other) { return (*this) = (*this) - other; } inline const Matrix& operator*=(double r) { return (*this) = (*this) * r; } inline const Matrix& operator*=(const Matrix& other) { return (*this) = (*this) * other; } public: friend std::istream& operator>>(std::istream& input, Matrix& entries); }; inline Matrix operator*(double r, const Matrix& matrix) { return matrix * r; } std::istream& operator>>(std::istream& input, Matrix& matrix); std::ostream& operator<<(std::ostream& output, const Matrix& matrix); #endif // MATRIZ_H