Diff of /mex/comp_filterbank_fft.c [000000] .. [a5c381] Maximize Restore

  Switch to unified view

a b/mex/comp_filterbank_fft.c
1
#ifndef _LTFAT_MEX_FILE
2
#define _LTFAT_MEX_FILE
3
4
#define ISNARGINEQ 3
5
#define TYPEDEPARGS 0, 1
6
#define SINGLEARGS
7
#define COMPLEXARGS
8
#define EXPORTALIAS comp_filterbank_fft
9
10
#endif // _LTFAT_MEX_FILE - INCLUDED ONCE
11
12
#define MEX_FILE __BASE_FILE__
13
#include "ltfat_mex_template_helper.h"
14
15
#if defined(LTFAT_SINGLE) || defined(LTFAT_DOUBLE)
16
#include "ltfat_types.h"
17
#include "math.h"
18
19
// Calling convention:
20
// c = comp_filterbank_fft(F,G,a)
21
22
void LTFAT_NAME(ltfatMexFnc)( int nlhs, mxArray *plhs[],int nrhs, const mxArray *prhs[] )
23
{
24
  const mxArray* mxF = prhs[0];
25
  const mxArray* mxG = prhs[1];
26
  double* a = (double*) mxGetData(prhs[2]);
27
28
  // input data length
29
  mwSize L = mxGetM(mxF);
30
  // number of channels
31
  mwSize W = mxGetN(mxF);
32
  // filter number
33
  mwSize M = mxGetNumberOfElements(mxG);
34
35
  // output lengths
36
  mwSize outLen[M];
37
  //mwSize* outLen = mxMalloc(M*sizeof(mwSize));
38
39
  for(unsigned int m = 0; m < M; m++)
40
  {
41
     outLen[m] = (mwSize) ceil( L/a[m] );
42
  }
43
 
44
45
     // POINTER TO THE INPUT
46
     LTFAT_REAL _Complex* FPtr = (LTFAT_REAL _Complex*) mxGetData(prhs[0]);
47
48
     // POINTER TO THE FILTERS
49
     LTFAT_REAL _Complex* GPtrs[M];
50
     // LTFAT_TYPE** gPtrs = (LTFAT_TYPE**) mxMalloc(M*sizeof(LTFAT_TYPE*));
51
     for(mwIndex m=0;m<M;m++)
52
     {
53
        GPtrs[m] = (LTFAT_REAL _Complex*) mxGetPr(mxGetCell(mxG, m));
54
     }
55
56
     // POINTER TO OUTPUTS
57
     LTFAT_REAL _Complex* cPtrs[M]; // C99 feature
58
     //LTFAT_TYPE** cPtrs = (LTFAT_TYPE**) mxMalloc(M*sizeof(LTFAT_TYPE*));
59
     plhs[0] = mxCreateCellMatrix(M, 1);
60
     for(mwIndex m=0;m<M;++m)
61
     {
62
        mxSetCell(plhs[0], m, ltfatCreateMatrix(outLen[m], W,LTFAT_MX_CLASSID,mxCOMPLEX));
63
        cPtrs[m] = (LTFAT_REAL _Complex*) mxGetData(mxGetCell(plhs[0],m));
64
        memset(cPtrs[m],0,outLen[m]*W*sizeof(LTFAT_REAL _Complex));
65
     }
66
67
     // over all channels
68
   //  #pragma omp parallel for private(m)
69
70
        for(mwIndex m =0; m<M; m++)
71
        {
72
          for(mwIndex w =0; w<W; w++)
73
          {
74
           // Obtain pointer to w-th column in input
75
           LTFAT_REAL _Complex *FPtrCol = FPtr + w*L;
76
           // Obtaing pointer to w-th column in m-th element of output cell-array
77
           LTFAT_REAL _Complex *cPtrCol = cPtrs[m] + w*outLen[m];
78
          
79
           LTFAT_NAME(convsub_fft)(FPtrCol,GPtrs[m],L,(size_t)a[m],cPtrCol);
80
          }
81
        }
82
}
83
#endif
84
85
86
87