Skip to content

Commit

Permalink
analyze sparse pattern once
Browse files Browse the repository at this point in the history
  • Loading branch information
michel2323 committed Apr 17, 2018
1 parent 880f88c commit 2482ad6
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion include/ad.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,19 @@ template <class T> void integrate(pVector<T> &x) {
std::vector<Eigen::Triplet<T> > tripletList;
tripletList.reserve(y.dim()*y.dim());
SparseLU<SparseMatrix<T> > solver;
#ifdef EIGEN_SPARSE
sys->jac_beuler<T>(x, xold, J);
for(size_t i = 0; i < J.nrows(); ++i) {
for (size_t j = 0; j < J.ncols(); ++j) {
if(J[i][j] != 0.0) {
tripletList.push_back(Eigen::Triplet<T>(i,j, J[i][j]));
}
}
}
sJ.setFromTriplets(tripletList.begin(), tripletList.end());
tripletList.clear();
solver.analyzePattern(sJ);
#endif
#endif
do {
iteration = iteration + 1;
Expand All @@ -469,7 +482,6 @@ template <class T> void integrate(pVector<T> &x) {
}
sJ.setFromTriplets(tripletList.begin(), tripletList.end());
tripletList.clear();
solver.analyzePattern(sJ);
solver.compute(sJ);
eigymap = solver.solve(eigymap);
#elif EIGEN
Expand Down

0 comments on commit 2482ad6

Please sign in to comment.