Changeset 39a7b26 for src/cvec.c


Ignore:
Timestamp:
Nov 26, 2013, 8:09:06 PM (11 years ago)
Author:
Paul Brossier <piem@piem.org>
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
Message:

src/cvec.h: improve cvec_t api

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/cvec.c

    r923a7a8 r39a7b26  
    7171}
    7272
    73 void cvec_set(cvec_t *s, smpl_t val) {
     73void 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
     91void cvec_set_all_norm(cvec_t *s, smpl_t val) {
    7492  uint_t j;
    7593  for (j=0; j< s->length; j++) {
     
    7896}
    7997
    80 void cvec_zeros(cvec_t *s) {
    81   cvec_set(s, 0.);
     98void 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
    82104}
    83105
    84 void cvec_ones(cvec_t *s) {
    85   cvec_set(s, 1.);
     106void cvec_ones_norm(cvec_t *s) {
     107  cvec_set_all_norm(s, 1.);
    86108}
    87109
     110void 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
     117void 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
     125void cvec_ones_phas(cvec_t *s) {
     126  cvec_set_all_phas(s, 1.);
     127}
     128
     129void cvec_zeros(cvec_t *s) {
     130  cvec_zeros_norm(s);
     131  cvec_zeros_phas(s);
     132}
Note: See TracChangeset for help on using the changeset viewer.