Esempio n. 1
0
int is_rectangle_inside (rectangle_t *rect, point_t *pt) {
    double half_w = rect->width / 2.0;
    double half_h = rect->height / 2.0;

    return (islessequal     (rect->center.x - half_w, pt->x)        &&
            isgreaterequal  (rect->center.x + half_w, pt->x)        &&
            islessequal     (rect->center.y - half_h, pt->y)        &&
            isgreaterequal  (rect->center.y + half_h, pt->y));
}
Esempio n. 2
0
int main(void)
{
    __VERIFIER_assert(isgreaterequal(2.0, 1.0));
    __VERIFIER_assert(!isgreaterequal(1.0, 2.0));
    __VERIFIER_assert(isgreaterequal(1.0, 1.0));
    __VERIFIER_assert(isgreaterequal(INFINITY, 1.0));
    __VERIFIER_assert(!isgreaterequal(1.0, NAN));
 
    return 0;
}
Esempio n. 3
0
void test_isgreaterequal()
{
    static_assert((std::is_same<decltype(isgreaterequal((float)0, (float)0)), bool>::value), "");
    static_assert((std::is_same<decltype(isgreaterequal((float)0, (double)0)), bool>::value), "");
    static_assert((std::is_same<decltype(isgreaterequal((float)0, (long double)0)), bool>::value), "");
    static_assert((std::is_same<decltype(isgreaterequal((double)0, (float)0)), bool>::value), "");
    static_assert((std::is_same<decltype(isgreaterequal((double)0, (double)0)), bool>::value), "");
    static_assert((std::is_same<decltype(isgreaterequal((double)0, (long double)0)), bool>::value), "");
    static_assert((std::is_same<decltype(isgreaterequal((long double)0, (float)0)), bool>::value), "");
    static_assert((std::is_same<decltype(isgreaterequal((long double)0, (double)0)), bool>::value), "");
    static_assert((std::is_same<decltype(isgreaterequal((long double)0, (long double)0)), bool>::value), "");
    assert(isgreaterequal(-1.0, 0.F) == false);
}
Esempio n. 4
0
long double
__ieee754_exp2l (long double x)
{
  if (__glibc_likely (isless (x, (long double) LDBL_MAX_EXP)))
    {
      if (__builtin_expect (isgreaterequal (x, (long double) (LDBL_MIN_EXP
							      - LDBL_MANT_DIG
							      - 1)), 1))
	{
	  int intx = (int) x;
	  long double fractx = x - intx;
	  if (fabsl (fractx) < LDBL_EPSILON / 4.0L)
	    return __scalbnl (1.0L + fractx, intx);
	  return __scalbnl (__ieee754_expl (M_LN2l * fractx), intx);
	}
      else
	{
	  /* Underflow or exact zero.  */
	  if (isinf (x))
	    return 0;
	  else
	    return LDBL_MIN * LDBL_MIN;
	}
    }
  else
    /* Infinity, NaN or overflow.  */
    return LDBL_MAX * x;
}
Esempio n. 5
0
static int
map_open(struct sol_flow_node *node, void *data, const struct sol_flow_node_options *options)
{
    struct drange_map_data *mdata = data;
    const struct sol_flow_node_type_float_map_options *opts;

    SOL_FLOW_NODE_OPTIONS_SUB_API_CHECK(options, SOL_FLOW_NODE_TYPE_FLOAT_MAP_OPTIONS_API_VERSION, -EINVAL);

    opts = (const struct sol_flow_node_type_float_map_options *)options;

    mdata->use_input_range = opts->use_input_range;
    mdata->input = opts->input_range;

    if (!mdata->use_input_range &&
        isgreaterequal(mdata->input.min, mdata->input.max)) {
        SOL_WRN("Invalid range: input max must to be bigger than min");
        return -EINVAL;
    }

    mdata->output = opts->output_range;

    if (isless(mdata->output.min, mdata->output.max)) {
        mdata->output_value.min = mdata->output.min;
        mdata->output_value.max = mdata->output.max;
    } else {
        mdata->output_value.max = mdata->output.min;
        mdata->output_value.min = mdata->output.max;
    }

    mdata->output_value.step = opts->output_range.step;

    return 0;
}
Esempio n. 6
0
static int
map_process(struct sol_flow_node *node, void *data, uint16_t port, uint16_t conn_id, const struct sol_flow_packet *packet)
{
    struct drange_map_data *mdata = data;
    struct sol_drange in_value;
    double out_value;
    int r;

    r = sol_flow_packet_get_drange(packet, &in_value);
    SOL_INT_CHECK(r, < 0, r);

    if (mdata->use_input_range) {
        if (isgreaterequal(in_value.min, in_value.max)) {
            SOL_WRN("Invalid range: input max must to be bigger than min");
            return -EINVAL;
        }
        r = _map(in_value.val, in_value.min, in_value.max, mdata->output.min,
            mdata->output.max, mdata->output_value.step, &out_value);
    } else
        r = _map(in_value.val, mdata->input.min, mdata->input.max,
            mdata->output.min, mdata->output.max, mdata->output_value.step,
            &out_value);

    SOL_INT_CHECK(r, < 0, r);

    mdata->output_value.val = out_value;

    return sol_flow_send_drange_packet(node,
        SOL_FLOW_NODE_TYPE_FLOAT_MAP__OUT__OUT,
        &mdata->output_value);
}
Esempio n. 7
0
int is_rectangle_covered (rectangle_t *dest, rectangle_t *src) {
    double d_half_w = dest->width / 2.0;
    double d_half_h = dest->height / 2.0;

    double s_half_w = src->width / 2.0;
    double s_half_h = src->height / 2.0;


    return (islessequal     (src->center.x - s_half_w,
                            dest->center.x - d_half_w)          &&
            islessequal     (src->center.y - s_half_h,
                            dest->center.y - d_half_h)          &&
            isgreaterequal  (src->center.x + s_half_w,
                            dest->center.x + d_half_w)          &&
            isgreaterequal  (src->center.y + s_half_h,
                            dest->center.y + d_half_h));
}
Esempio n. 8
0
void
vtc_expect(struct vtclog *vl,
    const char *olhs, const char *lhs,
    const char *cmp,
    const char *orhs, const char *rhs)
{
	vre_t *vre;
	const char *error;
	int erroroffset;
	int i, j, retval = -1;
	double fl, fr;

	j = lhs == NULL || rhs == NULL;
	if (lhs == NULL)
		lhs = "<undef>";
	if (rhs == NULL)
		rhs = "<undef>";

	if (!strcmp(cmp, "~") || !strcmp(cmp, "!~")) {
		vre = VRE_compile(rhs, 0, &error, &erroroffset);
		if (vre == NULL)
			vtc_fatal(vl, "REGEXP error: %s (@%d) (%s)",
			    error, erroroffset, rhs);
		i = VRE_exec(vre, lhs, strlen(lhs), 0, 0, NULL, 0, 0);
		retval = (i >= 0 && *cmp == '~') || (i < 0 && *cmp == '!');
		VRE_free(&vre);
	} else if (!strcmp(cmp, "==")) {
		retval = strcmp(lhs, rhs) == 0;
	} else if (!strcmp(cmp, "!=")) {
		retval = strcmp(lhs, rhs) != 0;
	} else if (j) {
		// fail inequality comparisons if either side is undef'ed
		retval = 0;
	} else {
		fl = VNUM(lhs);
		fr = VNUM(rhs);
		if (!strcmp(cmp, "<"))
			retval = isless(fl, fr);
		else if (!strcmp(cmp, ">"))
			retval = isgreater(fl, fr);
		else if (!strcmp(cmp, "<="))
			retval = islessequal(fl, fr);
		else if (!strcmp(cmp, ">="))
			retval = isgreaterequal(fl, fr);
	}

	if (retval == -1)
		vtc_fatal(vl,
		    "EXPECT %s (%s) %s %s (%s) test not implemented",
		    olhs, lhs, cmp, orhs, rhs);
	else if (retval == 0)
		vtc_fatal(vl, "EXPECT %s (%s) %s \"%s\" failed",
		    olhs, lhs, cmp, rhs);
	else
		vtc_log(vl, 4, "EXPECT %s (%s) %s \"%s\" match",
		    olhs, lhs, cmp, rhs);
}
Esempio n. 9
0
static inline char *format_value_with_precision_and_unit(char *value_string, size_t value_string_len, calculated_number value, const char *units, int precision) {
    if(unlikely(isnan(value) || isinf(value)))
        value = 0.0;

    char *separator = "";
    if(unlikely(isalnum(*units)))
        separator = " ";

    if(precision < 0) {
        int len, lstop = 0, trim_zeros = 1;

        calculated_number abs = value;
        if(isless(value, 0)) {
            lstop = 1;
            abs = calculated_number_fabs(value);
        }

        if(isgreaterequal(abs, 1000)) {
            len = snprintfz(value_string, value_string_len, "%0.0" LONG_DOUBLE_MODIFIER, (LONG_DOUBLE) value);
            trim_zeros = 0;
        }
        else if(isgreaterequal(abs, 10))     len = snprintfz(value_string, value_string_len, "%0.1" LONG_DOUBLE_MODIFIER, (LONG_DOUBLE) value);
        else if(isgreaterequal(abs, 1))      len = snprintfz(value_string, value_string_len, "%0.2" LONG_DOUBLE_MODIFIER, (LONG_DOUBLE) value);
        else if(isgreaterequal(abs, 0.1))    len = snprintfz(value_string, value_string_len, "%0.2" LONG_DOUBLE_MODIFIER, (LONG_DOUBLE) value);
        else if(isgreaterequal(abs, 0.01))   len = snprintfz(value_string, value_string_len, "%0.4" LONG_DOUBLE_MODIFIER, (LONG_DOUBLE) value);
        else if(isgreaterequal(abs, 0.001))  len = snprintfz(value_string, value_string_len, "%0.5" LONG_DOUBLE_MODIFIER, (LONG_DOUBLE) value);
        else if(isgreaterequal(abs, 0.0001)) len = snprintfz(value_string, value_string_len, "%0.6" LONG_DOUBLE_MODIFIER, (LONG_DOUBLE) value);
        else                                 len = snprintfz(value_string, value_string_len, "%0.7" LONG_DOUBLE_MODIFIER, (LONG_DOUBLE) value);

        if(unlikely(trim_zeros)) {
            int l;
            // remove trailing zeros from the decimal part
            for(l = len - 1; l > lstop; l--) {
                if(likely(value_string[l] == '0')) {
                    value_string[l] = '\0';
                    len--;
                }

                else if(unlikely(value_string[l] == '.')) {
                    value_string[l] = '\0';
                    len--;
                    break;
                }

                else
                    break;
            }
        }

        if(unlikely(len <= 0)) len = 1;
        snprintfz(&value_string[len], value_string_len - len, "%s%s", separator, units);
    }
    else {
        if(precision > 50) precision = 50;
        snprintfz(value_string, value_string_len, "%0.*" LONG_DOUBLE_MODIFIER "%s%s", precision, (LONG_DOUBLE) value, separator, units);
    }

    return value_string;
}
Esempio n. 10
0
FLOAT
M_DECL_FUNC (__fmax) (FLOAT x, FLOAT y)
{
  if (isgreaterequal (x, y))
    return x;
  else if (isless (x, y))
    return y;
  else if (issignaling (x) || issignaling (y))
    return x + y;
  else
    return isnan (y) ? x : y;
}
Esempio n. 11
0
/* wrapper atanhl */
long double
__atanhl (long double x)
{
  if (__builtin_expect (isgreaterequal (fabsl (x), 1.0L), 0)
      && _LIB_VERSION != _IEEE_)
    return __kernel_standard_l (x, x,
				fabsl (x) > 1.0L
				? 230		/* atanh(|x|>1) */
				: 231);		/* atanh(|x|==1) */

  return __ieee754_atanhl (x);
}
Esempio n. 12
0
File: audio.c Progetto: 0xheart0/vlc
int libvlc_audio_set_volume( libvlc_media_player_t *mp, int volume )
{
    float vol = volume / 100.f;
    if (!isgreaterequal(vol, 0.f))
    {
        libvlc_printerr( "Volume out of range" );
        return -1;
    }

    int ret = -1;
    audio_output_t *aout = GetAOut( mp );
    if( aout != NULL )
    {
        ret = aout_VolumeSet( aout, vol );
        vlc_object_release( aout );
    }
    return ret;
}
Esempio n. 13
0
static int
float_filter_process(struct sol_flow_node *node, void *data, uint16_t port, uint16_t conn_id, const struct  sol_flow_packet *packet)
{
    struct sol_drange value;
    int r;
    struct float_filter_data *mdata = data;

    r = sol_flow_packet_get_drange(packet, &value);
    SOL_INT_CHECK(r, < 0, r);

    if (isgreaterequal(value.val, mdata->min) && islessequal(value.val, mdata->max)) {
        if (mdata->range_override) {
            value.min = mdata->min;
            value.max = mdata->max;
            value.step = 1;
        }
        return sol_flow_send_drange_packet(node, SOL_FLOW_NODE_TYPE_FLOAT_FILTER__OUT__OUT, &value);
    }
    return 0;
}
Esempio n. 14
0
static int
angle_set(struct sol_flow_node *node, void *data, uint16_t port, uint16_t conn_id, const struct sol_flow_packet *packet)
{
    double in_value;
    struct servo_motor_data *mdata = data;
    int r, pulse_width;

    r = sol_flow_packet_get_drange_value(packet, &in_value);
    SOL_INT_CHECK(r, < 0, r);

    if (isless(in_value, 0) || isgreaterequal(in_value, 180)) {
        SOL_WRN("Invalid value %f. It must be >= 0 and < 180", in_value);
        return -EINVAL;
    }

    pulse_width = in_value * mdata->duty_cycle_diff / 180 +
        mdata->duty_cycle_range.min;

    return set_pulse_width(mdata, pulse_width);
}
Esempio n. 15
0
static bool
drange_val_greater_or_equal(double var0, double var1)
{
    return isgreaterequal(var0, var1);
}
Esempio n. 16
0
#ifndef TRANSITIVE
#include <math.h>
#endif

#include "util.h"

TYPE_ARITH(float_t);
TYPE_ARITH(double_t);

IDENT(fpclassify(0.0), int);
IDENT(isfinite(0.0), int);
IDENT(isgreater(0.0, 0.0), int);
IDENT(isgreaterequal(0.0, 0.0), int);
IDENT(isinf(0.0), int);
IDENT(isless(0.0, 0.0), int);
IDENT(islessequal(0.0, 0.0), int);
IDENT(islessgreater(0.0, 0.0), int);
IDENT(isnan(0.0), int);
IDENT(isnormal(0.0), int);
IDENT(isunordered(0.0, 0.0), int);
IDENT(signbit(0.0), int);

IDENT(M_E, double);
IDENT(M_LOG2E, double);
IDENT(M_LOG10E, double);
IDENT(M_LN2, double);
IDENT(M_LN10, double);
IDENT(M_PI, double);
IDENT(M_PI_2, double);
IDENT(M_PI_4, double);
IDENT(M_1_PI, double);
Esempio n. 17
0
double
fmax (double _x, double _y)
{
   return ( isgreaterequal (_x, _y)|| __isnan (_y) ?  _x : _y );
}
Esempio n. 18
0
Double
__ieee754_exp2 (Double x)
{
  static const Double himark = (Double) DBL_MAX_EXP;
  static const Double lomark = (Double) (DBL_MIN_EXP - DBL_MANT_DIG - 1);

  /* Check for usual case.  */
  if (isless (x, himark) && isgreaterequal (x, lomark))
    {
      static const Double THREEp42 = 13194139533312.0;
      int tval, unsafe;
      Double rx, x22, result;
      union ieee754_double ex2_u, scale_u;
      fenv_t oldenv;

      feholdexcept (&oldenv);
#ifdef FE_TONEAREST
      /* If we don't have this, it's too bad.  */
      fesetround (FE_TONEAREST);
#endif

      /* 1. Argument reduction.
	 Choose integers ex, -256 <= t < 256, and some real
	 -1/1024 <= x1 <= 1024 so that
	 x = ex + t/512 + x1.

	 First, calculate rx = ex + t/512.  */
      rx = x + THREEp42;
      rx -= THREEp42;
      x -= rx;  /* Compute x=x1. */
      /* Compute tval = (ex*512 + t)+256.
	 Now, t = (tval mod 512)-256 and ex=tval/512  [that's mod, NOT %; and
	 /-round-to-nearest not the usual c integer /].  */
      tval = (int) (rx * 512.0 + 256.0);

      /* 2. Adjust for accurate table entry.
	 Find e so that
	 x = ex + t/512 + e + x2
	 where -1e6 < e < 1e6, and
	 (Double)(2^(t/512+e))
	 is accurate to one part in 2^-64.  */

      /* 'tval & 511' is the same as 'tval%512' except that it's always
	 positive.
	 Compute x = x2.  */
      x -= exp2_deltatable[tval & 511];

      /* 3. Compute ex2 = 2^(t/512+e+ex).  */
      ex2_u.d() = exp2_accuratetable[tval & 511];
      tval >>= 9;
      unsafe = abs(tval) >= -DBL_MIN_EXP - 1;
      ex2_u.ieee.exponent += tval >> unsafe;
      scale_u.d() = 1.0;
      scale_u.ieee.exponent += tval - (tval >> unsafe);

      /* 4. Approximate 2^x2 - 1, using a fourth-degree polynomial,
	 with maximum error in [-2^-10-2^-30,2^-10+2^-30]
	 less than 10^-19.  */

      x22 = (((.0096181293647031180
	       * x + .055504110254308625)
	      * x + .240226506959100583)
	     * x + .69314718055994495) * ex2_u.d();

      /* 5. Return (2^x2-1) * 2^(t/512+e+ex) + 2^(t/512+e+ex).  */
      fesetenv (&oldenv);

      result = x22 * x + ex2_u.d();

      if (!unsafe)
	return result;
      else
	return result * scale_u.d();
    }
  /* Exceptional cases:  */
  else if (isless (x, himark))
double
__fmax (double x, double y)
{
  return (isgreaterequal (x, y) || isnan (y)) ? x : y;
}
Esempio n. 20
0
void
domathl (void)
{
#ifndef NO_LONG_DOUBLE
  long double f1;
  long double f2;

  int i1;

  f1 = acosl(0.0);
  fprintf( stdout, "acosl          : %Lf\n", f1);

  f1 = acoshl(0.0);
  fprintf( stdout, "acoshl         : %Lf\n", f1);

  f1 = asinl(1.0);
  fprintf( stdout, "asinl          : %Lf\n", f1);

  f1 = asinhl(1.0);
  fprintf( stdout, "asinhl         : %Lf\n", f1);

  f1 = atanl(M_PI_4);
  fprintf( stdout, "atanl          : %Lf\n", f1);

  f1 = atan2l(2.3, 2.3);
  fprintf( stdout, "atan2l         : %Lf\n", f1);

  f1 = atanhl(1.0);
  fprintf( stdout, "atanhl         : %Lf\n", f1);

  f1 = cbrtl(27.0);
  fprintf( stdout, "cbrtl          : %Lf\n", f1);

  f1 = ceill(3.5);
  fprintf( stdout, "ceill          : %Lf\n", f1);

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

  f1 = cosl(M_PI_2);
  fprintf( stdout, "cosl           : %Lf\n", f1);

  f1 = coshl(M_PI_2);
  fprintf( stdout, "coshl          : %Lf\n", f1);

  f1 = erfl(42.0);
  fprintf( stdout, "erfl           : %Lf\n", f1);

  f1 = erfcl(42.0);
  fprintf( stdout, "erfcl          : %Lf\n", f1);

  f1 = expl(0.42);
  fprintf( stdout, "expl           : %Lf\n", f1);

  f1 = exp2l(0.42);
  fprintf( stdout, "exp2l          : %Lf\n", f1);

  f1 = expm1l(0.00042);
  fprintf( stdout, "expm1l         : %Lf\n", f1);

  f1 = fabsl(-1.123);
  fprintf( stdout, "fabsl          : %Lf\n", f1);

  f1 = fdiml(1.123, 2.123);
  fprintf( stdout, "fdiml          : %Lf\n", f1);

  f1 = floorl(0.5);
  fprintf( stdout, "floorl         : %Lf\n", f1);
  f1 = floorl(-0.5);
  fprintf( stdout, "floorl         : %Lf\n", f1);

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

  f1 = fmaxl(-0.42, 0.42);
  fprintf( stdout, "fmaxl          : %Lf\n", f1);

  f1 = fminl(-0.42, 0.42);
  fprintf( stdout, "fminl          : %Lf\n", f1);

  f1 = fmodl(42.0, 3.0);
  fprintf( stdout, "fmodl          : %Lf\n", f1);

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

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

  f1 = hypotl(42.0, 42.0);
  fprintf( stdout, "hypotl         : %Lf\n", f1);

  i1 = ilogbl(42.0);
  fprintf( stdout, "ilogbl         : %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 = j0l(1.2);
  fprintf( stdout, "j0l            : %Lf\n", f1);

  f1 = j1l(1.2);
  fprintf( stdout, "j1l            : %Lf\n", f1);

  f1 = jnl(2,1.2);
  fprintf( stdout, "jnl            : %Lf\n", f1);

  f1 = ldexpl(1.2,3);
  fprintf( stdout, "ldexpl         : %Lf\n", f1);

  f1 = lgammal(42.0);
  fprintf( stdout, "lgammal        : %Lf\n", f1);

  f1 = llrintl(-0.5);
  fprintf( stdout, "llrintl        : %Lf\n", f1);
  f1 = llrintl(0.5);
  fprintf( stdout, "llrintl        : %Lf\n", f1);

  f1 = llroundl(-0.5);
  fprintf( stdout, "lroundl        : %Lf\n", f1);
  f1 = llroundl(0.5);
  fprintf( stdout, "lroundl        : %Lf\n", f1);

  f1 = logl(42.0);
  fprintf( stdout, "logl           : %Lf\n", f1);

  f1 = log10l(42.0);
  fprintf( stdout, "log10l         : %Lf\n", f1);

  f1 = log1pl(42.0);
  fprintf( stdout, "log1pl         : %Lf\n", f1);

  f1 = log2l(42.0);
  fprintf( stdout, "log2l          : %Lf\n", f1);

  f1 = logbl(42.0);
  fprintf( stdout, "logbl          : %Lf\n", f1);

  f1 = lrintl(-0.5);
  fprintf( stdout, "lrintl         : %Lf\n", f1);
  f1 = lrintl(0.5);
  fprintf( stdout, "lrintl         : %Lf\n", f1);

  f1 = lroundl(-0.5);
  fprintf( stdout, "lroundl        : %Lf\n", f1);
  f1 = lroundl(0.5);
  fprintf( stdout, "lroundl        : %Lf\n", f1);

  f1 = modfl(42.0,&f2);
  fprintf( stdout, "lmodfl         : %Lf\n", f1);

  f1 = nanl("");
  fprintf( stdout, "nanl           : %Lf\n", f1);

  f1 = nearbyintl(1.5);
  fprintf( stdout, "nearbyintl     : %Lf\n", f1);

  f1 = nextafterl(1.5,2.0);
  fprintf( stdout, "nextafterl     : %Lf\n", f1);

  f1 = powl(3.01, 2.0);
  fprintf( stdout, "powl           : %Lf\n", f1);

  f1 = remainderl(3.01,2.0);
  fprintf( stdout, "remainderl     : %Lf\n", f1);

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

  f1 = rintl(0.5);
  fprintf( stdout, "rintl          : %Lf\n", f1);
  f1 = rintl(-0.5);
  fprintf( stdout, "rintl          : %Lf\n", f1);

  f1 = roundl(0.5);
  fprintf( stdout, "roundl         : %Lf\n", f1);
  f1 = roundl(-0.5);
  fprintf( stdout, "roundl         : %Lf\n", f1);

  f1 = scalblnl(1.2,3);
  fprintf( stdout, "scalblnl       : %Lf\n", f1);

  f1 = scalbnl(1.2,3);
  fprintf( stdout, "scalbnl        : %Lf\n", f1);

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

  f1 = sinl(M_PI_4);
  fprintf( stdout, "sinl           : %Lf\n", f1);

  f1 = sinhl(M_PI_4);
  fprintf( stdout, "sinhl          : %Lf\n", f1);

  f1 = sqrtl(9.0);
  fprintf( stdout, "sqrtl          : %Lf\n", f1);

  f1 = tanl(M_PI_4);
  fprintf( stdout, "tanl           : %Lf\n", f1);

  f1 = tanhl(M_PI_4);
  fprintf( stdout, "tanhl          : %Lf\n", f1);

  f1 = tgammal(2.1);
  fprintf( stdout, "tgammal        : %Lf\n", f1);

  f1 = truncl(3.5);
  fprintf( stdout, "truncl         : %Lf\n", f1);

  f1 = y0l(1.2);
  fprintf( stdout, "y0l            : %Lf\n", f1);

  f1 = y1l(1.2);
  fprintf( stdout, "y1l            : %Lf\n", f1);

  f1 = ynl(3,1.2);
  fprintf( stdout, "ynl            : %Lf\n", f1);
#endif
}
void
domath  (void)
{
#ifndef NO_DOUBLE
  double f1;
  double f2;

  int i1;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  i1 = ilogb (42.0);
  fprintf( stdout, "ilogb          : %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 = j0 (1.2);
  fprintf( stdout, "j0             : %f\n", f1);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  f1 = yn (3,1.2);
  fprintf( stdout, "yn             : %f\n", f1);
#endif
}
Esempio n. 22
0
float
__ieee754_exp2f (float x)
{
  static const float himark = (float) FLT_MAX_EXP;
  static const float lomark = (float) (FLT_MIN_EXP - FLT_MANT_DIG - 1);

  /* Check for usual case.  */
  if (isless (x, himark) && isgreaterequal (x, lomark))
    {
      static const float THREEp14 = 49152.0;
      int tval, unsafe;
      float rx, x22, result;
      union ieee754_float ex2_u, scale_u;

      if (fabsf (x) < FLT_EPSILON / 4.0f)
	return 1.0f + x;

      {
	SET_RESTORE_ROUND_NOEXF (FE_TONEAREST);

	/* 1. Argument reduction.
	   Choose integers ex, -128 <= t < 128, and some real
	   -1/512 <= x1 <= 1/512 so that
	   x = ex + t/512 + x1.

	   First, calculate rx = ex + t/256.  */
	rx = x + THREEp14;
	rx -= THREEp14;
	x -= rx;  /* Compute x=x1. */
	/* Compute tval = (ex*256 + t)+128.
	   Now, t = (tval mod 256)-128 and ex=tval/256  [that's mod, NOT %;
	   and /-round-to-nearest not the usual c integer /].  */
	tval = (int) (rx * 256.0f + 128.0f);

	/* 2. Adjust for accurate table entry.
	   Find e so that
	   x = ex + t/256 + e + x2
	   where -7e-4 < e < 7e-4, and
	   (float)(2^(t/256+e))
	   is accurate to one part in 2^-64.  */

	/* 'tval & 255' is the same as 'tval%256' except that it's always
	   positive.
	   Compute x = x2.  */
	x -= __exp2f_deltatable[tval & 255];

	/* 3. Compute ex2 = 2^(t/255+e+ex).  */
	ex2_u.f = __exp2f_atable[tval & 255];
	tval >>= 8;
	/* x2 is an integer multiple of 2^-30; avoid intermediate
	   underflow from the calculation of x22 * x.  */
	unsafe = abs(tval) >= -FLT_MIN_EXP - 32;
	ex2_u.ieee.exponent += tval >> unsafe;
	scale_u.f = 1.0;
	scale_u.ieee.exponent += tval - (tval >> unsafe);

	/* 4. Approximate 2^x2 - 1, using a second-degree polynomial,
	   with maximum error in [-2^-9 - 2^-14, 2^-9 + 2^-14]
	   less than 1.3e-10.  */

	x22 = (.24022656679f * x + .69314736128f) * ex2_u.f;
      }

      /* 5. Return (2^x2-1) * 2^(t/512+e+ex) + 2^(t/512+e+ex).  */
      result = x22 * x + ex2_u.f;

      if (!unsafe)
	return result;
      else
	{
	  result *= scale_u.f;
	  math_check_force_underflow_nonneg (result);
	  return result;
	}
    }
  /* Exceptional cases:  */
  else if (isless (x, himark))
Esempio n. 23
0
static void
cmd_http_expect(CMD_ARGS)
{
	struct http *hp;
	const char *lhs, *clhs;
	char *cmp;
	const char *rhs, *crhs;
	vre_t *vre;
	const char *error;
	int erroroffset;
	int i, retval = -1;

	(void)cmd;
	(void)vl;
	CAST_OBJ_NOTNULL(hp, priv, HTTP_MAGIC);
	AZ(strcmp(av[0], "expect"));
	av++;

	AN(av[0]);
	AN(av[1]);
	AN(av[2]);
	AZ(av[3]);
	lhs = cmd_var_resolve(hp, av[0]);
	cmp = av[1];
	rhs = cmd_var_resolve(hp, av[2]);

	clhs = lhs ? lhs : "<undef>";
	crhs = rhs ? rhs : "<undef>";

	if (!strcmp(cmp, "~") || !strcmp(cmp, "!~")) {
		vre = VRE_compile(crhs, 0, &error, &erroroffset);
		if (vre == NULL)
			vtc_log(hp->vl, 0, "REGEXP error: %s (@%d) (%s)",
			    error, erroroffset, crhs);
		i = VRE_exec(vre, clhs, strlen(clhs), 0, 0, NULL, 0, 0);
		retval = (i >= 0 && *cmp == '~') || (i < 0 && *cmp == '!');
		VRE_free(&vre);
	} else if (!strcmp(cmp, "==")) {
		retval = strcmp(clhs, crhs) == 0;
	} else if (!strcmp(cmp, "!=")) {
		retval = strcmp(clhs, crhs) != 0;
	} else if (lhs == NULL || rhs == NULL) {
		// fail inequality comparisons if either side is undef'ed
		retval = 0;
	} else if (!strcmp(cmp, "<")) {
		retval = isless(VNUM(lhs), VNUM(rhs));
	} else if (!strcmp(cmp, ">")) {
		retval = isgreater(VNUM(lhs), VNUM(rhs));
	} else if (!strcmp(cmp, "<=")) {
		retval = islessequal(VNUM(lhs), VNUM(rhs));
	} else if (!strcmp(cmp, ">=")) {
		retval = isgreaterequal(VNUM(lhs), VNUM(rhs));
	}

	if (retval == -1)
		vtc_log(hp->vl, 0,
		    "EXPECT %s (%s) %s %s (%s) test not implemented",
		    av[0], clhs, av[1], av[2], crhs);
	else
		vtc_log(hp->vl, retval ? 4 : 0, "EXPECT %s (%s) %s \"%s\" %s",
		    av[0], clhs, cmp, crhs, retval ? "match" : "failed");
}
Esempio n. 24
0
long double
fmaxl (long double _x, long double  _y)
{
  return (( isgreaterequal(_x, _y) || __isnanl (_y)) ?  _x : _y );
}
Esempio n. 25
0
long double
__fmaxl (long double x, long double y)
{
  return (isgreaterequal (x, y) || isnan (y)) ? x : y;
}
Esempio n. 26
0
static int
wave_generator_trapezoidal_open(struct sol_flow_node *node,
    void *data,
    const struct sol_flow_node_options *options)
{
    struct drange_wave_generator_trapezoidal_data *mdata = data;
    const struct sol_flow_node_type_wave_generator_trapezoidal_options *opts = (const struct sol_flow_node_type_wave_generator_trapezoidal_options *)options;
    uint32_t tick_start;
    struct t_state *t_state;
    struct sol_drange *val;

    SOL_FLOW_NODE_OPTIONS_SUB_API_CHECK(opts, SOL_FLOW_NODE_TYPE_WAVE_GENERATOR_TRAPEZOIDAL_OPTIONS_API_VERSION, -EINVAL);

    if (isgreaterequal(opts->min.val, opts->max.val)) {
        SOL_ERR("Trapezoidal wave generator's min must be less than its max");
        return -EDOM;
    }
    if (opts->ticks_inc.val < 1) {
        SOL_ERR("Trapezoidal wave generator's ticks_inc value (%d) cannot"
            " be less than 1)", opts->ticks_inc.val);
        return -EDOM;
    }
    if (opts->ticks_dec.val < 1) {
        SOL_ERR("Trapezoidal wave generator's ticks_dec value (%d) cannot"
            " be less than 1)", opts->ticks_dec.val);
        return -EDOM;
    }
    if (opts->tick_start.val < 0) {
        SOL_ERR("Trapezoidal wave generator's tick_start value (%d) cannot"
            " be less than 0)", opts->tick_start.val);
        return -EDOM;
    }
    if (opts->ticks_at_max.val < 0) {
        SOL_ERR("Trapezoidal wave generator's ticks_at_max value (%d) cannot"
            " be less than 0)", opts->ticks_at_max.val);
        return -EDOM;
    }
    if (opts->ticks_at_min.val < 0) {
        SOL_ERR("Trapezoidal wave generator's ticks_at_min value (%d) cannot"
            " be less than 0)", opts->ticks_at_min.val);
        return -EDOM;
    }

    mdata->ticks_at_min = opts->ticks_at_min.val;
    mdata->ticks_at_max = opts->ticks_at_max.val;

    t_state = &mdata->t_state;
    val = &t_state->val;

    t_state->did_first = false;

    val->min = opts->min.val;
    val->max = opts->max.val;

    mdata->ticks_inc = opts->ticks_inc.val;
    mdata->ticks_dec = opts->ticks_dec.val;
    mdata->inc_step = (val->max - val->min) / mdata->ticks_inc;
    mdata->dec_step = (val->min - val->max) / mdata->ticks_dec;

    /* calculating starting val from tick_start */
    t_state->increasing = true;
    mdata->period_in_ticks = mdata->ticks_at_min + mdata->ticks_inc
                             + mdata->ticks_at_max + mdata->ticks_dec;

    tick_start = opts->tick_start.val % mdata->period_in_ticks;

    t_state->max_tick_cnt = 0;
    t_state->min_tick_cnt = mdata->ticks_at_min;

    val->val = val->min;
    val->step = mdata->inc_step;

    while (t_state->curr_period_tick != tick_start) {
        trapezoidal_iterate_do(mdata);
        /* we set min_tick_cnt manually, but max_tick_cnt has be
         * updated on the run */
        direction_check(mdata, false, true);
    }

    return 0;
}
Esempio n. 27
0
    __kernel void optical_flow (
                                read_only
                                image2d_t current_image,
                                read_only image2d_t previous_image,
                                write_only image2d_t optical_flow,
                                const float scale,
                                const float offset,
                                const float lambda,
                                const float threshold )
    {
        sampler_t sampler = CLK_ADDRESS_CLAMP_TO_EDGE;
        int2 coords = (int2)(get_global_id(0), get_global_id(1));
        float4 current_pixel    = read_imagef(current_image,
                                              sampler,
                                              coords);
        float4 previous_pixel   = read_imagef(previous_image,
                                              sampler,
                                              coords);
        int2 x1 	= (int2)(offset, 0.f);
        int2 y1 	= (int2)(0.f, offset);

        //get the difference
        float4 curdif = previous_pixel - current_pixel;

        //calculate the gradient
        //Image 2 first
        float4 gradx = read_imagef(previous_image,
                                   sampler,
                                   coords+x1) -
                       read_imagef(previous_image,
                                   sampler,
                                   coords-x1);
        //Image 1
        gradx += read_imagef(current_image,
                             sampler,
                             coords+x1) -
                 read_imagef(current_image,
                             sampler,
                             coords-x1);
        //Image 2 first
        float4 grady = read_imagef(previous_image,
                                   sampler,
                                   coords+y1) -
                       read_imagef(previous_image,
                                   sampler,
                                   coords-y1);
        //Image 1
        grady += read_imagef(current_image,
                             sampler,
                             coords+y1) -
                 read_imagef(current_image,
                             sampler,
                             coords-y1);

        float4 sqr = (gradx*gradx) + (grady*grady) +
                     (float4)(lambda,lambda, lambda, lambda);
        float4 gradmag = sqrt(sqr);

        ///////////////////////////////////////////////////
        float4 vx = curdif * (gradx / gradmag);
        float vxd = vx.x;//assumes greyscale

        //format output for flowrepos, out(-x,+x,-y,+y)
        float2 xout = (float2)(fmax(vxd,0.f),fabs(fmin(vxd,0.f)));
        xout *= scale;
        ///////////////////////////////////////////////////
        float4 vy = curdif*(grady/gradmag);
        float vyd = vy.x;//assumes greyscale

        //format output for flowrepos, out(-x,+x,-y,+y)
        float2 yout = (float2)(fmax(vyd,0.f),fabs(fmin(vyd,0.f)));
        yout *= scale;
        ///////////////////////////////////////////////////

        float4 out = (float4)(xout, yout);
        float cond = (float)isgreaterequal(length(out), threshold);
        out *= cond;

        write_imagef(optical_flow, coords, out);
    }
Esempio n. 28
0
FLOAT
M_DECL_FUNC (__fmax) (FLOAT x, FLOAT y)
{
  return (isgreaterequal (x, y) || isnan (y)) ? x : y;
}
Esempio n. 29
0
double
__ieee754_exp2 (double x)
{
  static const double himark = (double) DBL_MAX_EXP;
  static const double lomark = (double) (DBL_MIN_EXP - DBL_MANT_DIG - 1);

  /* Check for usual case.  */
  if (__glibc_likely (isless (x, himark)))
    {
      /* Exceptional cases:  */
      if (__glibc_unlikely (!isgreaterequal (x, lomark)))
	{
	  if (isinf (x))
	    /* e^-inf == 0, with no error.  */
	    return 0;
	  else
	    /* Underflow */
	    return TWOM1000 * TWOM1000;
	}

      static const double THREEp42 = 13194139533312.0;
      int tval, unsafe;
      double rx, x22, result;
      union ieee754_double ex2_u, scale_u;

      if (fabs (x) < DBL_EPSILON / 4.0)
	return 1.0 + x;

      {
	SET_RESTORE_ROUND_NOEX (FE_TONEAREST);

	/* 1. Argument reduction.
	   Choose integers ex, -256 <= t < 256, and some real
	   -1/1024 <= x1 <= 1024 so that
	   x = ex + t/512 + x1.

	   First, calculate rx = ex + t/512.  */
	rx = x + THREEp42;
	rx -= THREEp42;
	x -= rx;  /* Compute x=x1. */
	/* Compute tval = (ex*512 + t)+256.
	   Now, t = (tval mod 512)-256 and ex=tval/512  [that's mod, NOT %;
	   and /-round-to-nearest not the usual c integer /].  */
	tval = (int) (rx * 512.0 + 256.0);

	/* 2. Adjust for accurate table entry.
	   Find e so that
	   x = ex + t/512 + e + x2
	   where -1e6 < e < 1e6, and
	   (double)(2^(t/512+e))
	   is accurate to one part in 2^-64.  */

	/* 'tval & 511' is the same as 'tval%512' except that it's always
	   positive.
	   Compute x = x2.  */
	x -= exp2_deltatable[tval & 511];

	/* 3. Compute ex2 = 2^(t/512+e+ex).  */
	ex2_u.d = exp2_accuratetable[tval & 511];
	tval >>= 9;
	/* x2 is an integer multiple of 2^-54; avoid intermediate
	   underflow from the calculation of x22 * x.  */
	unsafe = abs (tval) >= -DBL_MIN_EXP - 56;
	ex2_u.ieee.exponent += tval >> unsafe;
	scale_u.d = 1.0;
	scale_u.ieee.exponent += tval - (tval >> unsafe);

	/* 4. Approximate 2^x2 - 1, using a fourth-degree polynomial,
	   with maximum error in [-2^-10-2^-30,2^-10+2^-30]
	   less than 10^-19.  */

	x22 = (((.0096181293647031180
		 * x + .055504110254308625)
		* x + .240226506959100583)
	       * x + .69314718055994495) * ex2_u.d;
	math_opt_barrier (x22);
      }

      /* 5. Return (2^x2-1) * 2^(t/512+e+ex) + 2^(t/512+e+ex).  */
      result = x22 * x + ex2_u.d;

      if (!unsafe)
	return result;
      else
	return result * scale_u.d;
    }
  else
    /* Return x, if x is a NaN or Inf; or overflow, otherwise.  */
    return TWO1023 * x;
Esempio n. 30
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
}