#include #include class Matrix { public: Matrix(); Matrix(int x, int y); ~Matrix(); typedef Matrix ThisType; double GetVal( const unsigned int pos_x_, const unsigned int pos_y_ ) const ; void SetVal( const unsigned int pos_x_, const unsigned int pos_y_, const double val_ ) ; void Add(const ThisType& other) ; void Mult( const ThisType& other ) ; void Print( std::ostream& outstream_ = std::cout ) const ; double Dot(const ThisType& other); void Resize(const unsigned int size_); void Resize(const unsigned int size_x, const unsigned int size_y); Matrix& operator= ( const ThisType& other ) { if (AssertSize( other ) ){ for (unsigned int i = 0; i < this->GetSizeX(); i++) for (unsigned int j = 0; j < this->GetSizeY(); j++){ this->SetVal(i,j, other.GetVal(i,j)); } return *this; } } protected: double** m_values; public: inline unsigned int GetSizeX() const { return m_sz_x; } ; inline unsigned int GetSizeY() const { return m_sz_y; } ; protected: unsigned int m_sz_x; unsigned int m_sz_y; inline bool AssertSize( const Matrix& otherMatrix_ ) const { if ( otherMatrix_.GetSizeX() != m_sz_x || otherMatrix_.GetSizeY() != m_sz_y ){ std::cerr << "Size of matrices is not equal" << std::endl; return false; } return true; } inline bool AssertBounds( const unsigned int pos_x_, const unsigned int pos_y_ ) const { if ( pos_x_ > m_sz_x || pos_y_ > m_sz_y ){ std::cerr << "Position exceeds matrix dimensinos" << std::endl; return false; } return true; } inline bool AssertTransposedSize( const Matrix& otherMatrix_ ) const { if ( otherMatrix_.GetSizeX() != m_sz_y ){ std::cerr << "Matrix sizes mismatch" << std::endl; return false; } return true; } };