Skip to content

Commit

Permalink
References for 'BlueBrain/nmodl#1349'.
Browse files Browse the repository at this point in the history
  • Loading branch information
GitHub Actions Bot committed Jul 16, 2024
1 parent 237859f commit f310173
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
7 changes: 6 additions & 1 deletion global/neuron/thread_newton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,9 @@ EIGEN_DEVICE_FUNC int newton_solver(Eigen::Matrix<double, N, 1>& X,
// we have converged: return iteration count
return iter;
}
Eigen::Matrix<double, N, 1> X_solve;

#if defined(CORENEURON_ENABLE_GPU)
// In Eigen the default storage order is ColMajor.
// Crout's implementation requires matrices stored in RowMajor order (C-style arrays).
// Therefore, the transposeInPlace is critical such that the data() method to give the rows
Expand All @@ -290,8 +293,10 @@ EIGEN_DEVICE_FUNC int newton_solver(Eigen::Matrix<double, N, 1>& X,
// Check if J is singular
if (nmodl::crout::Crout<double>(N, J.data(), pivot.data(), rowmax.data()) < 0)
return -1;
Eigen::Matrix<double, N, 1> X_solve;
nmodl::crout::solveCrout<double>(N, J.data(), F.data(), X_solve.data(), pivot.data());
#else
X_solve = J.partialPivLu().solve(F);
#endif
X -= X_solve;
}
// If we fail to converge after max_iter iterations, return -1
Expand Down
7 changes: 6 additions & 1 deletion kinetic/coreneuron/X2Y.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,9 @@ EIGEN_DEVICE_FUNC int newton_solver(Eigen::Matrix<double, N, 1>& X,
// we have converged: return iteration count
return iter;
}
Eigen::Matrix<double, N, 1> X_solve;

#if defined(CORENEURON_ENABLE_GPU)
// In Eigen the default storage order is ColMajor.
// Crout's implementation requires matrices stored in RowMajor order (C-style arrays).
// Therefore, the transposeInPlace is critical such that the data() method to give the rows
Expand All @@ -299,8 +302,10 @@ EIGEN_DEVICE_FUNC int newton_solver(Eigen::Matrix<double, N, 1>& X,
// Check if J is singular
if (nmodl::crout::Crout<double>(N, J.data(), pivot.data(), rowmax.data()) < 0)
return -1;
Eigen::Matrix<double, N, 1> X_solve;
nmodl::crout::solveCrout<double>(N, J.data(), F.data(), X_solve.data(), pivot.data());
#else
X_solve = J.partialPivLu().solve(F);
#endif
X -= X_solve;
}
// If we fail to converge after max_iter iterations, return -1
Expand Down
7 changes: 6 additions & 1 deletion kinetic/neuron/X2Y.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,9 @@ EIGEN_DEVICE_FUNC int newton_solver(Eigen::Matrix<double, N, 1>& X,
// we have converged: return iteration count
return iter;
}
Eigen::Matrix<double, N, 1> X_solve;

#if defined(CORENEURON_ENABLE_GPU)
// In Eigen the default storage order is ColMajor.
// Crout's implementation requires matrices stored in RowMajor order (C-style arrays).
// Therefore, the transposeInPlace is critical such that the data() method to give the rows
Expand All @@ -290,8 +293,10 @@ EIGEN_DEVICE_FUNC int newton_solver(Eigen::Matrix<double, N, 1>& X,
// Check if J is singular
if (nmodl::crout::Crout<double>(N, J.data(), pivot.data(), rowmax.data()) < 0)
return -1;
Eigen::Matrix<double, N, 1> X_solve;
nmodl::crout::solveCrout<double>(N, J.data(), F.data(), X_solve.data(), pivot.data());
#else
X_solve = J.partialPivLu().solve(F);
#endif
X -= X_solve;
}
// If we fail to converge after max_iter iterations, return -1
Expand Down

0 comments on commit f310173

Please sign in to comment.