#include #include #include #include "myc_fortran.h" void F_FUN(dat_axis_range)(float *xin, int *nin, float *xstart, float *xend, float *pMargin, int *i1, int *i2) { int i; float x1, x2, margin; margin=*pMargin; if (margin<0) margin=-margin; if (*xstart>*xend) { x1=*xend-margin; x2=*xstart+margin; } else { x1=*xstart-margin; x2=*xend+margin; } *i1=*nin; *i2=0; for (i=0; i<*nin; i++) { if (x1 < xin[i] && xin[i] < x2) { if (i>*i2) *i2=i; if (i<*i1) *i1=i; } } } void dat_fillin(float *src, float *dst, int size, float *wsum, int j, float weight) { int k; dst += j*size; if (wsum!=NULL) wsum[j] += weight; for (k=0; k| ** ** The values from the source are distributed to the destination according to the overlap ** of the intervals. Output channel 0 will get a small part from input channel 0 and ** a large part from channel 1, output channel 5 will get all of channel 4 plus ** some part of channel 3 and channel 5. ** ** xin x-values (size nin) (may be NULL, if x-values are [0.0,1.0,2.0,3.0,4.0,....]) ** src source (size grpsize*nin*nblocks) ** xstart start value ** xs x-step for output ** nout number of output channels ** dst destination (size grpsize*nout*nblocks) ** wout output weights (size nout, may be NULL if not needed) */ int i, j, m, ja, jb, bsize; float w, x, xl, xr, xa, xb, dx0, dx1, dx; assert(nin>=1 && src !=NULL && grpsize>0 && nblocks>0 && xs!=0.0 && nout>0 && dst!=NULL && wout!=NULL); for (j=0; j-0.5) { if (xb<0.5) { w=1.0; } else { w=(0.5-xa)/dx; } } else { if (xb<0.5) { w=(xb+0.5)/dx; } else { w=1.0; } } if (w>0.0) { dat_fillin(src, dst, grpsize, wout, 0, w); } src+=grpsize; } } else { for (i=0; ixa) ja--; xb=xa+dx; jb=xb; if (jb=nout) { jb=nout; if (xb>nout) xb=nout; } if (ja=0) dat_fillin(src, dst, grpsize, wout, ja, (1-x)*w); if (jb=0) dat_fillin(src, dst, grpsize, wout, ja, xl*xl*w/2); if (ja+2==jb) { dat_fillin(src, dst, grpsize, wout, ja+1, ((1-xl/2)*xl+(1-xr/2)*xr)*w); } else { dat_fillin(src, dst, grpsize, wout, ja+1, ((1-xl/2)*xl+0.5)*w); for (j=ja+1; j32) return NX_ERROR; /* for now, support only f32, i32 and f64 */ ncells=1; for (i=0; i<*rank; i++) { cstart[i]=start[*rank-i-1]; csize[i]=size[*rank-i-1]; ncells=ncells*size[i]; } for (;i<32;i++) { cstart[i]=0; csize[i]=1; } data=calloc(ncells, cellsize); if (data==NULL) return NX_ERROR; flts=(float *)data; status=NXgetslab(handle, data, cstart, csize); if (status!=NX_OK) { free(data); return NX_ERROR; } if (type==NX_INT32) { /* convert int32 to float 32 */ ip=(int *)data; for (i=0; i