diff --git a/bnet.mod b/bnet.mod index 2e4f859..c63962d 100644 --- a/bnet.mod +++ b/bnet.mod @@ -105,21 +105,21 @@ brule* addrule (boonet* pnet, double* psrc, int targid, double weight, double* p int idx,i; if(pnet->prules == 0x0) { // take care of memory allocation pnet->rulebufsz = 16; - pnet->prules = calloc(pnet->rulebufsz, sizeof(brule) ); + pnet->prules = (struct BRULE*) calloc(pnet->rulebufsz, sizeof(brule) ); pnet->nrules = 0; } else if(pnet->nrules >= pnet->rulebufsz) { pnet->rulebufsz *= 2; - pnet->prules = realloc(pnet->prules, pnet->rulebufsz * sizeof(brule) ); + pnet->prules = (struct BRULE*) realloc(pnet->prules, pnet->rulebufsz * sizeof(brule) ); } idx = pnet->nrules; pnet->prules[idx].nsrc = nsrc; // set # of sources pnet->prules[idx].ptarg = &pnet->pnodes[targid]; // set target pnet->prules[idx].weight = weight; // set weight // set the sources - pnet->prules[idx].psrc = calloc(nsrc, sizeof(bnode*)); + pnet->prules[idx].psrc = (struct BNODE **) calloc(nsrc, sizeof(bnode*)); for(i=0;iprules[idx].psrc[i] = &pnet->pnodes[(int)psrc[i]]; // set source state for rule to be 'on' - pnet->prules[idx].psrcstate = calloc(nsrc, sizeof(int)); + pnet->prules[idx].psrcstate = (int *) calloc(nsrc, sizeof(int)); for(i=0;iprules[idx].psrcstate[i] = (int) psrcstate[i]; return &pnet->prules[ pnet->nrules++ ]; // return the new rule and inc # rules } @@ -193,7 +193,7 @@ CONSTRUCTOR { printf("BNET err0: must have a network with positive # of nodes!\n"); hxe(); } - _p_sop = (void*) makeboonet(sz); + _p_sop = (double*) makeboonet(sz); pnet = BP; pnet->id = ifarg(2) ? (int) *getarg(2) : 0; ENDVERBATIM @@ -267,7 +267,7 @@ PROCEDURE pr () { if(prule->psrc[j]->name) { sprintf(stmp,"%s%s%s ", j>0?"AND ":"", prule->psrcstate[j]?"":"!", prule->psrc[j]->name); } else { - sprintf(stmp,"%s%s%s ", j>0?"AND ":"", prule->psrcstate[j]?"":"!", prule->psrc[j]->id); + sprintf(stmp,"%s%s%d ", j>0?"AND ":"", prule->psrcstate[j]?"":"!", prule->psrc[j]->id); } strcat(srcstr,stmp); } @@ -288,13 +288,12 @@ FUNCTION graphviz () { int i, j, k, LR, fsz, w, h; bnode* pnodes = BP->pnodes; brule* prule; - char *ncolor, *fcolor, *arrowtype, *lstyle, *shape;//node color, font color, arrow type, line style, node shape - char buf[4096], *dotname, *fname, *ext, fontsize[128]; + char buf[4096], *dotname, *fname, fontsize[128]; double penw; // penwidth FILE* fp = 0x0; dotname = ifarg(1) ? gargstr(1) : 0x0; fname = ifarg(2) ? gargstr(2) : 0x0; - ext = ifarg(3) ? gargstr(3) : "gif"; + const char* ext = ifarg(3) ? gargstr(3) : "gif"; LR = ifarg(4) ? (int) *getarg(4) : 1; w = ifarg(5) ? (int) *getarg(5) : -1; h = ifarg(6) ? (int) *getarg(6) : -1; @@ -308,9 +307,9 @@ FUNCTION graphviz () { if(LR){sprintf(buf, "%s", "\trankdir=LR;\n"); if(fp) fprintf(fp,"%s",buf); else fprintf(stdout,"%s",buf); } if(w>0 && h>0) {sprintf(buf, "size=\"%d,%d\"\n",w,h); if(fp) fprintf(fp,"%s",buf); else fprintf(stdout,"%s",buf);} for(i=0;inumnodes;i++) { - ncolor = BP->pnodes[i].knockout ? "white" : BP->pnodes[i].state > 0 ? "black" : "gray"; - fcolor = BP->pnodes[i].knockout ? "black" : "white"; - shape = pnodes[i].sthresh > 0 ? "invtriangle" : "doublecircle"; + const char* ncolor = BP->pnodes[i].knockout ? "white" : BP->pnodes[i].state > 0 ? "black" : "gray"; + const char* fcolor = BP->pnodes[i].knockout ? "black" : "white"; + const char* shape = pnodes[i].sthresh > 0 ? "invtriangle" : "doublecircle"; if(BP->pnodes[i].name) { sprintf(buf,"\t%s [fontcolor=%s,%sstyle=filled,shape=%s,fillcolor=%s,color=%s]\n", BP->pnodes[i].name,fcolor,fontsize,shape,ncolor,ncolor); @@ -324,8 +323,8 @@ FUNCTION graphviz () { prule = &BP->prules[i]; for(j=0;jnsrc;j++) { penw = prule->psrcstate[j] == prule->psrc[j]->state ? 6.0 : 1.0; - arrowtype = prule->weight < 0 ? "tee" : "open"; - lstyle = prule->psrcstate[j] == 0 ? ",style=dashed" : " "; + const char* arrowtype = prule->weight < 0 ? "tee" : "open"; + const char* lstyle = prule->psrcstate[j] == 0 ? ",style=dashed" : " "; if(prule->psrc[j]->name) { if(prule->ptarg->name) { sprintf(buf,"\t%s -> %s [arrowhead=%s,penwidth=%g,color=%s%s]\n", @@ -613,7 +612,6 @@ FUNCTION setnname () { FUNCTION getnname () { VERBATIM int i, id, sz; char **pname, string[BUFSIZ]; - char** hoc_pgargstr(); id = (int) *getarg(1); if(id < 0 || id >= BP->numnodes) { printf("BNET.getnname ERR0: invalid node index %d\n",id); diff --git a/misc.h b/misc.h index 1fa7839..1b23320 100644 --- a/misc.h +++ b/misc.h @@ -4,7 +4,7 @@ #include #include /* contains LONG_MAX */ #include -#include +#include #include #include @@ -54,15 +54,15 @@ 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 double *vector_newsize(void* v, int n); extern unsigned int dcrsz; extern double *dcr; extern double *dcrset(int); @@ -73,6 +73,7 @@ extern unsigned int iscrsz; extern int *iscr; extern int *iscrset(int); extern double BVBASE; +#ifndef NRN_VERSION_GTEQ_8_2_0 extern double* hoc_pgetarg(); extern void hoc_notify_iv(); extern double hoc_call_func(Symbol*, int narg); @@ -80,7 +81,6 @@ 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(); @@ -88,35 +88,37 @@ 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 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 int hoc_is_tempobj_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(); +#endif +extern void dshuffle(double* x,int nx); +int uniq2(int, double*, double*, double*); +extern int cmpdfn(double, double); extern int openvec(int, double **); -int list_vector_px(); -double *list_vector_resize(); +int list_vector_px(Object*, int, double**); +int list_vector_px2(Object *, int, double**, IvocVect**); +int list_vector_px3(Object*, int, double**, IvocVect**); +int list_vector_px4(Object *ob, int i, double** px, unsigned int n); +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(); +int IsList(Object*); static double sc[6]; static FILE* testout; @@ -132,8 +134,3 @@ 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); - - - - - diff --git a/misc.mod b/misc.mod index 63883ee..95e9085 100644 --- a/misc.mod +++ b/misc.mod @@ -41,6 +41,8 @@ NEURON { } VERBATIM +#include "misc.h" + #include /* F_OK */ #include /* errno */ #include @@ -48,7 +50,6 @@ VERBATIM #include #include #include -extern int hoc_is_tempobj(int narg); ENDVERBATIM :* FUNCTION file_exist() @@ -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,7 +86,6 @@ FUNCTION sassign() { VERBATIM FILE *pipein; char string[BUFSIZ], **strname, *syscall; - char** hoc_pgargstr(); strname = hoc_pgargstr(1); syscall = gargstr(2); @@ -197,7 +197,7 @@ VERBATIM size_t x,y; x=(size_t)_lsz; pmlc=(char *)malloc(x); - printf("Did %ld: %x\n",x,pmlc); + printf("Did %ld: %p\n",x,pmlc); y=(unsigned int)_lsz-1; pmlc[y]=(char)97; printf("WRITE/READ 'a': "); @@ -217,8 +217,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/readme.html b/readme.html index ce403b5..37b001c 100644 --- a/readme.html +++ b/readme.html @@ -98,6 +98,11 @@ For questions/comments email: samuel dot neymotin at yale dot edu or samn at neurosim dot downstate dot edu +Changelog: + 20160920 This updated version from the Lytton lab allows this model to run on the mac. +20220523 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. diff --git a/stats.mod b/stats.mod index bb9519d..9a2e124 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, int); static int compare_ul(const void* l1, const void* l2) { int retval; @@ -426,9 +427,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; @@ -470,9 +471,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; @@ -643,7 +644,7 @@ int qsort2 (double *p1in, double* p2in, int n,double* p1out,double* p2out) { int i; scr=scrset(n); for (i=0;i 1.0 + IvocVect* vhso; if(!(pHocVecFunc=hoc_lookup(gargstr(4)))){ printf("rsampsig ERRA: couldn't find hoc vec func %s\n",gargstr(4)); goto CLEANRSAMPSIG; @@ -1416,7 +1417,7 @@ static double rsampsig(void* vv){ hoc_pushx(dm0); hoc_pushx(dm1); hoc_call_func(pHocCompFunc,2); //call comparison function pthis[i]=onesided?hretval:fabs(hretval); //save value from comparison function } - vector_resize(vv,nruncombs);//resize calling vec + vector_resize((IvocVect*)vv,nruncombs);//resize calling vec //get comparison function value for original data groups vector_resize(vhso,n0); memcpy(phso,g0,sizeof(double)*n0); hoc_call_func(pHocVecFunc,0); dm0 = hretval; //get measure on original group 0 @@ -1446,7 +1447,7 @@ static double rantran (void* vv) { int i,j,ix,ixe,ixvn,nvn,rvn,na,xj; double *ixv, *nv, *x, y[1], ixn,step,indx; rvn=vector_instance_px(vv, &x); - for (na=1;ifarg(na);na++); na--; // count args + for (na=1;ifarg(na);na++) {} na--; // count args for (i=1;i(int)newline){printf("\n ",colc); colc=0;} + if (colc>(int)newline){printf("\n "); colc=0;} } } printf("\n"); @@ -1660,10 +1661,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.; } static void vprpr (double x, int base) { @@ -1693,7 +1695,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); @@ -1742,7 +1744,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();} @@ -1783,8 +1785,8 @@ 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_instance_px(vv, &prate); + vector_resize((IvocVect*)vv,nx); + vector_instance_px((IvocVect*)vv, &prate); binsz = *getarg(2); for(i=0;iUINT_MAX) y/=1e9; // UINT_MAX is 4.294967e+09 ihigh*=(unsigned int)y; // keep multiplying these out } @@ -2148,7 +2151,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; @@ -2222,7 +2224,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/vecst.mod b/vecst.mod index 035fffa..8b73d0a 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*%p Dbl*%p 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 %p\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 %p\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,14 +2438,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(void* vv, int n) { vector_resize(vv,n); return vector_vec(vv); } @@ -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;iscrsz*sizeof(int)) { if (scrsz>0) { free(scr); scr=(unsigned int *)NULL; } scr=(unsigned int *)ecalloc(1, sz); @@ -2802,7 +2812,7 @@ static double rdfile (void* vv) { i+=(vsz*sizeof(short)); } else printf("rdfile() type %d not implemented\n",ty); } - if (vflag) vector_resize(vector_arg(2), k); + if (vflag) vector_resize((IvocVect*)vector_arg(2), k); if (scrsz>1e7) { 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; } }