root/applications/bdmtoolbox/mex/epdf_marginal.cpp @ 937

Revision 937, 1.4 kB (checked in by smidl, 14 years ago)

matlab class extension for pdf

Line 
1/*!
2\file
3\brief wrapper function for epdf.marginal()
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 "mexPdf.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                                                "vec=pdf_marginal(pdf_struct, RVs)\n"
20                                                "  pdf_struct = struct('class','pdf_offspring',...);  % description of pdf\n"
21                                                "  RVs  = RV(...);                                    % description of variables of teh marginal"
22                                                "output:\n"
23                                                "  pdf_struct = struct('class','marginal_type',...);  % description of marginal pdf." );
24
25        RV::clear_all();
26        //CONFIG
27        if (n_input<2){mexErrMsgTxt("RVs not given"); }
28       
29        UImxArray Cfg(input[0]);
30        UImxArray RVs(input[1]);
31        //Cfg.writeFile("epdf_marginal.cfg");
32
33        shared_ptr<epdf> ep=UI::build<epdf>(Cfg);
34       
35        if (ep){       
36                //if ( n_output<1 ) mexErrMsgTxt ( "No output - nothing to do!" );
37                shared_ptr<RV> rv=UI::build<RV>(RVs);
38                shared_ptr<epdf> marginal = ep->marginal(*rv);
39                UImxArray Out;
40                UI::save(marginal, Out);
41                output[0]=UImxArray::create_mxArray(Out);
42        } else { 
43                mexErrMsgTxt ( "Given object is not epdf" );
44        }
45}
46#endif
Note: See TracBrowser for help on using the browser.