Changeset 3b2d32c for src/fvec.c
- Timestamp:
- Sep 12, 2009, 2:28:00 PM (15 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:
- 6f1727f
- Parents:
- ae4d5de
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/fvec.c
rae4d5de r3b2d32c 62 62 } 63 63 64 /* helper functions */ 65 64 66 void fvec_print(fvec_t *s) { 65 67 uint_t i,j; … … 71 73 } 72 74 } 75 76 void fvec_set(fvec_t *s, smpl_t val) { 77 uint_t i,j; 78 for (i=0; i< s->channels; i++) { 79 for (j=0; j< s->length; j++) { 80 s->data[i][j] = val; 81 } 82 } 83 } 84 85 void fvec_zeros(fvec_t *s) { 86 fvec_set(s, 0.); 87 } 88 89 void fvec_ones(fvec_t *s) { 90 fvec_set(s, 1.); 91 } 92 93 void fvec_rev(fvec_t *s) { 94 uint_t i,j; 95 for (i=0; i< s->channels; i++) { 96 for (j=0; j< FLOOR(s->length/2); j++) { 97 ELEM_SWAP(s->data[i][j], s->data[i][s->length-1-j]); 98 } 99 } 100 } 101 102 void fvec_weight(fvec_t *s, fvec_t *weight) { 103 uint_t i,j; 104 uint_t length = MIN(s->length, weight->length); 105 for (i=0; i< s->channels; i++) { 106 for (j=0; j< length; j++) { 107 s->data[i][j] *= weight->data[0][j]; 108 } 109 } 110 } 111 112 void fvec_copy(fvec_t *s, fvec_t *t) { 113 uint_t i,j; 114 uint_t channels = MIN(s->channels, t->channels); 115 uint_t length = MIN(s->length, t->length); 116 if (s->channels != t->channels) { 117 AUBIO_ERR("warning, trying to copy %d channels to %d channels\n", 118 s->channels, t->channels); 119 } 120 if (s->length != t->length) { 121 AUBIO_ERR("warning, trying to copy %d elements to %d elements \n", 122 s->length, t->length); 123 } 124 for (i=0; i< channels; i++) { 125 for (j=0; j< length; j++) { 126 t->data[i][j] = s->data[i][j]; 127 } 128 } 129 } 130
Note: See TracChangeset
for help on using the changeset viewer.