-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
treeset: use eigen instead of sparse13 #2643
Changes from 27 commits
5c5c730
42fa353
52816fc
7b93bc5
e85f753
29c58af
6ce1dcb
20e595b
2abf500
6e03f48
6e2eb67
135fc52
8794fda
d52b91e
c4ae1a0
dfbc7ac
ad75001
94276eb
92b0857
a2eae5e
3e64192
e08cef1
f17b925
cbd6995
09546eb
3706ba0
61aca57
846364d
f4bc02d
40d6844
bd7248d
299d2ed
e1df5f2
9541fd9
6b411b6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ | |
#include "utils/profile/profiler_interface.h" | ||
#include "nonvintblock.h" | ||
#include "nrncvode.h" | ||
#include "spmatrix.h" | ||
#include <Eigen/Eigen> | ||
|
||
#include <vector> | ||
|
||
|
@@ -672,11 +672,11 @@ void nrn_print_matrix(NrnThread* _nt) { | |
Node* nd; | ||
if (use_sparse13) { | ||
if (ifarg(1) && chkarg(1, 0., 1.) == 0.) { | ||
spPrint(_nt->_sp13mat, 1, 0, 1); | ||
std::cout << &_nt->_sparseMat << std::endl; | ||
} else { | ||
int i, n = spGetSize(_nt->_sp13mat, 0); | ||
spPrint(_nt->_sp13mat, 1, 1, 1); | ||
for (i = 1; i <= n; ++i) { | ||
std::cout << &_nt->_sparseMat << std::endl; | ||
int n = _nt->_sparseMat->cols(); | ||
for (int i = 1; i <= n; ++i) { | ||
Comment on lines
-675
to
+679
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What should we do about that? I'm for removing... |
||
Printf("%d %g\n", i, _nt->actual_rhs(i)); | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,10 @@ actual_v, etc. | |
*/ | ||
|
||
#include "membfunc.h" | ||
namespace Eigen { | ||
template <typename _Scalar, int _Options, typename _StorageIndex> | ||
class SparseMatrix; | ||
} | ||
Comment on lines
+30
to
+33
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file is installed and use, so if we include |
||
|
||
#include <cstddef> | ||
|
||
|
@@ -89,12 +93,12 @@ struct NrnThread { | |
int* _v_parent_index; | ||
Node** _v_node; | ||
Node** _v_parent; | ||
double* _sp13_rhs; /* rhs matrix for sparse13 solver. updates to and from this vector | ||
need to be transfered to actual_rhs */ | ||
char* _sp13mat; /* handle to general sparse matrix */ | ||
Memb_list* _ecell_memb_list; /* normally nullptr */ | ||
Node** _ecell_children; /* nodes with no extcell but parent has it */ | ||
void* _vcv; /* replaces old cvode_instance and nrn_cvode_ */ | ||
double* _sparse_rhs; /* rhs matrix for sparse13 solver. updates to and from this vector | ||
need to be transfered to actual_rhs */ | ||
Eigen::SparseMatrix<double, 1, int>* _sparseMat{}; /* handle to general sparse matrix */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We give number otherwise we have to declare the enum behind the option and I have no idea how to do that without conflict at resolution... |
||
Memb_list* _ecell_memb_list; /* normally nullptr */ | ||
Node** _ecell_children; /* nodes with no extcell but parent has it */ | ||
void* _vcv; /* replaces old cvode_instance and nrn_cvode_ */ | ||
|
||
#if 1 | ||
double _ctime; /* computation time in seconds (using nrnmpi_wtime) */ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,7 +57,8 @@ node.v + extnode.v[0] | |
#include "nrnmpiuse.h" | ||
#include "ocnotify.h" | ||
#include "section.h" | ||
#include "spmatrix.h" | ||
#include <Eigen/Eigen> | ||
#include <Eigen/LU> | ||
#include "treeset.h" | ||
|
||
#include <stdio.h> | ||
|
@@ -364,22 +365,13 @@ void nrn_solve(NrnThread* _nt) { | |
} | ||
#else | ||
if (use_sparse13) { | ||
int e; | ||
nrn_thread_error("solve use_sparse13"); | ||
update_sp13_mat_based_on_actual_d(_nt); | ||
e = spFactor(_nt->_sp13mat); | ||
if (e != spOKAY) { | ||
switch (e) { | ||
case spZERO_DIAG: | ||
hoc_execerror("spFactor error:", "Zero Diagonal"); | ||
case spNO_MEMORY: | ||
hoc_execerror("spFactor error:", "No Memory"); | ||
case spSINGULAR: | ||
hoc_execerror("spFactor error:", "Singular"); | ||
} | ||
} | ||
update_sp13_rhs_based_on_actual_rhs(_nt); | ||
spSolve(_nt->_sp13mat, _nt->_sp13_rhs, _nt->_sp13_rhs); | ||
_nt->_sparseMat->makeCompressed(); | ||
Eigen::SparseLU<Eigen::SparseMatrix<double, Eigen::RowMajor>> lu(*_nt->_sparseMat); | ||
Eigen::Map<Eigen::VectorXd> rhs(_nt->_sparse_rhs + 1, _nt->_sparseMat->cols()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. other joke of |
||
rhs = lu.solve(rhs); | ||
update_actual_d_based_on_sp13_mat(_nt); | ||
update_actual_rhs_based_on_sp13_rhs(_nt); | ||
} else { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a joke of
sparse13
I can explain that (this is funny)