diff --git a/Numeric/fullMatrix.cpp b/Numeric/fullMatrix.cpp index cd289f5f681821bb3559c15d93d47bd6d1b057dc..d35cf997345f7e0b82ef18d93edf9d6bf4afb0a7 100644 --- a/Numeric/fullMatrix.cpp +++ b/Numeric/fullMatrix.cpp @@ -297,7 +297,7 @@ bool fullMatrix<double>::invert(fullMatrix<double> &result) const { int M = size1(), N = size2(), lda = size1(), info; int *ipiv = new int[std::min(M, N)]; - result = *this; + result.setAll(*this); F77NAME(dgetrf)(&M, &N, result._data, &lda, ipiv, &info); if(info == 0){ int lwork = M * 4; diff --git a/Numeric/fullMatrix.h b/Numeric/fullMatrix.h index ba89fb6086608189007f40f4ecd7a935295fa1c6..8d555d84d370a6c125b4bd41a3fcb58b2ce2c395 100644 --- a/Numeric/fullMatrix.h +++ b/Numeric/fullMatrix.h @@ -251,20 +251,7 @@ class fullMatrix } fullMatrix<scalar> & operator = (const fullMatrix<scalar> &other) { - if(this != &other){ - if (_r != other._r || _c != other._c) { - _r = other._r; - _c = other._c; - if (_data && _own_data) delete[] _data; - if ((_r == 0) || (_c == 0)) - _data=0; - else{ - _data = new scalar[_r * _c]; - _own_data=true; - } - } - for(int i = 0; i < _r * _c; ++i) _data[i] = other._data[i]; - } + copy(other); return *this; } void operator += (const fullMatrix<scalar> &other) @@ -300,6 +287,8 @@ class fullMatrix } void copy(const fullMatrix<scalar> &a) { + if (_data && !_own_data) + Msg::Fatal("fullMatrix::copy operation is prohibited for proxies, use setAll instead"); if (_r != a._r || _c != a._c) { if(_data && _own_data) delete [] _data; @@ -360,6 +349,8 @@ class fullMatrix } inline void setAll(const fullMatrix<scalar> &m) { + if (_r != m._r || _c != m._c ) + Msg::Fatal("fullMatrix size does not match"); for(int i = 0; i < _r * _c; i++) _data[i] = m._data[i]; } void scale(const double s)