Skip to content
This repository was archived by the owner on Mar 25, 2025. It is now read-only.

Commit 1f8f3c1

Browse files
committed
Use Eigen on CPUs.
1 parent 25da002 commit 1f8f3c1

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/solver/newton/newton.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ EIGEN_DEVICE_FUNC int newton_solver(Eigen::Matrix<double, N, 1>& X,
9595
if (is_converged(X, J, F, eps)) {
9696
return iter;
9797
}
98+
Eigen::Matrix<double, N, 1> X_solve;
99+
100+
#if defined(CORENEURON_ENABLE_GPU)
98101
// In Eigen the default storage order is ColMajor.
99102
// Crout's implementation requires matrices stored in RowMajor order (C-style arrays).
100103
// Therefore, the transposeInPlace is critical such that the data() method to give the rows
@@ -107,9 +110,10 @@ EIGEN_DEVICE_FUNC int newton_solver(Eigen::Matrix<double, N, 1>& X,
107110
// Check if J is singular
108111
if (nmodl::crout::Crout<double>(N, J.data(), pivot.data(), rowmax.data()) < 0) {
109112
return -1;
110-
}
111-
Eigen::Matrix<double, N, 1> X_solve;
112113
nmodl::crout::solveCrout<double>(N, J.data(), F.data(), X_solve.data(), pivot.data());
114+
#else
115+
X_solve = J.partialPivLu().solve(F);
116+
#endif
113117
X -= X_solve;
114118
}
115119
// If we fail to converge after max_iter iterations, return -1

0 commit comments

Comments
 (0)