Changeset 155cc10 for src/fmat.c
- Timestamp:
- Mar 10, 2017, 2:26:32 PM (8 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/applefworks, fix/ffmpeg5, master, sampler
- Children:
- ee8a57c
- Parents:
- 00d0275 (diff), 67b6618 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/fmat.c
r00d0275 r155cc10 54 54 } 55 55 56 smpl_t fmat_get_sample( fmat_t *s, uint_t channel, uint_t position) {56 smpl_t fmat_get_sample(const fmat_t *s, uint_t channel, uint_t position) { 57 57 return s->data[channel][position]; 58 58 } 59 59 60 void fmat_get_channel( fmat_t *s, uint_t channel, fvec_t *output) {60 void fmat_get_channel(const fmat_t *s, uint_t channel, fvec_t *output) { 61 61 output->data = s->data[channel]; 62 62 output->length = s->length; … … 64 64 } 65 65 66 smpl_t * fmat_get_channel_data( fmat_t *s, uint_t channel) {66 smpl_t * fmat_get_channel_data(const fmat_t *s, uint_t channel) { 67 67 return s->data[channel]; 68 68 } 69 69 70 smpl_t ** fmat_get_data( fmat_t *s) {70 smpl_t ** fmat_get_data(const fmat_t *s) { 71 71 return s->data; 72 72 } … … 74 74 /* helper functions */ 75 75 76 void fmat_print( fmat_t *s) {76 void fmat_print(const fmat_t *s) { 77 77 uint_t i,j; 78 78 for (i=0; i< s->height; i++) { … … 94 94 95 95 void fmat_zeros(fmat_t *s) { 96 #if HAVE_MEMCPY_HACKS96 #ifdef HAVE_MEMCPY_HACKS 97 97 uint_t i; 98 98 for (i=0; i< s->height; i++) { 99 99 memset(s->data[i], 0, s->length * sizeof(smpl_t)); 100 100 } 101 #else 101 #else /* HAVE_MEMCPY_HACKS */ 102 102 fmat_set(s, 0.); 103 #endif 103 #endif /* HAVE_MEMCPY_HACKS */ 104 104 } 105 105 … … 111 111 uint_t i,j; 112 112 for (i=0; i< s->height; i++) { 113 for (j=0; j< FLOOR( s->length/2); j++) {113 for (j=0; j< FLOOR((smpl_t)s->length/2); j++) { 114 114 ELEM_SWAP(s->data[i][j], s->data[i][s->length-1-j]); 115 115 } … … 117 117 } 118 118 119 void fmat_weight(fmat_t *s, fmat_t *weight) {119 void fmat_weight(fmat_t *s, const fmat_t *weight) { 120 120 uint_t i,j; 121 121 uint_t length = MIN(s->length, weight->length); … … 127 127 } 128 128 129 void fmat_copy( fmat_t *s, fmat_t *t) {129 void fmat_copy(const fmat_t *s, fmat_t *t) { 130 130 uint_t i; 131 #if !HAVE_MEMCPY_HACKS131 #ifndef HAVE_MEMCPY_HACKS 132 132 uint_t j; 133 #endif 133 #endif /* HAVE_MEMCPY_HACKS */ 134 134 if (s->height != t->height) { 135 135 AUBIO_ERR("trying to copy %d rows to %d rows \n", … … 142 142 return; 143 143 } 144 #if HAVE_MEMCPY_HACKS144 #ifdef HAVE_MEMCPY_HACKS 145 145 for (i=0; i< s->height; i++) { 146 146 memcpy(t->data[i], s->data[i], t->length * sizeof(smpl_t)); 147 147 } 148 #else 148 #else /* HAVE_MEMCPY_HACKS */ 149 149 for (i=0; i< t->height; i++) { 150 150 for (j=0; j< t->length; j++) { … … 152 152 } 153 153 } 154 #endif /* HAVE_MEMCPY_HACKS */ 155 } 156 157 void fmat_vecmul(const fmat_t *s, const fvec_t *scale, fvec_t *output) { 158 uint_t k; 159 #if 0 160 assert(s->height == output->length); 161 assert(s->length == scale->length); 162 #endif 163 #if !defined(HAVE_ACCELERATE) && !defined(HAVE_ATLAS) 164 uint_t j; 165 fvec_zeros(output); 166 for (j = 0; j < s->length; j++) { 167 for (k = 0; k < s->height; k++) { 168 output->data[k] += scale->data[j] 169 * s->data[k][j]; 170 } 171 } 172 #elif defined(HAVE_ATLAS) 173 for (k = 0; k < s->height; k++) { 174 output->data[k] = aubio_cblas_dot( s->length, scale->data, 1, s->data[k], 1); 175 } 176 #elif defined(HAVE_ACCELERATE) 177 #if 0 178 // seems slower and less precise (and dangerous?) 179 vDSP_mmul (s->data[0], 1, scale->data, 1, output->data, 1, s->height, 1, s->length); 180 #else 181 for (k = 0; k < s->height; k++) { 182 aubio_vDSP_dotpr( scale->data, 1, s->data[k], 1, &(output->data[k]), s->length); 183 } 184 #endif 154 185 #endif 155 186 } 156
Note: See TracChangeset
for help on using the changeset viewer.