mex_function.h
00001 #ifndef MXFNC_H 00002 #define MXFNC_H 00003 00004 00005 #include <base/bdmbase.h> 00006 #include "mex_parser.h" 00007 00008 namespace bdm { 00009 00012 class mexFnc: public fnc { 00013 protected: 00014 string fname; 00015 public: 00016 vec eval(const vec &cond) { 00017 mxArray *mxinp = mxCreateDoubleMatrix ( cond.length(), 1, mxREAL ); 00018 mxArray *mxout; 00019 00020 vec2mxArray(cond,mxinp); 00021 mexCallMATLAB ( 1, &mxout, 1, &mxinp, fname.c_str() ); 00022 00023 bdm_assert(int(mxGetN(mxout))==(dimension()) || int(mxGetM(mxout))==(dimension()), "vector length mismatch"); 00024 vec tmp=mxArray2vec(mxout); 00025 return tmp; 00026 } 00032 void from_setting(const Setting &set) { 00033 fnc::from_setting(set); 00034 UI::get(fname, set, "function", UI::compulsory); 00035 } 00036 void to_setting(Setting &set) const { 00037 fnc::to_setting(set); 00038 UI::save(fname, set, "function"); 00039 } 00040 }; 00041 UIREGISTER(mexFnc); 00042 } 00043 #endif //MXFNC_H
Generated on 2 Dec 2013 for mixpp by 1.4.7