void LTFAT_NAME(ltfatMexFnc)( int nlhs, mxArray *plhs[],int nrhs, const mxArray *prhs[] ) { int a, M, N, L, W, Lg, lt1, lt2; mwSize ndim; mwSize dims[3]; double *lt; // Get matrix dimensions. L = mxGetM(prhs[0]); W = mxGetN(prhs[0]); Lg = mxGetM(prhs[1]); a=(int)mxGetScalar(prhs[2]); M=(int)mxGetScalar(prhs[3]); // Read the values of lt and round them to integers. lt = mxGetPr(prhs[4]); lt1 = ltfat_round(lt[0]); lt2 = ltfat_round(lt[1]); N = L/a; dims[0]=M; dims[1]=N; dims[2]=W; ndim=3; if (W==1) { ndim=2; } plhs[0] = ltfatCreateNdimArray(ndim,dims,LTFAT_MX_CLASSID,mxCOMPLEX); const LTFAT_REAL _Complex* f_combined = (const LTFAT_REAL _Complex*) mxGetData(prhs[0]); const LTFAT_REAL _Complex* g_combined = (const LTFAT_REAL _Complex*) mxGetData(prhs[1]); LTFAT_REAL _Complex* out_combined = (LTFAT_REAL _Complex*) mxGetData(plhs[0]); LTFAT_NAME(dgt_multi)(f_combined,g_combined,L,Lg,W,a,M,lt1,lt2, out_combined); return; }
LTFAT_EXTERN void LTFAT_NAME(gabreassign)(const LTFAT_REAL *s, const LTFAT_REAL *tgrad, const LTFAT_REAL *fgrad, const ltfatInt L, const ltfatInt W, const ltfatInt a, const ltfatInt M, LTFAT_REAL *sr) { ltfatInt ii, posi, posj; const ltfatInt N=L/a; const ltfatInt b=L/M; ltfatInt *timepos = ltfat_malloc(N*sizeof*timepos); ltfatInt *freqpos = ltfat_malloc(M*sizeof*freqpos); fftindex(N,timepos); fftindex(M,freqpos); /* Zero the output array. */ memset(sr,0,M*N*W*sizeof*sr); for (ltfatInt w=0; w<W; w++) { for (ii=0; ii<M; ii++) { for (ltfatInt jj=0; jj<N; jj++) { /* Do a 'round' followed by a 'mod'. 'round' is not * present in all libraries, so use trunc(x+.5) instead */ /*posi=positiverem((ltfatInt)trunc(tgrad[ii+jj*M]/b+freqpos[ii]+.5),M); posj=positiverem((ltfatInt)trunc(fgrad[ii+jj*M]/a+timepos[jj]+.5),N);*/ posi=positiverem(ltfat_round(tgrad[ii+jj*M]/b+freqpos[ii]),M); posj=positiverem(ltfat_round(fgrad[ii+jj*M]/a+timepos[jj]),N); sr[posi+posj*M]+=s[ii+jj*M]; } } } LTFAT_SAFEFREEALL(freqpos,timepos); }
void LTFAT_NAME(ltfatMexFnc)( int nlhs, mxArray *plhs[],int nrhs, const mxArray *prhs[] ) { ltfatInt a, M, L, Lg, lt1, lt2; double *lt; // Get matrix dimensions. Lg = mxGetM(prhs[0]); a=(ltfatInt)mxGetScalar(prhs[1]); M=(ltfatInt)mxGetScalar(prhs[2]); L=(ltfatInt)mxGetScalar(prhs[4]); // Read the values of lt and round them to integers. lt = mxGetPr(prhs[3]); lt1 = ltfat_round(lt[0]); lt2 = ltfat_round(lt[1]); plhs[0] = ltfatCreateMatrix(L, lt2,LTFAT_MX_CLASSID,mxCOMPLEX); const LTFAT_COMPLEX* g_combined = (const LTFAT_COMPLEX*) mxGetData(prhs[0]); LTFAT_COMPLEX* out_combined = (LTFAT_COMPLEX*) mxGetData(plhs[0]); LTFAT_NAME(nonsepwin2multi)(g_combined,L,Lg,a,M,lt1,lt2,out_combined); }