source: tests/src/test-fvec.c @ bd1fa89

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change on this file since bd1fa89 was 7e35b37, checked in by Paul Brossier <piem@piem.org>, 12 years ago

tests/src/: improve examples

  • Property mode set to 100644
File size: 840 bytes
Line 
1#include <aubio.h>
2#include <assert.h>
3
4int main ()
5{
6  uint_t vec_size = 10, i;
7  fvec_t * vec = new_fvec (vec_size);
8
9  // vec->length matches requested size
10  assert(vec->length == vec_size);
11
12  // all elements are initialized to `0.`
13  for ( i = 0; i < vec->length; i++ ) {
14    assert(vec->data[i] == 0.);
15  }
16
17  // all elements can be set to `0.`
18  fvec_zeros(vec);
19  for ( i = 0; i < vec->length; i++ ) {
20    assert(vec->data[i] == 0.);
21  }
22  fvec_print(vec);
23
24  // all elements can be set to `1.`
25  fvec_ones(vec);
26  for ( i = 0; i < vec->length; i++ ) {
27    assert(vec->data[i] == 1.);
28  }
29  fvec_print(vec);
30
31  // each element can be accessed directly
32  for ( i = 0; i < vec->length; i++ ) {
33    vec->data[i] = i;
34    assert(vec->data[i] == i);
35  }
36  fvec_print(vec);
37
38  // now destroys the vector
39  del_fvec(vec);
40
41  return 0;
42}
43
Note: See TracBrowser for help on using the repository browser.