当前位置: 首页>>代码示例>>C++>>正文


C++ rintf函数代码示例

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


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

示例1: exp

/**
 * Initialize Dense Inverse Log Polar Table
 * Fill each DILP[x][y] element with N <ecc,ang,dist> values so a
 * weighted sum can be computed for reconstrucion
 */
void LPolar::initDataDILP(int ecc, int ang, int s)
{
	float base,mod,lmod,alfa,lalfa,x,y;
	float radius= (float)s/2.;
	  		
	base = exp(log(radius)/((float)ecc));  //Such that pow(base,ecc) = radius

	for(int i=0; i<s; i++)
		for(int j=0; j<s; j++)
		{
			x = i - radius;
			y = j - radius;
			//Compute mod
			mod = sqrt(x*x +y*y);
			if(mod  >= radius) mod = radius-1;
			//Compute log-mod from base using log-base conversion. Result in 0..ecc range as computed in base
			lmod = log(mod)/log(base);
			//compute angle from atan2. Result in -Pi and Pi range
			alfa = atan2(y,x);
			//take alfa to 0..ang range
			lalfa = alfa*(float)ang/(2.* M_PI) + (ang/2);
			//closest ecc to lmod is (int)lmod.
			DILP[i][j].ecc = (int)rintf(lmod);
			DILP[i][j].ang = (int)rintf(lalfa);
			
		}
		
}
开发者ID:BasilMVarghese,项目名称:robocomp,代码行数:33,代码来源:lpolar.cpp

示例2: sur_run

static void
sur_run(LV2_Handle instance, uint32_t n_samples)
{
	LV2meter* self = (LV2meter*)instance;
	uint32_t cors = self->chn > 3 ? 4 : 3;

	for (uint32_t c = 0; c < cors; ++c) {
		uint32_t in_a = rintf (*self->surc_a[c]);
		uint32_t in_b = rintf (*self->surc_b[c]);
		if (in_a >= self->chn) in_a = self->chn - 1;
		if (in_b >= self->chn) in_b = self->chn - 1;
		self->cor4[c]->process (self->input[in_a], self->input[in_b], n_samples);
		*self->surc_c[c] = self->cor4[c]->read();
	}

	for (uint32_t c = 0; c < self->chn; ++c) {
		float m, p;

		float* const input  = self->input[c];
		float* const output = self->output[c];

		self->mtr[c]->process(input, n_samples);

		static_cast<Kmeterdsp*>(self->mtr[c])->read(m, p);

		*self->level[c] = m;
		*self->peak[c]  = p;

		if (input != output) {
			memcpy(output, input, sizeof(float) * n_samples);
		}
	}
}
开发者ID:x42,项目名称:meters.lv2,代码行数:33,代码来源:surmeter.c

示例3: addpoint

void addpoint(float x, float y, float z)
{
	if (points == NULL)
	{
		points = (vector3f*) malloc(sizeof(vector3f));
		count_points = 1;
	}
	else
	{
		count_points++;
		points = (vector3f*)realloc(points, count_points * sizeof(vector3f));
	}

	if( pieVersion == 2)
	{
		points[count_points-1].x = rintf(x);
		points[count_points-1].y = rintf(y);
		points[count_points-1].z = rintf(z);
	}
	else // pieVersion == 3
	{
		points[count_points-1].x = x;
		points[count_points-1].y = y;
		points[count_points-1].z = z;
	}
}
开发者ID:C1annad,项目名称:warzone2100,代码行数:26,代码来源:obj2pie.c

示例4: rintf

BRect
WorkspacesView::_WindowFrame(const BRect& workspaceFrame,
	const BRect& screenFrame, const BRect& windowFrame,
	BPoint windowPosition)
{
	BRect frame = windowFrame;
	frame.OffsetTo(windowPosition);

	// scale down the rect
	float factor = workspaceFrame.Width() / screenFrame.Width();
	frame.left = frame.left * factor;
	frame.right = frame.right * factor;

	factor = workspaceFrame.Height() / screenFrame.Height();
	frame.top = frame.top * factor;
	frame.bottom = frame.bottom * factor;

	// offset by the workspace fame position
	// and snap to integer coordinates without distorting the size too much
	frame.OffsetTo(rintf(frame.left + workspaceFrame.left),
		rintf(frame.top + workspaceFrame.top));
	frame.right = rintf(frame.right);
	frame.bottom = rintf(frame.bottom);

	return frame;
}
开发者ID:mmanley,项目名称:Antares,代码行数:26,代码来源:WorkspacesView.cpp

示例5: mri_bport_make_indexes

intvec * mri_bport_make_indexes( float dt, float fbot, float ftop, int ntime )
{
   int nfbot , nftop , nev=(ntime%2==0) , nth=ntime/2 , ff ;
   float df ;
   intvec *ivv ;

ENTRY("mri_bport_make_indexes") ;

   if( dt   <= 0.0f ) dt   = 1.0f ;
   if( fbot <  0.0f ) fbot = 0.0f ;
   if( ntime < 9 || ftop < fbot ) RETURN(NULL) ;

   df = 1.0f / (ntime *dt) ;  /* frequency spacing */

   nfbot = (int)rintf(fbot/df+0.1666666f) ;
   if( nfbot > nth      ) nfbot = nth ;
   if( nfbot < BP_ffbot ) nfbot = BP_ffbot ;

   nftop = (int)rintf(ftop/df-0.1666666f) ;
   if( nftop < nfbot   ) nftop = nfbot ;
   if( nftop > ntime/2 ) nftop = nth ;

   MAKE_intvec(ivv,nftop-nfbot+1) ;

   for( ff=nfbot ; ff <= nftop ; ff++ ) ivv->ar[ff-nfbot] = ff ;

#if 0
fprintf(stderr,"indexes: fbot=%g ftop=%g df=%g ntime=%d\n",fbot,ftop,df,ntime) ;
for( ff=nfbot ; ff <= nftop ; ff++ ) fprintf(stderr," %d",ivv->ar[ff-nfbot]) ;
fprintf(stderr,"\n") ;
#endif

   RETURN(ivv) ;
}
开发者ID:Gilles86,项目名称:afni,代码行数:34,代码来源:mri_bport.c

示例6: mri_bport_contig

MRI_IMAGE * mri_bport_contig( float dt , float fbot , float ftop ,
                              int ntime , int nbefore , int nafter )
{
   MRI_IMAGE *fim ; float *far , *fii , *fip ;
   int nfbot , nftop , ff , ii,jj , nev=(ntime%2==0) , ncol,nrow ;
   float df , freq ;

ENTRY("mri_bport_contig") ;

   if( dt   <= 0.0f ) dt   = 1.0f ;
   if( fbot <  0.0f ) fbot = 0.0f ;
   if( ntime < 9 || ftop < fbot ) RETURN(NULL) ;
   if( nbefore < 0 ) nbefore = 0 ;
   if( nafter  < 0 ) nafter  = 0 ;

   df  = 1.0f / (ntime * dt) ;  /* frequency spacing */

   nfbot = (int)rintf(fbot/df+0.1666666f) ;
   if( nfbot > ntime/2    ) nfbot = ntime/2 ;
   if( nfbot < BP_ffbot   ) nfbot = BP_ffbot ;

   nftop = (int)rintf(ftop/df-0.1666666f) ;
   if( nftop < nfbot   ) nftop = nfbot   ;
   if( nftop > ntime/2 ) nftop = ntime/2 ;
#if 1
   ININFO_message("Frequency indexes: blocklen=%d nfbot=%d nftop=%d",ntime,nfbot,nftop) ;
#endif

   ncol = 2*(nftop-nfbot-1) ; if( ncol < 0 ) ncol = 0 ;
   ncol += (nfbot == 0 || (nfbot == ntime/2 && nev==1) ) ? 1 : 2 ;
   if( nftop > nfbot )
     ncol += (nftop == ntime/2 && nev) ? 1 : 2 ;

   if( ncol <= 0 ){
     ININFO_message("Failure :-(") ; RETURN(NULL) ;  /* should never happen */
   }

   nrow = ntime + nbefore + nafter ;
   fim  = mri_new( nrow , ncol , MRI_float ) ;
   far  = MRI_FLOAT_PTR(fim) ;

   for( ii=0,ff=nfbot ; ff <= nftop ; ff++ ){
     fii = far + (ii*nrow + nbefore) ;
     if( ff == 0 ){
       for( jj=0 ; jj < ntime ; jj++ ) fii[jj] = 1.0f ;
       ii++ ;
     } else if( ff == ntime/2 && nev ){
       for( jj=0 ; jj < ntime ; jj++ ) fii[jj] = 2*(jj%2)-1 ;
       ii++ ;
     } else {
       fip = fii + nrow ; freq = ff*df * (2.0f*3.141593f) * dt ;
       for( jj=0 ; jj < ntime ; jj++ ){
         fii[jj] = cos(freq*jj) ; fip[jj] = sin(freq*jj) ;
       }
       ii += 2 ;
     }
   }

   RETURN(fim) ;
}
开发者ID:Gilles86,项目名称:afni,代码行数:60,代码来源:mri_bport.c

示例7: TEST

TEST(math, rint) {
  auto guard = make_scope_guard([]() {
    fesetenv(FE_DFL_ENV);
  });

  fesetround(FE_UPWARD); // rint/rintf/rintl obey the rounding mode.
  feclearexcept(FE_ALL_EXCEPT); // rint/rintf/rintl do set the FE_INEXACT flag.
  ASSERT_EQ(1234.0, rint(1234.0));
  ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) == 0);
  ASSERT_EQ(1235.0, rint(1234.01));
  ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) != 0);

  feclearexcept(FE_ALL_EXCEPT); // rint/rintf/rintl do set the FE_INEXACT flag.
  ASSERT_EQ(1234.0f, rintf(1234.0f));
  ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) == 0);
  ASSERT_EQ(1235.0f, rintf(1234.01f));
  ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) != 0);

  feclearexcept(FE_ALL_EXCEPT); // rint/rintf/rintl do set the FE_INEXACT flag.
  ASSERT_EQ(1234.0, rintl(1234.0L));
  ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) == 0);
  ASSERT_EQ(1235.0, rintl(1234.01L));
  ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) != 0);

  fesetround(FE_TOWARDZERO); // rint/rintf obey the rounding mode.
  ASSERT_EQ(1234.0, rint(1234.01));
  ASSERT_EQ(1234.0f, rintf(1234.01f));
  ASSERT_EQ(1234.0, rintl(1234.01L));
}
开发者ID:316181444,项目名称:platform_bionic,代码行数:29,代码来源:math_test.cpp

示例8: focusblur_fft_buffer_update_depth_table

static void
focusblur_fft_buffer_update_depth_table (FblurFftBuffer *fft,
                                         gint            division,
                                         gint            slide)
{
  FblurFftDepthTable    *table;
  gfloat                 dfac, fval;
  gfloat                 r, f, c;
  gint                   ri, fi, ci;
  gint                   i;

  g_assert (division > 0);

  if (division == fft->depth.division &&
      slide    == fft->depth.slide)
    return;

  dfac = (gfloat) FBLUR_DEPTH_MAX / division;

  for (i = 0; i <= FBLUR_DEPTH_MAX; i ++)
    {
      table = &(fft->depth.table[i]);
      fval = (gfloat) (i - slide) / dfac;

      r = rintf (fval);

      ri = rintf (r * dfac) + slide;
      ri = CLAMP (ri, 0, FBLUR_DEPTH_MAX);

      table->round = ri;

      if (fabsf (r - fval) < 0.001f)
        {
          table->floor = table->ceil = ri;
          table->diff = 0.0f;
        }
      else
        {
          f = floorf (fval);
          c = ceilf (fval);

          fi = rintf (f * dfac) + slide;
          ci = rintf (c * dfac) + slide;

          fi = CLAMP (fi, 0, FBLUR_DEPTH_MAX);
          ci = CLAMP (ci, 0, FBLUR_DEPTH_MAX);

          table->floor = fi;
          table->ceil  = ci;

          table->diff  = (ci > fi) ? (gfloat) (i - fi) / (ci - fi) : 0.0f;
        }
    }

  fft->depth.division = division;
  fft->depth.slide = slide;
  fft->depth.count = 0;
}
开发者ID:Felllini,项目名称:sprezzos-world,代码行数:58,代码来源:fftblurbuffer.c

示例9: nearest_neighbor_interpolation_at

static float nearest_neighbor_interpolation_at(float *x,
        int w, int h, float p, float q)
{
	int ip = rintf(p);
	int iq = rintf(q);
	float r = getpixel_1(x, w, h, ip, iq);
    if (r < -1000) return NAN;
	return r;
}
开发者ID:cpalmann,项目名称:s2p,代码行数:9,代码来源:srtm4.c

示例10: deth

void deth(int nr, TYPE *h) {
    const int hmax = 20;
    const int kmax = 30;
    const int lmax = 15;
    int i;
    for (i = 0; i < nr; i++) {
        h[DIM2_H * i + 0] = rintf(2 * hmax * (TYPE) random() / (TYPE) RAND_MAX - hmax);
        h[DIM2_H * i + 1] = rintf(2 * kmax * (TYPE) random() / (TYPE) RAND_MAX - kmax);
        h[DIM2_H * i + 2] = rintf(2 * lmax * (TYPE) random() / (TYPE) RAND_MAX - lmax);
    }
}
开发者ID:grypp,项目名称:macc-openmp4-benchmarks,代码行数:11,代码来源:krist.c

示例11: isPPostive2

ISRF isPPostive2(SACHEAD *hdr, float *trace, float interval)
{
	int pre, suf;
	int index ;
	index = rintf( (hdr->o - hdr->b) / (hdr->delta) );
	pre = rintf( (hdr->o - hdr->b - interval ) / (hdr->delta) );
	suf = rintf( (hdr->o - hdr->b + interval ) / (hdr->delta) );
	if( integf(trace, pre, suf, hdr->delta) > 0.0f &&  trace[index] < 1.0f )
		return GOOD;
	else
		return BAD;
}
开发者ID:sheng09,项目名称:AutoRF-toolkit,代码行数:12,代码来源:autorf.c

示例12: zpadax_pm

static int_pair zpadax_pm( int nx_super , float xorg_super ,
                           int nx_input , float xorg_input , float dx )
{
   int_pair pm ; float ts , ti ;

   ts   = xorg_super + nx_super * dx ;
   ti   = xorg_input + nx_input * dx ;
   pm.i = (int)rintf((xorg_input-xorg_super)/dx) ;
   pm.j = (int)rintf((ts-ti)/dx) ;

   return pm ;
}
开发者ID:neurodebian,项目名称:afni,代码行数:12,代码来源:thd_conformist.c

示例13: ai_checkpos

/* check if we are still running and fill out the position 
	return == 0 we're still walking ... else we have reached a point */
inline int
ai_checkpos (_player * pl, _point * pos)
{
    _pointf _p;

    _p.x = CUTINT (pl->pos.x);
    _p.y = CUTINT (pl->pos.y);

    pos->x = rintf (pl->pos.x);
    pos->y = rintf (pl->pos.y);

    return ((_p.x < 0.15f || _p.x > 0.85f) && (_p.y < 0.15f || _p.y > 0.85f));
};
开发者ID:tapted,项目名称:bomberclone-nacl,代码行数:15,代码来源:single.c

示例14: approximately_equal

static int approximately_equal(float a, float b)
{
#ifdef STARPU_HAVE_NEARBYINTF
	int ai = (int) nearbyintf(a * 1000.0);
	int bi = (int) nearbyintf(b * 1000.0);
#elif defined(STARPU_HAVE_RINTF)
	int ai = (int) rintf(a * 1000.0);
	int bi = (int) rintf(b * 1000.0);
#else
#error "Please define either nearbyintf or rintf."
#endif
	return ai == bi;
}
开发者ID:excess-project,项目名称:starpu-ex-1.2.0rc5,代码行数:13,代码来源:vector_scal.c

示例15: plot_data_fft

static void plot_data_fft(SFSUI* ui) {
	cairo_t* cr;
	cr = cairo_create (ui->sf_dat);

	rounded_rectangle (cr, SS_BORDER, SS_BORDER, SS_SIZE, SS_SIZE, SS_BORDER);
	cairo_clip_preserve (cr);

	const float persistence = robtk_dial_get_value(ui->screen);
	float transp;
	cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
	if (persistence > 0) {
		cairo_set_source_rgba(cr, 0, 0, 0, .25 - .0025 * persistence);
		transp = 0.05;
	} else {
		cairo_set_source_rgba(cr, 0, 0, 0, 1.0);
		transp = .5;
	}
	cairo_fill(cr);

	cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND);
	cairo_set_line_width (cr, 1.0);

	const float xmid = rintf(SS_BORDER + SS_SIZE *.5) + .5;
	const float dnum = SS_SIZE / ui->log_base;
	const float denom = ui->log_rate / (float)ui->fft_bins;

	cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
	for (uint32_t i = 1; i < ui->fft_bins-1 ; ++i) {
		if (ui->level[i] < 0) continue;

		const float level = MAKEUP_GAIN + fftx_power_to_dB(ui->level[i]);
		if (level < -80) continue;

		const float y  = rintf(SS_BORDER + SS_SIZE - dnum * fast_log10(1.0 + i * denom)) + .5;
		const float y1 = rintf(SS_BORDER + SS_SIZE - dnum * fast_log10(1.0 + (i+1) * denom)) + .5;
		const float pk = level > 0.0 ? 1.0 : (80 + level) / 80.0;
		const float a_lr = ui->lr[i];

		float clr[3];
		hsl2rgb(clr, .70 - .72 * pk, .9, .3 + pk * .4);
		cairo_set_source_rgba(cr, clr[0], clr[1], clr[2], transp  + pk * .2);
		cairo_set_line_width (cr, MAX(1.0, (y - y1)));

		cairo_move_to(cr, xmid, y);
		cairo_line_to(cr, SS_BORDER + SS_SIZE * a_lr, y);
		cairo_stroke(cr);

	}
	cairo_destroy (cr);
}
开发者ID:87maxi,项目名称:meters.lv2,代码行数:50,代码来源:stereoscope.c


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