static double queue_mode(void* v) { hoc_return_type_code = 1; // integer #if BBTQ == 3 || BBTQ == 4 if (ifarg(1)) { nrn_use_fifo_queue_ = chkarg(1, 0, 1) ? true : false; } return double(nrn_use_fifo_queue_); #endif #if BBTQ == 5 if (ifarg(1)) { nrn_use_bin_queue_ = chkarg(1, 0, 1) ? true : false; } if (ifarg(2)) { #if NRNMPI nrn_use_selfqueue_ = chkarg(2, 0, 1) ? 1 : 0; #else if (chkarg(2, 0, 1)) { hoc_warning("CVode.queue_mode with second arg == 1 requires", "configuration --with-mpi or related"); } #endif } return double(nrn_use_bin_queue_ + 2*nrn_use_selfqueue_); #endif return 0.; }
static double aiset(void* v) { if (nrndaq_) { u32 nchan = (u32)chkarg(1, 0, 16); double tstep = chkarg(2, .025, 10000.); nrndaq_->ai_setup(nchan, tstep); } return 0.; }
static double r_binomial(void* r) { Rand* x = (Rand*)r; int a1 = int(chkarg(1, 0, 1e99)); double a2 = chkarg(2, 0, 1); delete x->rand; x->rand = new Binomial(a1, a2, x->gen); return (*(x->rand))(); }
static double dae_init_dteps(void* v) { if (ifarg(1)) { Daspk::dteps_ = chkarg(1, 1e-100, 1); } if (ifarg(2)) { Daspk::init_failure_style_ = (int)chkarg(2, 0, 013); } return Daspk::dteps_; }
static double statename(void* v) { NetCvode* d = (NetCvode*)v; int i = (int)chkarg(1,0,1e9); int style = 1; if (ifarg(3)) { style = (int)chkarg(3, 0, 2); } hoc_assign_str(hoc_pgargstr(2), d->statename(i, style)); return 0.; }
static double aoplay(void* v) { if (nrndaq_) { u32 ichan = (u32)chkarg(1, 0, 16); double* pvar = hoc_pgetarg(2); double scl = 1., offset = 0.0; if (ifarg(3)) { scl = chkarg(3, -1e9, 1e9); } if (ifarg(4)) { offset = chkarg(4, -1e9, 1e9); } nrndaq_->ao_play(ichan, pvar, scl, offset); } return 0.; }
static double r_nrnran123(void* r) { Rand* x = (Rand*)r; uint32_t id1 = 0; uint32_t id2 = 0; if (ifarg(1)) id1 = (uint32_t)(chkarg(1, 0., dmaxuint)); if (ifarg(2)) id2 = (uint32_t)(chkarg(2, 0., dmaxuint)); NrnRandom123* r123 = new NrnRandom123(id1, id2); x->rand->generator(r123); delete x->gen; x->gen = x->rand->generator(); x->type_ = 4; return 0.; }
batch_run() /* avoid interpreter overhead */ { double tstop, tstep, tnext; char* filename; char* comment; tstopunset; tstop = chkarg(1,0.,1e20); tstep = chkarg(2, 0., 1e20); if (ifarg(3)) { filename = gargstr(3); }else{ filename = 0; } if (ifarg(4)) { comment = gargstr(4); }else{ comment = ""; } if (tree_changed) { setup_topology(); } #if VECTORIZE if (v_structure_change) { v_setup_vectors(); } #endif batch_open(filename, tstop, tstep, comment); batch_out(); if (cvode_active_) { while (t < tstop) { cvode_fadvance(t+tstep); batch_out(); } }else{ tstep -= dt/4.; tstop -= dt/4.; tnext = t + tstep; while (t < tstop) { nrn_fixed_step(); if (t > tnext) { batch_out(); tnext = t + tstep; } if (stoprun) { tstopunset; break; } } } batch_close(); ret(1.); }
static double r_MCellRan4(void* r) { Rand* x = (Rand*)r; uint32_t seed1 = 0; uint32_t ilow = 0; if (ifarg(1)) seed1 = (uint32_t)(chkarg(1, 0., dmaxuint)); if (ifarg(2)) ilow = (uint32_t)(chkarg(2, 0., dmaxuint)); MCellRan4* mcr = new MCellRan4(seed1, ilow); x->rand->generator(mcr); delete x->gen; x->gen = x->rand->generator(); x->type_ = 2; return (double)mcr->orig_; }
static double r_sequence(void* r) { Rand* x = (Rand*)r; if (x->type_ != 2 && x->type_ != 4) { hoc_execerror("Random.seq() can only be used if the random generator was MCellRan4 or Random123", 0); } if (x->type_ == 4) { uint32_t seq; char which; if (ifarg(1)) { double s = chkarg(1, 0., 17179869183.); /* 2^34 - 1 */ seq = (uint32_t)(s/4.); which = char(s - seq*4.); NrnRandom123* nr = (NrnRandom123*)x->gen; nrnran123_setseq(nr->s_, seq, which); } nrnran123_getseq(((NrnRandom123*)x->gen)->s_, &seq, &which); return double(seq)*4. + double(which); } MCellRan4* mcr = (MCellRan4*)x->gen; if (ifarg(1)) { mcr->ihigh_ = (long)(*getarg(1)); } return (double)mcr->ihigh_; }
static double r_ran123_globalindex(void* r) { if (ifarg(1)) { uint32_t gix = (uint32_t)chkarg(1, 0., 4294967295.); /* 2^32 - 1 */ nrnran123_set_globalindex(gix); } return (double)nrnran123_get_globalindex(); }
void nrn_print_matrix(NrnThread* _nt) { extern int section_count; extern Section** secorder; int isec, inode; Section* sec; Node* nd; if (use_sparse13) { if(ifarg(1) && chkarg(1, 0., 1.) == 0.) { spPrint(_nt->_sp13mat, 1, 0, 1); }else{ int i, n = spGetSize(_nt->_sp13mat, 0); spPrint(_nt->_sp13mat, 1, 1, 1); for (i=1; i <= n; ++i) { printf("%d %g\n", i, _nt->_actual_rhs[i]); } } }else if (_nt) { for (inode = 0; inode < _nt->end; ++inode) { nd = _nt->_v_node[inode]; printf("%d %g %g %g %g\n", inode, ClassicalNODEB(nd), ClassicalNODEA(nd), NODED(nd), NODERHS(nd)); } }else{ for (isec = 0; isec < section_count; ++isec) { sec = secorder[isec]; for (inode = 0; inode < sec->nnode; ++inode) { nd = sec->pnode[inode]; printf("%d %d %g %g %g %g\n", isec, inode, ClassicalNODEB(nd), ClassicalNODEA(nd), NODED(nd), NODERHS(nd)); } } } }
lispval Lminus() { register lispval arg1, handy; lispval subbig(); chkarg(1,"minus"); arg1 = lbot->val; handy = nil; switch(TYPE(arg1)) { case INT: handy= inewint(0 - arg1->i); break; case DOUB: handy = newdoub(); handy->r = -arg1->r; break; case SDOT: { struct sdot dummyb; handy = (lispval) &dummyb; handy->s.I = 0; handy->s.CDR = (lispval) 0; handy = subbig(handy,arg1); break; } default: error("non-numeric argument",FALSE); } return(handy); }
lispval Leval1(){ register struct nament *bindptr; register lispval handy; if (np-lbot == 2) { /*if two arguments to eval */ if (TYPE((lbot+1)->val) != INT) error("Eval: 2nd arg not legal alist pointer", FALSE); bindptr = orgbnp + (lbot+1)->val->i; if (rsetsw == 0 || rsetatom->a.clb == nil) error("Not in *rsetmode; second arg is useless - eval", TRUE); if (bptr_atom->a.clb != nil) error("WARNING - Nesting 2nd args to eval will give spurious values", TRUE); if (bindptr < orgbnp || bindptr >bnplim) error("Illegal pdl pointer as 2nd arg - eval", FALSE); handy = newdot(); handy->d.car = (lispval)bindptr; handy->d.cdr = (lispval)bnp; PUSHDOWN(bptr_atom, handy); handy = eval(lbot->val); POP; return(handy); } else { /* normal case - only one arg */ chkarg(1,"eval"); handy = eval(lbot->val); return(handy); }; }
static void* finithnd_cons(Object*) { int type = 1; // default is after INITIAL blocks are called int ia = 1; if (hoc_is_double_arg(ia)) { type = (int)chkarg(ia, 0, 3); ++ia; } char* s = NULL; Object* pyact = NULL; if (hoc_is_object_arg(ia)) { pyact = *hoc_objgetarg(ia); if (!pyact) { hoc_execerror("arg is None", 0); } }else{ s =gargstr(ia); } ++ia; Object* obj = NULL; if (ifarg(ia)) { obj = *hoc_objgetarg(ia); } FInitialHandler* f = new FInitialHandler(type, s, obj, pyact); return f; }
static double dio_write(void* v) { u8 value = (u8)chkarg(1, 0, 255); if (nrndaq_) { nrndaq_->dio_write(value); } return double(value); }
static double abstol(void* v) { NetCvode* d = (NetCvode*)v; Symbol* sym; if (hoc_is_str_arg(1)) { sym = d->name2sym(gargstr(1)); }else{ hoc_pgetarg(1); sym = hoc_get_last_pointer_symbol(); if (!sym) { hoc_execerror("Cannot find the symbol associated with the pointer when called from Python", "Use a string instead of pointer argument"); } if (nrn_vartype(sym) != STATE && sym->u.rng.type != VINDEX) { hoc_execerror(sym->name, "is not a STATE"); } } if (ifarg(2)) { hoc_symbol_tolerance(sym, chkarg(2, 1e-30, 1e30)); d->structure_change(); } if (sym->extra && sym->extra->tolerance > 0.) { return sym->extra->tolerance; }else{ return 1.; } }
static double rtol(void* v) { NetCvode* d = (NetCvode*)v; if (ifarg(1)) { d->rtol(chkarg(1, 0., 1e9)); } return d->rtol(); }
static double aosetup(void* v) { if (nrndaq_) { u32 nchan = (u32)chkarg(1, 0, 4); nrndaq_->ao_setup(nchan); } return 0.; }
static double jacobian(void* v) { NetCvode* d = (NetCvode*)v; if (ifarg(1)) { d->jacobian((int)chkarg(1, 0, 2)); } return double(d->jacobian()); }
static double tstop_event(void* v) { NetCvode* d = (NetCvode*)v; double x = *getarg(1); if (!cvode_active_) { // watch out for fixed step roundoff if x // close to n*dt double y = x/nrn_threads->_dt; if (y > 1 && fabs(floor(y + 1e-6) - y) < 1e-6) { //printf("reduce %g to avoid fixed step roundoff\n", x); x -= nrn_threads->_dt/4.; } } if (ifarg(2)) { Object* ppobj = nil; int reinit = 0; if (ifarg(3)) { ppobj = *hoc_objgetarg(3); if (!ppobj || ppobj->ctemplate->is_point_ <= 0 || nrn_is_artificial_[ob2pntproc(ppobj)->prop->type] ){ hoc_execerror(hoc_object_name(ppobj), "is not a POINT_PROCESS"); } reinit = int(chkarg(4, 0, 1)); } if (hoc_is_object_arg(2)) { d->hoc_event(x, nil, ppobj, reinit, *hoc_objgetarg(2)); }else{ d->hoc_event(x, gargstr(2), ppobj, reinit); } }else{ //d->tstop_event(x); d->hoc_event(x, 0, 0, 0); } return x; }
static double maxstep(void* v) { NetCvode* d = (NetCvode*)v; if (ifarg(1)) { d->maxstep(chkarg(1, 0., 1e9)); } return d->maxstep(); }
static double ste_state(void* v) { StateTransitionEvent* ste = (StateTransitionEvent*)v; int state = ste->state(); if (ifarg(1)) { ste->state((int)chkarg(1, 0, ste->nstate()-1)); } return (double)state; }
static double ste_transition(void* v) { StateTransitionEvent* ste = (StateTransitionEvent*)v; int src = (int)chkarg(1, 0, ste->nstate()-1); int dest = (int)chkarg(2, 0, ste->nstate()-1); if (src == dest) { hoc_execerror("source and destination are the same", 0); } double* var1 = hoc_pgetarg(3); double* var2 = hoc_pgetarg(4); char* stmt = gargstr(5); Object* obj = nil; if (ifarg(6)) { obj = hoc_obj_get(6); } ste->transition(src, dest, var1, var2, 1, stmt, obj); return 1.; }
static double debug_event(void* v) { NetCvode* d = (NetCvode*)v; if (ifarg(1)) { int i = (int)chkarg(1, 0, 10); d->print_event_ = i; } return (double)d->print_event_; }
static double condition_order(void* v) { NetCvode* d = (NetCvode*)v; if (ifarg(1)) { int i = (int)chkarg(1,1,2); d->condition_order(i); } return (double) d->condition_order(); }
static double cache_efficient(void* v) { NetCvode* d = (NetCvode*)v; if (ifarg(1)) { int i = (int)chkarg(1,0,1); nrn_cachevec(i); } return (double) use_cachevec; }
static double nrn_atol(void* v) { NetCvode* d = (NetCvode*)v; if (ifarg(1)) { d->atol(chkarg(1, 0., 1e9)); d->structure_change(); } return d->atol(); }
static double stiff(void* v) { NetCvode* d = (NetCvode*)v; if (ifarg(1)) { d->stiff((int)chkarg(1, 0, 2)); } hoc_return_type_code = 1; // integer return double(d->stiff()); }
static double maxorder(void* v) { NetCvode* d = (NetCvode*)v; if (ifarg(1)) { d->maxorder((int)chkarg(1, 0, 5)); } hoc_return_type_code = 1; // integer return d->maxorder(); }