예제 #1
0
void test_cbrt()
{
    static_assert((std::is_same<decltype(cbrt((double)0)), double>::value), "");
    static_assert((std::is_same<decltype(cbrtf(0)), float>::value), "");
    static_assert((std::is_same<decltype(cbrtl(0)), long double>::value), "");
    assert(cbrt(1) == 1);
}
예제 #2
0
  inline long double MathTrait<long double>::cbrt( const long double val )
  {
#ifdef _MSC_VER
    return cbrt( val ) ;
#else
    return cbrtl( val ) ;
#endif
  }
예제 #3
0
int isCube(unsigned long long int c)
{
    unsigned long long int root=llroundl(cbrtl((long double)c));

    if(c==root*root*root)
	return 1;
    else
	return 0;
}
예제 #4
0
void testValues() {
    f = 2;
    long double result;
    
    cbrtl(anylongdouble());
    
    //@ assert f == 2;
    //@ assert vacuous: \false;
}
예제 #5
0
파일: square.c 프로젝트: svkampen/square
double *xyz2lab(double arr[]) {
	double ref_x = 95.047;
	double ref_y = 100.000;
	double ref_z = 108.883;

	arr[0] /= ref_x; arr[1] /= ref_y; arr[2] /= ref_z;

	for (int n = 0; n < 3; n++) {
		if (arr[n] > 0.008856)
			arr[n] = cbrtl(arr[n]);
		else
			arr[n] = (7.787 * arr[n]) + (16 / 116.0);
	}

	double *lab = malloc(3 * sizeof(double));
	lab[0] = (116.0 * arr[1]) - 16;
	lab[1] = 500.0 * (arr[0] - arr[1]);
	lab[2] = 200.0 * (arr[1] - arr[2]);

	return lab;
}
예제 #6
0
파일: exp_agent.c 프로젝트: levenkov/olver
static TACommandVerdict cbrtl_cmd(TAThread thread,TAInputStream stream)
{
    long double x, res;

    // Prepare

    x = readLongDouble(&stream);
    
    START_TARGET_OPERATION(thread);
    
    // Execute

    res = cbrtl(x);
    
    END_TARGET_OPERATION(thread);
    
    // Response
    
    writeLongDouble(thread, res);

    sendResponse(thread);
    return taDefaultVerdict;
}
예제 #7
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
}
예제 #8
0
void runSuccess() {
    cbrtl(1.0L);
    cbrtl(0.0L);
    cbrtl(-1.0L);
    cbrtl(anylongdouble());
}
예제 #9
0
void test (float f, double d, long double ld)
{
  if (sqrt (0.0) != 0.0)
    link_error ();

  if (sqrt (1.0) != 1.0)
    link_error ();

  if (cbrt (0.0) != 0.0)
    link_error ();

  if (cbrt (1.0) != 1.0)
    link_error ();

  if (cbrt (-1.0) != -1.0)
    link_error ();

  if (exp (0.0) != 1.0)
    link_error ();

  if (exp (1.0) <= 2.71 || exp (1.0) >= 2.72)
    link_error ();

  if (log (1.0) != 0.0)
    link_error ();

  if (sin (0.0) != 0.0)
    link_error ();

  if (cos (0.0) != 1.0)
    link_error ();

  if (tan (0.0) != 0.0)
    link_error ();

  if (atan (0.0) != 0.0)
    link_error ();

  if (4.0*atan (1.0) <= 3.14 || 4.0*atan (1.0) >= 3.15)
    link_error ();

  if (pow (d, 0.0) != 1.0)
    link_error ();

  if (pow (1.0, d) != 1.0)
    link_error ();


  if (sqrtf (0.0F) != 0.0F)
    link_error ();

  if (sqrtf (1.0F) != 1.0F)
    link_error ();

  if (cbrtf (0.0F) != 0.0F)
    link_error ();

  if (cbrtf (1.0F) != 1.0F)
    link_error ();

  if (cbrtf (-1.0F) != -1.0F)
    link_error ();

  if (expf (0.0F) != 1.0F)
    link_error ();

  if (expf (1.0F) <= 2.71F || expf (1.0F) >= 2.72F)
    link_error ();

  if (logf (1.0F) != 0.0F)
    link_error ();

  if (sinf (0.0F) != 0.0F)
    link_error ();

  if (cosf (0.0F) != 1.0F)
    link_error ();

  if (tanf (0.0F) != 0.0F)
    link_error ();

  if (atanf (0.0F) != 0.0F)
    link_error ();

  if (4.0F*atanf (1.0F) <= 3.14F || 4.0F*atanf (1.0F) >= 3.15F)
    link_error ();

  if (powf (f, 0.0F) != 1.0F)
    link_error ();

  if (powf (1.0F, f) != 1.0F)
    link_error ();


  if (sqrtl (0.0L) != 0.0L)
    link_error ();

  if (sqrtl (1.0L) != 1.0L)
    link_error ();

  if (cbrtl (0.0L) != 0.0L)
    link_error ();

  if (cbrtl (1.0L) != 1.0L)
    link_error ();

  if (cbrtl (-1.0L) != -1.0L)
    link_error ();

  if (expl (0.0L) != 1.0L)
    link_error ();

  if (expl (1.0L) <= 2.71L || expl (1.0L) >= 2.72L)
    link_error ();

  if (logl (1.0L) != 0.0L)
    link_error ();

  if (sinl (0.0L) != 0.0L)
    link_error ();

  if (cosl (0.0L) != 1.0L)
    link_error ();

  if (tanl (0.0L) != 0.0L)
    link_error ();

  if (atanl (0.0) != 0.0L)
    link_error ();

  if (4.0L*atanl (1.0L) <= 3.14L || 4.0L*atanl (1.0L) >= 3.15L)
    link_error ();

  if (powl (ld, 0.0L) != 1.0L)
    link_error ();

  if (powl (1.0L, ld) != 1.0L)
    link_error ();
}
예제 #10
0
TEST(math, cbrtl) {
  ASSERT_DOUBLE_EQ(3.0L, cbrtl(27.0L));
}
예제 #11
0
TEST(math, cbrtl) {
  ASSERT_FLOAT_EQ(3.0, cbrtl(27.0));
}
예제 #12
0
static int testl(long double long_double_x, int int_x, long long_x)
{
int r = 0;
r += __finitel(long_double_x);
r += __fpclassifyl(long_double_x);
r += __isinfl(long_double_x);
r += __isnanl(long_double_x);
r += __signbitl(long_double_x);
r += acoshl(long_double_x);
r += acosl(long_double_x);
r += asinhl(long_double_x);
r += asinl(long_double_x);
r += atan2l(long_double_x, long_double_x);
r += atanhl(long_double_x);
r += atanl(long_double_x);
r += cbrtl(long_double_x);
r += ceill(long_double_x);
r += copysignl(long_double_x, long_double_x);
r += coshl(long_double_x);
r += cosl(long_double_x);
r += erfcl(long_double_x);
r += erfl(long_double_x);
r += exp2l(long_double_x);
r += expl(long_double_x);
r += expm1l(long_double_x);
r += fabsl(long_double_x);
r += fdiml(long_double_x, long_double_x);
r += floorl(long_double_x);
r += fmal(long_double_x, long_double_x, long_double_x);
r += fmaxl(long_double_x, long_double_x);
r += fminl(long_double_x, long_double_x);
r += fmodl(long_double_x, long_double_x);
r += frexpl(long_double_x, &int_x);
r += hypotl(long_double_x, long_double_x);
r += ilogbl(long_double_x);
r += ldexpl(long_double_x, int_x);
r += lgammal(long_double_x);
r += llrintl(long_double_x);
r += llroundl(long_double_x);
r += log10l(long_double_x);
r += log1pl(long_double_x);
r += log2l(long_double_x);
r += logbl(long_double_x);
r += logl(long_double_x);
r += lrintl(long_double_x);
r += lroundl(long_double_x);
r += modfl(long_double_x, &long_double_x);
r += nearbyintl(long_double_x);
r += nextafterl(long_double_x, long_double_x);
r += nexttowardl(long_double_x, long_double_x);
r += powl(long_double_x, long_double_x);
r += remainderl(long_double_x, long_double_x);
r += remquol(long_double_x, long_double_x, &int_x);
r += rintl(long_double_x);
r += roundl(long_double_x);
r += scalblnl(long_double_x, long_x);
r += scalbnl(long_double_x, int_x);
r += sinhl(long_double_x);
r += sinl(long_double_x);
r += sqrtl(long_double_x);
r += tanhl(long_double_x);
r += tanl(long_double_x);
r += tgammal(long_double_x);
r += truncl(long_double_x);
return r;
}
예제 #13
0
int main(int argc, char *argv[])
{
  long double x = 0.0;
  if (argv) x = cbrtl((long double) argc);
  return 0;
}
예제 #14
0
파일: math.c 프로젝트: DeforaOS/libc
double cbrt(double x)
{
	return cbrtl(x);
}