[ba1662]: mex / comp_dst.c Maximize Restore History

Download this file

comp_dst.c    111 lines (83 with data), 2.0 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
#include "fftw3.h"
#include <stdlib.h>
#include <math.h>
#ifndef _LTFAT_MEX_FILE
#define _LTFAT_MEX_FILE
#define ISNARGINEQ 2
#define TYPEDEPARGS 0
#define SINGLEARGS
#define REALARGS
#define COMPLEXARGS
#define NOCOMPLEXFMTCHANGE
#endif /* _LTFAT_MEX_FILE */
#define MEX_FILE __BASE_FILE__
#include "ltfat_mex_template_helper.h"
#if defined(LTFAT_SINGLE) || defined(LTFAT_DOUBLE)
#include "ltfat_types.h"
#include "config.h"
static LTFAT_FFTW(plan) LTFAT_NAME(p_old) = 0;
static void LTFAT_NAME(dctMexAtExitFnc)()
{
if(LTFAT_NAME(p_old)!=0)
{
LTFAT_FFTW(destroy_plan)(LTFAT_NAME(p_old));
}
}
void
LTFAT_NAME(ltfatMexFnc)( int nlhs, mxArray *plhs[],
int nrhs, const mxArray *prhs[] )
{
// Register exit function only once
static int atExitFncRegistered = 0;
if(!atExitFncRegistered)
{
LTFAT_NAME(ltfatMexAtExit)(LTFAT_NAME(dctMexAtExitFnc));
atExitFncRegistered = 1;
}
LTFAT_REAL *c_r, *c_i;
const LTFAT_REAL *f_r, *f_i;
dct_kind kind;
mwIndex L = mxGetM(prhs[0]);
mwIndex W = mxGetN(prhs[0]);
mwIndex type = (mwIndex) mxGetScalar(prhs[1]);
// Copy inputs and get pointers
if( mxIsComplex(prhs[0]))
{
f_i = mxGetImagData(prhs[0]);
plhs[0] = ltfatCreateMatrix(L, W, LTFAT_MX_CLASSID, mxCOMPLEX);
c_i = mxGetImagData(plhs[0]);
}
else
{
plhs[0] = ltfatCreateMatrix(L, W, LTFAT_MX_CLASSID, mxREAL);
}
f_r = mxGetData(prhs[0]);
c_r = mxGetData(plhs[0]);
switch(type)
{
case 1:
kind = DSTI;
break;
case 2:
kind = DSTII;
break;
case 3:
kind = DSTIII;
break;
case 4:
kind = DSTIV;
break;
default:
mexErrMsgTxt("Unknown type.");
}
LTFAT_FFTW(plan) p = LTFAT_NAME(dst_init)( c_r, L, W, kind);
LTFAT_NAME(dctMexAtExitFnc)();
LTFAT_NAME(p_old) = p;
LTFAT_NAME(dst_plan)(f_r,L,W,kind,c_r,p);
if( mxIsComplex(prhs[0]))
{
LTFAT_NAME(dst_plan)(f_i,L,W,kind,c_i,p);
}
return;
}
#endif