diff --git a/README b/README index f9aa707..039a7ad 100644 --- a/README +++ b/README @@ -47,5 +47,11 @@ babbling noise can be changed by resetting the value of 'inputseed' in Line 13 in stim.hoc. After resetting these parameters and saving the files, simulations can then be started as above. +CHANGELOG + 20160921 Updates from the Lytton lab to allow the model to run on mac OS X. + +20220517 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 function and fix hashseed2 argument. diff --git a/infot.mod b/infot.mod index 60c86f6..e77c6ee 100644 --- a/infot.mod +++ b/infot.mod @@ -29,7 +29,9 @@ VERBATIM #include #include static const double* ITsortdata = NULL; /* used in the quicksort algorithm */ -static double tetrospks2(), pdfpr(), tetrospks3(); +static double tetrospks2 (double* X1d,double* X2d,double* XO,int szX1,int szXO,int shuf); +static void pdfpr (double* pdf,int szp,int dim, char* name); +static double tetrospks3 (double* X1d,double* X2d,double* X3d,double* XO,int szX1,int szXO,int shuf); static int dbxi[10]; typedef struct ITNode_ { @@ -42,9 +44,9 @@ typedef struct ITNode_ { ITNode* allocITNode(int idims) { ITNode* p; - p = calloc(1,sizeof(ITNode)); + p = (ITNode*)calloc(1,sizeof(ITNode)); if(!p) { printf("allocITNode: out of mem!\n"); hxe(); return 0x0; } - p->pvals = calloc(idims,sizeof(int)); + p->pvals = (int*)calloc(idims,sizeof(int)); return p; } @@ -411,7 +413,7 @@ double tentropd (double* x,double* y,int iLen,int nbins,int xpast,int ypast,int dsum=0.0; *sig=-1e6;//init sig to neg *nTE = 0.0; - sh=cntjxy=cntjx=cntpx=cntpx=0; teavg=testd=te=teout=0.0; + sh=cntjxy=cntjx=cntpx=cntpxy=0; teavg=testd=te=teout=0.0; px = nbins>0 ? getnormd(x,iLen,nbins) : doublep2intp(x,iLen); //discretize x to nbins, or just copy to ints py = nbins>0 ? getnormd(y,iLen,nbins) : doublep2intp(y,iLen); //discretize y to nbins, or just copy to ints @@ -508,7 +510,7 @@ double tentropd (double* x,double* y,int iLen,int nbins,int xpast,int ypast,int } if(verbose>1) {printf("cntjxy=%d\n",cntjxy); for(i=0;i=MINLOG2 && tmp[3]<=MAXLOG2) { tmp[0] -=tmp[2]*_n_LOG2(tmp[3]); } else { tmp[0] -=tmp[2]* log2d(tmp[3]); if (usetable&&verbose>0.4) { - printf("WARNA:%g outside of [%g,%g] TABLE\n",tmp[4],MINLOG2,MAXLOG2); }}}} + printf("WARNA:%g outside of [%g,%g] TABLE\n",tmp[3],MINLOG2,MAXLOG2); }}}} return tmp[0]; } @@ -867,10 +869,10 @@ double entropxfgxpd (double* pXP, double* pXFXP,int minv,int maxv,int szp) { // Vector has elements of X static double entropxfgxp (void* vv) { double *x,*pXP,*pXFXP,dret; - int sz,minv,maxv,cnt,i,j,szp,*X; - sz = vector_instance_px(vv,&x); + int sz,minv,maxv,cnt,i,j,szp; + sz = vector_instance_px((IvocVect*)vv,&x); cnt=0; - X=scrset(sz); + unsigned int* X=scrset(sz); minv=1e9; maxv=-1e9; for (i=0;ibinmax) return -11.; else if (cnt2>binmax) return -12.; + /* this should probably be fabs in C */ if (abs(cnt1-cnt2)>cutoff) return -13.; } if(verbose>2)printf("tentropspks:minv1=%d,maxv1=%d,minv2=%d,maxv2=%d\n",minv1,maxv1,minv2,maxv2); @@ -1165,7 +1168,7 @@ static double tetrospks2 (double* X1d,double* X2d,double* XO,int szX1,int szXO,i } // for debugging -- print out a pdf -static double pdfpr (double* pdf,int szp,int dim, char* name) { +static void pdfpr (double* pdf,int szp,int dim, char* name) { double x,ds; int i,j,k,l,m,cnt,*nonzero; ds=0.; printf("Contents of PDF %s\n",name); @@ -1306,9 +1309,9 @@ static double* ITgetrank (int n, double mdata[]) { int i; double* rank; int* index; - rank = calloc(n,sizeof(double)); + rank = (double*)calloc(n,sizeof(double)); if (!rank) return NULL; - index = calloc(n,sizeof(int)); + index = (int*)calloc(n,sizeof(int)); if (!index) { free(rank); return NULL; @@ -1394,13 +1397,13 @@ static double mutinfb (void* v) { double entropspksd (double* x,int sz) { double *px,ret,dinf,size; - int i,*X,maxv,minv,cnt,err; + int i,maxv,minv,cnt,err; if(sz<1) {printf("entropspks ERR0: min size must be > 0!\n"); return -1.0;} size=(double)sz; ret=-1.0; err=0; px=NULL; minv=1000000000; maxv=-1000000000; - X=scrset(sz*2); // move into integer arrays + unsigned int* X=scrset(sz*2); // move into integer arrays cnt=0; for (i=0;i + static int ctt(unsigned int, char**); -static int setdvi2(double*,double*,char*,int,int,double*,double*); -static int setdvi3(double*,double*,char*,int,double*,double*); -void freesywv(); +static void setdvi2(double*,double*,char*,int,int,double*,double*); +static void setdvi3(double*,double*,char*,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*); // Definitions for synaptic scaling procs void raise_activity_sensor(double time); void decay_activity_sensor(double time); @@ -59,7 +64,7 @@ typedef struct VPT { unsigned int id; unsigned int size; unsigned int p; - void* vv[NSV]; + IvocVect* vv[NSV]; double* vvo[NSV]; } vpt; @@ -70,8 +75,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; @@ -163,7 +168,10 @@ 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 +void freesywv (id0*); +static id0* lop (Object *, unsigned int ); +static id0* getlp (Object *, unsigned int); +static id0 *lopr(); // 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 void applyEDOPE (id0* ppo,double pospkt); // apply DOPAMINE eligibility @@ -178,11 +186,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 @@ -361,7 +369,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->del=0x0; ip->sprob=0x0; @@ -492,7 +500,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; } @@ -687,7 +695,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; @@ -1205,7 +1213,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 @@ -1441,7 +1449,7 @@ FUNCTION getdvi () { { int i,j,k,iarg,av1,a2,a3,a4,a6,a7,dvt,getactive=0,idx=0,*pact,prty,poty,sy,ii; double *dbs, *x,*x1,*x2,*x3,*x4,*x5,*x6,*x7,idty,y[2],flag; - void* voi, *voi2,*voi3; Point_process **das; + IvocVect* voi, *voi2,*voi3; Point_process **das; ip=IDP; pg=ip->pg; getactive=a2=a3=a4=0; if (ip->dead) return 0.0; @@ -1493,7 +1501,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++) { @@ -1518,7 +1526,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; @@ -1612,27 +1620,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; @@ -1725,7 +1734,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; if(wsetting==1) freesywv(qp); } } @@ -2067,7 +2076,7 @@ ENDVERBATIM : intf.geteconv(vec) - get presynaptic E cell IDs FUNCTION geteconv () { VERBATIM - int i; double *x; void *voi; + int i; double *x; IvocVect *voi; ip=IDP; pg=ip->pg; if(!ip->peconv) ip->peconv=getpeconv(ip,&ip->econvsz); voi=vector_arg(1); @@ -2080,7 +2089,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); @@ -2092,7 +2101,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; @@ -2208,13 +2217,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,w1,w2) // 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; @@ -2226,7 +2236,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;} @@ -2238,7 +2248,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; ip->pdope=0x0; if(wsetting==1) freesywv(ip); @@ -2282,7 +2292,7 @@ ENDVERBATIM VERBATIM // setdvi3(divid_vec,del_vec,syns_vec,div_cnt,w1,w2) // based on setdvi2() but uses qp statt IDP and does reallocs -static int setdvi3 (double *y, double *d, char* s, int dvt, double* w1, double* w2) { +static void setdvi3 (double *y, double *d, char* s, int dvt, 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; @@ -2319,7 +2329,7 @@ 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.) { @@ -2344,6 +2354,7 @@ PROCEDURE prune () { for (j=0;jdvt;j++) ip->sprob[j]=(unsigned char)x[j]; } } + return 0; ENDVERBATIM } @@ -2392,22 +2403,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;idvi) { free(jp->dvi); free(jp->del); free(jp->sprob); free(jp->syns); if(jp->wgain){free(jp->wgain); jp->wgain=0x0;} @@ -2441,7 +2452,7 @@ static int freedvi2 (struct ID0* jp) { if(ip->pplastinc){free(ip->pplastinc);ip->pplastinc=0x0;} if(ip->pplastmaxw){free(ip->pplastmaxw);ip->pplastmaxw=0x0;} if(ip->pdope){free(ip->pdope);ip->pdope=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 @@ -2539,7 +2550,7 @@ PROCEDURE cinit () { if(inumcols >= 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[inumcols-1] = pg; pg->col = colid; @@ -2553,7 +2564,7 @@ PROCEDURE cinit () { 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"); // column specific @@ -2596,7 +2607,7 @@ PROCEDURE jitcondiv () { if(inumcols >= 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[inumcols-1] = pg; pg->col = colid; @@ -2610,7 +2621,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"); @@ -2670,6 +2681,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 } @@ -2786,7 +2798,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); @@ -2802,7 +2814,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); @@ -3002,11 +3014,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) { @@ -3018,11 +3031,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 } @@ -3081,7 +3095,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 @@ -3107,13 +3121,13 @@ 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); if (num!=7) { printf("INTF6 lof ERR %d>7\n",num); hxe(); } for (i=0;ip,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); @@ -3234,7 +3248,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;iNSW) { printf("INTF6 initwrec() WARN: can only store %d ww vecs\n",NSW); hxe();} nsw=(double)num; for (k=0;kpg; voi=vector_arg(1); x=vector_newsize(voi,pg->cesz); for (i=0,sum=0;icesz;i++) { lopr(pg->ce,i); @@ -3677,7 +3692,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/intfsw.mod b/intfsw.mod index e35cdfe..989e1e9 100644 --- a/intfsw.mod +++ b/intfsw.mod @@ -412,7 +412,7 @@ FUNCTION GetCCR () { } double** pLV = pList->pv; - int* pLen = pList->plen; + unsigned int* pLen = pList->plen; //init vector of distances to each cell , 0 == no path found int* pNeighbors = (int*)calloc(iCells,sizeof(int)); @@ -543,7 +543,7 @@ FUNCTION GetCentrality () { } double** pLV = pList->pv; - int* pLen = pList->plen; + unsigned int* pLen = pList->plen; //init vector of avg distances to each cell , 0 == no path found double* pCE; @@ -655,7 +655,7 @@ FUNCTION GetCC () { } double** pLV = pList->pv; - int* pLen = pList->plen; + unsigned int* pLen = pList->plen; //init vector of distances to each cell , 0 == no path found int* pNeighbors = (int*)calloc(iCells,sizeof(int)); @@ -753,7 +753,7 @@ FUNCTION CountNeighborsR () { } double** pLV = pList->pv; - int* pLen = pList->plen; + unsigned int* pLen = pList->plen; //init vector of avg distances to each cell , 0 == no path found double* pVD; @@ -1166,7 +1166,7 @@ FUNCTION GetPathR () { } double** pLV = pList->pv; - int* pLen = pList->plen; + unsigned int* pLen = pList->plen; //init vector of avg distances to each cell , 0 == no path found double* pVD; @@ -1313,7 +1313,7 @@ FUNCTION GetCCSubPop () { } double** pLV = pList->pv; - int* pLen = pList->plen; + unsigned int* pLen = pList->plen; //init vector of distances to each cell , 0 == no path found int* pNeighbors = (int*)calloc(iCells,sizeof(int)); @@ -1422,7 +1422,7 @@ FUNCTION GetCCSubPop () { FUNCTION GetRecurCount () { VERBATIM ListVec* pList; - int iCells,*pLen,iFromSz,iThruSz,idx,myID,youID,jdx,iCheckSz,*pVisited,*pCheck; + int iCells,iFromSz,iThruSz,idx,myID,youID,jdx,iCheckSz,*pVisited,*pCheck; double **pLV,*pFrom,*pThru,*pR; pList = AllocListVec(*hoc_objgetarg(1)); @@ -1439,7 +1439,7 @@ FUNCTION GetRecurCount () { } pLV = pList->pv; - pLen = pList->plen; + unsigned int* pLen = pList->plen; pFrom=pThru=0; iFromSz = vector_arg_px(3,&pFrom); iThruSz = vector_arg_px(4,&pThru); @@ -1509,7 +1509,7 @@ FUNCTION GetPairDist () { } double** pLV = pList->pv; - int* pLen = pList->plen; + unsigned int* pLen = pList->plen; double* pFrom = 0, *pTo = 0; int iFromSz = vector_arg_px(3,&pFrom) , iToSz = vector_arg_px(4,&pTo); @@ -1632,7 +1632,7 @@ FUNCTION GetPathSubPop () { } double** pLV = pList->pv; - int* pLen = pList->plen; + unsigned int* pLen = pList->plen; //init vector of avg distances to each cell , 0 == no path found double* pVD; @@ -1787,7 +1787,7 @@ FUNCTION GetLoopLength () { } double** pLV = pList->pv; - int* pLen = pList->plen; + unsigned int* pLen = pList->plen; //init vector of avg distances to each cell , 0 == no path found double* pVD; @@ -1928,7 +1928,7 @@ FUNCTION GetPathEV () { } double** pLV = pList->pv; - int* pLen = pList->plen; + unsigned int* pLen = pList->plen; //init vector of distances to each cell , 0 == no path found double* pVD; diff --git a/misc.h b/misc.h index 1fa7839..d506bc0 100644 --- a/misc.h +++ b/misc.h @@ -1,10 +1,10 @@ // $Id: misc.h,v 1.38 2011/11/02 15:26:48 billl Exp $ - +#include /* uint32_t */ #include #include #include /* contains LONG_MAX */ #include -#include +#include #include #include @@ -54,25 +54,16 @@ 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; +extern double *vector_newsize (void* vv, int n); +#ifndef NRN_VERSION_GTEQ_8_2_0 extern double* hoc_pgetarg(); extern void hoc_notify_iv(); extern double hoc_call_func(Symbol*, int narg); @@ -85,38 +76,56 @@ 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 void mcell_ran4_init(u_int32_t); -extern double mcell_ran4(u_int32_t *idx1, double *x, unsigned int n, double range); -extern int nrn_mlh_gsort(); +extern void mcell_ran4_init(uint32_t); +extern double mcell_ran4(uint32_t* high, double* x, unsigned int n, double range); +extern int nrn_mlh_gsort(double* vec, int* base_ptr, int total_elems, int (*cmp)(double, double)); 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 int cmpdfn(); +extern double nrn_event_queue_stats(double*); +extern Symbol *hoc_get_symbol(char *); +extern void cvode_fadvance(double); +extern void clear_event_queue(); +extern Object* ivoc_list_item(Object*, int); +extern int hoc_is_tempobj(int narg); +extern int hoc_is_tempobj_arg(int narg); +extern double hoc_epsilon; +extern int stoprun; +extern void set_seed(); +#endif +extern unsigned int hashseed2 (int na, double* x); +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 void dshuffle(double* x,int nx); +extern void ishuffle(int* x,int nx); +extern unsigned int valseed; +extern int list_vector_px2 (Object *ob, int i, double** px, void** vv); +extern int list_vector_px3 (Object *ob, int i, double** px, void** vv); +int list_vector_px4(Object *ob, int i, double** px, unsigned int n); +extern int cmpdfn(double a, double b); extern int openvec(int, double **); -int list_vector_px(); -double *list_vector_resize(); +int list_vector_px(Object *ob, int i, double** px); +double *list_vector_resize(Object *ob, int i, int sz); 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; @@ -127,6 +136,7 @@ extern void freeint2D(int*** ppp,int rows); extern double** getdouble2D(int rows,int cols); extern void freedouble2D(double*** ppp,int rows); extern double ismono1 (double *x, int n, int flag); +int uniq2(int n, double *x, double *y, double *z); //* in stats.mod double kcorfast(double* input1, double* input2, double* i1d , double* i2d,int n,double* ps); diff --git a/misc.mod b/misc.mod index 63883ee..3424ef0 100644 --- a/misc.mod +++ b/misc.mod @@ -48,7 +48,7 @@ VERBATIM #include #include #include -extern int hoc_is_tempobj(int narg); +#include "misc.h" 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,7 +85,6 @@ FUNCTION sassign() { VERBATIM FILE *pipein; char string[BUFSIZ], **strname, *syscall; - char** hoc_pgargstr(); strname = hoc_pgargstr(1); syscall = gargstr(2); @@ -217,8 +216,7 @@ ENDVERBATIM FUNCTION hocgetc() { VERBATIM { - FILE* f, *hoc_obj_file_arg(); - f = hoc_obj_file_arg(1); + FILE* f = hoc_obj_file_arg(1); _lhocgetc = (double)getc(f); } ENDVERBATIM diff --git a/stats.mod b/stats.mod index bb9519d..c3cf7ea 100644 --- a/stats.mod +++ b/stats.mod @@ -40,6 +40,7 @@ ASSIGNED { seed } VERBATIM #include "misc.h" +#include /* uint32_t, uintptr_t */ #define MIN_MERGESORT_LIST_SIZE 32 union dblint { @@ -50,7 +51,7 @@ union dblint { static u_int32_t ilow=0; static u_int32_t ihigh=0; // same as ihigh in (/usr/site/nrniv/nrn/src/ivoc/ivocrand.cpp:75) 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; @@ -424,11 +425,9 @@ static double* getrank (int n, double mdata[]) * a memory allocation error, it returns NULL. */ { int i; - double* rank; - int* index; - rank = malloc(n*sizeof(double)); + double* rank = (double*)malloc(n*sizeof(double)); if (!rank) return NULL; - index = malloc(n*sizeof(int)); + int* index = (int*)malloc(n*sizeof(int)); if (!index) { free(rank); return NULL; @@ -468,11 +467,9 @@ static double spearman(int n, double* data1, double* data2) double denom1 = 0.; double denom2 = 0.; double avgrank; - double* tdata1; - double* tdata2; - tdata1 = malloc(n*sizeof(double)); + double* tdata1 = (double*)malloc(n*sizeof(double)); if(!tdata1) return 0.0; /* Memory allocation error */ - tdata2 = malloc(n*sizeof(double)); + double* tdata2 = (double*)malloc(n*sizeof(double)); if(!tdata2) /* Memory allocation error */ { free(tdata1); return 0.0; @@ -643,7 +640,7 @@ int qsort2 (double *p1in, double* p2in, int n,double* p1out,double* p2out) { int i; scr=scrset(n); for (i=0;iUINT_MAX) y/=1e9; // UINT_MAX is 4.294967e+09 ihigh*=(unsigned int)y; // keep multiplying these out } @@ -2148,8 +2146,6 @@ FUNCTION gammln (xx) { FUNCTION betai(a,b,x) { VERBATIM { double bt; - double gammln(),betacf(); - 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; else @@ -2222,7 +2218,6 @@ FUNCTION tstat() { FUNCTION tdistrib() { VERBATIM - double gammln(); double x = *getarg(1); double dof = *getarg(2); double res = (gammln( (dof+1.0) / 2.0 ) / gammln( dof / 2.0 ) ); diff --git a/updown.mod b/updown.mod index e9f5c0a..6185891 100644 --- a/updown.mod +++ b/updown.mod @@ -15,32 +15,7 @@ PARAMETER { } VERBATIM -#include -#include -#include // contains LONG_MAX -#include -extern double* hoc_pgetarg(); -extern double hoc_call_func(Symbol*, int narg); -extern FILE* hoc_obj_file_arg(int narg); -extern Object** hoc_objgetarg(); -extern void vector_resize(); -extern int vector_instance_px(); -extern void* vector_arg(); -extern double* vector_vec(); -extern double hoc_epsilon; -extern double chkarg(); -extern void set_seed(); -extern int ivoc_list_count(Object*); -extern Object* ivoc_list_item(Object*, int); -extern int hoc_is_double_arg(int narg); -extern char* hoc_object_name(Object*); -char ** hoc_pgargstr(); -int list_vector_px(); -int list_vector_px2(); -int list_vector_px3(); -double *list_vector_resize(); -int ismono1(); -static void hxe() { hoc_execerror("",0); } +#include "misc.h" static void hxf(void *ptr) { free(ptr); hoc_execerror("",0); } ENDVERBATIM diff --git a/vecst.mod b/vecst.mod index 035fffa..f5cd04d 100644 --- a/vecst.mod +++ b/vecst.mod @@ -102,6 +102,7 @@ ASSIGNED { RES } VERBATIM #include "misc.h" +int IsList (Object* p); ENDVERBATIM VERBATIM @@ -150,7 +151,7 @@ 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); + printf("Obj*%p Dbl*%p Size: %d Bufsize: %d\n", vv, x, nx, bsz); return (double)nx; } ENDVERBATIM @@ -710,8 +711,7 @@ VERBATIM static double iwr (void* vv) { int i, j, nx; size_t r; double *x; - FILE* f, *hoc_obj_file_arg(); - f = hoc_obj_file_arg(1); + FILE* f = hoc_obj_file_arg(1); nx = vector_instance_px(vv, &x); scrset(nx); for (i=0;iscrsz) { @@ -755,7 +754,7 @@ 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); @@ -794,6 +793,7 @@ static double fread2 (void* vv) { } free((char *)xf); } else hoc_execerror("Type unsupported in fread2 ", 0); + return 0.0; } ENDVERBATIM @@ -815,6 +815,7 @@ static double revec (void* vv) { } } vector_resize(vv,k); + return 0.0; } ENDVERBATIM @@ -917,6 +918,7 @@ static double vfill (void* vv) { nx = vector_instance_px(vv, &x); nv1 = vector_arg_px(1, &v1); 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 && kkpL->isz) vector_resize(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 %p\n", i, ix, pL->pv[i]); FreeListVec(&pL); hxe();} y[j]=pL->pv[i][ix]; cnt++; @@ -1880,7 +1887,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 %p\n", i, ix, pL->pv[i]); FreeListVec(&pL); hxe();} *hoc_pgetarg(j)=ret=pL->pv[i][ix]; cnt++; @@ -2297,7 +2304,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) { @@ -2905,7 +2912,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;