Changes in tests/src/test-cvec.c [7e35b37:aea235c]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/src/test-cvec.c
r7e35b37 raea235c 1 1 #include <aubio.h> 2 #include "utils_tests.h"3 2 4 int main () 5 { 6 uint_t i, window_size = 16; // window size 7 utils_init_random(); 8 cvec_t * complex_vector = new_cvec (window_size); // input buffer 9 uint_t rand_times = 4; 3 int main(){ 4 /* allocate some memory */ 5 uint_t win_s = 1024; /* window size */ 6 cvec_t * sp = new_cvec (win_s); /* input buffer */ 7 del_cvec(sp); 10 8 11 while (rand_times -- ) { 12 // fill with random phas and norm 13 for ( i = 0; i < complex_vector->length; i++ ) { 14 complex_vector->norm[i] = ( 2. / RAND_MAX * random() - 1. ); 15 complex_vector->phas[i] = ( 2. / RAND_MAX * random() - 1. ) * M_PI; 16 } 17 // print the vector 18 cvec_print(complex_vector); 19 } 9 return 0; 10 } 20 11 21 // set all vector elements to `0`22 cvec_zeros(complex_vector);23 for ( i = 0; i < complex_vector->length; i++ ) {24 assert( complex_vector->norm[i] == 0. );25 // assert( complex_vector->phas[i] == 0 );26 }27 cvec_print(complex_vector);28 29 // set all vector elements to `1`30 cvec_ones(complex_vector);31 for ( i = 0; i < complex_vector->length; i++ ) {32 assert( complex_vector->norm[i] == 1. );33 // assert( complex_vector->phas[i] == 0 );34 }35 cvec_print(complex_vector);36 // destroy it37 del_cvec(complex_vector);38 return 0;39 }
Note: See TracChangeset
for help on using the changeset viewer.