root/applications/bdmtoolbox/mex/epdf_evallog_mat.cpp @ 943

Revision 943, 1.3 kB (checked in by smidl, 14 years ago)

syntax of epredictor

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