Revision 803, 1.3 kB
(checked in by smidl, 15 years ago)
|
new wrappers in bdmtoolbox + display functions
|
Line | |
---|
1 | /*! |
---|
2 | \file |
---|
3 | \brief wrapper function for epdf.evallog_mat() |
---|
4 | |
---|
5 | |
---|
6 | */ |
---|
7 | |
---|
8 | #include <stat/emix.h> |
---|
9 | |
---|
10 | using namespace bdm; |
---|
11 | |
---|
12 | #ifdef MEX |
---|
13 | #include <mex/mex_parser.h> |
---|
14 | |
---|
15 | void mexFunction ( int n_output, mxArray *output[], int n_input, const mxArray *input[] ) { |
---|
16 | // Check the number of inputs and output arguments |
---|
17 | if ( n_input<1 ) mexErrMsgTxt ( "Usage:\n" |
---|
18 | "mat=pdf_evallog_mat(pdf_struct, nos)\n" |
---|
19 | " pdf_struct = struct('class','pdf_offspring',...); % description of pdf\n" |
---|
20 | " points = pdf_dimension x npoints matrix; % points in which to evaluate\n" |
---|
21 | "output:\n" |
---|
22 | " vector of log-likelihoods" ); |
---|
23 | |
---|
24 | RV::clear_all(); |
---|
25 | //CONFIG |
---|
26 | if (n_input<2) mexErrMsgTxt("evaluation points are not given"); |
---|
27 | UImxArray Cfg(input[0]); |
---|
28 | shared_ptr<epdf> ep=UI::build<epdf>(Cfg); |
---|
29 | |
---|
30 | int nop, dim; |
---|
31 | nop = mxGetN(input[1]); |
---|
32 | dim = mxGetM(input[1]); |
---|
33 | if (dim != ep->dimension()) { |
---|
34 | string msg="pdf is of dimension " + num2str(ep->dimension()) + "size of data points is " + num2str(dim); |
---|
35 | mexErrMsgTxt(msg.c_str()); |
---|
36 | } |
---|
37 | |
---|
38 | output[0] = mxCreateDoubleMatrix(nop, 1, mxREAL); |
---|
39 | mat points = mxArray2mat(input[1]); |
---|
40 | vec v=ep->evallog_mat(points); |
---|
41 | vec2mxArray(v, output[0]); |
---|
42 | } |
---|
43 | #endif |
---|