improve a_version_parse and implement a_version_tostr
[liba.git] / test / lpf.h
blob99993d2727ebb0a93314d726b486b76fe68e7870
1 #define MAIN_(x) A_CAST_2(x, _lpf)
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;