root/applications/bdmtoolbox/mex/epdf_sample_mat.cpp @ 730

Revision 730, 1.2 kB (checked in by smidl, 15 years ago)

Reworked epdf_harness - testing is now more general.

Corrections of existing tests.

Line 
1/*!
2\file
3\brief wrapper function for epdf.sample_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
15void 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_sample_mat(pdf_struct, nos)\n"
19                                                "  pdf_struct = struct('class','pdf_offspring',...);  % description of pdf\n"
20                                                "  nos        = 10;                                   % number of samples\n"
21                                                "output:\n"
22                                                "  matrix of samples, each sample in one column." );
23
24        RV::clear_all();
25        //CONFIG
26        if (!mxIsStruct(input[0])) mexErrMsgTxt("Given input is not a struct.");
27
28        int nos=10;
29        if (n_input>1) {nos = (int)(*mxGetPr(input[1]));}
30       
31        UImxArray Cfg(input[0]);
32        Cfg.writeFile("epdf_sample_mat.cfg");
33
34        shared_ptr<epdf> ep=UI::build<epdf>(Cfg.getRoot());
35       
36        if ( n_output<1 ) mexErrMsgTxt ( "No output - nothing to do!" );
37        output[0] = mxCreateDoubleMatrix(ep->dimension(), nos, mxREAL);
38        mat2mxArray(ep->sample_mat(nos), output[0]);
39}
40#endif
Note: See TracBrowser for help on using the browser.