Example #1
0
static void nrn_jacob(_NrnThread* _nt, _Memb_list* _ml, int _type){
Node *_nd; int* _ni; int _iml, _cntml;
#if CACHEVEC
    _ni = _ml->_nodeindices;
#endif
_cntml = _ml->_nodecount;
for (_iml = 0; _iml < _cntml; ++_iml) {
 _p = _ml->_data[_iml];
#if CACHEVEC
  if (use_cachevec) {
	VEC_D(_ni[_iml]) += _g;
  }else
#endif
  {
     _nd = _ml->_nodelist[_iml];
	NODED(_nd) += _g;
  }
 
}}
Example #2
0
method3_setup_tree_matrix() /* construct diagonal elements */
{
	int i;
	if (diam_changed) {
		recalc_diam();
	}
#if _CRAY
#pragma _CRI ivdep
#endif
	for (i = 0; i < v_node_count; ++i) {
		Node* nd = v_node[i];
		NODED(nd) = 0.;
		NODERHS(nd) = 0.;
		nd->thisnode.GC = 0.;
		nd->thisnode.EC = 0.;
	}
	for (i=0; i < n_memb_func; ++i) if (memb_func[i].current && memb_list[i].nodecount) {
		if (memb_func[i].vectorized) {
			memb_func[i].current(
			   memb_list[i].nodecount,
			   memb_list[i].nodelist,
			   memb_list[i].data,
			   memb_list[i].pdata
			);
		}else{
			int j, count;
			Pfrd s = memb_func[i].current;
			Memb_list* m = memb_list + i;
			count = m->nodecount;
		   if (memb_func[i].is_point) {
			for (j = 0; j < count; ++j) {
				Node* nd = m->nodelist[j];
				NODERHS(nd) -= (*s)(m->data[j], m->pdata[j],
				  		&NODED(nd),nd->v);
			};
		   }else{
			for (j = 0; j < count; ++j) {
				Node* nd = m->nodelist[j];
				nd->thisnode.EC -= (*s)(m->data[j], m->pdata[j],
				  		&nd->thisnode.GC,nd->v);
			};
		   }
		}
		if (errno) {
			if (nrn_errno_check(i)) {
hoc_warning("errno set during calculation of currents", (char*)0);
			}
		}
	}
#if 0 && _CRAY
#pragma _CRI ivdep
#endif
	for (i=rootnodecount; i < v_node_count; ++i) {
		Node* nd2;
		Node* nd = v_node[i];
		Node* pnd = v_parent[nd->v_node_index];
		double dg, de, dgp, dep, fac;

#if 0
if (i == rootnodecount) {
	printf("v0 %g  vn %g  jstim %g  jleft %g jright %g\n",
	nd->v, pnd->v, nd->fromparent.current, nd->toparent.current,
	nd[1].fromparent.current);
}
#endif

		/* dg and de must be second order when used */
		if ((nd2 = nd->toparent.nd2) != (Node*)0) {
			dgp = -(3*(pnd->thisnode.GC - pnd->thisnode.Cdt)
				- 4*(nd->thisnode.GC - nd->thisnode.Cdt)
				+(nd2->thisnode.GC - nd2->thisnode.Cdt))/2
			;
			dep = -(3*(pnd->thisnode.EC - pnd->thisnode.Cdt * pnd->v)
				- 4*(nd->thisnode.EC - nd->thisnode.Cdt * nd->v)
				+(nd2->thisnode.EC - nd2->thisnode.Cdt * nd2->v))/2
			;
		}else{
			dgp = 0.;
			dep = 0.;
		}

		if ((nd2 = pnd->fromparent.nd2) != (Node*)0) {
			dg = -(3*(nd->thisnode.GC - nd->thisnode.Cdt)
				- 4*(pnd->thisnode.GC - pnd->thisnode.Cdt)
				+(nd2->thisnode.GC - nd2->thisnode.Cdt))/2
			;
			de = -(3*(nd->thisnode.EC - nd->thisnode.Cdt * nd->v)
				- 4*(pnd->thisnode.EC - pnd->thisnode.Cdt * pnd->v)
				+(nd2->thisnode.EC - nd2->thisnode.Cdt * nd2->v))/2
			;
		}else{
			dg = 0.;
			de = 0.;
		}

		fac = 1. + nd->toparent.coefjdot * nd->thisnode.GC;
		nd->toparent.djdv0 = (
			nd->toparent.coefj
			+ nd->toparent.coef0 * nd->thisnode.GC
			+ nd->toparent.coefdg * dg
			)/fac;
		NODED(nd) += nd->toparent.djdv0;
		nd->toparent.current = (
			- nd->toparent.coef0 * nd->thisnode.EC
			- nd->toparent.coefn * pnd->thisnode.EC
			+ nd->toparent.coefjdot * 
				nd->thisnode.Cdt * nd->toparent.current
			- nd->toparent.coefdg * de
			)/fac;
		NODERHS(nd) -= nd->toparent.current;
		NODEB(nd) = (
			- nd->toparent.coefj
			+ nd->toparent.coefn * pnd->thisnode.GC
			)/fac;

		/* this can break cray vectors */
		fac = 1. + nd->fromparent.coefjdot * pnd->thisnode.GC;
		nd->fromparent.djdv0 = (
			nd->fromparent.coefj
			+ nd->fromparent.coef0 * pnd->thisnode.GC
			+ nd->fromparent.coefdg * dgp
			)/fac;
		pNODED(nd) += nd->fromparent.djdv0;
		nd->fromparent.current = (
			- nd->fromparent.coef0 * pnd->thisnode.EC
			- nd->fromparent.coefn * nd->thisnode.EC
			+ nd->fromparent.coefjdot * 
				nd->thisnode.Cdt * nd->fromparent.current
			- nd->fromparent.coefdg * dep
			)/fac;
		pNODERHS(nd) -= nd->fromparent.current;
		NODEA(nd) = (
			- nd->fromparent.coefj
			+ nd->fromparent.coefn * nd->thisnode.GC
			)/fac;
	}
	activstim();
	activsynapse();
#if SEJNOWSKI
	activconnect();
#endif
	activclamp();
}