Skip to content

Instantly share code, notes, and snippets.

@moritz
Created May 12, 2009 21:18
Show Gist options
  • Save moritz/110739 to your computer and use it in GitHub Desktop.
Save moritz/110739 to your computer and use it in GitHub Desktop.
void pseudo_sparse_solve(const eslu * const slu,
const esm &rhs,
esm &result,
const bool adjoint = false) {
assert( rhs.cols() == rhs.rows() );
int n = rhs.cols();
ers setter(result);
Eigen::VectorXcd *invCol = new Eigen::VectorXcd(n);
int transpose_flag;
if (adjoint) {
transpose_flag = Eigen::SvAdjoint;
} else {
transpose_flag = Eigen::SvNoTrans;
}
for (int k=0; k<rhs.outerSize(); ++k) {
Eigen::VectorXcd base(n);
int i = 0;
for (esm::InnerIterator it(rhs,k); it; ++it) {
base(it.col()) = it.value();
i++;
}
if (i != 0) {
slu->solve(base, invCol, transpose_flag);
for (int j = 0; j < n; j++) {
if (abs((*invCol)[j]) > 1e-18) {
setter(j, k) = (*invCol)[j];
}
}
}
}
delete invCol;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment