Changeset 39a7b26
- Timestamp:
- Nov 26, 2013, 8:09:06 PM (11 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
- Children:
- 88fee8f
- Parents:
- 923a7a8
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/cvec.c
r923a7a8 r39a7b26 71 71 } 72 72 73 void cvec_set(cvec_t *s, smpl_t val) { 73 void cvec_copy(cvec_t *s, cvec_t *t) { 74 if (s->length != t->length) { 75 AUBIO_ERR("trying to copy %d elements to %d elements \n", 76 s->length, t->length); 77 return; 78 } 79 #if HAVE_MEMCPY_HACKS 80 memcpy(t->norm, s->norm, t->length * sizeof(smpl_t)); 81 memcpy(t->phas, s->phas, t->length * sizeof(smpl_t)); 82 #else 83 uint_t j; 84 for (j=0; j< t->length; j++) { 85 t->norm[j] = s->norm[j]; 86 t->phas[j] = s->phas[j]; 87 } 88 #endif 89 } 90 91 void cvec_set_all_norm(cvec_t *s, smpl_t val) { 74 92 uint_t j; 75 93 for (j=0; j< s->length; j++) { … … 78 96 } 79 97 80 void cvec_zeros(cvec_t *s) { 81 cvec_set(s, 0.); 98 void cvec_zeros_norm(cvec_t *s) { 99 #if HAVE_MEMCPY_HACKS 100 memset(s->norm, 0, s->length * sizeof(smpl_t)); 101 #else 102 cvec_set_all_norm(s, 0.); 103 #endif 82 104 } 83 105 84 void cvec_ones (cvec_t *s) {85 cvec_set (s, 1.);106 void cvec_ones_norm(cvec_t *s) { 107 cvec_set_all_norm(s, 1.); 86 108 } 87 109 110 void cvec_set_all_phas(cvec_t *s, smpl_t val) { 111 uint_t j; 112 for (j=0; j< s->length; j++) { 113 s->phas[j] = val; 114 } 115 } 116 117 void cvec_zeros_phas(cvec_t *s) { 118 #if HAVE_MEMCPY_HACKS 119 memset(s->phas, 0, s->length * sizeof(smpl_t)); 120 #else 121 cvec_set_all_phas(s, 0.); 122 #endif 123 } 124 125 void cvec_ones_phas(cvec_t *s) { 126 cvec_set_all_phas(s, 1.); 127 } 128 129 void cvec_zeros(cvec_t *s) { 130 cvec_zeros_norm(s); 131 cvec_zeros_phas(s); 132 } -
src/cvec.h
r923a7a8 r39a7b26 159 159 void cvec_print(cvec_t *s); 160 160 161 /** set all elements to a given value 161 /** make a copy of a vector 162 163 \param s source vector 164 \param t vector to copy to 165 166 */ 167 void cvec_copy(cvec_t *s, cvec_t *t); 168 169 /** set all norm elements to a given value 162 170 163 171 \param s vector to modify … … 165 173 166 174 */ 167 void cvec_set(cvec_t *s, smpl_t val); 168 169 /** set all elements to zero 175 void cvec_set_all_norm(cvec_t *s, smpl_t val); 176 177 /** set all norm elements to zero 178 179 \param s vector to modify 180 181 */ 182 void cvec_zeros_norm(cvec_t *s); 183 184 /** set all norm elements to one 185 186 \param s vector to modify 187 188 */ 189 void cvec_ones_norm(cvec_t *s); 190 191 /** set all phase elements to a given value 192 193 \param s vector to modify 194 \param val value to set elements to 195 196 */ 197 void cvec_set_all_phas(cvec_t *s, smpl_t val); 198 199 /** set all phase elements to zero 200 201 \param s vector to modify 202 203 */ 204 void cvec_zeros_phas(cvec_t *s); 205 206 /** set all phase elements to one 207 208 \param s vector to modify 209 210 */ 211 void cvec_ones_phas(cvec_t *s); 212 213 /** set all norm and phas elements to zero 170 214 171 215 \param s vector to modify … … 173 217 */ 174 218 void cvec_zeros(cvec_t *s); 175 176 /** set all elements to ones177 178 \param s vector to modify179 180 */181 void cvec_ones(cvec_t *s);182 219 183 220 #ifdef __cplusplus -
tests/src/spectral/test-mfcc.c
r923a7a8 r39a7b26 13 13 aubio_mfcc_t *o = new_aubio_mfcc (win_s, n_filters, n_coefs, samplerate); 14 14 15 cvec_set (in, 1.);15 cvec_set_all_norm (in, 1.); 16 16 aubio_mfcc_do (o, in, out); 17 17 fvec_print (out); 18 18 19 cvec_set (in, .5);19 cvec_set_all_norm (in, .5); 20 20 aubio_mfcc_do (o, in, out); 21 21 fvec_print (out); -
tests/src/test-cvec.c
r923a7a8 r39a7b26 20 20 21 21 // set all vector elements to `0` 22 cvec_zeros (complex_vector);22 cvec_zeros_norm(complex_vector); 23 23 for ( i = 0; i < complex_vector->length; i++ ) { 24 24 assert( complex_vector->norm[i] == 0. ); … … 28 28 29 29 // set all vector elements to `1` 30 cvec_ones (complex_vector);30 cvec_ones_norm(complex_vector); 31 31 for ( i = 0; i < complex_vector->length; i++ ) { 32 32 assert( complex_vector->norm[i] == 1. ); … … 34 34 } 35 35 cvec_print(complex_vector); 36 37 cvec_zeros(complex_vector); 38 cvec_zeros_phas(complex_vector); 39 cvec_zeros_norm(complex_vector); 40 cvec_ones_norm(complex_vector); 41 cvec_ones_phas(complex_vector); 42 cvec_copy(complex_vector, complex_vector); 43 36 44 // destroy it 37 45 del_cvec(complex_vector);
Note: See TracChangeset
for help on using the changeset viewer.