-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmx_fwht.cpp
47 lines (35 loc) · 1.16 KB
/
mx_fwht.cpp
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
//================================================
// @title mx_fwht.cpp
// @author Jonathan Hadida
// @contact Jonathan.hadida [at] dtc.ox.ac.uk
//================================================
#include "fwht.h"
#include "ndArray.h"
#include <algorithm>
#define SEQUENCY_ORDER false
/******************** ********** ********************/
/******************** ********** ********************/
/**
* Dependency to ndArray (see https://github.com/Sheljohn/ndArray).
* Use the script start_matlab.sh to start Matlab, and compile with:
* mex CXXFLAGS="\$CXXFLAGS -std=c++0x -Wall -O2" mx_fwht.cpp
*/
void mexFunction( int nargout, mxArray *out[],
int nargin, const mxArray *in[] )
{
if ( nargin != 1 )
{
mexErrMsgTxt("Usage: w = mx_fwht(sequence);");
return;
}
ndArray<const double,2> input(in[0]);
ndArray<double,2> output;
std::vector<double> d( input.begin(), input.end() );
fwht( d, SEQUENCY_ORDER );
int size[2];
size[0] = 1;
size[1] = d.size();
out[0] = mxCreateNumericArray( 2, size, mx_type<double>::id, mxREAL );
output.assign( out[0] );
std::copy( d.begin(), d.end(), output.begin() );
}