diff --git a/src/ivoc/ocmatrix.cpp b/src/ivoc/ocmatrix.cpp index dda8336e00..e0e6843814 100644 --- a/src/ivoc/ocmatrix.cpp +++ b/src/ivoc/ocmatrix.cpp @@ -232,7 +232,11 @@ double* OcSparseMatrix::mep(int i, int j) { } void OcSparseMatrix::zero() { - m_.setZero(); + for (int k = 0; k < m_.outerSize(); ++k) { + for (decltype(m_)::InnerIterator it(m_, k); it; ++it) { + it.valueRef() = 0.; + } + } } double OcSparseMatrix::getval(int i, int j) { @@ -288,7 +292,7 @@ void OcSparseMatrix::setdiag(int k, Vect* in) { } } else { for (int i = -k, j = 0; i < row && j < col; ++i, ++j) { - m_.coeffRef(i, j) = in->elem(i); + m_.coeffRef(i, j) = in->elem(j); } } } @@ -313,8 +317,15 @@ void OcSparseMatrix::ident(void) { void OcSparseMatrix::setdiag(int k, double in) { int row = m_.rows(); - for (int i = 0; i < row; ++i) { - m_.coeffRef(i, i) = in; + int col = m_.cols(); + if (k >= 0) { + for (int i = 0, j = k; i < row && j < col; ++i, ++j) { + m_.coeffRef(i, j) = in; + } + } else { + for (int i = -k, j = 0; i < row && j < col; ++i, ++j) { + m_.coeffRef(i, j) = in; + } } }