root/library/bdm/mex/mex_function.h @ 826

Revision 826, 0.9 kB (checked in by smidl, 14 years ago)

win32 fixes

Line 
1#ifndef MXFNC_H
2#define MXFNC_H
3
4
5#include <base/bdmbase.h>
6#include "mex_parser.h"
7
8namespace bdm {
9
10        /*! class mapping fnc.eval to call of matlab function via mexCallMatlab
11        */
12        class mexFnc: public fnc{
13                protected:
14                string fname;
15                public:
16                        vec eval(const vec &cond){
17                                mxArray *mxinp = mxCreateDoubleMatrix ( cond.length(), 1, mxREAL );
18                                mxArray *mxout;
19                               
20                                vec2mxArray(cond,mxinp);
21                                mexCallMATLAB ( 1, &mxout, 1, &mxinp, fname.c_str() );
22                               
23                                bdm_assert(mxGetN(mxout)==(dimension()) || mxGetM(mxout)==(dimension()), "vector length mismatch");
24                                vec tmp=mxArray2vec(mxout);
25                                return tmp;
26                        }
27                        void from_setting(const Setting &set){
28                                fnc::from_setting(set);
29                                UI::get(fname, set, "function", UI::compulsory);
30                        }
31                        void to_setting(Setting &set) const {
32                                fnc::to_setting(set);
33                                UI::save(fname, set, "function");
34                        }
35        };
36        UIREGISTER(mexFnc);
37}
38#endif //MXFNC_H
Note: See TracBrowser for help on using the browser.