diff --git a/include/internal/Matrix.h b/include/internal/Matrix.h index d26c19e..d34a91e 100644 --- a/include/internal/Matrix.h +++ b/include/internal/Matrix.h @@ -394,9 +394,9 @@ void Matrix::resize(size_type rows, size_type columns, const T& initialValu this->_matEls.resize(newSize); this->_rows = rows; this->_columns = columns; - for(size_type i = 0; i < oldRows; i++) + for(size_type i = 0; i < (oldRows > rows ? rows : oldRows); i++) { - for(size_type j = 0; j < oldColumns; j++) + for(size_type j = 0; j < (oldColumns > columns ? columns : oldColumns); j++) { this->at(i,j) = oldMat.at(i,j); } @@ -482,6 +482,7 @@ bool Matrix::operator!=(const Matrix& rhs) return !(*this == rhs); } +//FIXME: Consider non-square matrices template void Matrix::transpose_inplace() { @@ -689,28 +690,32 @@ Matrix,M> operator-(const Matrix& lhs, const Matrix Matrix& Matrix::operator+=(const Matrix& rhs) { - (*this) = (*this) + rhs; + std::transform(this->begin(),this->end(),rhs.begin(),this->begin(),std::plus()); +// (*this) = (*this) + rhs; return *this; } template Matrix& Matrix::operator-=(const Matrix& rhs) { - (*this) = (*this) - rhs; + std::transform(this->begin(),this->end(),rhs.begin(),this->begin(),std::minus()); +// (*this) = (*this) - rhs; return *this; } template Matrix& Matrix::operator*=(const Matrix& rhs) { - (*this) = (*this) * rhs; + std::transform(this->begin(),this->end(),rhs.begin(),this->begin(),std::multiplies()); +// (*this) = (*this) * rhs; return *this; } template Matrix& Matrix::operator*=(const T& rhs) { - (*this) = (*this) * rhs; + std::transform(this->begin(),this->end(),this->begin(),std::bind2nd(std::multiplies(),rhs)); +// (*this) = (*this) * rhs; return *this; }