|
nsz |
0c7d46 |
#include "test.h"
|
|
nsz |
0c7d46 |
#include <math.h>
|
|
nsz |
0c7d46 |
#include <stdint.h>
|
|
nsz |
0c7d46 |
|
|
nsz |
0c7d46 |
static struct {
|
|
nsz |
0c7d46 |
double x,y;
|
|
nsz |
0c7d46 |
} testdata[] = {
|
|
nsz |
0c7d46 |
0x1.fffffffffffffp+1023, 0x1.fffffffffffffp+511,
|
|
nsz |
0c7d46 |
0x1.ffffffffffffbp+1023, 0x1.ffffffffffffdp+511,
|
|
nsz |
0c7d46 |
0x1.ffffffffffff7p+1023, 0x1.ffffffffffffbp+511,
|
|
nsz |
0c7d46 |
0x1.ffffffffffff3p+1023, 0x1.ffffffffffff9p+511,
|
|
nsz |
0c7d46 |
0x1.fffffffffffefp+1023, 0x1.ffffffffffff7p+511,
|
|
nsz |
0c7d46 |
0x1.fffffffffffebp+1023, 0x1.ffffffffffff5p+511,
|
|
nsz |
0c7d46 |
0x1.fffffffffffe7p+1023, 0x1.ffffffffffff3p+511,
|
|
nsz |
0c7d46 |
0x1.fffffffffffe3p+1023, 0x1.ffffffffffff1p+511,
|
|
nsz |
0c7d46 |
0x1.fffffffffffdfp+1023, 0x1.fffffffffffefp+511,
|
|
nsz |
0c7d46 |
0x1.fffffffffffdbp+1023, 0x1.fffffffffffedp+511,
|
|
nsz |
0c7d46 |
0x1.fffffffffffd7p+1023, 0x1.fffffffffffebp+511,
|
|
nsz |
0c7d46 |
0x1.0000000000003p-1022, 0x1.0000000000001p-511,
|
|
nsz |
0c7d46 |
0x1.0000000000007p-1022, 0x1.0000000000003p-511,
|
|
nsz |
0c7d46 |
0x1.000000000000bp-1022, 0x1.0000000000005p-511,
|
|
nsz |
0c7d46 |
0x1.000000000000fp-1022, 0x1.0000000000007p-511,
|
|
nsz |
0c7d46 |
0x1.0000000000013p-1022, 0x1.0000000000009p-511,
|
|
nsz |
0c7d46 |
0x1.0000000000017p-1022, 0x1.000000000000bp-511,
|
|
nsz |
0c7d46 |
0x1.000000000001bp-1022, 0x1.000000000000dp-511,
|
|
nsz |
0c7d46 |
0x1.000000000001fp-1022, 0x1.000000000000fp-511,
|
|
nsz |
0c7d46 |
0x1.0000000000023p-1022, 0x1.0000000000011p-511,
|
|
nsz |
0c7d46 |
0x1.0000000000027p-1022, 0x1.0000000000013p-511,
|
|
nsz |
0c7d46 |
0x1.000000000002bp-1022, 0x1.0000000000015p-511,
|
|
nsz |
0c7d46 |
0x1.000000000002fp-1022, 0x1.0000000000017p-511,
|
|
nsz |
0c7d46 |
0x1.0000000000033p-1022, 0x1.0000000000019p-511,
|
|
nsz |
0c7d46 |
0x1.0000000000037p-1022, 0x1.000000000001bp-511,
|
|
nsz |
0c7d46 |
0x1.7167bc36eaa3bp+6, 0x1.3384c7db650cdp+3,
|
|
nsz |
0c7d46 |
0x1.7570994273ad7p+6, 0x1.353186e89b8ffp+3,
|
|
nsz |
0c7d46 |
0x1.7dae969442fe6p+6, 0x1.389640fb18b75p+3,
|
|
nsz |
0c7d46 |
0x1.7f8444fcf67e5p+6, 0x1.395659e94669fp+3,
|
|
nsz |
0c7d46 |
0x1.8364650e63a54p+6, 0x1.3aea9efe1a3d7p+3,
|
|
nsz |
0c7d46 |
0x1.85bedd274edd8p+6, 0x1.3bdf20c867057p+3,
|
|
nsz |
0c7d46 |
0x1.8609cf496ab77p+6, 0x1.3bfd7e14b5eabp+3,
|
|
nsz |
0c7d46 |
0x1.873849c70a375p+6, 0x1.3c77ed341d27fp+3,
|
|
nsz |
0c7d46 |
0x1.8919c962cbaaep+6, 0x1.3d3a7113ee82fp+3,
|
|
nsz |
0c7d46 |
0x1.8de4493e22dc6p+6, 0x1.3f27d448220c3p+3,
|
|
nsz |
0c7d46 |
0x1.924829a17a288p+6, 0x1.40e9552eec28fp+3,
|
|
nsz |
0c7d46 |
0x1.92702cd992f12p+6, 0x1.40f94a6fdfddfp+3,
|
|
nsz |
0c7d46 |
0x1.92b763a8311fdp+6, 0x1.4115af614695fp+3,
|
|
nsz |
0c7d46 |
0x1.947da013c7293p+6, 0x1.41ca91102940fp+3,
|
|
nsz |
0c7d46 |
0x1.9536091c494d2p+6, 0x1.4213e334c77adp+3,
|
|
nsz |
0c7d46 |
0x1.61b04c6p-1019, 0x1.a98b88f18b46dp-510,
|
|
nsz |
0c7d46 |
0x1.93789f1p-1018, 0x1.4162ae43d5821p-509,
|
|
nsz |
0c7d46 |
0x1.a1989b4p-1018, 0x1.46f6736eb44bbp-509,
|
|
nsz |
0c7d46 |
0x1.f93bc9p-1018, 0x1.67a36ec403bafp-509,
|
|
nsz |
0c7d46 |
0x1.2f675e3p-1017, 0x1.8a22ab6dcfee1p-509,
|
|
nsz |
0c7d46 |
0x1.a158508p-1017, 0x1.ce418a96cf589p-509,
|
|
nsz |
0c7d46 |
0x1.cd31f078p-1017, 0x1.e5ef1c65dccebp-509,
|
|
nsz |
0c7d46 |
0x1.33b43b08p-1016, 0x1.18a9f607e1701p-508,
|
|
nsz |
0c7d46 |
0x1.6e66a858p-1016, 0x1.324402a00b45fp-508,
|
|
nsz |
0c7d46 |
0x1.8661cbf8p-1016, 0x1.3c212046bfdffp-508,
|
|
nsz |
0c7d46 |
0x1.bbb221b4p-1016, 0x1.510681b939931p-508,
|
|
nsz |
0c7d46 |
0x1.c4942f3cp-1016, 0x1.5461e59227ab5p-508,
|
|
nsz |
0c7d46 |
0x1.dbb258c8p-1016, 0x1.5cf7b0f78d3afp-508,
|
|
nsz |
0c7d46 |
0x1.57103ea4p-1015, 0x1.a31ab946d340bp-508,
|
|
nsz |
0c7d46 |
0x1.9b294f88p-1015, 0x1.cad197e28e85bp-508,
|
|
nsz |
0c7d46 |
0x1.0000000000001p+0, 0x1p+0,
|
|
nsz |
0c7d46 |
0x1.fffffffffffffp-1, 0x1.fffffffffffffp-1,
|
|
nsz |
0c7d46 |
};
|
|
nsz |
0c7d46 |
|
|
nsz |
0c7d46 |
void test_sqrt(void)
|
|
nsz |
0c7d46 |
{
|
|
nsz |
0c7d46 |
int j;
|
|
nsz |
0c7d46 |
double x, y, y0;
|
|
nsz |
0c7d46 |
|
|
nsz |
0c7d46 |
for (j = 0; j < sizeof testdata / sizeof *testdata; j++) {
|
|
nsz |
0c7d46 |
x = testdata[j].x;
|
|
nsz |
0c7d46 |
y = testdata[j].y;
|
|
nsz |
0c7d46 |
y0 = sqrt(x);
|
|
nsz |
0c7d46 |
if (y != y0)
|
|
nsz |
0c7d46 |
error("sqrt(%a): wanted %a got %a\n", x, y, y0);
|
|
nsz |
0c7d46 |
}
|
|
nsz |
0c7d46 |
}
|
|
nsz |
0c7d46 |
|
|
nsz |
0c7d46 |
void bench_sqrt(int N)
|
|
nsz |
0c7d46 |
{
|
|
nsz |
0c7d46 |
int i;
|
|
nsz |
0c7d46 |
double x;
|
|
nsz |
0c7d46 |
volatile double y;
|
|
nsz |
0c7d46 |
|
|
nsz |
0c7d46 |
x = 0x1.23456p7;
|
|
nsz |
0c7d46 |
for (i = 0; i < N; i++) {
|
|
nsz |
0c7d46 |
y = sqrt(x);
|
|
nsz |
0c7d46 |
x += 0.0000001;
|
|
nsz |
0c7d46 |
}
|
|
nsz |
0c7d46 |
}
|