From b6c1ff6cfdfe0f4ce602fe83e54c3112a1c95690 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Sat, 29 Mar 2025 10:04:16 +0100 Subject: Optimize genptable for coordinate solve (20x speedup) --- test/015_math_intpow/00_1_0.in | 3 +++ test/015_math_intpow/00_1_0.out | 1 + test/015_math_intpow/01_x_0.in | 3 +++ test/015_math_intpow/01_x_0.out | 1 + test/015_math_intpow/02_3_2.in | 3 +++ test/015_math_intpow/02_3_2.out | 1 + test/015_math_intpow/intpow_tests.c | 26 ++++++++++++++++++++++++++ 7 files changed, 38 insertions(+) create mode 100644 test/015_math_intpow/00_1_0.in create mode 100644 test/015_math_intpow/00_1_0.out create mode 100644 test/015_math_intpow/01_x_0.in create mode 100644 test/015_math_intpow/01_x_0.out create mode 100644 test/015_math_intpow/02_3_2.in create mode 100644 test/015_math_intpow/02_3_2.out create mode 100644 test/015_math_intpow/intpow_tests.c (limited to 'test') diff --git a/test/015_math_intpow/00_1_0.in b/test/015_math_intpow/00_1_0.in new file mode 100644 index 0000000..41c18f9 --- /dev/null +++ b/test/015_math_intpow/00_1_0.in @@ -0,0 +1,3 @@ +1.0 +0 +1.0 diff --git a/test/015_math_intpow/00_1_0.out b/test/015_math_intpow/00_1_0.out new file mode 100644 index 0000000..7326d96 --- /dev/null +++ b/test/015_math_intpow/00_1_0.out @@ -0,0 +1 @@ +Ok diff --git a/test/015_math_intpow/01_x_0.in b/test/015_math_intpow/01_x_0.in new file mode 100644 index 0000000..1545b05 --- /dev/null +++ b/test/015_math_intpow/01_x_0.in @@ -0,0 +1,3 @@ +234324.52324234 +0 +1.0 diff --git a/test/015_math_intpow/01_x_0.out b/test/015_math_intpow/01_x_0.out new file mode 100644 index 0000000..7326d96 --- /dev/null +++ b/test/015_math_intpow/01_x_0.out @@ -0,0 +1 @@ +Ok diff --git a/test/015_math_intpow/02_3_2.in b/test/015_math_intpow/02_3_2.in new file mode 100644 index 0000000..b1c935f --- /dev/null +++ b/test/015_math_intpow/02_3_2.in @@ -0,0 +1,3 @@ +3.0 +2 +9.0 diff --git a/test/015_math_intpow/02_3_2.out b/test/015_math_intpow/02_3_2.out new file mode 100644 index 0000000..7326d96 --- /dev/null +++ b/test/015_math_intpow/02_3_2.out @@ -0,0 +1 @@ +Ok diff --git a/test/015_math_intpow/intpow_tests.c b/test/015_math_intpow/intpow_tests.c new file mode 100644 index 0000000..48b255c --- /dev/null +++ b/test/015_math_intpow/intpow_tests.c @@ -0,0 +1,26 @@ +#include "../test.h" + +#define ABS(x) ((x) < 0 ? (-(x)) : (x)) + +double intpow(double, uint64_t); + +const double tolerance = 1e-6; + +void run(void) { + char str[STRLENMAX]; + double b, r, c; + uint64_t e; + + fgets(str, STRLENMAX, stdin); + b = atof(str); + fgets(str, STRLENMAX, stdin); + e = atoll(str); + fgets(str, STRLENMAX, stdin); + r = atof(str); + + c = intpow(b, e); + if (ABS(r - c) > tolerance) + printf("Error! Expected %lf but got %lf\n", r, c); + else + printf("Ok\n"); +} -- cgit v1.3