Esempio n. 1
0
File: xplot.c Progetto: E-LLP/QuIP
void xp_fill_polygon(int num_points,
			float* x_vals, float* y_vals)
{
	int *xp,*yp;
	int i;
	float fx,fy;

	if( plot_vp == NO_VIEWER ) return;

	/* BUG should scale the points */
	xp = (int *) getbuf( num_points * sizeof(int) );
	yp = (int *) getbuf( num_points * sizeof(int) );

	for(i=0;i<num_points;i++){
		fx=x_vals[i]; fy=y_vals[i];
		scale_fxy(plot_vp,&fx,&fy);
		xp[i] = (int) nearbyintf(fx);
		yp[i] = (int) nearbyintf(fy);
	}

	_xp_fill_polygon(plot_vp, num_points, xp, yp);

	givbuf(xp);
	givbuf(yp);
}
Esempio n. 2
0
TEST(math, nearbyint) {
  auto guard = make_scope_guard([]() {
    fesetenv(FE_DFL_ENV);
  });
  fesetround(FE_UPWARD); // nearbyint/nearbyintf/nearbyintl obey the rounding mode.
  feclearexcept(FE_ALL_EXCEPT); // nearbyint/nearbyintf/nearbyintl don't set the FE_INEXACT flag.
  ASSERT_EQ(1234.0, nearbyint(1234.0));
  ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) == 0);
  ASSERT_EQ(1235.0, nearbyint(1234.01));
  ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) == 0);

  feclearexcept(FE_ALL_EXCEPT);
  ASSERT_EQ(1234.0f, nearbyintf(1234.0f));
  ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) == 0);
  ASSERT_EQ(1235.0f, nearbyintf(1234.01f));
  ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) == 0);

  feclearexcept(FE_ALL_EXCEPT); // nearbyint/nearbyintf/nearbyintl don't set the FE_INEXACT flag.
  ASSERT_EQ(1234.0, nearbyintl(1234.0L));
  ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) == 0);
  ASSERT_EQ(1235.0, nearbyintl(1234.01L));
  ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) == 0);

  fesetround(FE_TOWARDZERO); // nearbyint/nearbyintf/nearbyintl obey the rounding mode.
  ASSERT_EQ(1234.0, nearbyint(1234.01));
  ASSERT_EQ(1234.0f, nearbyintf(1234.01f));
  ASSERT_EQ(1234.0, nearbyintl(1234.01L));
}
Esempio n. 3
0
// read the x and y coordinates and convert them into the internal move
// representation
void readmv(int x, int y, int *en)
{
	int ef, er;	

	ef = (int)nearbyintf(((float)x - 50) / 50.f);
	er = (int)nearbyintf(((float)y - 50) / 50.f);

	*en = ef + 10*er + 11;
}
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;
}
Esempio n. 5
0
void test_nearbyint()
{
    static_assert((std::is_same<decltype(nearbyint((double)0)), double>::value), "");
    static_assert((std::is_same<decltype(nearbyintf(0)), float>::value), "");
    static_assert((std::is_same<decltype(nearbyintl(0)), long double>::value), "");
    assert(nearbyint(1) == 1);
}
Esempio n. 6
0
void
vector_nearbyint (void)
{
  int i;

  for (i = 0; i < SIZE; i++)
    a[i] = nearbyintf (b[i]);
}
Esempio n. 7
0
void DCTFFTW::Float2Bytes (uint8_t * dstp8, int dst_pitch, float * realdata)
{
    PixelType *dstp = (PixelType *)dstp8;

    dst_pitch /= sizeof(PixelType);

    int pixelMax = (1 << bitsPerSample) - 1;
    int pixelHalf = 1 << (bitsPerSample - 1);

    int floatpitch = sizex;
    int i, j;
    int integ;
    float f = realdata[0]*0.5f; // to be compatible with integer DCTINT8
    /*
       _asm fld f;
       _asm fistp integ;
       */
    // XXX function call to nearbyintf can be avoided by using cvtss2si
    integ = (int)(nearbyintf(f));
    dstp[0] = std::min(pixelMax, std::max(0, (integ>>dctshift0) + pixelHalf)); // DC
    for (i = 1; i < sizex; i+=1) {
        f = realdata[i]*0.707f; // to be compatible with integer DCTINT8
        /*
           _asm fld f;
           _asm fistp integ;
           */
        integ = (int)(nearbyintf(f));
        dstp[i] = std::min(pixelMax, std::max(0, (integ>>dctshift) + pixelHalf));
    }
    dstp += dst_pitch;
    realdata += floatpitch;
    for (j = 1; j < sizey; j++) {
        for (i = 0; i < sizex; i+=1) {
            f = realdata[i]*0.707f; // to be compatible with integer DCTINT8
            /*
               _asm fld f;
               _asm fistp integ;
               */
            integ = (int)(nearbyintf(f));
            dstp[i] = std::min(pixelMax, std::max(0, (integ>>dctshift) + pixelHalf));
        }
        dstp += dst_pitch;
        realdata += floatpitch;
    }
}
Esempio n. 8
0
static void testit(int testnum, float in, float out)
{

    feclearexcept(ALL_STD_EXCEPT);
    assert(fpequal(out, nearbyintf(in)));
    assert(fpequal(-out, nearbyintf(-in)));
    assert(fetestexcept(ALL_STD_EXCEPT) == 0);

    assert(fpequal(out, nearbyint(in)));
    assert(fpequal(-out, nearbyint(-in)));
    assert(fetestexcept(ALL_STD_EXCEPT) == 0);

    assert(fpequal(out, nearbyintl(in)));
    assert(fpequal(-out, nearbyintl(-in)));
    assert(fetestexcept(ALL_STD_EXCEPT) == 0);

    printf("ok %d\t\t# nearbyint(%g)\n", testnum, in);
}
Esempio n. 9
0
void
rationalize32 (float f,uint32_t *numerator,uint32_t *denominator)
{
    uint32_t i,j;
    // try x for 32 bit x
    j=1;
    i=nearbyintf(((float)j)*f);
    if (i==0){
        i=nearbyintf(1000000000*f);
        if (i==0){
            *numerator=0;
            *denominator=1;
            return;           
        }
    } else if (fequal(f,(float)i)){
        *numerator=i;
        *denominator=1;
        return;
    }
    // try x/y for 8 bit x,y
    for(j=2;j<256;j++){
        i=nearbyintf(((float)j)*f);
        if (i<=0 || i>=256) continue;
        if (fequal(f,((float)i)/((float)j))){
            *numerator=i;
            *denominator=j;
            return;
        }
    }
    // try 3(4??) digit decimal.
    for(j=1000;j<1000000000;j=j*10){
        i=nearbyintf(((float)j)*f);
        if (i<=100 || i>10000) continue;
        if (fequal(f,((float)i)/((float)j))){
            uint32_t c=gcd32(i,j);
            *numerator=i/c;
            *denominator=j/c;
            return;
        }
    }
    Abort("Attempt to reverse engineer %f failed",f);
}
Esempio n. 10
0
static int custom_round(float v, int direction) {
	switch (direction) {
	case 0 :
		fesetround(FE_TOWARDZERO);
		break;
	case 1 :
		fesetround(FE_TONEAREST);
		break;
	case 2 :
		fesetround(FE_UPWARD);
		break;
	case 3 :
		fesetround(FE_DOWNWARD);
		break;
	}
	return nearbyintf(v);
}
int ResetStateOnTriggerTestProbe::calcValues(double timevalue) {
   int nBatch = getNumValues();
   if (timevalue > parent->getStartTime()) {
      int N = targetLayer->getNumNeurons();
      int NGlobal = targetLayer->getNumGlobalNeurons();
      PVLayerLoc const * loc = targetLayer->getLayerLoc();
      PVHalo const * halo = &loc->halo;
      int inttime = (int) nearbyintf(timevalue/parent->getDeltaTime());
      for (int b=0; b<nBatch; b++) {
         int numDiscreps = 0;
         pvadata_t const * activity = targetLayer->getLayerData() + b*targetLayer->getNumExtended();
         for (int k=0; k<N; k++) {
            int kex = kIndexExtended(k, loc->nx, loc->ny, loc->nf, halo->lt, halo->rt, halo->dn, halo->up);
            pvadata_t a = activity[kex];
            int kGlobal = globalIndexFromLocal(k, *loc);
            int correctValue = 4*kGlobal*((inttime + 4)%5+1) + (kGlobal==((((inttime-1)/5)*5)+1)%NGlobal);
            if ( a != (pvadata_t) correctValue ) { numDiscreps++; }
         }
         getValuesBuffer()[b] = (double) numDiscreps;
      }
      MPI_Allreduce(MPI_IN_PLACE, getValuesBuffer(), nBatch, MPI_DOUBLE, MPI_SUM, parent->icCommunicator()->communicator());
      if (probeStatus==0) {
         for (int k=0; k<nBatch; k++) {
            if (getValuesBuffer()[k]) {
               probeStatus = 1;
               firstFailureTime = timevalue;
            }
         }
      }      
   }
   else {
      for (int b=0; b<nBatch; b++) {
         getValuesBuffer()[b] = 0.0;
      }
   }
   return PV_SUCCESS;
}
Esempio n. 12
0
float AutomatableModel::fittedValue( float value, bool forceStep ) const
{
	value = tLimit<float>( value, m_minValue, m_maxValue );

	if( m_step != 0 && ( m_hasStrictStepSize || forceStep ) )
	{
		value = nearbyintf( value / m_step ) * m_step;
	}

	roundAt( value, m_maxValue );
	roundAt( value, m_minValue );
	roundAt( value, 0.0f );

	if( value < m_minValue )
	{
		return m_minValue;
	}
	else if( value > m_maxValue )
	{
		return m_maxValue;
	}

	return value;
}
Esempio n. 13
0
float AutomatableModel::fittedValue( float value ) const
{
	value = tLimit<float>( value, m_minValue, m_maxValue );

	if( m_step != 0 )
	{
		value = nearbyintf( value / m_step ) * m_step;
	}

	roundAt( value, m_maxValue );
	roundAt( value, m_minValue );
	roundAt( value, 0.0f );

	if( value < m_minValue )
	{
		return m_minValue;
	}
	else if( value > m_maxValue )
	{
		return m_maxValue;
	}

	return value;
}
Esempio n. 14
0
glm::i32vec2 CrystalPicker::Vec3ToMatrixPosition(glm::vec3 pos)
{
  return glm::i32vec2(nearbyintf((30 - pos.x) / 43), nearbyint((180 - pos.z) / 43));
}
Esempio n. 15
0
static int testf(float float_x, long double long_double_x, /*float complex float_complex_x,*/ int int_x, long long_x)
{
int r = 0;
r += acosf(float_x);
r += acoshf(float_x);
r += asinf(float_x);
r += asinhf(float_x);
r += atan2f(float_x, float_x);
r += atanf(float_x);
r += atanhf(float_x);
/*r += cargf(float_complex_x); - will fight with complex numbers later */
r += cbrtf(float_x);
r += ceilf(float_x);
r += copysignf(float_x, float_x);
r += cosf(float_x);
r += coshf(float_x);
r += erfcf(float_x);
r += erff(float_x);
r += exp2f(float_x);
r += expf(float_x);
r += expm1f(float_x);
r += fabsf(float_x);
r += fdimf(float_x, float_x);
r += floorf(float_x);
r += fmaf(float_x, float_x, float_x);
r += fmaxf(float_x, float_x);
r += fminf(float_x, float_x);
r += fmodf(float_x, float_x);
r += frexpf(float_x, &int_x);
r += gammaf(float_x);
r += hypotf(float_x, float_x);
r += ilogbf(float_x);
r += ldexpf(float_x, int_x);
r += lgammaf(float_x);
r += llrintf(float_x);
r += llroundf(float_x);
r += log10f(float_x);
r += log1pf(float_x);
r += log2f(float_x);
r += logbf(float_x);
r += logf(float_x);
r += lrintf(float_x);
r += lroundf(float_x);
r += modff(float_x, &float_x);
r += nearbyintf(float_x);
r += nexttowardf(float_x, long_double_x);
r += powf(float_x, float_x);
r += remainderf(float_x, float_x);
r += remquof(float_x, float_x, &int_x);
r += rintf(float_x);
r += roundf(float_x);
#ifdef __UCLIBC_SUSV3_LEGACY__
r += scalbf(float_x, float_x);
#endif
r += scalblnf(float_x, long_x);
r += scalbnf(float_x, int_x);
r += significandf(float_x);
r += sinf(float_x);
r += sinhf(float_x);
r += sqrtf(float_x);
r += tanf(float_x);
r += tanhf(float_x);
r += tgammaf(float_x);
r += truncf(float_x);
return r;
}
float test5f(float x)
{
  return nearbyintf(x);
}
Esempio n. 17
0
static void
allocate_cb (RutObject *graphable,
             void *user_data)
{
    RutBin *bin = RUT_BIN (graphable);

    if (bin->child)
    {
        float child_width, child_height;
        float child_x = bin->left_padding;
        float child_y = bin->top_padding;
        float available_width =
            bin->width - bin->left_padding - bin->right_padding;
        float available_height =
            bin->height - bin->top_padding - bin->bottom_padding;

        rut_sizable_get_preferred_width (bin->child,
                                         -1, /* for_height */
                                         NULL, /* min_width_p */
                                         &child_width);

        if (child_width > available_width)
            child_width = available_width;

        switch (bin->x_position)
        {
        case RUT_BIN_POSITION_BEGIN:
            break;

        case RUT_BIN_POSITION_CENTER:
            if (child_width < available_width)
                child_x = nearbyintf (bin->width / 2.0f - child_width / 2.0f);
            break;

        case RUT_BIN_POSITION_END:
            if (child_width < available_width)
                child_x = bin->width - bin->right_padding - child_width;
            break;

        case RUT_BIN_POSITION_EXPAND:
            child_width = available_width;
            break;
        }

        rut_sizable_get_preferred_height (bin->child,
                                          child_width, /* for_width */
                                          NULL, /* min_height_p */
                                          &child_height);

        if (child_height > available_height)
            child_height = available_height;

        switch (bin->y_position)
        {
        case RUT_BIN_POSITION_BEGIN:
            break;

        case RUT_BIN_POSITION_CENTER:
            if (child_height < available_height)
                child_y = nearbyintf (bin->height / 2.0f - child_height / 2.0f);
            break;

        case RUT_BIN_POSITION_END:
            if (child_height < available_height)
                child_y = bin->height - bin->bottom_padding - child_height;
            break;

        case RUT_BIN_POSITION_EXPAND:
            child_height = available_height;
            break;
        }

        rut_transform_init_identity (bin->child_transform);
        rut_transform_translate (bin->child_transform, child_x, child_y, 0.0f);
        rut_sizable_set_size (bin->child, child_width, child_height);
    }
}
Esempio n. 18
0
__host__ void single_precision_math_functions()
{
    int iX;
    float fX, fY;

    acosf(1.0f);
    acoshf(1.0f);
    asinf(0.0f);
    asinhf(0.0f);
    atan2f(0.0f, 1.0f);
    atanf(0.0f);
    atanhf(0.0f);
    cbrtf(0.0f);
    ceilf(0.0f);
    copysignf(1.0f, -2.0f);
    cosf(0.0f);
    coshf(0.0f);
    //cospif(0.0f);
    //cyl_bessel_i0f(0.0f);
    //cyl_bessel_i1f(0.0f);
    erfcf(0.0f);
    //erfcinvf(2.0f);
    //erfcxf(0.0f);
    erff(0.0f);
    //erfinvf(1.0f);
    exp10f(0.0f);
    exp2f(0.0f);
    expf(0.0f);
    expm1f(0.0f);
    fabsf(1.0f);
    fdimf(1.0f, 0.0f);
    //fdividef(0.0f, 1.0f);
    floorf(0.0f);
    fmaf(1.0f, 2.0f, 3.0f);
    fmaxf(0.0f, 0.0f);
    fminf(0.0f, 0.0f);
    fmodf(0.0f, 1.0f);
    frexpf(0.0f, &iX);
    hypotf(1.0f, 0.0f);
    ilogbf(1.0f);
    isfinite(0.0f);
    isinf(0.0f);
    isnan(0.0f);
    ///j0f(0.0f);
    ///j1f(0.0f);
    ///jnf(-1.0f, 1.0f);
    ldexpf(0.0f, 0);
    ///lgammaf(1.0f);
    ///llrintf(0.0f);
    ///llroundf(0.0f);
    log10f(1.0f);
    log1pf(-1.0f);
    log2f(1.0f);
    logbf(1.0f);
    logf(1.0f);
    ///lrintf(0.0f);
    ///lroundf(0.0f);
    modff(0.0f, &fX);
    ///nanf("1");
    nearbyintf(0.0f);
    //nextafterf(0.0f);
    //norm3df(1.0f, 0.0f, 0.0f);
    //norm4df(1.0f, 0.0f, 0.0f, 0.0f);
    //normcdff(0.0f);
    //normcdfinvf(1.0f);
    //fX = 1.0f; normf(1, &fX);
    powf(1.0f, 0.0f);
    //rcbrtf(1.0f);
    remainderf(2.0f, 1.0f);
    remquof(1.0f, 2.0f, &iX);
    //rhypotf(0.0f, 1.0f);
    ///rintf(1.0f);
    //rnorm3df(0.0f, 0.0f, 1.0f);
    //rnorm4df(0.0f, 0.0f, 0.0f, 1.0f);
    //fX = 1.0f; rnormf(1, &fX);
    roundf(0.0f);
    //rsqrtf(1.0f);
    ///scalblnf(0.0f, 1);
    scalbnf(0.0f, 1);
    signbit(1.0f);
    sincosf(0.0f, &fX, &fY);
    //sincospif(0.0f, &fX, &fY);
    sinf(0.0f);
    sinhf(0.0f);
    //sinpif(0.0f);
    sqrtf(0.0f);
    tanf(0.0f);
    tanhf(0.0f);
    tgammaf(2.0f);
    truncf(0.0f);
    ///y0f(1.0f);
    ///y1f(1.0f);
    ///ynf(1, 1.0f);
}
Esempio n. 19
0
void
domathf (void)
{
#ifndef NO_FLOAT
  float f1;
  float f2;

  int i1;

  f1 = acosf(0.0);
  fprintf( stdout, "acosf          : %f\n", f1);

  f1 = acoshf(0.0);
  fprintf( stdout, "acoshf         : %f\n", f1);

  f1 = asinf(1.0);
  fprintf( stdout, "asinf          : %f\n", f1);

  f1 = asinhf(1.0);
  fprintf( stdout, "asinhf         : %f\n", f1);

  f1 = atanf(M_PI_4);
  fprintf( stdout, "atanf          : %f\n", f1);

  f1 = atan2f(2.3, 2.3);
  fprintf( stdout, "atan2f         : %f\n", f1);

  f1 = atanhf(1.0);
  fprintf( stdout, "atanhf         : %f\n", f1);

  f1 = cbrtf(27.0);
  fprintf( stdout, "cbrtf          : %f\n", f1);

  f1 = ceilf(3.5);
  fprintf( stdout, "ceilf          : %f\n", f1);

  f1 = copysignf(3.5, -2.5);
  fprintf( stdout, "copysignf      : %f\n", f1);

  f1 = cosf(M_PI_2);
  fprintf( stdout, "cosf           : %f\n", f1);

  f1 = coshf(M_PI_2);
  fprintf( stdout, "coshf          : %f\n", f1);

  f1 = erff(42.0);
  fprintf( stdout, "erff           : %f\n", f1);

  f1 = erfcf(42.0);
  fprintf( stdout, "erfcf          : %f\n", f1);

  f1 = expf(0.42);
  fprintf( stdout, "expf           : %f\n", f1);

  f1 = exp2f(0.42);
  fprintf( stdout, "exp2f          : %f\n", f1);

  f1 = expm1f(0.00042);
  fprintf( stdout, "expm1f         : %f\n", f1);

  f1 = fabsf(-1.123);
  fprintf( stdout, "fabsf          : %f\n", f1);

  f1 = fdimf(1.123, 2.123);
  fprintf( stdout, "fdimf          : %f\n", f1);

  f1 = floorf(0.5);
  fprintf( stdout, "floorf         : %f\n", f1);
  f1 = floorf(-0.5);
  fprintf( stdout, "floorf         : %f\n", f1);

  f1 = fmaf(2.1, 2.2, 3.01);
  fprintf( stdout, "fmaf           : %f\n", f1);

  f1 = fmaxf(-0.42, 0.42);
  fprintf( stdout, "fmaxf          : %f\n", f1);

  f1 = fminf(-0.42, 0.42);
  fprintf( stdout, "fminf          : %f\n", f1);

  f1 = fmodf(42.0, 3.0);
  fprintf( stdout, "fmodf          : %f\n", f1);

  /* no type-specific variant */
  i1 = fpclassify(1.0);
  fprintf( stdout, "fpclassify     : %d\n", i1);

  f1 = frexpf(42.0, &i1);
  fprintf( stdout, "frexpf         : %f\n", f1);

  f1 = hypotf(42.0, 42.0);
  fprintf( stdout, "hypotf         : %f\n", f1);

  i1 = ilogbf(42.0);
  fprintf( stdout, "ilogbf         : %d\n", i1);

  /* no type-specific variant */
  i1 = isfinite(3.0);
  fprintf( stdout, "isfinite       : %d\n", i1);

  /* no type-specific variant */
  i1 = isgreater(3.0, 3.1);
  fprintf( stdout, "isgreater      : %d\n", i1);

  /* no type-specific variant */
  i1 = isgreaterequal(3.0, 3.1);
  fprintf( stdout, "isgreaterequal : %d\n", i1);

  /* no type-specific variant */
  i1 = isinf(3.0);
  fprintf( stdout, "isinf          : %d\n", i1);

  /* no type-specific variant */
  i1 = isless(3.0, 3.1);
  fprintf( stdout, "isless         : %d\n", i1);

  /* no type-specific variant */
  i1 = islessequal(3.0, 3.1);
  fprintf( stdout, "islessequal    : %d\n", i1);

  /* no type-specific variant */
  i1 = islessgreater(3.0, 3.1);
  fprintf( stdout, "islessgreater  : %d\n", i1);

  /* no type-specific variant */
  i1 = isnan(0.0);
  fprintf( stdout, "isnan          : %d\n", i1);

  /* no type-specific variant */
  i1 = isnormal(3.0);
  fprintf( stdout, "isnormal       : %d\n", i1);

  /* no type-specific variant */
  f1 = isunordered(1.0, 2.0);
  fprintf( stdout, "isunordered    : %d\n", i1);

  f1 = j0f(1.2);
  fprintf( stdout, "j0f            : %f\n", f1);

  f1 = j1f(1.2);
  fprintf( stdout, "j1f            : %f\n", f1);

  f1 = jnf(2,1.2);
  fprintf( stdout, "jnf            : %f\n", f1);

  f1 = ldexpf(1.2,3);
  fprintf( stdout, "ldexpf         : %f\n", f1);

  f1 = lgammaf(42.0);
  fprintf( stdout, "lgammaf        : %f\n", f1);

  f1 = llrintf(-0.5);
  fprintf( stdout, "llrintf        : %f\n", f1);
  f1 = llrintf(0.5);
  fprintf( stdout, "llrintf        : %f\n", f1);

  f1 = llroundf(-0.5);
  fprintf( stdout, "lroundf        : %f\n", f1);
  f1 = llroundf(0.5);
  fprintf( stdout, "lroundf        : %f\n", f1);

  f1 = logf(42.0);
  fprintf( stdout, "logf           : %f\n", f1);

  f1 = log10f(42.0);
  fprintf( stdout, "log10f         : %f\n", f1);

  f1 = log1pf(42.0);
  fprintf( stdout, "log1pf         : %f\n", f1);

  f1 = log2f(42.0);
  fprintf( stdout, "log2f          : %f\n", f1);

  f1 = logbf(42.0);
  fprintf( stdout, "logbf          : %f\n", f1);

  f1 = lrintf(-0.5);
  fprintf( stdout, "lrintf         : %f\n", f1);
  f1 = lrintf(0.5);
  fprintf( stdout, "lrintf         : %f\n", f1);

  f1 = lroundf(-0.5);
  fprintf( stdout, "lroundf        : %f\n", f1);
  f1 = lroundf(0.5);
  fprintf( stdout, "lroundf        : %f\n", f1);

  f1 = modff(42.0,&f2);
  fprintf( stdout, "lmodff         : %f\n", f1);

  f1 = nanf("");
  fprintf( stdout, "nanf           : %f\n", f1);

  f1 = nearbyintf(1.5);
  fprintf( stdout, "nearbyintf     : %f\n", f1);

  f1 = nextafterf(1.5,2.0);
  fprintf( stdout, "nextafterf     : %f\n", f1);

  f1 = powf(3.01, 2.0);
  fprintf( stdout, "powf           : %f\n", f1);

  f1 = remainderf(3.01,2.0);
  fprintf( stdout, "remainderf     : %f\n", f1);

  f1 = remquof(29.0,3.0,&i1);
  fprintf( stdout, "remquof        : %f\n", f1);

  f1 = rintf(0.5);
  fprintf( stdout, "rintf          : %f\n", f1);
  f1 = rintf(-0.5);
  fprintf( stdout, "rintf          : %f\n", f1);

  f1 = roundf(0.5);
  fprintf( stdout, "roundf         : %f\n", f1);
  f1 = roundf(-0.5);
  fprintf( stdout, "roundf         : %f\n", f1);

  f1 = scalblnf(1.2,3);
  fprintf( stdout, "scalblnf       : %f\n", f1);

  f1 = scalbnf(1.2,3);
  fprintf( stdout, "scalbnf        : %f\n", f1);

  /* no type-specific variant */
  i1 = signbit(1.0);
  fprintf( stdout, "signbit        : %i\n", i1);

  f1 = sinf(M_PI_4);
  fprintf( stdout, "sinf           : %f\n", f1);

  f1 = sinhf(M_PI_4);
  fprintf( stdout, "sinhf          : %f\n", f1);

  f1 = sqrtf(9.0);
  fprintf( stdout, "sqrtf          : %f\n", f1);

  f1 = tanf(M_PI_4);
  fprintf( stdout, "tanf           : %f\n", f1);

  f1 = tanhf(M_PI_4);
  fprintf( stdout, "tanhf          : %f\n", f1);

  f1 = tgammaf(2.1);
  fprintf( stdout, "tgammaf        : %f\n", f1);

  f1 = truncf(3.5);
  fprintf( stdout, "truncf         : %f\n", f1);

  f1 = y0f(1.2);
  fprintf( stdout, "y0f            : %f\n", f1);

  f1 = y1f(1.2);
  fprintf( stdout, "y1f            : %f\n", f1);

  f1 = ynf(3,1.2);
  fprintf( stdout, "ynf            : %f\n", f1);
#endif
}
Esempio n. 20
0
u_char to_dir(int origin_x, int origin_y, int destination_x, int destination_y)
{
    return (u_char) ((int) nearbyintf(40.743665f * atan2f(destination_x - origin_x, origin_y - destination_y)));  /* (128/pi)*theta */
}
Esempio n. 21
0
__global__ void FloatMathPrecise() {
    int iX;
    float fX, fY;

    acosf(1.0f);
    acoshf(1.0f);
    asinf(0.0f);
    asinhf(0.0f);
    atan2f(0.0f, 1.0f);
    atanf(0.0f);
    atanhf(0.0f);
    cbrtf(0.0f);
    fX = ceilf(0.0f);
    fX = copysignf(1.0f, -2.0f);
    cosf(0.0f);
    coshf(0.0f);
    cospif(0.0f);
    cyl_bessel_i0f(0.0f);
    cyl_bessel_i1f(0.0f);
    erfcf(0.0f);
    erfcinvf(2.0f);
    erfcxf(0.0f);
    erff(0.0f);
    erfinvf(1.0f);
    exp10f(0.0f);
    exp2f(0.0f);
    expf(0.0f);
    expm1f(0.0f);
    fX = fabsf(1.0f);
    fdimf(1.0f, 0.0f);
    fdividef(0.0f, 1.0f);
    fX = floorf(0.0f);
    fmaf(1.0f, 2.0f, 3.0f);
    fX = fmaxf(0.0f, 0.0f);
    fX = fminf(0.0f, 0.0f);
    fmodf(0.0f, 1.0f);
    frexpf(0.0f, &iX);
    hypotf(1.0f, 0.0f);
    ilogbf(1.0f);
    isfinite(0.0f);
    fX = isinf(0.0f);
    fX = isnan(0.0f);
    j0f(0.0f);
    j1f(0.0f);
    jnf(-1.0f, 1.0f);
    ldexpf(0.0f, 0);
    lgammaf(1.0f);
    llrintf(0.0f);
    llroundf(0.0f);
    log10f(1.0f);
    log1pf(-1.0f);
    log2f(1.0f);
    logbf(1.0f);
    logf(1.0f);
    lrintf(0.0f);
    lroundf(0.0f);
    modff(0.0f, &fX);
    fX = nanf("1");
    fX = nearbyintf(0.0f);
    nextafterf(0.0f, 0.0f);
    norm3df(1.0f, 0.0f, 0.0f);
    norm4df(1.0f, 0.0f, 0.0f, 0.0f);
    normcdff(0.0f);
    normcdfinvf(1.0f);
    fX = 1.0f;
    normf(1, &fX);
    powf(1.0f, 0.0f);
    rcbrtf(1.0f);
    remainderf(2.0f, 1.0f);
    remquof(1.0f, 2.0f, &iX);
    rhypotf(0.0f, 1.0f);
    fY = rintf(1.0f);
    rnorm3df(0.0f, 0.0f, 1.0f);
    rnorm4df(0.0f, 0.0f, 0.0f, 1.0f);
    fX = 1.0f;
    rnormf(1, &fX);
    fY = roundf(0.0f);
    rsqrtf(1.0f);
    scalblnf(0.0f, 1);
    scalbnf(0.0f, 1);
    signbit(1.0f);
    sincosf(0.0f, &fX, &fY);
    sincospif(0.0f, &fX, &fY);
    sinf(0.0f);
    sinhf(0.0f);
    sinpif(0.0f);
    sqrtf(0.0f);
    tanf(0.0f);
    tanhf(0.0f);
    tgammaf(2.0f);
    fY = truncf(0.0f);
    y0f(1.0f);
    y1f(1.0f);
    ynf(1, 1.0f);
}