diff --git a/intf6_.mod b/intf6_.mod index aa33646..2fd4da7 100644 --- a/intf6_.mod +++ b/intf6_.mod @@ -23,9 +23,14 @@ ENDCOMMENT VERBATIM #include "misc.h" +#include "unistd.h" static int ctt(unsigned int, char**); -static int setdvi2(double*,double*,char*,int,int,double*,double*); +static void setdvi2(double*,double*,char*,int,int,double*,double*); +void gsort3 (double *, Point_process **, char*, int, double *, Point_process **,char*); +void gsort2 (double *, Point_process **, int, double *, Point_process **); +void gsort5 (double *, Point_process **, char*, double*, double*, int, + double *, Point_process **, char*, double*, double*); #define PI 3.14159265358979323846264338327950288419716939937510 #define nil 0 @@ -51,7 +56,7 @@ typedef struct VPT { unsigned int id; unsigned int size; unsigned int p; - void* vv[NSV]; + IvocVect* vv[NSV]; double* vvo[NSV]; } vpt; @@ -62,8 +67,8 @@ typedef struct POSTGRP { // postsynaptic group unsigned int col; // COLUMN ID double* jrid; // for recording SPIKES double* jrtv; - void* jridv; - void* jrtvv; + IvocVect* jridv; + IvocVect* jrtvv; unsigned int jtpt,jtmax,jrmax; unsigned long jri,jrj; unsigned long spktot,eventtot; @@ -142,7 +147,9 @@ static Symbol* cbsv; static char iflags[100]="typ inh rec wre jtt inp vin inv jcn dea vbr dbx fla out"; static char iflnum=14, iflneg=11, errflag; // turn on after generating an error message static double *jsp, *invlp; -static id0 *lop(), *lopr(), *getlp(); // accessed by all INTF6, get pointer from list +static id0* lop (Object *ob, unsigned int i); // accessed by all INTF6 +static id0* getlp (Object *ob, unsigned int i); // get pointer from list +static id0* lopr (Object *ob, unsigned int i); // accessed by all INTF6, get pointer from list static void applyEXSTDP (id0* ppo,double pospkt); // apply standard STDP from E->X cells static void applyIXSTDP (id0* ppo,double pospkt); // apply STDP from I->X cells static double vii[NSV]; // temp storage @@ -155,11 +162,11 @@ static int cty[CTYPp], process, ctymap[CTYPp]; static int CTYN, CTYPi, STYPi, dscrsz; // from labels.hoc static double qlimit, *dscr; FILE *wf1, *wf2, *tf; -void* ww[NSW]; +IvocVect* ww[NSW]; double* wwo[NSW]; static int AM=0, NM=1, GA=2, GB=3, AM2=4, NM2=5, GA2=6, SU=3, IN=4, DP=2; // from labels.hoc static double wts[13],hsh[13]; // for jitcons to use as a junk pointer -static int spkoutf2(); +static void spkoutf2(); ENDVERBATIM :* NEURON, PARAMETER, ASSIGNED blocks @@ -290,7 +297,7 @@ CONSTRUCTOR { if (ifarg(2)) { lty=(int) *getarg(2); } else { lty= -1; } // type if (ifarg(3)) { lin=(int) *getarg(3); } else { lin= -1; } // inhib if (ifarg(4)) { lco=(int) *getarg(4); } else { lco= -1; } // column - _p_sop = (void*)ecalloc(1, sizeof(id0)); // important that calloc sets all flags etc to 0 + _p_sop = (double*)ecalloc(1, sizeof(id0)); // important that calloc sets all flags etc to 0 ip = IDP; ip->id=lid; ip->type=lty; ip->inhib=lin; ip->col=lco; ip->pg=0x0; ip->dvi=0x0; ip->sprob=0x0; ip->syns=0x0; ip->wgain=0x0; ip->peconv=ip->piconv=0x0; ip->syw1=ip->syw2=0x0; @@ -382,7 +389,7 @@ unsigned int GetDVIDSeedVal(unsigned int id) { } else { if (seadsetting==2) printf("Warning: GetDVIDSeedVal called with wt rand turned off\n"); x[0]=(double)id; x[1]=seaddvioff; - sead=hashseed2(2,&x); + sead=hashseed2(2, x); } return sead; } @@ -520,7 +527,7 @@ ENDVERBATIM sead=(unsigned int)(floor(_lflag)*ip->id*seedstep); // all integers } else { // hash on presynaptic id+FOFFSET,poid,seedstep hsh[0]=floor(_lflag); hsh[1]=(double)ip->id; hsh[2]=seedstep; - sead=hashseed2(3,&hsh); // hsh[] is just scratch pad + sead=hashseed2(3, hsh); // hsh[] is just scratch pad } mcell_ran4(&sead, &_args[sy], 2, 1.); for (ii=sy;ii=qlimit) { printf("qlimit %g exceeded at t=%g\n",qlimit,t); qlimit*=2; } ip=IDP; pg=ip->pg; @@ -1023,7 +1030,7 @@ ENDVERBATIM } VERBATIM -static int spkoutf2 () { +static void spkoutf2 () { fprintf(wf1,"//b9 -2 t%0.2f %ld %ld\n",t/1e3,pg->jrj,ftell(wf2)); fwrite(pg->jrtv,sizeof(double),pg->jrj,wf2); // write times fwrite(pg->jrid,sizeof(double),pg->jrj,wf2); // write id @@ -1112,7 +1119,7 @@ PROCEDURE callback (fl) { if (jp->sprob[i]) (*pnt_receive[jp->dvi[i]->_prop->_type])(jp->dvi[i], wts, idtflg); _p=upnt->_prop->param; _ppvar=upnt->_prop->dparam; // restore pointers i++; - if (i>=jp->dvt) return; // ran out + if (i>=jp->dvt) return 0; // ran out ddel=jp->del[i]-del0; // delays are relative to event; use difference in delays } // skip over pruned outputs and dead cells: @@ -1136,7 +1143,7 @@ VERBATIM { int i,j,k,prty,poty,dv,dvt,dvii; double *x, *db, *dbs; Object *lb; Point_process *pnnt, **da, **das; ip=IDP; pg=ip->pg;//this should only be called after jitcondiv() - if (ip->dead) return; + if (ip->dead) return 0; prty=ip->type; sead=GetDVIDSeedVal(ip->id);//seed for divergence and delays for (i=0,k=0,dvt=0;ipg; getactive=a2=a3=a4=0; - if (ip->dead) return; + if (ip->dead) return 0.0; dvt=ip->dvt; dbs=ip->del; das=ip->dvi; _lgetdvi=(double)dvt; @@ -1308,7 +1315,7 @@ FUNCTION getdvi () { sead=(unsigned int)(FOFFSET+ip->id)*qp->id*seedstep; } else { // hashed sead setting hsh[0]=(double)(FOFFSET+ip->id); hsh[1]=(double)(qp->id); hsh[2]=seedstep; - sead=hashseed2(3,&hsh); + sead=hashseed2(3, hsh); } mcell_ran4(&sead, y, 2, 1.); for(ii=0;ii<2;ii++) { @@ -1333,7 +1340,7 @@ FUNCTION getconv () { VERBATIM { int iarg,i,j,k,dvt,sz,prfl,getactive; double *x,flag; - void* voi; Point_process **das; id0 *pp; + IvocVect* voi; Point_process **das; id0 *pp; ip=IDP; pg=ip->pg; // this should only be called after jitcondiv() sz=ip->dvt; // // assume conv similar to div getactive=0; @@ -1427,27 +1434,28 @@ FUNCTION rddvi () { for(iCell=0;iCellcesz;iCell++){ if(iCell%1000==0)printf("%d ",iCell); lop(pg->ce,iCell); - fread(&qp->id,sizeof(unsigned int),1,fp); // read id - fread(&qp->type,sizeof(unsigned char),1,fp); // read type id - fread(&qp->col,sizeof(unsigned int),1,fp); // read column id - fread(&qp->dead,sizeof(unsigned char),1,fp); // read alive/dead status - fread(&qp->dvt,sizeof(unsigned int),1,fp); // read divergence size + int ret; + ret = fread(&qp->id,sizeof(unsigned int),1,fp); // read id + ret = fread(&qp->type,sizeof(unsigned char),1,fp); // read type id + ret = fread(&qp->col,sizeof(unsigned int),1,fp); // read column id + ret = fread(&qp->dead,sizeof(unsigned char),1,fp); // read alive/dead status + ret = fread(&qp->dvt,sizeof(unsigned int),1,fp); // read divergence size //free up old pointers if(qp->del){ free(qp->del); free(qp->dvi); free(qp->sprob); - qp->dvt=0; qp->dvi=(Point_process**)0x0; qp->del=(double*)0x0; qp->sprob=(char *)0x0; } + qp->dvt=0; qp->dvi=(Point_process**)0x0; qp->del=(double*)0x0; qp->sprob=(unsigned char *)0x0; } //if divergence == 0 , continue if(!qp->dvt) continue; qp->dvi = (Point_process**)malloc(sizeof(Point_process*)*qp->dvt); for(i=0;idvt;i++){ - fread(&iOutID,sizeof(unsigned int),1,fp); // id of output cell + ret = fread(&iOutID,sizeof(unsigned int),1,fp); // id of output cell if (!(lb=ivoc_list_item(pg->ce,iOutID))) { printf("INTF6:callback %d exceeds %d for list ce\n",iOutID,pg->cesz); hxe(); } qp->dvi[i]=(Point_process *)lb->u.this_pointer; } qp->del = (double*)malloc(sizeof(double)*qp->dvt); - fread(qp->del,sizeof(double),qp->dvt,fp); // read divergence delays + ret = fread(qp->del,sizeof(double),qp->dvt,fp); // read divergence delays qp->sprob = (unsigned char*)malloc(sizeof(unsigned char)*qp->dvt); - fread(qp->sprob,sizeof(unsigned char),qp->dvt,fp); // read divergence firing probabilities + ret = fread(qp->sprob,sizeof(unsigned char),qp->dvt,fp); // read divergence firing probabilities } printf("\n"); return 1.0; @@ -1540,7 +1548,7 @@ PROCEDURE clrdvi () { lop(pg->ce,i); if (qp->dvt!=0x0) { free(qp->dvi); free(qp->del); free(qp->sprob); - qp->dvt=0; qp->dvi=(Point_process**)0x0; qp->del=(double*)0x0; qp->sprob=(char *)0x0; + qp->dvt=0; qp->dvi=(Point_process**)0x0; qp->del=(double*)0x0; qp->sprob=(unsigned char *)0x0; } } ENDVERBATIM @@ -1554,7 +1562,7 @@ FUNCTION setdviv () { nprv=vector_arg_px(1, &prv); i=vector_arg_px(2, &pov); j=vector_arg_px(3, &dlv); - s-0x0; + s=0x0; if(ifarg(4)) { s=(char*)calloc((l=vector_arg_px(4,&ds)),sizeof(char)); for(k=0;kpg; if(!ip->peconv) ip->peconv=getpeconv(ip,&ip->econvsz); voi=vector_arg(1); @@ -1802,7 +1810,7 @@ FUNCTION geteconv () { : intf.geticonv(vec) - get presynaptic I cell IDs FUNCTION geticonv () { VERBATIM - int i; double *x; void *voi; + int i; double *x; IvocVect *voi; ip=IDP; pg=ip->pg; if(!ip->piconv) ip->piconv=getpiconv(ip,&ip->iconvsz); voi=vector_arg(1); @@ -1814,7 +1822,7 @@ FUNCTION geticonv () { : finishdvi2 () -- finalize dvi , sort dvi , allocate and set sprob VERBATIM -static int finishdvi2 (struct ID0* p) { +static void finishdvi2 (struct ID0* p) { Point_process **da,**das; double *db,*dbs,*w1,*w1s,*w2,*w2s; char *syns,*synss; @@ -1914,9 +1922,9 @@ FUNCTION getplast () { PROCEDURE setdvi () { VERBATIM { int i,j,k,dvt,flag; double *d, *y, *ds, *w1, *w2; char* s; - if (! ifarg(1)) {printf("setdvi(v1,v2[,v3,flag]): v1:cell#s; v2:delays; v3:distal synapses\n"); return; } + if (! ifarg(1)) {printf("setdvi(v1,v2[,v3,flag]): v1:cell#s; v2:delays; v3:distal synapses\n"); return 0; } ip=IDP; pg=ip->pg; // this should only be called after jitcondiv() - if (ip->dead) return; + if (ip->dead) return 0; dvt=vector_arg_px(1, &y); i=vector_arg_px(2, &d); s=ifarg(3)?(char*)calloc((j=vector_arg_px(3,&ds)),sizeof(char)):0x0; @@ -1929,13 +1937,14 @@ VERBATIM { if(ifarg(6) && dvt!=vector_arg_px(6,&w2)){printf("setdvi ERR: wrong size for w2 vector!\n"); hxe();} setdvi2(y,d,s,dvt,flag,w1,w2); } + return 0; ENDVERBATIM } VERBATIM // setdvi2(divid_vec,del_vec,syns_vec,div_cnt,flag) // flag 1 means just augment, 0or2: sort by del, 0: clear lists and replace -static int setdvi2 (double *y,double *d,char* s,int dvt,int flag,double* w1,double* w2) { +static void setdvi2 (double *y,double *d,char* s,int dvt,int flag,double* w1,double* w2) { int i,j,ddvi; double *db, *dbs, *w1s, *w2s; unsigned char pdead; unsigned int b,e; char* syns; Object *lb; Point_process *pnnt, **da, **das; ddvi=(int)DEAD_DIV; @@ -1947,7 +1956,7 @@ static int setdvi2 (double *y,double *d,char* s,int dvt,int flag,double* w1,doub if (flag==0) { b=0; e=dvt; // begin to end if (ip->dvi) { free(ip->dvi); free(ip->del); free(ip->sprob); free(ip->syns); - ip->dvt=0; ip->dvi=(Point_process**)0x0; ip->del=(double*)0x0; ip->sprob=(char *)0x0; ip->syns=(char*)0x0; + ip->dvt=0; ip->dvi=(Point_process**)0x0; ip->del=(double*)0x0; ip->sprob=(unsigned char *)0x0; ip->syns=(char*)0x0; if(ip->wgain){free(ip->wgain); ip->wgain=0x0;} if(ip->peconv){free(ip->peconv); ip->peconv=0x0;} if(ip->piconv){free(ip->piconv); ip->piconv=0x0;} @@ -1958,7 +1967,7 @@ static int setdvi2 (double *y,double *d,char* s,int dvt,int flag,double* w1,doub } // make sure all null pointers for realloc } else { if (ip->dvt==0) { - ip->dvi=(Point_process**)0x0; ip->del=(double*)0x0; ip->sprob=(char *)0x0; ip->syns=(char*)0x0; + ip->dvi=(Point_process**)0x0; ip->del=(double*)0x0; ip->sprob=(unsigned char *)0x0; ip->syns=(char*)0x0; ip->wgain=0x0; ip->peconv=0x0; ip->piconv=0x0; ip->pplasttau=0x0; ip->pplastinc=0x0; ip->pplastmaxw=0x0; if(wsetting==1) freesywv(ip); @@ -2009,12 +2018,12 @@ PROCEDURE prune () { if (hoc_is_double_arg(1)) { // prune a certain percent of targets p=*getarg(1); if (p<0 || p>1) {printf("INTF6:pruneERR0:need # [0,1] to prune [ALL,NONE]: %g\n",p); hxe();} - if (p==1.) printf("INTF6pruneWARNING: pruning 100% of cell %d\n",ip->id); + if (p==1.) printf("INTF6pruneWARNING: pruning 100%% of cell %d\n",ip->id); if (verbose && ip->dvt>dscrsz) { printf("INTF6pruneB:Div exceeds dscrsz: %d>%d\n",ip->dvt,dscrsz); hxe(); } if (p==0.) { for (j=0;jdvt;j++) ip->sprob[j]=1; // unprune completely - return; // now that unpruning is done, can return + return 0; // now that unpruning is done, can return } potype=ifarg(2)?(int)*getarg(2):-1; sead=(ifarg(3))?(unsigned int)*getarg(3):GetDVIDSeedVal(ip->id);//seed for divergence and delays @@ -2034,6 +2043,7 @@ PROCEDURE prune () { for (j=0;jdvt;j++) ip->sprob[j]=(unsigned char)x[j]; } } + return 0; ENDVERBATIM } @@ -2082,22 +2092,22 @@ PROCEDURE turnoff () { VERBATIM // gsort2() sorts 2 parallel vectors -- delays and Point_process pointers -int gsort2 (double *db, Point_process **da,int dvt,double *dbs, Point_process **das) { +void gsort2 (double *db, Point_process **da,int dvt,double *dbs, Point_process **das) { int i; scr=scrset(dvt); for (i=0;ipplasttau){free(ip->pplasttau);ip->pplasttau=0x0;} if(ip->pplastinc){free(ip->pplastinc);ip->pplastinc=0x0;} if(ip->pplastmaxw){free(ip->pplastmaxw);ip->pplastmaxw=0x0;} - jp->dvt=0; jp->dvi=(Point_process**)0x0; jp->del=(double*)0x0; jp->sprob=(char *)0x0; jp->syns=(char *)0x0; + jp->dvt=0; jp->dvi=(Point_process**)0x0; jp->del=(double*)0x0; jp->sprob=(unsigned char *)0x0; jp->syns=(char *)0x0; } } ENDVERBATIM @@ -2224,7 +2234,7 @@ PROCEDURE jitcondiv () { if(colid >= ippgbufsz) { // need more memory? then realloc ippgbufsz *= 2; - ppg = realloc((void*)ppg,(size_t)ippgbufsz*sizeof(postgrp*)); + ppg = (postgrp**) realloc((void*)ppg,(size_t)ippgbufsz*sizeof(postgrp*)); } ppg[colid] = pg; pg->col = colid; @@ -2238,7 +2248,7 @@ PROCEDURE jitcondiv () { if (sz==pg->cesz && colid==0) printf("\t**** INTF6 WARNING cesz unchanged: INTF6(s) created off-list ****\n"); } else installed=2.0; pg->cesz = ivoc_list_count(pg->ce); if(verbose) printf("cesz=%d\n",pg->cesz); - pg->lastspk = calloc(pg->cesz,sizeof(double)); // last spike time of each cell + pg->lastspk = (double*)calloc(pg->cesz,sizeof(double)); // last spike time of each cell // not column specific CTYPi=HVAL("CTYPi"); STYPi=HVAL("STYPi"); dscrsz=HVAL("scrsz"); dscr=HPTR("scr"); @@ -2288,7 +2298,7 @@ PROCEDURE jitrec () { if(verbose>1) printf("jitrec from col %d, ip=%p, pg=%p\n",ip->col,ip,pg); if (! ifarg(2)) { // clear with jitrec() or jitrec(0) pg->jrmax=0; pg->jridv=0x0; pg->jrtvv=0x0; - return; + return 0; } i = vector_arg_px(1, &pg->jrid); // could just set up the pointers once pg->jrmax=vector_arg_px(2, &pg->jrtv); @@ -2298,6 +2308,7 @@ PROCEDURE jitrec () { printf("jitrec() ERRA: not same size: %d %d\n",i,pg->jrmax); pg->jrmax=0; hxe(); } pg->jri=pg->jrj=0; // needs to be set at beginning of run } + return 0; ENDVERBATIM } @@ -2404,7 +2415,7 @@ PROCEDURE vers () { :** val(t,tstart) fills global vii[] to pass values back to record() (called from record()) VERBATIM -double val (double xx, double ta) { +void val (double xx, double ta) { vii[1]=VAM*EXP(-(xx - ta)/tauAM); vii[2]=VNM*EXP(-(xx - ta)/tauNM); vii[3]=VGA*EXP(-(xx - ta)/tauGA); @@ -2420,7 +2431,7 @@ ENDVERBATIM :** valps(t,tstart) like val but builds voltages for pop spike VERBATIM -double valps (double xx, double ta) { +void valps (double xx, double ta) { vii[1]=VAM*EXP(-(xx - ta)/tauAM); vii[2]=VNM*EXP(-(xx - ta)/tauNM); vii[3]=VGA*EXP(-(xx - ta)/tauGA); @@ -2437,8 +2448,8 @@ PROCEDURE record () { VERBATIM { int i,j,k,nz; double ti; vp = SOP; - if(!vp) {printf("**** record ERRA: vp=NULL!\n"); return;} - if (tg>=t) return; + if(!vp) {printf("**** record ERRA: vp=NULL!\n"); return 0;} + if (tg>=t) return 0; if (ip->record==1) { while ((int)vp->p >= (int)vp->size-(int)((t-tg)/vdt)-10) { vp->size*=2; @@ -2476,7 +2487,7 @@ PROCEDURE recspk (x) { VERBATIM { vp = SOP; record(); - if (vp->p > vp->size || vp->vvo[6]==0) return; + if (vp->p > vp->size || vp->vvo[6]==0) return 0; if (vp->p > 0) { if (vp->vvo[0]!=0x0) vp->vvo[0][vp->p-1]=_lx; vp->vvo[6][vp->p-1]=spkht; // the spike @@ -2619,11 +2630,12 @@ PROCEDURE trvsp () { VERBATIM int i, flag; - double ind, t0; + double ind, local_t0; ip=IDP; pg=ip->pg; flag=(int) *getarg(1); if (subsvint==0.) {printf("trvsp"); return(0.);} - ind=pg->isp[0]; t0=pg->vsp[0]; + ind = pg->isp[0]; + local_t0 = pg->vsp[0]; if (flag==1) { for (i=0; ivspn; i++) { if (pg->isp[i]!=ind) { @@ -2635,11 +2647,12 @@ PROCEDURE trvsp () } else if (flag==2) { for (i=0; ivspn; i++) { if (pg->isp[i]!=ind) { - pg->vsp[i-1]=t0+subsvint; - ind=pg->isp[i]; t0=pg->vsp[i]; + pg->vsp[i-1] = local_t0 + subsvint; + ind = pg->isp[i]; + local_t0 = pg->vsp[i]; } } - pg->vsp[pg->vspn-1]=t0+subsvint; + pg->vsp[pg->vspn-1] = local_t0 + subsvint; } else {printf("trvsp flag %d not recognized\n",flag); hxe();} ENDVERBATIM } @@ -2698,7 +2711,7 @@ static id0* lopr (Object *ob, unsigned int i) { } // use stoppo() as a convenient conditional breakpoint in gdb (gdb watching is too slow) -int stoppo () { +void stoppo () { } //** ctt(ITEM#) find cells that exist by name @@ -2724,7 +2737,7 @@ PROCEDURE test () { : lof can find object information PROCEDURE lof () { VERBATIM { - Object *ob; int num,i,ii,j,k,si,nx; double *vvo[7], *par; void *vv[7]; + Object *ob; int num,i,ii,j,k,si,nx; double *vvo[7], *par; IvocVect *vv[7]; ob = *(hoc_objgetarg(1)); si=(int)*getarg(2); num = ivoc_list_count(ob); @@ -2832,13 +2845,13 @@ PROCEDURE chk (f) { if (SOP!=nil) { vp = SOP; printf("p %d size %d tg %g\n",vp->p,vp->size,tg); - for (i=0;ivv[i]) printf("%d %x %x;",i,(unsigned int)vp->vv[i],(unsigned int)vp->vvo[i]); + for (i=0;ivv[i]) printf("%d %p %p;",i,vp->vv[i],vp->vvo[i]); } else printf("Recording pointers not initialized"); } if (lfg==2) { printf("Global vectors for input and jitter (jttr): \n"); - if (pg->vsp!=nil) printf("VSP: %x (%d/%d-%d)\n",(unsigned int)pg->vsp,ip->rvi,ip->rvb,ip->rve); else printf("no VSP\n"); - if (jsp!=nil) printf("JSP: %x (%d/%d)\n",(unsigned int)jsp,pg->jtpt,pg->jtmax); else printf("no JSP\n"); + if (pg->vsp!=nil) printf("VSP: %p (%d/%d-%d)\n",pg->vsp,ip->rvi,ip->rvb,ip->rve); else printf("no VSP\n"); + if (jsp!=nil) printf("JSP: %p (%d/%d)\n",jsp,pg->jtpt,pg->jtmax); else printf("no JSP\n"); } if (lfg==3) { if (pg->vsp!=nil) { printf("VSP: (%d/%d-%d)\n",ip->rvi,ip->rvb,ip->rve); @@ -2851,7 +2864,7 @@ PROCEDURE chk (f) { if (lfg==5) { printf("wwpt %d wwsz %d\n WW vecs: ",wwpt,wwsz); printf("wwwid %g wwht %d nsw %g\n WW vecs: ",wwwid,(int)wwht,nsw); - for (i=0;i=t) { return; + } else if (twg>=t) { return 0; } else { for (ti=twg,k=(int)floor((twg-rebeg)/vdt+0.5);ti<=t && kpg; if (FLAG==OK) { // callback -- DO NOT SET FROM HOC FLAG=0.; - if (stoprun) {slowset=0; return;} + if (stoprun) {slowset=0; return 0.0;} if (IDP->dbx==-1)printf("slowset fi:%d ix:%d ss:%g delt:%g t:%g\n",fi,ix,slowset,delt,t); if (t>slowset || ix>=pg->cesz) { // done printf("Slow-setting of flag %d finished at %g: (%d,%g,%g)\n",fi,t,ix,delt,slowset); - slowset=0.; return; + slowset=0.; return 0.0; } if (ixcesz) { lop(pg->ce,ix); @@ -3213,12 +3227,12 @@ FUNCTION flag () { net_send((void**)0x0, wts,tpnt,delt,OK); #endif } - return; + return 0.0; } if (slowset>0 && ifarg(3)) { printf("INTF6 flag() slowset ERR; attempted set during slowset: fi:%d ix:%d ss:%g delt:%g t:%g",\ fi,ix,slowset,delt,t); - return; + return 0.0; } ip = IDP; setfl=ifarg(3); if (ifarg(4)) { slowset=*getarg(4); delt=slowset/pg->cesz; slowset+=t; } @@ -3266,7 +3280,7 @@ FUNCTION flag () { FUNCTION allspck () { VERBATIM - int i; double *x, sum; void *voi; + int i; double *x, sum; IvocVect *voi; ip = IDP; pg=ip->pg; voi=vector_arg(1); x=vector_newsize(voi,pg->cesz); for (i=0,sum=0;icesz;i++) { lopr(pg->ce,i); @@ -3294,7 +3308,7 @@ PROCEDURE resetall () { : type can be a number to pick up or a vector to find all FUNCTION floc () { VERBATIM - double x,y,z,r,min,rad, *ix, *dd, *tdy; int ii,i,n,cnt,ty,tvf; void *voi, *vod, *voty; + double x,y,z,r,min,rad, *ix, *dd, *tdy; int ii,i,n,cnt,ty,tvf; IvocVect *voi, *vod, *voty; cnt=0; n=1000; r=0; z=ty=1e9; tvf=0; ip = IDP; pg=ip->pg; x = *getarg(1); diff --git a/misc.h b/misc.h index 40bebca..c8498b6 100644 --- a/misc.h +++ b/misc.h @@ -1,12 +1,11 @@ -// $Id: misc.h,v 1.33 2010/06/05 15:32:28 billl Exp $ +// $Id: misc.h,v 1.38 2011/11/02 15:26:48 billl Exp $ #include #include #include /* contains LONG_MAX */ #include -#include -#include #include +#include #if !defined(t) #define _pval pval @@ -47,76 +46,85 @@ typedef struct BVEC { #define LG2 0.69314718055994530941723212145818 #define VRRY 200 #define ISVEC(_OB__) (strncmp(hoc_object_name(_OB__),"Vector",6)==0) +#define dmaxuint 4294967295. // for 32 bits // Andre Fentons cast designations typedef unsigned char ui1; /* one byte unsigned integer */ typedef char si1; /* one byte signed integer */ typedef unsigned short ui2; /* two byte unsigned integer */ typedef short si2; /* two byte signed integer */ -typedef unsigned int ui4; /* four byte unsigned integer */ -typedef int si4; /* four byte signed integer */ -typedef float sf4; /* four byte signed floating point number */ -typedef double sf8; /* eight byte signed floating point number */ +typedef unsigned int ui4; /* four byte unsigned integer */ +typedef int si4; /* four byte signed integer */ +typedef float sf4; /* four byte signed floating point number */ +typedef double sf8; /* eight byte signed floating point number */ extern double ERR,GET,SET,OK,NOP,ALL,NEG,POS,CHK,NOZ,GTH,GTE,LTH,LTE,EQU; extern double EQV,EQW,EQX,NEQ,SEQ,RXP,IBE,EBI,IBI,EBE; -extern double *vector_newsize(); -extern unsigned int dcrsz; -extern double *dcr; -extern double *dcrset(int); -extern unsigned int scrsz; -extern unsigned int *scr; -extern unsigned int *scrset(int); -extern unsigned int iscrsz; -extern int *iscr; -extern int *iscrset(int); -extern double BVBASE; +#ifndef NRN_VERSION_GTEQ_8_2_0 +extern void cvode_fadvance(double); +extern void vector_resize(); +extern int vector_buffer_size(void*); +extern FILE* hoc_obj_file_arg(int narg); +extern Symbol *hoc_get_symbol(char *); +extern void mcell_ran4_init(uint32_t idum); +extern double mcell_ran4(unsigned int* idum,double* ran_vec,unsigned int n,double range); +extern int hoc_is_tempobj(int narg); +extern int hoc_is_tempobj_arg(int narg); +Object* ivoc_list_item(Object*, int); extern double* hoc_pgetarg(); extern void hoc_notify_iv(); extern double hoc_call_func(Symbol*, int narg); -extern FILE* hoc_obj_file_arg(int narg); extern Object** hoc_objgetarg(); char *gargstr(); char** hoc_pgargstr(); -extern void vector_resize(); extern int vector_instance_px(); extern void* vector_arg(); extern double* vector_vec(); -extern int vector_buffer_size(void*); extern double hoc_epsilon; extern int stoprun; extern void set_seed(); -extern void dshuffle(double* x,int nx); -extern unsigned int valseed; -extern void mcell_ran4_init(unsigned int *idum); -extern double mcell_ran4(unsigned int* idum,double* ran_vec,unsigned int n,double range); extern int nrn_mlh_gsort(); extern int ivoc_list_count(Object*); -extern Object* ivoc_list_item(Object*, int); -extern int list_vector_px2(); extern int hoc_is_double_arg(int narg); extern int hoc_is_str_arg(int narg); extern int hoc_is_object_arg(int narg); extern int hoc_is_pdouble_arg(int narg); -extern Symbol *hoc_get_symbol(char *); extern Symbol *hoc_lookup(const char*); extern Point_process* ob2pntproc(Object*); - extern char* hoc_object_name(Object*); +extern double nrn_event_queue_stats(double*); +extern void clear_event_queue(); +#endif +double *list_vector_resize(Object *ob, int i, int sz); +int list_vector_px(Object *ob, int i, double** px); +extern int list_vector_px2 (Object *ob, int i, double** px, IvocVect** vv); +extern int list_vector_px3 (Object *ob, int i, double** px, IvocVect** vv); +extern int list_vector_px4 (Object *ob, int i, double** px, unsigned int n); +extern int cmpdfn(double a, double b); +extern void dshuffle(double* x,int nx); +extern double *vector_newsize (IvocVect* vv, int n); +extern int IsList (Object* p); +int uniq2 (int n, double *x, double *y, double *z); + +extern unsigned int dcrsz; +extern double *dcr; +extern double *dcrset(int); +extern unsigned int scrsz; +extern unsigned int *scr; +extern unsigned int *scrset(int); +extern unsigned int iscrsz; +extern int *iscr; +extern int *iscrset(int); +extern double BVBASE; extern int cmpdfn(); extern int openvec(int, double **); -int list_vector_px(); -double *list_vector_resize(); static void hxe() { hoc_execerror("",0); } extern void FreeListVec(ListVec** pp); extern ListVec* AllocListVec(Object* p); extern ListVec* AllocILV(Object*, int, double *); void FillListVec(ListVec* p,double dval); void ListVecResize(ListVec* p,int newsz); -extern short *nrn_artcell_qindex_; -extern double nrn_event_queue_stats(double*); -extern void clear_event_queue(); static double sc[6]; static FILE* testout; @@ -132,3 +140,4 @@ extern double ismono1 (double *x, int n, int flag); double kcorfast(double* input1, double* input2, double* i1d , double* i2d,int n,double* ps); double Rktau (double* x, double* y, int n); // R version double kcorfast (double* input1, double* input2, double* i1d , double* i2d,int n,double* ps); +unsigned int hashseed2 (int na, double* x); diff --git a/misc.mod b/misc.mod index 87b063e..dc122e3 100644 --- a/misc.mod +++ b/misc.mod @@ -41,6 +41,7 @@ NEURON { } VERBATIM +#include "misc.h" #include /* F_OK */ #include /* errno */ #include @@ -48,7 +49,6 @@ VERBATIM #include #include #include -extern int hoc_is_tempobj(int narg); ENDVERBATIM :* FUNCTION file_exist() @@ -58,7 +58,7 @@ VERBATIM errno else will get a nrnoc error. Seems to be a problem even if I don't include */ - char *gargstr(), *filename; + char *filename; filename = gargstr(1); @@ -85,19 +85,19 @@ PROCEDURE sassign() { VERBATIM FILE *pipein; char string[BUFSIZ], **strname, *syscall; - char** hoc_pgargstr(); strname = hoc_pgargstr(1); syscall = gargstr(2); if( !(pipein = popen(syscall, "r"))) { fprintf(stderr,"System call failed\n"); - return; + return 0; } if (fgets(string,BUFSIZ,pipein) == NULL) { fprintf(stderr,"System call did not return a string\n"); - pclose(pipein); return; + pclose(pipein); + return 0; } /* assign_hoc_str(strname, string, 0); */ @@ -120,17 +120,17 @@ VERBATIM if ( !(outfile = fopen("dassign","w"))) { fprintf(stderr,"Can't open output file dassign\n"); - return; + return 0; } if( !(pipein = popen(syscall, "r"))) { fprintf(stderr,"System call failed\n"); - fclose(outfile); return; + fclose(outfile); return 0; } if (fscanf(pipein,"%lf",&num) != 1) { fprintf(stderr,"System call did not return a number\n"); - fclose(outfile); pclose(pipein); return; + fclose(outfile); pclose(pipein); return 0; } fprintf(outfile,"%s=%g\n",strname,num); @@ -214,7 +214,7 @@ ENDVERBATIM FUNCTION hocgetc() { VERBATIM { - FILE* f, *hoc_obj_file_arg(); + FILE* f; f = hoc_obj_file_arg(1); _lhocgetc = (double)getc(f); } diff --git a/readme.txt b/readme.txt index 1c4b383..60d3cc4 100644 --- a/readme.txt +++ b/readme.txt @@ -15,3 +15,9 @@ Reference: Neocortical simulation for epilepsy surgery guidance: Localization and intervention, by William W. Lytton, Samuel A. Neymotin, Jason C. Wester, and Diego Contreras in Computational Surgery and Dual Training, Springer, 2011 + +Changelog +--------- +202205: Updated MOD files to contain valid C++ and be compatible with the upcoming + versions 8.2 and 9.0 of NEURON. Updated to use post ~2011 signature of + mcell_ran4_init functionand fix hashseed2 argument. diff --git a/stats.mod b/stats.mod index e53ec95..94c0ed3 100644 --- a/stats.mod +++ b/stats.mod @@ -39,6 +39,10 @@ PARAMETER { ASSIGNED { seed } VERBATIM +#include +#include +#include + #include "misc.h" #define MIN_MERGESORT_LIST_SIZE 32 @@ -49,7 +53,7 @@ union dblint { unsigned int valseed; static double *x1x, *y1y, *z1z; -static void vprpr(); +static void vprpr (double x, int base); static int compare_ul(const void* l1, const void* l2) { int retval; @@ -425,9 +429,9 @@ static double* getrank (int n, double mdata[]) { int i; double* rank; int* index; - rank = malloc(n*sizeof(double)); + rank = (double*)malloc(n*sizeof(double)); if (!rank) return NULL; - index = malloc(n*sizeof(int)); + index = (int*)malloc(n*sizeof(int)); if (!index) { free(rank); return NULL; @@ -469,9 +473,9 @@ static double spearman(int n, double* data1, double* data2) double avgrank; double* tdata1; double* tdata2; - tdata1 = malloc(n*sizeof(double)); + tdata1 = (double*)malloc(n*sizeof(double)); if(!tdata1) return 0.0; /* Memory allocation error */ - tdata2 = malloc(n*sizeof(double)); + tdata2 = (double*)malloc(n*sizeof(double)); if(!tdata2) /* Memory allocation error */ { free(tdata1); return 0.0; @@ -642,7 +646,7 @@ int qsort2 (double *p1in, double* p2in, int n,double* p1out,double* p2out) { int i; scr=scrset(n); for (i=0;i(int)newline){printf("\n ",colc); colc=0;} + if (colc>(int)newline){printf("\n "); colc=0;} } } printf("\n"); @@ -1659,10 +1663,11 @@ static double vpr2 (void* vv) { if (fl2) {printf(" %2d ",n); colc+=3;} else {printf(" "); colc++;} n=fl2=0; } - if (colc>(int)newline){printf("\n ",colc); colc=0;} + if (colc>(int)newline){printf("\n "); colc=0;} } printf("\n"); } + return 0.0; } static void vprpr (double x, int base) { @@ -1692,7 +1697,7 @@ static double bin (void* vv) { int i, j, nx, maxsz, lfl; double* x, *y, *ix, invl, min, max, maxf, jj; Object* ob; - void* voi[2]; + IvocVect* voi[2]; min=0; max=1e9; maxf=-1e9; nx = vector_instance_px(vv, &x); @@ -1721,8 +1726,8 @@ static double bin (void* vv) { if (lfl) ix[j]=jj+min; } maxsz=(max==1e9)?(int)(maxf/invl+1):(int)((max-min)/invl+1); - vector_resize(voi[0], maxsz); - if (lfl) vector_resize(voi[1], maxsz); + vector_resize((IvocVect*)voi[0], maxsz); + if (lfl) vector_resize((IvocVect*)voi[1], maxsz); return (double)maxsz; } ENDVERBATIM @@ -1741,7 +1746,7 @@ static double ihist (void* vv) { i = vector_arg_px(1, &tv); // vector of times if (i!=nx) {printf("vecst:ihist()ERR0: diff size %d %d\n",nx,i); hxe();} if (!flag && !ismono1(tv,nx,1)){ - printf("vecst:ihist()ERR0A: set flag_stats for non-monotonic time vec\n",nx,i); hxe();} + printf("vecst:ihist()ERR0A: set flag_stats for non-monotonic time vec\n"); hxe();} pL = AllocListVec(obl=*hoc_objgetarg(2)); min=*getarg(3); max=*getarg(4); binsz=*getarg(5); if (binsz<=0) {printf("stats:ihist()ERR0B: binsz must be >0 (%g)\n",binsz); hxe();} @@ -1782,7 +1787,7 @@ static double irate (void* vv) { unsigned int i, j, n, nx; double *prate,*phist,binsz,t1,t2; nx = vector_arg_px(1, &phist); - vector_resize(vv,nx); + vector_resize((IvocVect*)vv,nx); vector_instance_px(vv, &prate); binsz = *getarg(2); for(i=0;iUINT_MAX) y/=1e9; // UINT_MAX is 4.294967e+09 valseed*=(unsigned int)y; // keep multiplying these out } @@ -2116,7 +2121,7 @@ FUNCTION mc4seed () { for (i=2;ifarg(i);i++) { valseed*=(unsigned int)(*getarg(i)); } - mcell_ran4_init(&valseed); // do initialization + mcell_ran4_init(valseed); // do initialization return valseed; ENDVERBATIM } @@ -2144,7 +2149,7 @@ FUNCTION gammln (xx) { FUNCTION betai(a,b,x) { VERBATIM { double bt; - double gammln(),betacf(); + double gammln(double),betacf(double,double,double); if (_lx < 0.0 || _lx > 1.0) {printf("Bad x in routine BETAI\n"); hxe();} if (_lx == 0.0 || _lx == 1.0) bt=0.0; @@ -2218,7 +2223,7 @@ FUNCTION tstat() { FUNCTION tdistrib() { VERBATIM - double gammln(); + double gammln(double); double x = *getarg(1); double dof = *getarg(2); double res = (gammln( (dof+1.0) / 2.0 ) / gammln( dof / 2.0 ) ); diff --git a/vecst.mod b/vecst.mod index 035fffa..3e2e43b 100644 --- a/vecst.mod +++ b/vecst.mod @@ -149,8 +149,8 @@ VERBATIM static double ident (void* vv) { int nx,bsz; double* x; nx = vector_instance_px(vv, &x); - bsz=vector_buffer_size(vv); - printf("Obj*%x Dbl*%x Size: %d Bufsize: %d\n",(unsigned int)vv,(unsigned int)x,nx,bsz); + bsz=vector_buffer_size((IvocVect*)vv); + printf("Obj*%x Dbl*%x Size: %d Bufsize: %d\n",vv,x,nx,bsz); return (double)nx; } ENDVERBATIM @@ -170,7 +170,7 @@ static double indset (void* vv) { if (hoc_is_object_arg(2)) { flag=1; nz = vector_arg_px(2, &z); - if (ny!=nz) z=vector_newsize(vector_arg(2),ny); + if (ny!=nz) z=vector_newsize((IvocVect*)vector_arg(2),ny); } else if (hoc_is_double_arg(2)) { val=*getarg(2); } else if (hoc_is_str_arg(2)) { @@ -207,7 +207,7 @@ static double mkind(void* vv) { min=x[0]; max=x[nx-1]; ny=max-min+4+(flag?0:min); if (ny>1e6) printf("vecst:mkind() WARNING: index of size %d being built\n",ny); - y=vector_newsize(vector_arg(1),ny); + y=vector_newsize((IvocVect*)vector_arg(1),ny); y[0]=0.; y[ny-3]=nx; y[ny-2]=min; y[ny-1]=max; // last 2 record min,max if (min==max) {printf("vecst:mkind() ERRA: min==max %g %g\n",min,max); hxe();} if (!flag) for (j=1;j<=min;j++) y[j]=0.; else j=1; @@ -237,7 +237,7 @@ static double circ (void* vv) { rad=sqrt((x0-x1)*(x0-x1) + (y0-y1)*(y0-y1)); lnew=*getarg(6); // resize the vectors } else if (ifarg(5)) lnew=*getarg(5); // resize the vectors - if (lnew) { nx=lnew; x=vector_newsize(vv,nx); y=vector_newsize(vector_arg(1),ny=nx); } + if (lnew) { nx=lnew; x=vector_newsize((IvocVect*)vv,nx); y=vector_newsize((IvocVect*)vector_arg(1),ny=nx); } for (i=0,theta=0; iscrsz) { @@ -369,6 +370,7 @@ ENDVERBATIM : ind picks out specific vectors if not doing all of them VERBATIM static double lma (void* vv) { + IvocVect* vv_tmp = (IvocVect*)vv; int i, j, k, ia, ib, ni, nj, nx, av[VRRY], bv[VRRY], num, numb, beg, end, *xx; Object *ob1, *ob2; double *ind, *avo[VRRY], *bvo[VRRY], mul,mmul,add,madd; @@ -395,8 +397,8 @@ static double lma (void* vv) { nx=av[0]; // size of source vecs if (beg>=end || beg<0 || end>nx) {printf("lma ERRC1 OOB %d - %d (%d)\n",beg,end,nx); hxe();} for (i=0;i0) { for (ia=0,ib=0,mmul=1.,madd=0.;ia %d :: ",n,nx); hoc_execerror("Vector max capacity too small for ird ", 0); @@ -755,19 +757,19 @@ VERBATIM static double fread2 (void* vv) { int i, j, nx, n, type, maxsz; size_t r; double *x; - FILE* fp, *hoc_obj_file_arg(); + FILE* fp; BYTEHEADER fp = hoc_obj_file_arg(1); nx = vector_instance_px(vv, &x); - maxsz=vector_buffer_size(vv); + maxsz=vector_buffer_size((IvocVect*)vv); n = (int)*getarg(2); type = (int)*getarg(3); if (n>maxsz) { printf("%d > %d :: ",n,maxsz); hoc_execerror("Vector max capacity too small for fread2 ", 0); } else { - vector_resize(vv, n); + vector_resize((IvocVect*)vv, n); } if (type==6 || type==16) { // unsigned ints unsigned int *xs; @@ -794,6 +796,7 @@ static double fread2 (void* vv) { } free((char *)xf); } else hoc_execerror("Type unsupported in fread2 ", 0); + return 0; } ENDVERBATIM @@ -802,19 +805,20 @@ VERBATIM static double revec (void* vv) { int i,j,k, nx, ny; double *x, *y; nx = vector_instance_px(vv, &x); - if (nx==0) x=vector_newsize(vv,nx=100); + if (nx==0) x=vector_newsize((IvocVect*)vv,nx=100); for (i=1,k=0;ifarg(i);i++,k++) { if (hoc_is_double_arg(i)) { - if (k>=nx) x=vector_newsize(vv,nx*=4); + if (k>=nx) x=vector_newsize((IvocVect*)vv,nx*=4); x[k]=*getarg(i); } else { ny=vector_arg_px(i, &y); - if (k+ny>=nx) x=vector_newsize(vv,nx=2*(nx+ny)); + if (k+ny>=nx) x=vector_newsize((IvocVect*)vv,nx=2*(nx+ny)); for (j=0;jisz;iv++) { @@ -897,13 +901,13 @@ static double linsct (void* vv) { } if (fl) cnt++; if (cnt>=min) { - if (k==maxsz) x=vector_newsize(vv, maxsz*=2); + if (k==maxsz) x=vector_newsize((IvocVect*)vv, maxsz*=2); x[k++]=val; break; } } } - vector_resize(vv, k); + vector_resize((IvocVect*)vv, k); return (double)k; } ENDVERBATIM @@ -917,6 +921,7 @@ static double vfill (void* vv) { nx = vector_instance_px(vv, &x); nv1 = vector_arg_px(1, &v1); for (i=0;i=maxsz) { printf("\tredundout WARNING: ran out of room: %d=ncntr) { printf("\tredundout WARNING: cntr ran out of room: %dVRRY) hoc_execerror("mredundout ****ERRA****: can only handle VRRY vectors", 0); for (i=0;imaxsz){printf("mredundout****ERRE**** vec overflow %d>%d\n",k,maxsz);hxe();} for (i=0;i0 && kVRRY) hoc_execerror("ERR: keyind can only handle VRRY vectors", 0); num = i-1; // number of vectors to be picked apart for (i=0;i0 && kk0 && kk=nv[1]) { printf("nearall WARN: oor %d %d\n",k,nv[1]); return -1.; } vvo[0][k]=dist; vvo[2][k]=targ; vvo[3][k]=x[minind]; k++; @@ -1397,14 +1406,14 @@ ENDVERBATIM VERBATIM static double nearest (void* vv) { int i, nx, minind, flag=0; - double *x, targ, dist, new, *to; + double *x, targ, dist, new_, *to; nx = vector_instance_px(vv, &x); targ = *getarg(1); if (ifarg(3)) flag = (int)*getarg(3); dist = 1e9; - for (i=0; imaxsz) {printf("VECST samp ERRA: dest vec too small: %d %d\n",iNewSz,maxsz); hxe();} - vector_resize(vv,iNewSz); + vector_resize((IvocVect*)vv,iNewSz); scale = (double) iOrigSz / (double) iNewSz; for(i=0;ith) { // ? passing thresh @@ -1655,8 +1665,8 @@ static double xing (void* vv) { } } } - vector_resize(vv, j); - if (d2f) vector_resize(vector_arg(d2f),j); + vector_resize((IvocVect*)vv, j); + if (d2f) vector_resize((IvocVect*)vector_arg(d2f),j); return (double)j; } ENDVERBATIM @@ -1672,13 +1682,13 @@ static double snap (void* vv) { nsrc = vector_arg_px(1, &src); ntvec = vector_arg_px(2, &tvec); mdt = *getarg(3); - maxsz=vector_buffer_size(vv); + maxsz=vector_buffer_size((IvocVect*)vv); tstop = tvec[nsrc-1]; size=(int)tstop/mdt; if (size>maxsz) { printf("%d > %d\n",size,maxsz); hoc_execerror("v.snap: insufficient room in dest", 0); } - vector_resize(vv, size); + vector_resize((IvocVect*)vv, size); if (nsrc!=ntvec) hoc_execerror("v.snap: src and tvec not same size", 0); for (tt=0,i=0;ith) { up=1; - if (cnt>=nv) x=vector_newsize(vv,(n+=100)); + if (cnt>=nv) x=vector_newsize((IvocVect*)vv,(n+=100)); x[cnt++]=(double)i; } } - x=vector_newsize(vv,cnt); + x=vector_newsize((IvocVect*)vv,cnt); return (double)cnt; } ENDVERBATIM @@ -1720,10 +1730,10 @@ ENDVERBATIM VERBATIM static double peak (void* vv) { int i, n, nc, ny, up, cnt; - double *x, *y, *vc, last; void* vy; + double *x, *y, *vc, last; IvocVect* vy; n = vector_instance_px(vv, &x); // for indices nc = vector_arg_px(1, &vc); // source vectors - if (n==0) x=vector_newsize(vv,n=100); + if (n==0) x=vector_newsize((IvocVect*)vv,n=100); if (ifarg(2)) y=vector_newsize(vy=vector_arg(2),ny=n); else ny=0; // same size as v1 if (vc[1]-vc[0]<0) up=0; else up=1; // F or T last=vc[1]; @@ -1731,7 +1741,7 @@ static double peak (void* vv) { if (up) { // look for starting down if (vc[i]-last<0) { up=0; - if (cnt>=n) { x=vector_newsize(vv,(n+=100)); + if (cnt>=n) { x=vector_newsize((IvocVect*)vv,(n+=100)); if (ny) y=vector_newsize(vy,n);} x[cnt]=(double)(i-1); if (ny) y[cnt]=last; @@ -1740,7 +1750,7 @@ static double peak (void* vv) { } else if (vc[i]-last>0) up=1; last=vc[i]; } - x=vector_newsize(vv,cnt); + x=vector_newsize((IvocVect*)vv,cnt); if (ny) y=vector_newsize(vy,cnt); return (double)cnt; } @@ -1841,7 +1851,7 @@ static double l2p (void* vv) { lob = *hoc_objgetarg(1); ix=(int)*getarg(2); num = ivoc_list_count(lob); - x=vector_newsize(vv,num); + x=vector_newsize((IvocVect*)vv,num); for (i=0;i=cnt) {printf("vecst:l2p() ERRA: %d %d %d\n",i,ix,cnt); hxe();} @@ -1869,9 +1879,9 @@ static double fetch (void* vv) { if (ix==n) {if (VERBOSE_VECST) printf("vecst:fetch() WARNING: %g not found\n",val); return ERR;} if (hoc_is_object_arg(3)) { ny = vector_arg_px(3, &y); - if (ny>pL->isz) vector_resize(vector_arg(3),pL->isz); // don't make bigger if only want a few + if (ny>pL->isz) vector_resize((IvocVect*)vector_arg(3),pL->isz); // don't make bigger if only want a few for (i=0,j=0,cnt=0;iisz && jpL->plen[i]) {printf("vecst:fetch()ERRB: %d %d %x\n",i,ix,(unsigned int)pL->pv[i]); + if (ix>pL->plen[i]) {printf("vecst:fetch()ERRB: %d %d %x\n",i,ix,pL->pv[i]); FreeListVec(&pL); hxe();} y[j]=pL->pv[i][ix]; cnt++; @@ -1880,7 +1890,7 @@ static double fetch (void* vv) { } else { for (i=0,j=3,cnt=0;iisz && ifarg(j);i++,j++) { if (hoc_is_double_arg(j)) continue; // skip this one - if (ix>pL->plen[i]) {printf("vecst:fetch()ERRB1: %d %d %x\n",i,ix,(unsigned int)pL->pv[i]); + if (ix>pL->plen[i]) {printf("vecst:fetch()ERRB1: %d %d %x\n",i,ix,pL->pv[i]); FreeListVec(&pL); hxe();} *hoc_pgetarg(j)=ret=pL->pv[i][ix]; cnt++; @@ -1906,7 +1916,7 @@ static double covar (void* vv) { m=pL->plen[0]; // dimensionality of data for (i=1;iisz;i++) if (m!=pL->plen[i]) { printf("vecst:covar()ERRB: sz mismatch %d %d@%d\n",m,pL->plen[i],i);FreeListVec(&pL);hxe();} - y=vector_newsize(vector_arg(2),m*m); + y=vector_newsize((IvocVect*)vector_arg(2),m*m); // pL->pv[i][j] -- i goes through the list and j goes through each vector mean=(double*)malloc(sizeof(double)*m); for (j=0;ju.this_pointer); - *px = vector_vec(obv->u.this_pointer); + sz = vector_capacity((IvocVect*)obv->u.this_pointer); + *px = vector_vec((IvocVect*)obv->u.this_pointer); return sz; } //* list_vector_px2(LIST,ITEM#,DOUBLE PTR ADDRESS,VEC POINTER ADDRESS) // returns the vector pointer as well as the double pointer -int list_vector_px2 (Object *ob, int i, double** px, void** vv) { +int list_vector_px2 (Object *ob, int i, double** px, IvocVect** vv) { Object* obv; int sz; obv = ivoc_list_item(ob, i); if (! ISVEC(obv)) return -1; - sz = vector_capacity(obv->u.this_pointer); - *px = vector_vec(obv->u.this_pointer); - *vv = (void*) obv->u.this_pointer; + sz = vector_capacity((IvocVect*)obv->u.this_pointer); + *px = vector_vec((IvocVect*)obv->u.this_pointer); + *vv = (IvocVect*) obv->u.this_pointer; return sz; } //* list_vector_px3(LIST,ITEM#,DOUBLE PTR ADDRESS,VEC POINTER ADDRESS) // same as px2 but returns max vec size instead of current vecsize // side effect -- increase vector size to maxsize -int list_vector_px3 (Object *ob, int i, double** px, void** vv) { +int list_vector_px3 (Object *ob, int i, double** px, IvocVect** vv) { Object* obv; int sz; obv = ivoc_list_item(ob, i); if (! ISVEC(obv)) return -1; - sz = vector_buffer_size(obv->u.this_pointer); - *px = vector_vec(obv->u.this_pointer); - *vv = (void*) obv->u.this_pointer; + sz = vector_buffer_size((IvocVect*)obv->u.this_pointer); + *px = vector_vec((IvocVect*)obv->u.this_pointer); + *vv = (IvocVect*) obv->u.this_pointer; vector_resize(*vv,sz); return sz; } @@ -2161,14 +2171,14 @@ int list_vector_px4 (Object *ob, int i, double** px, unsigned int n) { int sz; obv = ivoc_list_item(ob, i); if (! ISVEC(obv)) return -1; - sz = vector_buffer_size(obv->u.this_pointer); - *px = vector_vec(obv->u.this_pointer); + sz = vector_buffer_size((IvocVect*)obv->u.this_pointer); + *px = vector_vec((IvocVect*)obv->u.this_pointer); vv = (void*) obv->u.this_pointer; if (n>sz) { printf("List vector WARNING: unable to resize to %d requested (%d)\n",n,sz); - vector_resize(vv,sz); + vector_resize((IvocVect*)vv,sz); return 0; - } else vector_resize(vv,n); + } else vector_resize((IvocVect*)vv,n); return 1; } @@ -2177,8 +2187,8 @@ double *list_vector_resize (Object *ob, int i, int sz) { Object* obv; obv = ivoc_list_item(ob, i); if (! ISVEC(obv)) return 0x0; - vector_resize(obv->u.this_pointer,sz); - return vector_vec(obv->u.this_pointer); + vector_resize((IvocVect*)obv->u.this_pointer,sz); + return vector_vec((IvocVect*)obv->u.this_pointer); } ENDVERBATIM @@ -2268,7 +2278,7 @@ VERBATIM static double uniq (void* vv) { int i, j, k, n, cnt, ny, nz, flag, lt, rt, mid, res; double *x, *y, *z, lastx, num; - void* voi[2]; Object* ob; char *ix; + IvocVect* voi[2]; Object* ob; char *ix; n = vector_instance_px(vv, &x); flag=ny=nz=0; if (n==0) {printf("vecst:uniq WARNA empty input vector\n"); return 0;} @@ -2297,7 +2307,7 @@ static double uniq (void* vv) { } scrset(n); for (i=0;i0) z[0]=1.; for (i=1, lastx=x[scr[0]], cnt=1; ilastx+hoc_epsilon) { @@ -2428,15 +2438,15 @@ int openvec (int arg, double **y) { if (! ISVEC(ob)) return -1; vector_arg_px(arg, y); vv=vector_arg(arg); - max=vector_buffer_size(vv); - vector_resize(vv, max); + max=vector_buffer_size((IvocVect*)vv); + vector_resize((IvocVect*)vv, max); if (max==0) printf("openvec(): 0 size vec\n"); return max; } // vector_newsize() will also increase size of vector -double *vector_newsize (void* vv, int n) { - vector_resize(vv,n); +double *vector_newsize (IvocVect* vv, int n) { + vector_resize((IvocVect*)vv,n); return vector_vec(vv); } ENDVERBATIM @@ -2461,7 +2471,7 @@ static double pop (void* vv) { double *x; n = vector_instance_px(vv, &x); if (n==0) {printf("vec.pop ERR: empty vec\n");hxe();} - vector_resize(vv,n-1); + vector_resize((IvocVect*)vv,n-1); return x[n-1]; } ENDVERBATIM @@ -2514,9 +2524,9 @@ static double smgs (void* vv) { points = (int)((high-low)/step+hoc_epsilon); if (nsum!=points) { - maxsz=vector_buffer_size(vv); + maxsz=vector_buffer_size((IvocVect*)vv); if (points<=maxsz) { - nsum=points; vector_resize(vv, nsum); + nsum=points; vector_resize((IvocVect*)vv, nsum); } else { printf("%d > %d :: ",points,maxsz); hoc_execerror("Vector max capacity too small in smgs ", 0); @@ -2564,9 +2574,9 @@ static double smsy (void* vv) { points=(int)(tstop/mdt+hoc_epsilon); if (nsum!=points) { - maxsz=vector_buffer_size(vv); + maxsz=vector_buffer_size((IvocVect*)vv); if (points<=maxsz) { - vector_resize(vv, points); points=nsum; + vector_resize((IvocVect*)vv, points); points=nsum; } else { printf("%d > %d :: ",points,maxsz); hoc_execerror("Dest vector too small in smsy ", 0); @@ -2589,12 +2599,12 @@ static double vrdh (void* vv) { FILE* f; num = vector_instance_px(vv, &x); - maxsz=vector_buffer_size(vv); + maxsz=vector_buffer_size((IvocVect*)vv); f = hoc_obj_file_arg(1); num = (int)*getarg(2); // number of vectors to look for if (maxsz<2*num){printf("vrdh ERR0 need %d room in vec\n",2*num);hxe();} - vector_resize(vv, 2*num); + vector_resize((IvocVect*)vv, 2*num); for (i=0;i1e7) { free(scr); scr=(unsigned int *)NULL; scrsz=0; } return (double)num; } @@ -2905,7 +2915,15 @@ FUNCTION isojt () { Object *ob1, *ob2; ob1 = *hoc_objgetarg(1); ob2 = *hoc_objgetarg(2); if (!ob1) if (!ob2) return 1; else return 0; - if (!ob2 || ob1->template != ob2->template) { +#define ctemplate template +#ifdef NRN_VERSION_GTEQ_8_2_0 +#if NRN_VERSION_GTEQ(9, 0, 0) +#undef ctemplate +#define ctemplate ctemplate +#endif +#endif + if (!ob2 || ob1->ctemplate != ob2->ctemplate) { +#undef ctemplate return 0; } return 1; @@ -3147,9 +3165,9 @@ ListVec* AllocListVec (Object* p) { if(!pList->pv){free(pList->plen); printf("AllocListVec ERRC: Out of memory!\n"); hxe();} for(i=0;iisz;i++) { obv = ivoc_list_item(p,i); - pList->pv[i]=vector_vec(obv->u.this_pointer); - pList->plen[i]=vector_capacity(obv->u.this_pointer); - pList->pbuflen[i]=vector_buffer_size(obv->u.this_pointer);; + pList->pv[i]=vector_vec((IvocVect*)obv->u.this_pointer); + pList->plen[i]=vector_capacity((IvocVect*)obv->u.this_pointer); + pList->pbuflen[i]=vector_buffer_size((IvocVect*)obv->u.this_pointer);; } return pList; } @@ -3171,9 +3189,9 @@ ListVec* AllocILV (Object* p, int nx, double *x) { for(i=0;i=ilc){printf("AllocILV ERRD: index OOB: %d>=%d\n",j,ilc); hxe();} obv = ivoc_list_item(p,j); - pList->pv[i]=vector_vec(obv->u.this_pointer); - pList->plen[i]=vector_capacity(obv->u.this_pointer); - pList->pbuflen[i]=vector_buffer_size(obv->u.this_pointer);; + pList->pv[i]=vector_vec((IvocVect*)obv->u.this_pointer); + pList->plen[i]=vector_capacity((IvocVect*)obv->u.this_pointer); + pList->pbuflen[i]=vector_buffer_size((IvocVect*)obv->u.this_pointer);; } return pList; } @@ -3182,7 +3200,7 @@ void ListVecResize (ListVec* p,int newsz) { int i,j; Object* obv; for(i=0;iisz;i++){ obv = ivoc_list_item(p->pL, i); - p->pv[i]=vector_newsize(obv->u.this_pointer,newsz); + p->pv[i]=vector_newsize((IvocVect*)obv->u.this_pointer,newsz); p->plen[i]=newsz; } }