-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
27 lines (22 loc) · 799 Bytes
/
Copy pathmain.c
File metadata and controls
27 lines (22 loc) · 799 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include "fast_math.h"
#include <stdio.h>
#include <math.h>
float inv(float x) {
if (x == 0.f) {
return 0.f;
}
return 1.f / x;
}
int main() {
fast_math_function_t inv_struct = fast_math_init(inv, -3.f, 3.f, 2137);\
printf("Inv example:\n");
printf("1 / 0.1 = %f\n", fast_math_get(0.1f, &inv_struct));
printf("1 / 0.25 = %f\n", fast_math_get(0.25f, &inv_struct));
printf("1 / 2 = %f\n", fast_math_get(2.f, &inv_struct));
fast_math_function_t tanh_struct = fast_math_init(tanhf, -4.f, 4.f, 4096);
printf("\nTanh example:\n");
printf("tanh(0.1) = %f\n", fast_math_get(0.1f, &tanh_struct));
printf("tanh(-0.25) = %f\n", fast_math_get(-0.25f, &tanh_struct));
printf("tanh(5) = %f\n", fast_math_get(5.f, &tanh_struct));
return 0;
}