Ignore:
Timestamp:
Mar 3, 2013, 8:09:48 PM (7 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/constantq, feature/pitchshift, feature/pydocstrings, feature/timestretch, master, pitchshift, sampler, timestretch, yinfft+
Children:
474a573
Parents:
abd326c
Message:

tests/src/: improve examples

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/src/test-cvec.c

    rabd326c r7e35b37  
    11#include <aubio.h>
     2#include "utils_tests.h"
    23
    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);
     4int 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;
    810
    9         return 0;
     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  }
     20
     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 it
     37  del_cvec(complex_vector);
     38  return 0;
    1039}
    11 
Note: See TracChangeset for help on using the changeset viewer.