diff --git a/clampex.mod b/clampex.mod index c1c958a..71ea7c5 100644 --- a/clampex.mod +++ b/clampex.mod @@ -9,7 +9,9 @@ ASSIGNED { } VERBATIM +#ifndef NRN_VERSION_GTEQ_8_2_0 extern double chkarg(); +#endif typedef struct CEXData { #if 1 @@ -31,7 +33,7 @@ typedef struct CEXData { }CEXData; #define CEXD CEXData* cexd = (CEXData*)((unsigned long)pointer); -static void reverse(b, n ) char* b; int n; { +static void reverse(char* b, int n) { int i, j, v_; for (i=0, j=n-1; iheader); diff --git a/field.mod b/field.mod index a73b5c2..5f2818b 100644 --- a/field.mod +++ b/field.mod @@ -3,7 +3,7 @@ VERBATIM #include "misc.h" #define NSW 5 // store into this many ww field vecs -static void* ww[NSW]; +static IvocVect* ww[NSW]; static double* wwo[NSW]; static int ixp1; ENDVERBATIM diff --git a/infot.mod b/infot.mod index 60c86f6..c09e496 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 perhaps be fabs */ 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;iid=lid; ip->type=lty; ip->inhib=lin; ip->col=lco; ip->pg=0x0; ip->dvi=0x0; ip->sprob=0x0; @@ -323,7 +325,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; } @@ -414,7 +416,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;iisprob[i]) (*pnt_receive[jp->dvi[i]->_prop->_type])(jp->dvi[i], wts, idty); _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: @@ -934,7 +936,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 be called right 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; // this should be called right after jitcondiv() getactive=a2=a3=a4=0; - if (ip->dead) return; + if (ip->dead) return 0; dvt=ip->dvt; dbs=ip->del; das=ip->dvi; _lgetdvi=(double)dvt; @@ -1067,13 +1069,13 @@ FUNCTION getdvi () { } else av1=1; // 1st vector arg //just get active postsynapses (not dead and non pruned) voi=vector_arg(iarg++); - if (flag==2) { x1=vector_newsize(voi,CTYPi); for (i=0;iid)+1e-2*(double)ip->type+1e-3*(double)ip->inhib+1e-4; prty=ip->type; sy=ip->inhib?GA:AM; @@ -1095,7 +1097,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++) { @@ -1117,7 +1119,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 be called right after jitcondiv() sz=ip->dvt; // // assume conv similar to div getactive=0; @@ -1216,7 +1218,7 @@ FUNCTION rddvi () { 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); @@ -1319,7 +1321,7 @@ PROCEDURE clrdvi () { lop(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 @@ -1354,7 +1356,7 @@ FUNCTION setdviv () { : 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; int i, dvt; @@ -1393,9 +1395,9 @@ ENDVERBATIM PROCEDURE setdvi () { VERBATIM { int i,dvt,flag; double *d, *y; - if (! ifarg(1)) {printf("setdvi(v1,v2[,flag]): v1:cell#s; v2:delays\n"); return; } + if (! ifarg(1)) {printf("setdvi(v1,v2[,flag]): v1:cell#s; v2:delays\n"); return 0; } ip=IDP; pg=ip->pg; // this should be called right after jitcondiv() - if (ip->dead) return; + if (ip->dead) return 0; dvt=vector_arg_px(1, &y); i=vector_arg_px(2, &d); if (ifarg(3)) flag=(int)*getarg(3); else flag=0; @@ -1408,7 +1410,7 @@ ENDVERBATIM VERBATIM // setdvi2(divid_vec,del_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,int dvt,int flag) { +static void setdvi2 (double *y,double *d,int dvt,int flag) { int i,j,ddvi; double *db, *dbs; unsigned char pdead; unsigned int b,e; Object *lb; Point_process *pnnt, **da, **das; ddvi=(int)DEAD_DIV; @@ -1416,10 +1418,10 @@ static int setdvi2 (double *y,double *d,int dvt,int flag) { if (flag==0) { b=0; e=dvt; // begin to end if (ip->dvi) { free(ip->dvi); free(ip->del); free(ip->sprob); - ip->dvt=0; ip->dvi=(Point_process**)0x0; ip->del=(double*)0x0; ip->sprob=(char *)0x0; + ip->dvt=0; ip->dvi=(Point_process**)0x0; ip->del=(double*)0x0; ip->sprob=(unsigned char *)0x0; } // 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;} + if (ip->dvt==0) {ip->dvi=(Point_process**)0x0; ip->del=(double*)0x0; ip->sprob=(unsigned char *)0x0;} b=ip->dvt; e=ip->dvt+dvt; // dvt is amount to grow } @@ -1458,7 +1460,7 @@ PROCEDURE prune () { printf("INTFpruneB: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 @@ -1525,11 +1527,11 @@ 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); - jp->dvt=0; jp->dvi=(Point_process**)0x0; jp->del=(double*)0x0; jp->sprob=(char *)0x0; + jp->dvt=0; jp->dvi=(Point_process**)0x0; jp->del=(double*)0x0; jp->sprob=(unsigned char *)0x0; } } ENDVERBATIM @@ -1637,7 +1639,7 @@ PROCEDURE jitrec () { int i; if (! ifarg(2)) { // clear with jitrec() or jitrec(0) jrmax=0; jridv=0x0; jrtvv=0x0; - return; + return 0; } i = vector_arg_px(1, &jrid); // could just set up the pointers once jrmax=vector_arg_px(2, &jrtv); @@ -1748,7 +1750,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); @@ -1765,7 +1767,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); @@ -1780,7 +1782,7 @@ PROCEDURE record () { VERBATIM { int i,j,k,nz; double ti; vp = SOP; - if (tg>=t) return; + if (tg>=t) return 0; if (ip->record==1) { while ((int)vp->p >= (int)vp->size-(int)((t-tg)/vdt)-10) { vp->size*=2; @@ -1818,7 +1820,7 @@ PROCEDURE recspk (x) { VERBATIM { int k; 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->vvo[0]!=0x0) vp->vvo[0][vp->p-1]=_lx; vp->vvo[6][vp->p-1]=spkht; // the spike tg=_lx; @@ -1948,11 +1950,12 @@ PROCEDURE trvsp () { VERBATIM int i, flag; - double ind, t0; + double ind, local_t0; ip=IDP; flag=(int) *getarg(1); if (subsvint==0.) {printf("trvsp"); return(0.);} - ind=isp[0]; t0=vsp[0]; + ind=isp[0]; + local_t0=vsp[0]; if (flag==1) { 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 %x %x;",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 (vsp!=nil) printf("VSP: %x (%d/%d-%d)\n",(unsigned int)vsp,ip->rvi,ip->rvb,ip->rve); else printf("no VSP\n"); - if (jsp!=nil) printf("JSP: %x (%d/%d)\n",(unsigned int)jsp,jtpt,jtmax); else printf("no JSP\n"); + if (vsp!=nil) printf("VSP: %x (%d/%d-%d)\n",vsp,ip->rvi,ip->rvb,ip->rve); else printf("no VSP\n"); + if (jsp!=nil) printf("JSP: %x (%d/%d)\n",jsp,jtpt,jtmax); else printf("no JSP\n"); } if (lfg==3) { if (vsp!=nil) { printf("VSP: (%d/%d-%d)\n",ip->rvi,ip->rvb,ip->rve); @@ -2161,7 +2165,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 && kdbx==-1)printf("slowset fi:%d ix:%d ss:%g delt:%g t:%g\n",fi,ix,slowset,delt,t); if (t>slowset || ix>=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; } if (ix0 && ifarg(3)) { printf("INTF 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; } ip = IDP; setfl=ifarg(3); if (ifarg(4)) { slowset=*getarg(4); delt=slowset/cesz; slowset+=t; } @@ -2554,7 +2558,7 @@ FUNCTION flag () { FUNCTION allspck () { VERBATIM - int i; double *x, sum; void *voi; + int i; double *x, sum; IvocVect* voi; ip = IDP; voi=vector_arg(1); x=vector_newsize(voi,cesz); for (i=0,sum=0;ipv; - 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)); @@ -454,7 +454,7 @@ FUNCTION GetCCR () { return 0.0; } - unsigned int iSeed = ifarg(7)?(unsigned int)*getarg(7):INT_MAX-109754; + uint32_t iSeed = ifarg(7)?(uint32_t)*getarg(7):INT_MAX-109754; double* pUse = 0; @@ -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; @@ -562,7 +562,7 @@ FUNCTION GetCentrality () { return 0.0; } - unsigned int iSeed = ifarg(4)?(unsigned int)*getarg(4):INT_MAX-109754; + uint32_t iSeed = ifarg(4)?(uint32_t)*getarg(4):INT_MAX-109754; double* pUse = 0; @@ -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; @@ -780,7 +780,7 @@ FUNCTION CountNeighborsR () { double dSubsamp = ifarg(6)?*getarg(6):1.0; - unsigned int iSeed = ifarg(7)?(unsigned int)*getarg(7):INT_MAX-109754; + uint32_t iSeed = ifarg(7)?(uint32_t)*getarg(7):INT_MAX-109754; if(iStartID < 0 || iStartID >= iCells || iEndID < 0 || iEndID >= iCells || @@ -965,7 +965,7 @@ FUNCTION GetWPath () { double* ppre = 0, *ppo = 0, *pwght = 0, *pdel = 0, *pout = 0; int iSz,iTmp,i,j,k,l; - void* voi; + IvocVect* voi; iSz = vector_arg_px(1,&ppre); @@ -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; @@ -1185,7 +1185,7 @@ FUNCTION GetPathR () { double dSubsamp = ifarg(6)?*getarg(6):1.0; - unsigned int iSeed = ifarg(7)?(unsigned int)*getarg(7):INT_MAX-109754; + uint32_t iSeed = ifarg(7)?(uint32_t)*getarg(7):INT_MAX-109754; if(iStartID < 0 || iStartID >= iCells || iEndID < 0 || iEndID >= iCells || @@ -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,8 @@ FUNCTION GetCCSubPop () { FUNCTION GetRecurCount () { VERBATIM ListVec* pList; - int iCells,*pLen,iFromSz,iThruSz,idx,myID,youID,jdx,iCheckSz,*pVisited,*pCheck; + unsigned int* pLen; + int iCells,iFromSz,iThruSz,idx,myID,youID,jdx,iCheckSz,*pVisited,*pCheck; double **pLV,*pFrom,*pThru,*pR; pList = AllocListVec(*hoc_objgetarg(1)); @@ -1509,7 +1510,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 +1633,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; @@ -1656,7 +1657,7 @@ FUNCTION GetPathSubPop () { int bSelfLoop = ifarg(6)?(int)*getarg(6):0; - unsigned int iSeed = ifarg(7)?(unsigned int)*getarg(7):INT_MAX-109754; + uint32_t iSeed = ifarg(7)?(uint32_t)*getarg(7):INT_MAX-109754; //init array of cells/neighbors to check int* pCheck = (int*)malloc(sizeof(int)*iCells); @@ -1787,7 +1788,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; @@ -1809,7 +1810,7 @@ FUNCTION GetLoopLength () { } double dSubsamp = ifarg(5)?*getarg(5):1.0; - unsigned int iSeed = ifarg(6)?(unsigned int)*getarg(6):INT_MAX-109754; + uint32_t iSeed = ifarg(6)?(uint32_t)*getarg(6):INT_MAX-109754; //init array of cells/neighbors to check int* pCheck = (int*)malloc(sizeof(int)*iCells); @@ -1928,7 +1929,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 40bebca..6647555 100644 --- a/misc.h +++ b/misc.h @@ -2,11 +2,12 @@ #include #include +#include /* contains DBL_MAX */ #include /* contains LONG_MAX */ #include -#include -#include +#include #include +#include #if !defined(t) #define _pval pval @@ -53,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 (IvocVect* 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); @@ -84,17 +76,10 @@ 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 void mcell_ran4_init(uint32_t idum); extern double mcell_ran4(unsigned int* idum,double* ran_vec,unsigned int n,double range); -extern int nrn_mlh_gsort(); +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); @@ -102,12 +87,37 @@ 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 void clear_event_queue(); +extern void cvode_fadvance(double); +extern int hoc_is_tempobj_arg(int narg); +extern Object* ivoc_list_item(Object*, int); +#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 double hoc_epsilon; +extern int stoprun; +extern void set_seed(); +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, 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 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); @@ -115,8 +125,9 @@ 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(); +extern int IsList (Object* p); +extern int uniq2 (int n, double *x, double *y, double *z); +static void vprpr (double x, int base); static double sc[6]; static FILE* testout; diff --git a/misc.mod b/misc.mod index 87b063e..9442107 100644 --- a/misc.mod +++ b/misc.mod @@ -48,6 +48,7 @@ VERBATIM #include #include #include +#include "misc.h" extern int hoc_is_tempobj(int narg); ENDVERBATIM @@ -58,7 +59,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 +86,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 +121,20 @@ 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 +218,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/netrand.inc b/netrand.inc index 5737d41..59ff392 100644 --- a/netrand.inc +++ b/netrand.inc @@ -51,7 +51,7 @@ INITIAL { CONSTRUCTOR { VERBATIM cbsv=0x0; - _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; ENDVERBATIM } @@ -109,13 +109,13 @@ NET_RECEIVE (weight, on, nspike, r0, t0 (ms)) { PROCEDURE initrnd () { VERBATIM - int i,j,max; - if (hoc_is_str_arg(i=1)) { - i++; + int local_i,j,max; + if (hoc_is_str_arg(local_i=1)) { + local_i++; cbsv=hoc_lookup(gargstr(1)); } - j=vector_arg_px(i++, &ip->tsp); - max=vector_arg_px(i++, &ip->wsp); + j=vector_arg_px(local_i++, &ip->tsp); + max=vector_arg_px(local_i++, &ip->wsp); if (max!=j) {printf("initrnd ERR: vecs of different size: %d %d\n",max,j); hxe();} if (max==0) {printf("initrnd ERR: vec not initialized\n"); hxe();} ENDVERBATIM diff --git a/pregencv.mod b/pregencv.mod index 501f510..3b95dfc 100644 --- a/pregencv.mod +++ b/pregencv.mod @@ -87,7 +87,7 @@ PROCEDURE event_time() { PROCEDURE generate() { if (at_time(event)) { VERBATIM - {char func[8] = "pregencv_c"; + {char func[11] = "pregencv_c"; Symbol* s = hoc_lookup(func); if (s) { hoc_pushx(num); diff --git a/readme.txt b/readme.txt index 4b19334..d4a6ab8 100644 --- a/readme.txt +++ b/readme.txt @@ -59,3 +59,10 @@ For questions/comments/collaborations please contact Samuel Neymotin at samn at neurosim dot downstate dot edu or Bill Lytton at billl at neurosim dot downstate dot edu + +-------------------------------------------------------------------------- + Changelog +-------------------------------------------------------------------------- +2022-05: 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/stats.mod b/stats.mod index 13d4828..6198ce2 100644 --- a/stats.mod +++ b/stats.mod @@ -39,11 +39,12 @@ PARAMETER { ASSIGNED { seed } VERBATIM +#include #include "misc.h" #define MIN_MERGESORT_LIST_SIZE 32 union dblint { - int i[2]; + uint32_t i[2]; double d; }; @@ -425,9 +426,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 +470,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 +643,7 @@ int qsort2 (double *p1in, double* p2in, int n,double* p1out,double* p2out) { int i; scr=scrset(n); for (i=0;i2){ for(j=0;jUINT_MAX) y/=1e9; // UINT_MAX is 4.294967e+09 valseed*=(unsigned int)y; // keep multiplying these out @@ -2090,7 +2092,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 } @@ -2118,7 +2120,7 @@ FUNCTION gammln (xx) { FUNCTION betai(a,b,x) { VERBATIM { double bt; - double gammln(),betacf(); + 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; @@ -2192,7 +2194,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..ec290b7 100644 --- a/updown.mod +++ b/updown.mod @@ -19,28 +19,7 @@ VERBATIM #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 @@ -72,7 +51,7 @@ static double updown (void* vv) { int i, k, m, n, nqsz, nsrc, jj[UDSL], f[UDSL], lc, dsz[UDSL], nqmax, thsz, lc2, done, dbn; double *src, *tvec, *th, *dest[UDSL], *nq[UDNQ], *tmp, *dbx, lt, thdist; Object *ob, *ob2; - void *vvd[UDSL], *vvth, *vnq[UDNQ]; + IvocVect *vvd[UDSL], *vvth, *vnq[UDNQ]; //** read in vectors and verify sizes, etc nsrc = vector_instance_px(vv, &src); // trace to analyze thsz = vector_arg_px(1, &th); // vector of thresholds to check diff --git a/vecst.mod b/vecst.mod index d191865..a6c0170 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 @@ -228,7 +228,7 @@ static double circ (void* vv) { int i, nx, ny, flag, lnew; double *x, *y, x0, y0, x1, y1, rad, theta; lnew=0; - nx = vector_instance_px(vv, &x); + nx = vector_instance_px((IvocVect*)vv, &x); ny = vector_arg_px(1, &y); if (ny!=nx) { hoc_execerror("v.circ: Vector sizes don't match.", 0); } x0=*getarg(2); y0=*getarg(3); rad=*getarg(4); @@ -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(vector_arg(1),ny=nx); } for (i=0,theta=0; iscrsz) { @@ -372,7 +372,7 @@ static double lma (void* 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; - ni = vector_instance_px(vv, &ind); + ni = vector_instance_px((IvocVect*)vv, &ind); xx=iscrset(ni); ob1 = *hoc_objgetarg(1); ob2 = *hoc_objgetarg(2); beg = (int)*getarg(3); end= (int)*getarg(4); @@ -395,8 +395,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); @@ -753,19 +753,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; @@ -792,6 +792,7 @@ static double fread2 (void* vv) { } free((char *)xf); } else hoc_execerror("Type unsupported in fread2 ", 0); + return 0; } ENDVERBATIM @@ -799,20 +800,21 @@ ENDVERBATIM 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); + nx = vector_instance_px((IvocVect*)vv, &x); + 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;j0) vector_resize(vc,j); // only fall through here when doing indvwhere + if (j>0) vector_resize((IvocVect*)vc,j); // only fall through here when doing indvwhere return (double)j; } ENDVERBATIM @@ -851,17 +853,17 @@ VERBATIM static double insct (void* vv) { int i, j, k, nx, nv1, nv2, maxsz; double *x, *v1, *v2; - nx = vector_instance_px(vv, &x); + nx = vector_instance_px((IvocVect*)vv, &x); if (maxsz==0) maxsz=1000; - maxsz=vector_buffer_size(vv); - x=vector_newsize(vv, maxsz); + maxsz=vector_buffer_size((IvocVect*)vv); + x=vector_newsize((IvocVect*)vv, maxsz); nv1 = vector_arg_px(1, &v1); nv2 = vector_arg_px(2, &v2); for (i=0,k=0;iisz;iv++) { @@ -895,13 +897,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 @@ -915,6 +917,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++; @@ -1395,14 +1402,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;imaxsz) { 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;i=cnt) {printf("vecst:l2p() ERRA: %d %d %d\n",i,ix,cnt); hxe();} @@ -1833,9 +1841,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++; @@ -1844,7 +1852,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++; @@ -1969,9 +1977,9 @@ static double lcat (void* vv) { int i, j, k, n, lc, cap, maxsz; Object *ob1; double *x, *fr; - void *vw; + IvocVect *vw; n = vector_instance_px(vv, &x); - vector_resize(vv,maxsz=vector_buffer_size(vv)); // open it up fully + vector_resize((IvocVect*)vv,maxsz=vector_buffer_size((IvocVect*)vv)); // open it up fully ob1 = *hoc_objgetarg(1); lc = ivoc_list_count(ob1); for (i=0,j=0;iu.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; } @@ -2125,14 +2133,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; } @@ -2141,8 +2149,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 @@ -2232,7 +2240,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;} @@ -2261,7 +2269,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) { @@ -2352,6 +2348,18 @@ int uniq2 (int n, double *x, double *y, double *z) { return cnt; } +// x.unq(y,z) calls uniq2() -- functionality same as uniq(List,1) +static double unq (void* vv) { + int n, cnt; double *x, *y, *z; + n=vector_instance_px(vv, &x); + y=vector_newsize(vector_arg(1),n); // all same size + z=vector_newsize(vector_arg(2),n); + cnt=uniq2(n,x,y,z); + y=vector_newsize(vector_arg(1),cnt); + z=vector_newsize(vector_arg(2),cnt); + return (double)cnt; +} + // v1.nqsvt() for nqs vt iterator static double nqsvt (void* vv) { int i, j, n, flag, cols; @@ -2392,14 +2400,14 @@ 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) { +double *vector_newsize (IvocVect* vv, int n) { vector_resize(vv,n); return vector_vec(vv); } @@ -2425,7 +2433,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 @@ -2478,9 +2486,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); @@ -2528,9 +2536,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); @@ -2553,12 +2561,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; } @@ -2868,7 +2876,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; @@ -3110,9 +3126,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; } @@ -3134,9 +3150,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; } @@ -3145,7 +3161,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; } }