source: tests/src/test-cvec.c @ f7af440

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5
Last change on this file since f7af440 was 332487b, checked in by Paul Brossier <piem@piem.org>, 11 years ago

tests/src: clean up includes

  • Property mode set to 100644
File size: 1.3 KB
RevLine 
[332487b]1#include "aubio.h"
[7e35b37]2#include "utils_tests.h"
[4e9101e]3
[158e031]4int main (void)
[7e35b37]5{
6  uint_t i, window_size = 16; // window size
7  cvec_t * complex_vector = new_cvec (window_size); // input buffer
8  uint_t rand_times = 4;
[4e9101e]9
[491e6ea]10  utils_init_random();
11
[7e35b37]12  while (rand_times -- ) {
13    // fill with random phas and norm
14    for ( i = 0; i < complex_vector->length; i++ ) {
15      complex_vector->norm[i] = ( 2. / RAND_MAX * random() - 1. );
16      complex_vector->phas[i] = ( 2. / RAND_MAX * random() - 1. ) * M_PI;
17    }
18    // print the vector
19    cvec_print(complex_vector);
20  }
21
22  // set all vector elements to `0`
[5d10ac1]23  cvec_norm_zeros(complex_vector);
[7e35b37]24  for ( i = 0; i < complex_vector->length; i++ ) {
25    assert( complex_vector->norm[i] == 0. );
26    // assert( complex_vector->phas[i] == 0 );
27  }
28  cvec_print(complex_vector);
[4e9101e]29
[7e35b37]30  // set all vector elements to `1`
[5d10ac1]31  cvec_norm_ones(complex_vector);
[7e35b37]32  for ( i = 0; i < complex_vector->length; i++ ) {
33    assert( complex_vector->norm[i] == 1. );
34    // assert( complex_vector->phas[i] == 0 );
35  }
36  cvec_print(complex_vector);
[39a7b26]37
38  cvec_zeros(complex_vector);
[5d10ac1]39  cvec_phas_zeros(complex_vector);
40  cvec_norm_zeros(complex_vector);
41  cvec_norm_ones(complex_vector);
42  cvec_phas_ones(complex_vector);
[39a7b26]43  cvec_copy(complex_vector, complex_vector);
44
[7e35b37]45  // destroy it
46  del_cvec(complex_vector);
47  return 0;
48}
Note: See TracBrowser for help on using the repository browser.