aboutsummaryrefslogtreecommitdiff
path: root/fixsingen
diff options
context:
space:
mode:
authorflatmush <flatmush@d3e1167c-abe1-51d5-8199-f9061ebe54e4>2011-02-25 16:07:39 +0000
committerflatmush <flatmush@d3e1167c-abe1-51d5-8199-f9061ebe54e4>2011-02-25 16:07:39 +0000
commit5dd63f37ce73be2d36bb0ded9c7d8ba84932ccb7 (patch)
tree302052045a1fd37ea40af107fe1b208f8ff31256 /fixsingen
parent0317f964f43995d26d4a54d2f7d37b686ee5a97b (diff)
Updated sin lut to use ~200KiB for it's table with the same accuracy, the lookup table implementation tends to run at about 33-36% of the speed of sinf on my machine (Intel T5500).
Fixed a bug in the sin lut code so that the results are always accurate. Changed fixsingen tool to generate tables correctly for the new implementation.
Diffstat (limited to 'fixsingen')
-rw-r--r--fixsingen/fixsingen.depend4
-rw-r--r--fixsingen/main.c17
2 files changed, 15 insertions, 6 deletions
diff --git a/fixsingen/fixsingen.depend b/fixsingen/fixsingen.depend
index c4ab73e..e0c975d 100644
--- a/fixsingen/fixsingen.depend
+++ b/fixsingen/fixsingen.depend
@@ -1,5 +1,5 @@
# depslib dependency file v1.0
-1298645188 source:g:\vrfx\libfixmath\fixsingen\main.c
+1298649568 source:g:\vrfx\libfixmath\fixsingen\main.c
<stdio.h>
<stdlib.h>
<inttypes.h>
@@ -17,6 +17,6 @@
1298453688 g:\vrfx\libfixmath\\libfixmath\fract32.h
<stdint.h>
-1298634082 g:\vrfx\libfixmath\\libfixmath\fix16.h
+1298648502 g:\vrfx\libfixmath\\libfixmath\fix16.h
<stdint.h>
diff --git a/fixsingen/main.c b/fixsingen/main.c
index ce71647..05461dc 100644
--- a/fixsingen/main.c
+++ b/fixsingen/main.c
@@ -11,18 +11,27 @@ int main(int argc, char** argv) {
return EXIT_FAILURE;
}
+ // TODO - Store as uint16_t with a count to determine the end and return 1.
+
fprintf(fp, "#ifndef __fix16_trig_sin_lut_h__\n");
fprintf(fp, "#define __fix16_trig_sin_lut_h__\n");
fprintf(fp, "\n");
- fprintf(fp, "static fix16_t _fix16_sin_lut[%"PRIi32"] = {", (fix16_pi >> 1));
+ fix16_t fix16_sin_lut_count = (fix16_pi >> 1);
+ fix16_t fix16_sin_lut[fix16_sin_lut_count];
uintptr_t i;
- for(i = 0; i < (fix16_pi >> 1); i++) {
+ for(i = 0; i < fix16_sin_lut_count; i++)
+ fix16_sin_lut[i] = fix16_from_dbl(sin(fix16_to_dbl(i)));
+ for(i--; fix16_sin_lut[i] == fix16_one; i--, fix16_sin_lut_count--);
+
+ fprintf(fp, "static const uint32_t _fix16_sin_lut_count = %"PRIi32";\n", fix16_sin_lut_count);
+ fprintf(fp, "static uint16_t _fix16_sin_lut[%"PRIi32"] = {", fix16_sin_lut_count);
+
+ for(i = 0; i < fix16_sin_lut_count; i++) {
if((i & 7) == 0)
fprintf(fp, "\n\t");
- fix16_t fix16_sin_lut = fix16_from_dbl(sin(fix16_to_dbl(i)));
- fprintf(fp, "%"PRIi32", ", fix16_sin_lut);
+ fprintf(fp, "%"PRIi32", ", fix16_sin_lut[i]);
}
fprintf(fp, "\n\t};\n");