feature/cnnfeature/crepefix/ffmpeg5
Last change
on this file since 68d4565 was
1f382d6,
checked in by Paul Brossier <piem@piem.org>, 6 years ago
|
[tests] add test-vecutils
|
-
Property mode set to
100644
|
File size:
1.3 KB
|
Line | |
---|
1 | #include "aubio.h" |
---|
2 | #include "utils_tests.h" |
---|
3 | |
---|
4 | void assert_fvec_all_almost_equal(fvec_t *vec, smpl_t scalar, smpl_t err) |
---|
5 | { |
---|
6 | uint_t i; |
---|
7 | for (i = 0; i < vec->length; i++) { |
---|
8 | assert( fabs(vec->data[i] - scalar) < (smpl_t)err ); |
---|
9 | } |
---|
10 | } |
---|
11 | |
---|
12 | int main (void) |
---|
13 | { |
---|
14 | uint_t length = 10; |
---|
15 | |
---|
16 | fvec_t * vec = new_fvec(length); |
---|
17 | |
---|
18 | fvec_set_all(vec, 2); |
---|
19 | fvec_exp(vec); |
---|
20 | assert_fvec_all_almost_equal(vec, exp(2), 1e-10); |
---|
21 | |
---|
22 | fvec_set_all(vec, 0); |
---|
23 | fvec_cos(vec); |
---|
24 | assert_fvec_all_almost_equal(vec, 1., 1e-10); |
---|
25 | |
---|
26 | fvec_set_all(vec, 0); |
---|
27 | fvec_sin(vec); |
---|
28 | assert_fvec_all_almost_equal(vec, 0., 1e-10); |
---|
29 | |
---|
30 | fvec_set_all(vec, -1); |
---|
31 | fvec_abs(vec); |
---|
32 | assert_fvec_all_almost_equal(vec, 1., 1e-10); |
---|
33 | |
---|
34 | fvec_set_all(vec, 4); |
---|
35 | fvec_sqrt(vec); |
---|
36 | assert_fvec_all_almost_equal(vec, 2., 1e-10); |
---|
37 | |
---|
38 | fvec_set_all(vec, 10.); |
---|
39 | fvec_log10(vec); |
---|
40 | assert_fvec_all_almost_equal(vec, 1., 1e-10); |
---|
41 | |
---|
42 | fvec_set_all(vec, 1.); |
---|
43 | fvec_log(vec); |
---|
44 | assert_fvec_all_almost_equal(vec, 0., 1e-10); |
---|
45 | |
---|
46 | fvec_set_all(vec, 1.6); |
---|
47 | fvec_floor(vec); |
---|
48 | assert_fvec_all_almost_equal(vec, 1., 1e-10); |
---|
49 | |
---|
50 | fvec_set_all(vec, 1.6); |
---|
51 | fvec_ceil(vec); |
---|
52 | assert_fvec_all_almost_equal(vec, 2., 1e-10); |
---|
53 | |
---|
54 | fvec_set_all(vec, 1.6); |
---|
55 | fvec_round(vec); |
---|
56 | assert_fvec_all_almost_equal(vec, 2., 1e-10); |
---|
57 | |
---|
58 | fvec_set_all(vec, 2); |
---|
59 | fvec_pow(vec, 3); |
---|
60 | assert_fvec_all_almost_equal(vec, 8., 1e-10); |
---|
61 | |
---|
62 | if (vec) |
---|
63 | del_fvec(vec); |
---|
64 | return 0; |
---|
65 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.