From 8cbe9b3f9ba031773aea33e41ba1b7e77802beba Mon Sep 17 00:00:00 2001 From: flatmush Date: Fri, 25 Feb 2011 12:08:03 +0000 Subject: Added fix16_exp currently using the Taylor Series algorithm off Wikipedia, if anyone can optimize this better then go ahead. Modified fixtest to be a little more generic, can now easily change which function it tests. --- fixtest/fixtest.depend | 37 +++++++++++++++++++++++++++++++++++-- fixtest/fixtest.layout | 10 +++++----- fixtest/main.c | 25 ++++++++++++++++++------- 3 files changed, 58 insertions(+), 14 deletions(-) (limited to 'fixtest') diff --git a/fixtest/fixtest.depend b/fixtest/fixtest.depend index db7e8ce..2822106 100644 --- a/fixtest/fixtest.depend +++ b/fixtest/fixtest.depend @@ -1,5 +1,5 @@ # depslib dependency file v1.0 -1298567472 source:g:\vrfx\libfixmath\fixtest\main.c +1298635002 source:g:\vrfx\libfixmath\fixtest\main.c @@ -19,7 +19,7 @@ 1298453688 g:\vrfx\libfixmath\\libfixmath\fract32.h -1298454206 g:\vrfx\libfixmath\\libfixmath\fix16.h +1298634082 g:\vrfx\libfixmath\\libfixmath\fix16.h 1298562746 source:g:\vrfx\libfixmath\fixtest\hiclock.c @@ -32,3 +32,36 @@ +1298567472 source:i:\vrfx\libfixmath\fixtest\main.c + + + + + + + "hiclock.h" + +1298453688 i:\vrfx\libfixmath\\libfixmath\fixmath.h + "uint32.h" + "fract32.h" + "fix16.h" + +1298453688 i:\vrfx\libfixmath\\libfixmath\uint32.h + + +1298453688 i:\vrfx\libfixmath\\libfixmath\fract32.h + + +1298577432 i:\vrfx\libfixmath\\libfixmath\fix16.h + + +1298564182 i:\vrfx\libfixmath\fixtest\hiclock.h + + + + + + +1298562746 source:i:\vrfx\libfixmath\fixtest\hiclock.c + "hiclock.h" + diff --git a/fixtest/fixtest.layout b/fixtest/fixtest.layout index 6606349..36f21e7 100644 --- a/fixtest/fixtest.layout +++ b/fixtest/fixtest.layout @@ -1,13 +1,13 @@ - - + + - + - - + + diff --git a/fixtest/main.c b/fixtest/main.c index a7e9e89..93c945b 100644 --- a/fixtest/main.c +++ b/fixtest/main.c @@ -8,6 +8,17 @@ #include "hiclock.h" +//#define fix_func fix16_exp +//#define fix_func_str "fix16_exp" +//#define flt_func expf +//#define flt_func_str "expf" + +#define fix_func fix16_atan +#define fix_func_str "fix16_atan" +#define flt_func atanf +#define flt_func_str "atanf" + + int main(int argc, char** argv) { printf("libfixmath test tool\n"); @@ -16,7 +27,7 @@ int main(int argc, char** argv) { uintptr_t args = (1 << 8); uintptr_t iter = (1 << 8); - uintptr_t pass = (1 << 8); + uintptr_t pass = (1 << 6); uintptr_t i; srand(time(NULL)); @@ -35,7 +46,7 @@ int main(int argc, char** argv) { for(i = 0; i < iter; i++) { uintptr_t j; for(j = 0; j < args; j++) - fix_result[j] = fix16_atan(fix_args[j]); + fix_result[j] = fix_func(fix_args[j]); } hiclock_t fix_end = hiclock(); @@ -47,7 +58,7 @@ int main(int argc, char** argv) { for(i = 0; i < iter; i++) { uintptr_t j; for(j = 0; j < args; j++) - flt_result[j] = atanf(flt_args[j]); + flt_result[j] = flt_func(flt_args[j]); } hiclock_t flt_end = hiclock(); @@ -57,10 +68,10 @@ int main(int argc, char** argv) { fix_duration += (fix_end - fix_start); } - printf("Floating Point: %08"PRIuHICLOCK" @ %"PRIu32"Hz\n", flt_duration, HICLOCKS_PER_SEC); - printf("Fixed Point: %08"PRIuHICLOCK" @ %"PRIu32"Hz\n", fix_duration, HICLOCKS_PER_SEC); - printf("Difference: %08"PRIiHICLOCK" (% 3.2f%%)\n", (flt_duration - fix_duration), ((fix_duration * 100.0) / flt_duration)); - printf("Error: %f%%\n", ((fix16_to_dbl(fix_error) * 100.0) / (args * pass))); + printf("% 16s: %08"PRIuHICLOCK" @ %"PRIu32"Hz\n", fix_func_str, flt_duration, HICLOCKS_PER_SEC); + printf("% 16s: %08"PRIuHICLOCK" @ %"PRIu32"Hz\n", fix_func_str, fix_duration, HICLOCKS_PER_SEC); + printf(" Difference: %08"PRIiHICLOCK" (% 3.2f%%)\n", (flt_duration - fix_duration), ((fix_duration * 100.0) / flt_duration)); + printf(" Error: %f%%\n", ((fix16_to_dbl(fix_error) * 100.0) / (args * pass))); return EXIT_SUCCESS; } -- cgit v1.2.3