Skip to content

Commit

Permalink
Fix implem
Browse files Browse the repository at this point in the history
  • Loading branch information
alkino committed Aug 24, 2023
1 parent 12a9a6f commit a8a0058
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/ivoc/ocmatrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
}
}
Expand All @@ -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;
}
}
}

Expand Down

0 comments on commit a8a0058

Please sign in to comment.