Ejemplo n.º 1
0
extern double
cosmoPk_forceSigma8(cosmoPk_t pk,
                    double    sigma8,
                    double    kmin,
                    double    kmax,
                    double    *error)
{
	double sigma8Actual;
	double sigma8First;
	int    numIter    = 0;
	int    numIterMax = LOCAL_MAX_FORCESIGMA8_ITERATIONS;

	assert(pk != NULL);
	assert(isgreater(sigma8, 0.0));
	assert(isgreater(kmin, 0.0));
	assert(isgreater(kmax, kmin));
	assert(error != NULL);

	sigma8Actual = cosmoPk_calcSigma8(pk, kmin, kmax, error);
	sigma8First  = sigma8Actual;
	do {
		cosmoPk_scale(pk, POW2(sigma8 / sigma8Actual));
		sigma8Actual = cosmoPk_calcSigma8(pk, kmin, kmax, error);
		*error       = fabs(1. - sigma8 / sigma8Actual);
		numIter++;
	} while (numIter < numIterMax && isgreater(*error, 1e-10));
	if (numIter >= numIterMax)
		fprintf(stderr, "Exhausted iterations in %s: error %15.13e\n",
		        __func__, *error);

	return POW2(sigma8 / sigma8First);
}
Ejemplo n.º 2
0
void test_isgreater()
{
    static_assert((std::is_same<decltype(isgreater((float)0, (float)0)), bool>::value), "");
    static_assert((std::is_same<decltype(isgreater((float)0, (double)0)), bool>::value), "");
    static_assert((std::is_same<decltype(isgreater((float)0, (long double)0)), bool>::value), "");
    static_assert((std::is_same<decltype(isgreater((double)0, (float)0)), bool>::value), "");
    static_assert((std::is_same<decltype(isgreater((double)0, (double)0)), bool>::value), "");
    static_assert((std::is_same<decltype(isgreater((double)0, (long double)0)), bool>::value), "");
    static_assert((std::is_same<decltype(isgreater((long double)0, (float)0)), bool>::value), "");
    static_assert((std::is_same<decltype(isgreater((long double)0, (double)0)), bool>::value), "");
    static_assert((std::is_same<decltype(isgreater((long double)0, (long double)0)), bool>::value), "");
    assert(isgreater(-1.0, 0.F) == false);
}
Ejemplo n.º 3
0
extern double
cosmoPk_eval(cosmoPk_t pk, double k)
{
	assert(pk != NULL);
	assert(isgreater(k, 0.0));

	if (isless(k, pk->k[0]))
		return pk->P[0] * pow(k / (pk->k[0]), pk->slopeBeforeKmin);

	if (isgreater(k, pk->k[pk->numPoints - 1]))
		return pk->P[0] * pow(k / (pk->k[pk->numPoints - 1]),
		                      pk->slopeBeyondKmax);

	return gsl_spline_eval(pk->spline, k, pk->acc);
}
Ejemplo n.º 4
0
/* wrapper yn */
double
yn (int n, double x)
{
  if (__builtin_expect (islessequal (x, 0.0) || isgreater (x, X_TLOSS), 0)
      && _LIB_VERSION != _IEEE_)
    {
      if (x < 0.0)
	{
	  /* d = zero/(x-x) */
	  feraiseexcept (FE_INVALID);
	  return __kernel_standard (n, x, 13);
	}
      else if (x == 0.0)
	{
	  /* d = -one/(x-x) */
	  feraiseexcept (FE_DIVBYZERO);
	  return __kernel_standard (n, x, 12);
	}
      else if (_LIB_VERSION != _POSIX_)
	/* yn(n,x>X_TLOSS) */
	return __kernel_standard (n, x, 39);
    }

  return __ieee754_yn (n, x);
}
Ejemplo n.º 5
0
double
__ieee754_atanh (double x)
{
  double xa = fabs (x);
  double t;
  if (isless (xa, 0.5))
    {
      if (__builtin_expect (xa < 0x1.0p-28, 0))
	{
	  math_force_eval (huge + x);
	  return x;
	}

      t = xa + xa;
      t = 0.5 * __log1p (t + t * xa / (1.0 - xa));
    }
  else if (__builtin_expect (isless (xa, 1.0), 1))
    t = 0.5 * __log1p ((xa + xa) / (1.0 - xa));
  else
    {
      if (isgreater (xa, 1.0))
	return (x - x) / (x - x);

      return x / 0.0;
    }

  return __copysign (t, x);
}
Ejemplo n.º 6
0
/* wrapper y1f */
float
y1f (float x)
{
  if (__builtin_expect (islessequal (x, 0.0f)
			|| isgreater (x, (float) X_TLOSS), 0)
      && _LIB_VERSION != _IEEE_)
    {
      if (x < 0.0f)
	{
	  /* d = zero/(x-x) */
	  feraiseexcept (FE_INVALID);
	  return __kernel_standard_f (x, x, 111);
	}
      else if (x == 0.0f)
	{
	  /* d = -one/(x-x) */
	  feraiseexcept (FE_DIVBYZERO);
	  return __kernel_standard_f (x, x, 110);
	}
      else if (_LIB_VERSION != _POSIX_)
	/* y1(x>X_TLOSS) */
	return __kernel_standard_f (x, x, 137);
    }

  return __ieee754_y1f (x);
}
Ejemplo n.º 7
0
extern double
cosmoPk_evalGSL(double k, void *param)
{
	assert(param != NULL);
	assert(isgreater(k, 0.0));
	return cosmoPk_eval((cosmoPk_t)param, k);
}
Ejemplo n.º 8
0
float
__ieee754_atanhf (float x)
{
  float xa = fabsf (x);
  float t;
  if (isless (xa, 0.5f))
    {
      if (__builtin_expect (xa < 0x1.0p-28f, 0))
	{
	  math_force_eval (huge + x);
	  return x;
	}

      t = xa + xa;
      t = 0.5f * __log1pf (t + t * xa / (1.0f - xa));
    }
  else if (__builtin_expect (isless (xa, 1.0f), 1))
    t = 0.5f * __log1pf ((xa + xa) / (1.0f - xa));
  else
    {
      if (isgreater (xa, 1.0f))
	return (x - x) / (x - x);

      return x / 0.0f;
    }

  return __copysignf (t, x);
}
Ejemplo n.º 9
0
float_type
CONCATX(__,FUNC) (float_type x)
{
  if ((__m81_test (x) & __M81_COND_INF) == 0 && isgreater (x, o_threshold))
    __set_errno (ERANGE);
  return __m81_u(CONCATX(__, FUNC)) (x);
}
Ejemplo n.º 10
0
int main(){

	int i,m;
	frac max = {0,1};
	scanf("%d",&N);

	for(i = 0;i < N; i++){
		scanf("%d",&A[i]);
	}

	for(i = 0;i < N; i++){
		scanf("%d",&B[i]);
	}

	init();
	m = 0;

	for(i = N-1;i >=0 ;--i){
		if(isgreater(C[i],max)){
			max = C[i];
			maxima[m] = i;
			m++;
		}
	}

	int j = m-1;
	for(i = 0;i < N; i++){
		if(i > maxima[j]){
			j--;
		}
		printf("%d ",maxima[j]+1);
	}

	return 0;
}
Ejemplo n.º 11
0
double
__ieee754_atanh (double x)
{
  double xa = fabs (x);
  double t;
  if (isless (xa, 0.5))
    {
      if (__glibc_unlikely (xa < 0x1.0p-28))
	{
	  math_force_eval (huge + x);
	  math_check_force_underflow (x);
	  return x;
	}

      t = xa + xa;
      t = 0.5 * __log1p (t + t * xa / (1.0 - xa));
    }
  else if (__glibc_likely (isless (xa, 1.0)))
    t = 0.5 * __log1p ((xa + xa) / (1.0 - xa));
  else
    {
      if (isgreater (xa, 1.0))
	return (x - x) / (x - x);

      return x / 0.0;
    }

  return __copysign (t, x);
}
Ejemplo n.º 12
0
float
__ieee754_atanhf (float x)
{
  float xa = fabsf (x);
  float t;
  if (isless (xa, 0.5f))
    {
      if (__glibc_unlikely (xa < 0x1.0p-28f))
	{
	  math_force_eval (huge + x);
	  if (fabsf (x) < FLT_MIN)
	    {
	      float force_underflow = x * x;
	      math_force_eval (force_underflow);
	    }
	  return x;
	}

      t = xa + xa;
      t = 0.5f * __log1pf (t + t * xa / (1.0f - xa));
    }
  else if (__glibc_likely (isless (xa, 1.0f)))
    t = 0.5f * __log1pf ((xa + xa) / (1.0f - xa));
  else
    {
      if (isgreater (xa, 1.0f))
	return (x - x) / (x - x);

      return x / 0.0f;
    }

  return __copysignf (t, x);
}
Ejemplo n.º 13
0
FLOAT
M_DECL_FUNC (__expm1) (FLOAT x)
{
  if ((__m81_test (x) & __M81_COND_INF) == 0 && isgreater (x, o_threshold))
    __set_errno (ERANGE);
  return __m81_u(M_SUF (__expm1)) (x);
}
Ejemplo n.º 14
0
/**
 * Adjusts a value to fit the constraints for a certain variable:
 * - If the value is lower than the minimum, use the minimum.
 * - If the value is higher than the maximum, use the maximum.
 * - If the variable has steps, round the value to the nearest step.
 */
static void CheckValue(variable_t *var, vlc_value_t *val)
{
    /* Check that our variable is within the bounds */
    switch (var->i_type & VLC_VAR_TYPE)
    {
        case VLC_VAR_INTEGER:
            if (val->i_int < var->min.i_int)
               val->i_int = var->min.i_int;
            if (val->i_int > var->max.i_int)
                val->i_int = var->max.i_int;
            if (var->step.i_int != 0 && (val->i_int % var->step.i_int))
            {
                if (val->i_int > 0)
                    val->i_int = (val->i_int + (var->step.i_int / 2))
                                 / var->step.i_int * var->step.i_int;
                else
                    val->i_int = (val->i_int - (var->step.i_int / 2))
                                 / var->step.i_int * var->step.i_int;
            }
            break;

        case VLC_VAR_FLOAT:
            if (isless(val->f_float, var->min.f_float))
                val->f_float = var->min.f_float;
            if (isgreater(val->f_float, var->max.f_float))
                val->f_float = var->max.f_float;
            if (var->step.f_float != 0.f)
                val->f_float = var->step.f_float
                              * roundf(val->f_float / var->step.f_float);
            break;
    }
}
Ejemplo n.º 15
0
/* wrapper y0l */
long double
y0l (long double x)
{
#  if defined(__UCLIBC_HAS_FENV__)
  if (__builtin_expect (islessequal (x, 0.0L) || isgreater (x, X_TLOSS), 0)
      && _LIB_VERSION != _IEEE_)
    {
      if (x < 0.0L)
	{
	  /* d = zero/(x-x) */
	  feraiseexcept (FE_INVALID);
	  return __kernel_standard_l (x, x, 209);
	}
      else if (x == 0.0L)
	{
	  /* d = -one/(x-x) */
	  feraiseexcept (FE_DIVBYZERO);
	  return __kernel_standard_l (x, x, 208);
	}
      else if (_LIB_VERSION != _POSIX_)
	/* y0(x>X_TLOSS) */
	return __kernel_standard_l (x, x, 235);
    }
#  endif /* __UCLIBC_HAS_FENV__ */
  return (long double)__ieee754_y0 ((double) x);
}
Ejemplo n.º 16
0
extern double
cosmoPk_calcSigma8(cosmoPk_t pk,
                   double    kmin,
                   double    kmax,
                   double    *error)
{
	double scale = 8.0;
	double sigma8Sqr;

	assert(pk != NULL && isgreater(kmax, kmin) && isgreater(kmin, 0.0)
	       && error != NULL);

	sigma8Sqr = cosmoPk_calcMomentFiltered(pk, UINT32_C(0),
	                                       &cosmoFunc_tophatSqr,
	                                       &scale, kmin, kmax, error);
	return sqrt(sigma8Sqr);
}
Ejemplo n.º 17
0
extern void
artHeader_setAexp0(artHeader_t header, float aexp0)
{
	assert(header != NULL);
	assert(isgreater(aexp0, 0.0));

	header->aexp0 = aexp0;
}
Ejemplo n.º 18
0
extern void
artHeader_setAmplt(artHeader_t header, float amplt)
{
	assert(header != NULL);
	assert(isgreater(amplt, 0.0));

	header->amplt = amplt;
}
Ejemplo n.º 19
0
extern void
artHeader_setAstep(artHeader_t header, float astep)
{
	assert(header != NULL);
	assert(isgreater(astep, 0.0));

	header->astep = astep;
}
Ejemplo n.º 20
0
extern double
artHeader_getBoxsizeInMpch(const artHeader_t header)
{
	assert(header != NULL);
	assert(isgreater(header->extras[ARTHEADER_EXTRA_POS_BOXSIZE], 0.0));

	return (double)(header->extras[ARTHEADER_EXTRA_POS_BOXSIZE]);
}
Ejemplo n.º 21
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);
}
Ejemplo n.º 22
0
extern void
artHeader_setWspecies(artHeader_t header, float value, int position)
{
	assert(header != NULL);
	assert(position >= 0 && position < header->nspecies);
	assert(isgreater(value, 0.0));

	header->wspecies[position] = value;
}
Ejemplo n.º 23
0
extern void
artHeader_setAexpn(artHeader_t header, float aexpn)
{
	assert(header != NULL);
	assert(isgreater(aexpn, 0.0));

	header->aexpn = aexpn;
	local_calFactorVelocity(header);
}
Ejemplo n.º 24
0
/* wrapper jnf */
float
jnf (int n, float x)
{
  if (__builtin_expect (isgreater (fabsf (x), (float) X_TLOSS), 0)
      && _LIB_VERSION != _IEEE_ && _LIB_VERSION != _POSIX_)
    /* jn(n,|x|>X_TLOSS) */
    return __kernel_standard_f (n, x, 138);

  return __ieee754_jnf (n, x);
}
Ejemplo n.º 25
0
extern void
cosmoPk_scale(cosmoPk_t pk, double factor)
{
	assert(pk != NULL);
	assert(isgreater(factor, 0.0));

	for (uint32_t i = 0; i < pk->numPoints; i++)
		pk->P[i] *= factor;
	local_doInterpolation(pk);
}
Ejemplo n.º 26
0
/* wrapper jn */
double
jn (int n, double x)
{
  if (__builtin_expect (isgreater (fabs (x), X_TLOSS), 0)
      && _LIB_VERSION != _IEEE_ && _LIB_VERSION != _POSIX_)
    /* jn(n,|x|>X_TLOSS) */
    return __kernel_standard (n, x, 38);

  return __ieee754_jn (n, x);
}
Ejemplo n.º 27
0
Archivo: w_j1l.c Proyecto: dreal/tai
/* wrapper j1l */
long double
__j1l (long double x)
{
  if (__builtin_expect (isgreater (fabsl (x), X_TLOSS), 0)
      && _LIB_VERSION != _IEEE_)
    /* j1(|x|>X_TLOSS) */
    return __kernel_standard (x, x, 236);

  return __ieee754_j1l (x);
}
Ejemplo n.º 28
0
Archivo: w_j0f.c Proyecto: dreal/tai
/* wrapper j0f */
float
j0f (float x)
{
  if (__builtin_expect (isgreater (fabsf (x), (float) X_TLOSS), 0)
      && _LIB_VERSION != _IEEE_)
    /* j0(|x|>X_TLOSS) */
    return __kernel_standard_f (x, x, 134);

  return __ieee754_j0f (x);
}
Ejemplo n.º 29
0
/* wrapper j0 */
double
j0 (double x)
{
  if (__builtin_expect (isgreater (fabs (x), X_TLOSS), 0)
      && _LIB_VERSION != _IEEE_ && _LIB_VERSION != _POSIX_)
    /* j0(|x|>X_TLOSS) */
    return __kernel_standard (x, x, 34);

  return __ieee754_j0 (x);
}
Ejemplo n.º 30
0
/* wrapper j1f */
float
j1f (float x)
{
  if (__builtin_expect (isgreater (fabsf (x), X_TLOSS), 0)
      && _LIB_VERSION != _IEEE_ && _LIB_VERSION != _POSIX_)
    /* j1(|x|>X_TLOSS) */
    return __kernel_standard_f (x, x, 136);

  return __ieee754_j1f (x);
}