Created
May 12, 2009 21:18
-
-
Save moritz/110739 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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