KerMor  0.9
Model order reduction for nonlinear dynamical systems and nonlinear approximation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
mexTest.cpp
Go to the documentation of this file.
1 /*
2  * mexTest.c
3  *
4  * Created on: 22.07.2013
5  * Author: CreaByte
6  */
7 
8 #include "mex.h"
9 #include "matrix.h"
10 #include <math.h>
11 #include "../kermorpp.h"
12 #include "mstream.h"
13 #include <streambuf>
14 #include <iostream> // std.cout
15 using namespace kermorpp;
16 
17 void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
18 
19  mstream mout;
20  std.streambuf *outbuf = std.cout.rdbuf(&mout);
21 
22  Matrix x = Matrix(mxGetM(prhs[0]),mxGetN(prhs[0]));
23  x.values = mxGetPr(prhs[0]);
24 
25  Matrix y = Matrix(mxGetM(prhs[1]), mxGetN(prhs[1]));
26  y.values = mxGetPr(prhs[1]);
27 
28  double gamma = mxGetScalar(prhs[2]);
29 
30 // Gaussian* kernel = new Gaussian(gamma);
31 // Wendland* kernel = new Wendland(gamma,2,2);
32 
33  KernelExpansion* kexp = new KernelExpansion();
34  kexp->loadFrom(".");
35 
36  Matrix res = kexp->evaluate(x);
37 
38  plhs[0] = mxCreateDoubleMatrix(res.n, res.m, mxREAL);
39  double* mres = mxGetPr(plhs[0]);
40  for (size_t i = 0; i < res.n * res.m; i++) {
41  mres[i] = res.values[i];
42  }
43 
44  std.cout.rdbuf(outbuf);
45 }
46 
47 //#ifdef DEBUG
48 // sprintf(temp, "y size: %d x %d\n", d, m);
49 // mexPrintf(temp);
50 //#endif
MatrixXd evaluate(MatrixXd points)
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Definition: mexTest.cpp:17
static KernelExpansion * loadFrom(string dir)