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/intpow_tests.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 test/015_math_intpow/intpow_tests.c (limited to 'test/015_math_intpow/intpow_tests.c') 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