• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ NINT函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中NINT函数的典型用法代码示例。如果您正苦于以下问题:C++ NINT函数的具体用法?C++ NINT怎么用?C++ NINT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了NINT函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: rc1_fft

void rc1_fft(REAL *data, complex *cdata, int n, int sign)
{
	int    j;
	double *datft;

	if (NINT(pow(2.0, (double)NINT(log((double)n)/log(2.0)))) != n) {
		if (npfar(n) == n) pfarc(sign,n,data,cdata);
		else rcdft(data,cdata,n,sign);
	}
	else {
		datft = (double *)malloc(n*sizeof(double));
		if (datft == NULL) fprintf(stderr,"rc1_fft: memory allocation error\n");
	
		for (j = 0; j < n; j++) datft[j] = (double)data[j];
		realfft(n, datft);
		cdata[0].i = 0.0;
		for (j = 0; j < n/2; j++) {
			cdata[j].r = (REAL)datft[j]; 
			cdata[j+1].i = sign*(REAL)datft[n-j-1]; 
		}
		cdata[n/2].r = datft[n/2];
		cdata[n/2].i = 0.0; 
	
		free(datft);
	}

	return;
}
开发者ID:masterjkk,项目名称:OpenSource,代码行数:28,代码来源:lib_fft.c


示例2: cr1_fft

void cr1_fft(complex *cdata, REAL *data, int n, int sign)
{
	int    j;
	double *datft;

	if (NINT(pow(2.0, (double)NINT(log((double)n)/log(2.0)))) != n) {
		if (npfar(n) == n) pfacr(sign,n,cdata,data);
		else crdft(cdata,data,n,sign);
	}
	else {
		datft = (double *)malloc(n*sizeof(double));
		if (datft == NULL) fprintf(stderr,"cr1_fft: memory allocation error\n");

		for (j = 0; j < n/2; j++) {
			datft[j] = (double)cdata[j].r;
			datft[n-1-j] = (double)cdata[j+1].i;
		}
		datft[n/2] = (double)cdata[n/2].r;

		realifft(n, datft);
	
		if (sign == -1) {
			for (j = 0; j < n; j++) data[j] = (REAL)datft[j];
		}
		else if (sign == 1) {
			for (j = 1; j < n; j++) data[j] = (REAL)datft[n-j];
			data[0] = (REAL)datft[0];
		}
	
		free(datft);
	}
	
	return;
}
开发者ID:masterjkk,项目名称:OpenSource,代码行数:34,代码来源:lib_fft.c


示例3: FromLT

int FromLT (int rsize, double *ltm, double *ltv, int *bin, int *corner) {

/* arguments:
int rsize        i: reference pixel size
double ltm[2]    i: diagonal elements of MWCS matrix
double ltv[2]    i: MWCS linear transformation vector
int bin[2]       o: pixel size in X and Y
int corner[2]    o: corner of subarray in X and Y
*/

	extern int status;
	double dbinx, dbiny, dxcorner, dycorner;

	dbinx = (double)rsize / ltm[0];
	dbiny = (double)rsize / ltm[1];

	dxcorner = (dbinx - rsize) - dbinx * ltv[0];
	dycorner = (dbiny - rsize) - dbiny * ltv[1];

	/* Round off to the nearest integer. */
	corner[0] = NINT (dxcorner);
	corner[1] = NINT (dycorner);
	bin[0] = NINT (dbinx);
	bin[1] = NINT (dbiny);

	return (status);
}
开发者ID:brechmos-stsci,项目名称:hstcal,代码行数:27,代码来源:fromlt.c


示例4: NINT

asynStatus MCB4BAxis::sendAccelAndVelocity(double acceleration, double velocity) 
{
  asynStatus status;
  int ival;
  // static const char *functionName = "MCB4B::sendAccelAndVelocity";

  // Send the velocity
  ival = NINT(fabs(115200./velocity));
  if (ival < 2) ival=2;
  if (ival > 255) ival = 255;
  sprintf(pC_->outString_, "#%02dV=%d", axisNo_, ival);
  status = pC_->writeReadController();

  // Send the acceleration
  // acceleration is in steps/sec/sec
  // MCB is programmed with Ramp Index (R) where:
  //   dval (steps/sec/sec) = 720,000/(256-R) */
  //   or R=256-(720,000/dval) */
  ival = NINT(256-(720000./acceleration));
  if (ival < 1) ival=1;
  if (ival > 255) ival=255;
  sprintf(pC_->outString_, "#%02dR=%d", axisNo_, ival);
  status = pC_->writeReadController();
  return status;
}
开发者ID:epicsdeb,项目名称:synapps,代码行数:25,代码来源:MCB4BDriver.cpp


示例5: cc1_fft

void cc1_fft(complex *cdata, int n, int sign)
{
	int    j;
	double  *real, *imag;

	if (NINT(pow(2.0, (double)NINT(log((double)n)/log(2.0)))) != n) {
		if (npfa(n) == n) pfacc(sign, n, cdata);
		else ccdft(cdata,n,sign);
	}
	else {
		real = (double *)malloc(n*sizeof(double));
		if (real == NULL) fprintf(stderr,"cc1_fft: memory allocation error\n");
		imag = (double *)malloc(n*sizeof(double));
		if (imag == NULL) fprintf(stderr,"cc1_fft: memory allocation error\n");
	
		for (j = 0; j < n; j++) {
			real[j] = (double)cdata[j].r;
			imag[j] = (double)cdata[j].i;
		}

		if (sign < 0) fft(n, real, imag);
		else ifft(n, real, imag);

		for (j = 0; j < n; j++) {
			cdata[j].r = (REAL)real[j];
			cdata[j].i = (REAL)imag[j];
		}

		free(real);
		free(imag);
	}

	return;
}
开发者ID:masterjkk,项目名称:OpenSource,代码行数:34,代码来源:lib_fft.c


示例6: smooth

void smooth (float **in, float **out, long naxes[], float sigma, float radius)
{
    int i, j, k, l, xmin, ymin, xmax, ymax;
    float sumwt, sumflux, wt, rad;

    for (j=1; j <= naxes[2]; j++) {
	for (i=1; i <= naxes[1]; i++) {
	    xmin = IMAX (1, i - NINT(radius));
	    xmax = IMIN (i+NINT(radius), naxes[1]);
	    ymin = IMAX (1, j - NINT(radius));
	    ymax = IMIN (j+NINT(radius), naxes[2]);
	    sumwt = 0.;
	    sumflux = 0.;
	    for (l=ymin; l <= ymax; l++) {
		for (k=xmin; k <= xmax; k++) {
		    rad = sqrt((k-i)*(k-i)+(l-j)*(l-j));
		    if (rad <= radius) {
		        wt = exp (-rad*rad/2/sigma/sigma);
			sumwt += wt;
			sumflux += in[l][k] * wt;
		    };
		};	    
	    };
	    out[j][i] = sumflux / sumwt;
	};
    };
}
开发者ID:vvinuv,项目名称:pymorph,代码行数:27,代码来源:smooth.c


示例7: makefilter

void makefilter(float *f, int nfft, int nfreq, float dt, float *filter)
{
        float onfft = 1.0 / nfft;
        float df = onfft / dt;
        int nfreqm1 = nfreq - 1;
        int if1 = NINT(f[0]/df);
        int if2 = NINT(f[1]/df);
        int if3 = MIN(NINT(f[2]/df), nfreqm1);
        int if4 = MIN(NINT(f[3]/df), nfreqm1);


        { register int i;
	  register float c = PIBY2 / (if2 - if1 + 2);
	  for (i = if1; i <= if2; ++i) {
		register float s = sin(c*(i - if1 + 1));
		filter[i] = s * s * onfft;
          }
	 }

        { register int i;
	  register float c = PIBY2 / (if4 - if3 + 2);
	  for (i = if3; i <= if4; ++i) {
		register float s = sin(c*(if4 - i + 1));
		filter[i] = s * s * onfft;
	  }
        }

        { register int i;
          for (i = if2 + 1; i < if3;   ++i)  filter[i] = onfft; 
          for (i = 0;       i < if1;   ++i)  filter[i] = 0.0; 
          for (i = if4 + 1; i < nfreq; ++i)  filter[i] = 0.0; 
        }
}
开发者ID:JOravetz,项目名称:SeisUnix,代码行数:33,代码来源:sutvband.c


示例8: lnk_cell_dis

/*==========================================================================*/
void lnk_cell_dis(int ia, int ib, int ic, 
		  int ncell_a, int ncell_b, int ncell_c, 
		  double *rcell, double hmat_lnk[], int iperd)

/*==========================================================================*/
{/*Begin Routine */
/*==========================================================================*/
/*                 Local variables                                         */
  double acelli, bcelli, ccelli, dx, dy, dz, dsx, dsy, dsz;
  double dsxt, dsyt, dszt;

/*==========================================================================*/
/*  ia,ib,ic are the shifts along a,b,c                                     */
/*  ncell_a,ncell_b,ncell_c are the number of divisions along a,b,c         */
/*  hmat matrix of cell parameters                                          */
/*  rcell is return with cartesian distance associated with shifts          */
/* scalar temp                                                              */
/* get inverse number of divisions along cell axis                          */
/*==========================================================================*/

  acelli = 1. / (double) ncell_a;
  bcelli = 1. / (double) ncell_b;
  ccelli = 1. / (double) ncell_c;

  /* convert shifts to a displacement along fractional coord. (the s) */

  dsx = (double) ia * acelli;
  dsy = (double) ib * bcelli;
  dsz = (double) ic * ccelli;

  /* periodic image */
/*  if (iperd >= 1) {  dsx -= NINT(dsx);}*/
/*  if (iperd >= 2) {  dsy -= NINT(dsy);}*/
/*  if (iperd >= 3) {  dsz -= NINT(dsz);}*/
    dsx -= NINT(dsx);
    dsy -= NINT(dsy);
    dsz -= NINT(dsz);

  /* subtract out one cell to account that cell that share edges can have */
  /* particles separteded by one less cell distances */

/*  dsxt = copysign(acelli,dsx); */
/*  dsyt = copysign(bcelli,dsy); */
/*  dszt = copysign(ccelli,dsz); */
  if(dsx>=0){dsxt=acelli;}else{dsxt=-acelli;}
  if(dsy>=0){dsyt=bcelli;}else{dsyt=-bcelli;}
  if(dsz>=0){dszt=ccelli;}else{dszt=-ccelli;}
  if (dsx != 0.) {dsx -= dsxt;}
  if (dsy != 0.) {dsy -= dsyt;}
  if (dsz != 0.) {dsz -= dszt;}

  /* convert to cartesian displacements */
  dx = dsx * hmat_lnk[1] + dsy * hmat_lnk[4] + dsz * hmat_lnk[7];
  dy = dsx * hmat_lnk[2] + dsy * hmat_lnk[5] + dsz * hmat_lnk[8];
  dz = dsx * hmat_lnk[3] + dsy * hmat_lnk[6] + dsz * hmat_lnk[9];

  /* get distance */
  *rcell = sqrt(dx * dx + dy * dy + dz * dz);
} /* lnk_cell_dis */
开发者ID:Tang-QingYu,项目名称:PINY,代码行数:60,代码来源:lnk_lst_dis.c


示例9: main

int
main(int argc, char **argv)
{
	int i, j, n;
	float *f,  max, step, rstep;
	float fhist[1024], dev, rdev, ent, error; 
	int hist[1024];
	 
	initargs(argc, argv);
	requestdoc(1);

	MUSTGETPARINT("n",&n);

	f = alloc1float(n);

	fread(f,sizeof(float),n,stdin);
	
	for(i=0;i<1024;i++) hist[i] = 0;

	for(i=0,rdev=0.;i<n;i++)
	   rdev += f[i]*f[i]; 
	rdev = rdev/n;
	rdev = sqrt(rdev);

	if(!getparfloat("dev",&dev)) dev = rdev;

	fprintf(stderr,"dev=%f\n", dev);

	step = dev*3.464*.01;

	rstep = 1./step;

	error = 0.;
	for(i=0;i<n;i++){
	    max = f[i]*rstep;
	    error += (NINT(max)*step - f[i])*(NINT(max)*step - f[i]);
	    hist[NINT(max)+512] ++;
	}

	error = error/n;
	error = sqrt(error);
	error = error/rdev;

	ent = 0.;
	for(j=0;j<1024;j++){
		fhist[j] = ((float) hist[j])/((float) n);
		if(hist[j])
		    ent += fhist[j]*log(fhist[j])/log(2.);
	}
	ent = -ent;

fprintf(stderr,"entropy of the signal is=%f, average error=%f\n",ent, error);

	fwrite(fhist,sizeof(float),1024,stdout);

	return EXIT_SUCCESS;
}
开发者ID:gwowen,项目名称:seismicunix,代码行数:57,代码来源:entropy.c


示例10: remove_fb

void remove_fb(float *yp,float *ym,int n,short *scaler,short *shft)
/* Find Scale and timeshift 

	Yp = data trace
	Ym = wavelet
	
	F=min(Yp(x) - Ym(x)*a)^2 is a function to minimize for scaler
	
	find shift first with xcorrelation then
	
	solve for a - scaler 
*/



{

#define RAMPR 5

	void find_p(float *ym,float *yp,float *a,int *b,int n);
	
	int it,ir;
	
	float a=1.0;
	int b=0;
	int ramps;
	float *a_ramp;
	
	ramps=NINT(n-n/RAMPR);
	
	find_p(ym,yp,&a,&b,n);
	
	a_ramp = ealloc1float(n);
	
	for(it=0;it<ramps;it++)
		a_ramp[it]=1.0;
	
	for(it=ramps,ir=0;it<n;it++,ir++) {
		a_ramp[it]=1.0-(float)ir/(float)(n-ramps-1);
	}
	
	
	
	if (b<0) {
		for(it=0;it<n+b;it++) 
			yp[it-b] -=ym[it]*a*a_ramp[it-b];
	} else {
		for(it=0;it<n-b;it++) 
			yp[it] -=ym[it-b]*a*a_ramp[it+b];
	}
	
	*scaler = NINT((1.0-a)*100.0);
	*shft = b;
	
	free1float(a_ramp);
}
开发者ID:JohnWStockwellJr,项目名称:SeisUnix,代码行数:56,代码来源:sugprfb.c


示例11: lint2d_make

/*------------------------------------------------------------*/
lint2d lint2d_make(	int na, 
					pt2d *aa, 
					fdm2d fdm)
		   
/*< init 2D linear interpolation >*/
{
    lint2d ca;
    int    ia;
    float f1,f2;
    
    ca = (lint2d) sf_alloc(1,sizeof(*ca));

    ca->n = na;

    ca->w00 = sf_floatalloc(na);
    ca->w01 = sf_floatalloc(na);
    ca->w10 = sf_floatalloc(na);
    ca->w11 = sf_floatalloc(na);

    ca->jz  = sf_intalloc(na);
    ca->jx  = sf_intalloc(na);

    for (ia=0; ia<na; ia++) {
	
		if(aa[ia].z >= fdm->ozpad && 
			aa[ia].z <  fdm->ozpad + (fdm->nzpad-1)*fdm->dz &&
			aa[ia].x >= fdm->oxpad && 
			aa[ia].x <  fdm->oxpad + (fdm->nxpad-1)*fdm->dx   ) {
				
			ca->jz[ia] = NINT((aa[ia].z-fdm->ozpad)/fdm->dz);
			ca->jx[ia] = NINT((aa[ia].x-fdm->oxpad)/fdm->dx);
				
			f1 = (aa[ia].z-fdm->ozpad)/fdm->dz - ca->jz[ia];
			f2 = (aa[ia].x-fdm->oxpad)/fdm->dx - ca->jx[ia];
		}
		else {
			ca->jz[ia] = 0; 
			ca->jx[ia] = 0;
			
			f1 = 1; 
			f2 = 0;
		}
		
		ca->w00[ia] = (1-f1)*(1-f2);
		ca->w01[ia] = (  f1)*(1-f2);
		ca->w10[ia] = (1-f1)*(  f2);
		ca->w11[ia] = (  f1)*(  f2);
		
    }
	
    return ca;
}
开发者ID:1014511134,项目名称:src,代码行数:53,代码来源:fdutil.c


示例12: FirstLast

static void FirstLast (double *ltm, double *ltv, int *snpix, int *npix,
		int *rbin, int *first, int *last, int *sfirst) {

/* arguments:
double ltm[2], ltv[2]   i: linear transformation from scratch to image coords
				(adjusted for use with zero indexed coords)
int snpix[2]            i: size of scratch image
int npix[2]             i: size of actual image
int rbin[2]             o: number of pixels in scratch for one image pixel
int first[2], last[2]   o: corners of overlap region, in image coords
int sfirst[2]           o: lower left corner of overlap, in scratch array
*/

	double scr;		/* pixel coordinate in scratch array */
	int i, k;

	rbin[0] = NINT (1. / ltm[0]);
	rbin[1] = NINT (1. / ltm[1]);

	for (k = 0;  k < 2;  k++) {	/* axis number */
	    /* Search for the first pixel in the image array that maps to a
		point that is completely within the scratch array.  The left
		(lower) edge of pixel i is (i - 0.5).  Map (i - 0.5) to the
		scratch array, and if that point is within the scratch array,
		i is the first fully illuminated pixel.
	    */
	    for (i = 0;  i < npix[k];  i++) {
		scr = (i - 0.5 - ltv[k]) / ltm[k];
		/* -0.5 is left (lower) edge of first pixel in scratch */
		if (scr+TOLERANCE >= -0.5) {
		    first[k] = i;
		    sfirst[k] = NINT (scr+0.5);
		    break;
		}
	    }
	    /* Now look for the last fully illuminated pixel, using the
		right (upper) edge of the image pixels.
	    */
	    for (i = npix[k]-1;  i > 0;  i--) {
		scr = (i + 0.5 - ltv[k]) / ltm[k];
		/* compare scr with right (upper) edge of last pixel in the
		   scratch array
		*/
		if (scr-TOLERANCE <= snpix[k]-1. + 0.5) {
		    last[k] = i;
		    break;
		}
	    }
	}
}
开发者ID:jhunkeler,项目名称:hstcal,代码行数:50,代码来源:dodqi.c


示例13: crm_fft

void crm_fft(complex *cdata, REAL *data, int n1, int n2, int ldc, int ldr, int sign)
{
	int    j, i;
	double *datft;

	if (NINT(pow(2.0, (double)NINT(log((double)n1)/log(2.0)))) != n1) {
		if (npfar(n1) == n1) {
			if (ldr == n1 && ldc == n2) {
				pfa2cr(sign, 1, n1, n2, cdata, data);
			}
			else {
				for (i = 0; i < n2; i++) {
					pfacr(sign, n1, &cdata[i*ldc], &data[i*ldr]);
				}
			}
		}
		else {
			for (i = 0; i < n2; i++) {
				crdft(&cdata[i*ldc], &data[i*ldr], n1, sign);
			}
		}
	}
	else {
		datft = (double *)malloc(n1*sizeof(double));
		if (datft == NULL) fprintf(stderr,"crm_fft: memory allocation error\n");
	
		for (i = 0; i < n2; i++) {
			for (j = 0; j < n1/2; j++) {
				datft[j] = (double)cdata[i*ldc+j].r;
				datft[n1-1-j] = (double)cdata[i*ldc+j+1].i;
			}
			datft[n1/2] = (double)cdata[i*ldc+n1/2].r;
	
			realifft(n1, datft);
	
			if (sign == -1) {
				for (j = 0; j < n1; j++) data[i*ldr+j] = (REAL)datft[j];
			}
			else if (sign == 1) {
				for (j = 1; j < n1; j++) data[i*ldr+j] = (REAL)datft[n1-j];
				data[i*ldr] = (REAL)datft[0];
			}
		}
	
		free(datft);
	}

	return;
}
开发者ID:masterjkk,项目名称:OpenSource,代码行数:49,代码来源:lib_fft.c


示例14: sendAccelAndVelocity

asynStatus MCB4BAxis::move(double position, int relative, double minVelocity, double maxVelocity, double acceleration)
{
  asynStatus status;
  // static const char *functionName = "MCB4BAxis::move";

  status = sendAccelAndVelocity(acceleration, maxVelocity);
  
  if (relative) {
    sprintf(pC_->outString_, "#%02dI%+d", axisNo_, NINT(position));
  } else {
    sprintf(pC_->outString_, "#%02dG%+d", axisNo_, NINT(position));
  }
  status = pC_->writeReadController();
  return status;
}
开发者ID:epicsdeb,项目名称:synapps,代码行数:15,代码来源:MCB4BDriver.cpp


示例15: adjustAxesValues

static void adjustAxesValues (int n1, float d1, float f1,
	int n2, float d2, float f2,
	float *x1beg, float *x1end, float *x2beg, float *x2end)
/*****************************************************************************
Adjust axes values to nearest samples; ensure at least 2 by 2 samples.
*****************************************************************************/
{
	int ix1beg,ix1end,ix2beg,ix2end;
	
	ix1beg = NINT((*x1beg-f1)/d1);
	ix1end = NINT((*x1end-f1)/d1);
	ix1beg = MAX(0,MIN(n1-1,ix1beg));
	ix1end = MAX(0,MIN(n1-1,ix1end));
	if (ix1beg==ix1end) {
		if (*x1beg<*x1end) {
			if (ix1beg>0)
				ix1beg--;
			else
				ix1end++;
		} else {
			if (ix1beg<n1-1)
				ix1beg++;
			else
				ix1end--;
		}
	}
	*x1beg = f1+ix1beg*d1;
	*x1end = f1+ix1end*d1;
	ix2beg = NINT((*x2beg-f2)/d2);
	ix2end = NINT((*x2end-f2)/d2);
	ix2beg = MAX(0,MIN(n2-1,ix2beg));
	ix2end = MAX(0,MIN(n2-1,ix2end));
	if (ix2beg==ix2end) {
		if (*x2beg<*x2end) {
			if (ix2beg>0)
				ix2beg--;
			else
				ix2end++;
		} else {
			if (ix2beg<n2-1)
				ix2beg++;
			else
				ix2end--;
		}
	}	
	*x2beg = f2+ix2beg*d2;
	*x2end = f2+ix2end*d2;
}
开发者ID:JOravetz,项目名称:SeisUnix,代码行数:48,代码来源:xmovie.c


示例16: alpha_trim_w

float alpha_trim_w(float *a,float *w,int n,float p)
/******************************************************************
alpha_trim_w - Weighted Alpha trim of array 
******************************************************************
Notes:
 the value a[irp] is replaced by the mean of the 
 a values, but the largers and smallest p% of a 
 values are left out fo mean computation,array a is destroyed 
******************************************************************
Author: Balasz Nemeth, given to CWP in 2008 by Potash Corporation
******************************************************************/
{
	float mean=0;
	unsigned int ist=NINT(n*(p/100.0));
	unsigned int i,ic;
	int *ind=NULL;
	
	ind = ealloc1(n,sizeof(unsigned int));
	
	for(i=0;i<n;++i) ind[i]=i;
	
	qkisort(n,a,ind);
	
	for(i=ist,ic=0;i<n-ist;i++,ic++) 
		mean += a[ind[i]]*w[ind[i]];
		
	free1(ind);
	
	return(mean/(float)ic);
}
开发者ID:griscenco,项目名称:SeisUnix,代码行数:30,代码来源:sufwatrim.c


示例17: randdf

void randdf(float *x, float *z, int nxp, float dx, float dz, float **gridcp, float **gridcs, float **gridro, float **cp, float **cs, float **ro, float *interface, int *zp, int nx, float sizex, float sizez, int ndiff, int diffrwidth, int type)
{
    float x0, z0, dsx, dsz;
    int i, rtype;
    long lseed;
    
	rtype=type;
    lseed = (long)ndiff;
    srand48(lseed);
    x0 = x[0];
    z0 = z[0];
    if (nxp==2) { /* an area is defined, do not fill until end of x and z coordinate */
        dsx = x[1]-x0;
        dsz = z[1]-z0;
    }
    else { /* no area: fill until end of x and z range */
        dsx = sizex-x0;
        dsz = sizez-z0;
    }
    for (i=0; i<ndiff; i++) {
        nxp=1;
        if (rtype<0) type=NINT(2*drand48());
		else type = rtype;
        x[0] = x0 + diffrwidth*dx+drand48()*(dsx-2*diffrwidth*dx);
        z[0] = z0 + diffrwidth*dz+drand48()*(dsz-2*diffrwidth*dz);
        diffraction(x, z, nxp, dx, dz, gridcp, gridcs, gridro,
                    cp, cs, ro, interface, zp, nx, diffrwidth, type);
    }

	return;
}
开发者ID:masterjkk,项目名称:OpenSource,代码行数:31,代码来源:randdf.c


示例18: wipdecode

void wipdecode(const char *string, char *outstr, size_t maxout)
{
    char *ptr, *tmptr, *savptr;
    char ch;
    char tempstr[BUFSIZ], variable[BUFSIZ];
    int nsig, nopen;
    double arg;
    LOGICAL error;

    ptr = (char *)string;
    if (Strchr(string, ESC) != (char *)NULL) {
      arg = wipgetvar("nsig", &error);
      nsig = NINT(arg);        /* Tells how to format a user variable. */
      tmptr = tempstr;
      while (*ptr) {
        if (*ptr != ESC) {
          *tmptr++ = *ptr++;               /* Just copy the character. */
          continue;                         /* Get the next character. */
        }            /* At this point an ESC character has been found. */
        ch = *ptr++;                        /* save the ESC character. */
        if (*ptr != '[') {  /* No user variable here, so just store... */
          *tmptr++ = ch;        /* ...the two characters and continue. */
          *tmptr++ = *ptr++;           /* This is so "\\" gets passed. */
          continue;                         /* Get the next character. */
        }        /* At this point a user variable flag has been found. */
        ptr++;                          /* Increment ptr past the '['. */
        savptr = variable;       /* Set up user variable name pointer. */
        nopen = 1;              /* Initialize the number of open '['s. */
        while ((*ptr) && (nopen)) {         /* Get user variable name. */
          if (*ptr == '[') nopen++;
          if (*ptr == ']') nopen--;
          if (nopen) *savptr++ = *ptr++;
        }
        if (*ptr != Null) ptr++;                 /* Skip over last ']' */
        *savptr = Null;        /* Skip last ']'; add terminating Null. */
        if (wipisstring(variable)) {          /* User string variable. */
          savptr = wipgetstring(variable);    /* Find string variable. */
          if (savptr == (char *)NULL) savptr = "";     /* Error check. */
        } else {                            /* Standard user variable. */
          arg = wipevaluate(variable, &error);  /* Find user variable. */
          savptr = wipfpfmt(arg, nsig);           /* Format the value. */
        }
        while ((*savptr != Null) && (isspace(*savptr)))
          savptr++;                       /* Strip off leading blanks. */
        while (*savptr) *tmptr++ = *savptr++;    /* Include the value. */
      }                                 /* End of "while (*ptr)" loop. */
      *tmptr = Null;              /* Terminate the string with a Null. */
      ptr = tempstr;        /* Assign the work pointer to this string. */
    }                           /* End of "(domacs == TRUE)" if block. */

    if (Strlen(ptr) >= maxout)
      wipoutput(stderr, "Decoded string overflows output string size.\n");

    (void)Strncpy(outstr, ptr, maxout);
    outstr[maxout-1] = Null;       /* Make sure it is Null terminated. */

    return;
}
开发者ID:nhakobian,项目名称:carma-wip,代码行数:58,代码来源:decode.c


示例19: sprintf

asynStatus MCB4BAxis::setPosition(double position)
{
  asynStatus status;
  //static const char *functionName = "MCB4BAxis::setPosition";

  sprintf(pC_->outString_, "#%02dP=%+d", axisNo_, NINT(position));
  status = pC_->writeReadController();
  return status;
}
开发者ID:epicsdeb,项目名称:synapps,代码行数:9,代码来源:MCB4BDriver.cpp


示例20: pseudo_dist_from_viewer

NV_INT32 pseudo_dist_from_viewer (MISC *misc, NV_FLOAT64 x, NV_FLOAT64 y)
{
  NV_FLOAT64 xyz_y = ((y - misc->abe_share->edit_area.min_y) / edit_y_range) * misc->draw_area_height;
  NV_FLOAT64 xyz_x = ((x - misc->abe_share->edit_area.min_x) / edit_x_range) * misc->draw_area_width;


  xyz_x = xyz_x * misc->cos_array[misc->ortho_angle] - xyz_y * misc->sin_array[misc->ortho_angle];

  return (NINT (xyz_x * (NV_FLOAT64) misc->ortho_scale));
}
开发者ID:dmagiccys,项目名称:pfmabe,代码行数:10,代码来源:compute_ortho_values.cpp



注:本文中的NINT函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ NIPQUAD函数代码示例发布时间:2022-05-30
下一篇:
C++ NINDIR函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap