Go to the documentation of this file.
70 template <enabled_code code_to_enable = enabled_code::all>
74 unsigned vrow = so->
varord[row];
75 unsigned vcol = so->
varord[col];
78 return so->
diag[vrow];
82 for (el = so->
diag[vcol];; el = elnext) {
86 }
else if (elnext->
row == row) {
88 }
else if (so->
varord[elnext->
row] > vrow) {
110 for (el = so->
diag[vrow];; el = elnext) {
114 }
else if (so->
varord[elnext->
col] < vcol) {
125 so->
rowst[vrow] = new_elem;
129 for (el = so->
diag[vcol];; el = elnext) {
133 }
else if (elnext->
row == row) {
135 }
else if (so->
varord[elnext->
row] < vrow) {
144 new_elem =
new Elm{};
152 if (new_elem->
r_up) {
156 for (el = so->
diag[vrow];; el = elnext) {
160 }
else if (so->
varord[elnext->
col] > vcol) {
198 for (
Item* i1 = list->
next; i1 != list; i1 = i2) {
207 for (
unsigned i = 1;
i <= so->
neqn;
i++) {
214 assert(el->c_left ==
nullptr);
216 assert(el->c_left->c_right == el);
217 assert(so->
varord[el->c_left->col] < so->
varord[el->col]);
221 assert(el->r_up->r_down == el);
222 assert(so->
varord[el->r_up->row] < so->
varord[el->row]);
225 assert(el->r_down->r_up == el);
226 assert(so->
varord[el->r_down->row] > so->
varord[el->row]);
237 el->r_up->r_down = el->r_down;
239 el->r_down->r_up = el->r_up;
245 el->c_right->c_left = el->c_left;
247 el->c_left->c_right = el->c_right;
267 Elm *dright, *dleft, *dup, *ddown, *elnext;
276 for (
Elm* el = dright; el; el = elnext) {
278 getelm(so, el->row, el->col, el);
280 for (
Elm* el = dleft; el; el = elnext) {
282 getelm(so, el->row, el->col, el);
284 for (
Elm* el = dup; el; el = elnext) {
286 getelm(so, el->row, el->col, el);
288 for (
Elm* el = ddown; el; el = elnext) {
290 getelm(so, el->row, el->col, el);
296 for (
unsigned i = 1;
i <= so->
neqn;
i++) {
298 so->
diag[
i] =
nullptr;
320 for (
unsigned i = 1;
i <= so->
neqn;
i++) {
323 for (
unsigned i = 1;
i <= so->
neqn;
i++) {
371 getelm(so, el->row, pivot->col,
nullptr);
380 if (maxeqn == so->
neqn)
391 so->
diag =
new Elm*[maxeqn + 1];
392 so->
varord =
new unsigned[maxeqn + 1];
395 for (
unsigned i = 1;
i <= maxeqn;
i++) {
406 for (
unsigned i = 0;
i < nn; ++
i) {
419 for (
unsigned i = 1;
i <= so->
neqn;
i++) {
428 for (
unsigned i = 1;
i <= so->
neqn;
i++) {
430 el->value[_iml] = 0.;
435 #if defined(scopmath_sparse_d) || defined(scopmath_sparse_ix) || defined(scopmath_sparse_s) || \
436 defined(scopmath_sparse_x)
437 #error "naming clash on sparse_thread.hpp-internal macros"
439 #define scopmath_sparse_ix(arg) ((arg) *_STRIDE)
442 double const r{rowsub->
value[_iml] / pivot->
value[_iml]};
446 for (rowsub = rowsub->
c_right; rowsub->
col != el->col; rowsub = rowsub->
c_right) {
448 rowsub->
value[_iml] -= el->value[_iml] * r;
455 for (
unsigned i = so->
neqn;
i >= 1;
i--) {
469 for (
unsigned i = 1;
i <= so->
neqn;
i++) {
471 if (fabs(pivot->value[_iml]) <=
ROUNDOFF) {
478 for (
auto el = pivot->r_down; el; el = el->r_down) {
479 subrow(so, pivot, el, _iml);
486 template <
typename SPFUN>
504 template <enabled_code code_to_enable = enabled_code::all>
509 Elm* el = scopmath::sparse::getelm<code_to_enable>(so, (
unsigned) row, (
unsigned) col,
nullptr);
510 if (so->
phase == 1) {
522 #define scopmath_sparse_s(arg) _p[scopmath_sparse_ix(s[arg])]
523 #define scopmath_sparse_d(arg) _p[scopmath_sparse_ix(d[arg])]
530 template <
typename SPFUN>
560 template <
typename F>
573 for (
i = 0;
i < n;
i++) {
576 for (err = 1, j = 0; err >
CONVERGE; j++) {
582 for (err = 0.,
i = 1;
i <= n;
i++) {
597 for (
i = 0;
i < n;
i++) {
602 #undef scopmath_sparse_d
603 #undef scopmath_sparse_ix
604 #undef scopmath_sparse_s
605 #define scopmath_sparse_x(arg) _p[x[arg] * _STRIDE]
607 template <
typename SPFUN>
621 for (
int i = 1;
i <= n;
i++) {
626 #undef scopmath_sparse_x
#define scopmath_sparse_x(arg)
Elm * getelm(SparseObj *so, unsigned row, unsigned col, Elm *new_elem)
Return pointer to (row, col) element maintaining order in rows.
void check_assert(SparseObj *so)
void create_coef_list(SparseObj *so, int n, SPFUN fun, _threadargsproto_)
void increase_order(SparseObj *so, unsigned row)
void spar_minorder(SparseObj *so)
Minimum ordering algorithm to determine the order that the matrix should be solved.
void init_minorder(SparseObj *so)
THIS FILE IS AUTO GENERATED DONT MODIFY IT.
int matsol(SparseObj *so, int _iml)
void nrn_sparseobj_delete_from_device(SparseObj *so)
void free_elm(SparseObj *so)
void initeqn(SparseObj *so, unsigned maxeqn)
void bksub(SparseObj *so, int _iml)
void linkitem(Item *item, Item *ii)
void re_link(SparseObj *so, unsigned i)
#define scopmath_sparse_s(arg)
List * newlist()
The following routines support the concept of a list.
#define _threadargsproto_
int sparse_thread(SparseObj *so, int n, int *s, int *d, double *t, double dt, F fun, int linflag, _threadargsproto_)
This is an experimental numerical method for SCoP-3 which integrates kinetic rate equations.
void init_coef_list(SparseObj *so, int _iml)
void * nrn_cons_sparseobj(SPFUN fun, int n, Memb_list *ml, _threadargsproto_)
sparse matrix dynamic allocation: create_coef_list makes a list for fast setup, does minimum ordering...
void reduce_order(SparseObj *so, unsigned row)
int _cvode_sparse_thread(void **vpr, int n, int *x, SPFUN fun, _threadargsproto_)
#define scopmath_sparse_ix(arg)
void subrow(SparseObj *so, Elm *pivot, Elm *rowsub, int _iml)
void _nrn_destroy_sparseobj_thread(SparseObj *so)
void get_next_pivot(SparseObj *so, unsigned i)
void delete_item(Item *item)
double * thread_getelm(SparseObj *so, int row, int col, int _iml)
void nrn_sparseobj_copyto_device(SparseObj *so)
#define scopmath_sparse_d(arg)
nrn_pragma_acc(routine vector) static void triang_interleaved2(NrnThread *nt
void insert(SparseObj *so, Item *item)
void freelist(List *list)