rename jar.$target to java.test.$target
[liba.git] / test / lpf.h
blobad839b3603110c92c188114f7338a31b5e5beb01
1 #define MAIN(x) lpf##x
2 #include "test.h"
3 #include "a/lpf.h"
4 #include <time.h>
6 #define RAND_MAX_ 2147483647
7 static unsigned long rand_seed = 1;
8 static void srand_(unsigned long seed)
10 rand_seed = seed;
12 static long rand_(void)
14 rand_seed = (rand_seed * 1103515245 + 12345) % 2147483648;
15 return a_cast_s(long, rand_seed);
18 int main(int argc, char *argv[]) // NOLINT(misc-definitions-in-headers)
20 main_init(argc, argv, 1);
21 a_lpf ctx = A_LPF_INIT(A_LPF_GEN(10, 0.01));
22 a_lpf_init(&ctx, a_lpf_gen(10, A_FLOAT_C(0.01)));
23 srand_(a_cast_s(unsigned long, time(A_NULL)));
24 for (unsigned int i = 0; i < 100; ++i)
26 a_float noise = (a_float_c(rand_()) / a_float_c(RAND_MAX_) - A_FLOAT_C(0.5));
27 a_float x = A_FLOAT_PI / 25 * a_float_c(i);
28 a_float x0 = a_float_sin(x);
29 a_float x1 = x0 + A_FLOAT_C(0.2) * noise;
30 a_float x2 = a_lpf_iter(&ctx, x1);
31 debug(A_FLOAT_PRI("+", "f,") A_FLOAT_PRI("+", "f,") A_FLOAT_PRI("+", "f,") A_FLOAT_PRI("+", "f\n"), x, x0, x1, x2);
33 a_lpf_zero(&ctx);
34 #if defined(__cplusplus) && (__cplusplus > 201100L)
35 A_ASSERT_BUILD(std::is_pod<a_lpf>::value);
36 #endif /* __cplusplus */
37 return 0;