Changeset 407
- Timestamp:
- 07/02/09 22:16:11 (16 years ago)
- Files:
-
- 6 removed
- 3 modified
-
applications/bdmtoolbox/mex/CMakeLists.txt (modified) (1 diff)
-
applications/bdmtoolbox/mex/bm_kolo.sh (deleted)
-
applications/bdmtoolbox/mex/bm_note.sh (deleted)
-
applications/bdmtoolbox/mex/buildmex.bat (deleted)
-
applications/bdmtoolbox/mex/buildmex.sh (deleted)
-
applications/bdmtoolbox/mex/merger.cpp (modified) (4 diffs)
-
applications/bdmtoolbox/mex/merger_mx.cpp (deleted)
-
applications/bdmtoolbox/mex/mexopts-opt.bat (deleted)
-
library/system/SetBdmEnv.cmake (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
applications/bdmtoolbox/mex/CMakeLists.txt
r406 r407 1 1 IF(MEX_COMPILER) 2 2 3 MEX(merger _mx)3 MEX(merger) 4 4 EXEC(merger) 5 5 MEX(config2mxstruct) -
applications/bdmtoolbox/mex/merger.cpp
r400 r407 1 1 #include <stat/merger.h> 2 3 #ifdef MEX 4 #include <itpp/itmex.h> 5 #include <mex/mex_logger.h> 6 #include <mex/mex_parser.h> 7 #include <mex/config2mxstruct.h> 8 #endif 2 9 3 10 using namespace bdm; 4 11 5 int main() 12 #ifdef MEX 13 void mexFunction(int n_output, mxArray *output[], int n_input, const mxArray *input[]) 6 14 { 7 UIFile Cfg("merger_mx.cfg"); 8 15 // Check the number of inputs and output arguments 16 if(n_input!=3) mexErrMsgTxt("Usage:\n" 17 "result=merger(sources, support, merger)\n" 18 " sources= { struct('class','epdf'),... }; % cell of pdfs (epdfs or mpdfs) to be merged,\n" 19 " support= struct(\n" 20 " grid = {[dim1_start,dim1_end], [dim2_start, dim2_end]...} %support boundary \n" 21 " nbins = [bins_in_dim1, bins_in_dim2,...] %fixed \n" 22 " === OR ==\n" 23 " pdf = struct('class','epdf'); % pdf to draw samples from\n" 24 " nsamples= 100; % number of samples\n" 25 " );\n" 26 " If all elements are present, (grid,nbins) is used;\n" 27 " merger = struct('class','merger_*'); % object to be used for merging,\n\n" 28 "see documentation of classes epdf, mpdf, merger_base and their offsprings in BDM."); 29 30 // LOAD CONFIG 31 UImxArray Cfg; 32 Cfg.addList(input[0],"Sources"); 33 Cfg.addGroup(input[1],"Support"); 34 Cfg.addGroup(input[2],"Merger"); 35 36 //DBG 37 Cfg.writeFile("merger.cfg"); 38 #else 39 int main() 40 { 41 UIFile Cfg("merger.cfg"); 42 #endif 9 43 // Sources 10 44 Array<mpdf*> Sources; … … 24 58 if (etmp){ 25 59 Sources(i) = new mepdf(etmp, true); 26 } 27 60 } 28 61 } 29 62 catch (UIException e) … … 33 66 catch (std::exception e) { 34 67 it_error("Error in UI at "+_Sources[i].getPath()); 35 } 68 } 36 69 } 37 70 catch (std::exception e) { 38 71 it_error("Error in UI at "+_Sources[i].getPath()); 39 } 72 } 40 73 } 41 74 … … 66 99 Merger->merge(); 67 100 101 // save results 102 103 #ifdef MEX 104 mxArray* tmp ; 105 // Save results 106 if (n_output>0){ 107 tmp = mxCreateStructMatrix(1,1,0,NULL); 108 //support 109 Array<vec> &samples=Merger->_Smp()._samples(); 110 if (samples.size()>0){ 111 mxArray* fld=mxCreateDoubleMatrix(samples(0).length(), samples.size(), mxREAL); 112 Arrayvec2mxArray(samples,fld); 113 mxReplaceFieldNM(tmp, "support", fld); 114 } 115 116 //weights 117 vec &w = Merger->_Smp()._w(); 118 mxArray* fldw=mxCreateDoubleMatrix(1, w.length(), mxREAL); 119 vec2mxArray(w,fldw); 120 mxReplaceFieldNM(tmp, "weights", fldw); 121 122 // sources 123 char srcstr[20]; 124 for (int i=0;i<Sources.length();i++){ 125 sprintf(srcstr,"source%d",i+1); 126 vec sll=exp(Sources(i)->evallogcond_m(Merger->_Smp()._samples(),vec(0))); 127 128 mxArray* fldw=mxCreateDoubleMatrix(1, sll.length(), mxREAL); 129 vec2mxArray(sll/sum(sll),fldw); 130 mxReplaceFieldNM(tmp, srcstr, fldw); 131 } 132 133 output[0] = tmp; 134 } 135 #endif 68 136 } -
library/system/SetBdmEnv.cmake
r406 r407 100 100 INCLUDE_DIRECTORIES(${MATLAB_INCLUDE_DIR} "${BDM_SOURCE_DIR}/bdm") 101 101 LINK_DIRECTORIES("${BDM_SOURCE_DIR}/bdm") 102 ADD_LIBRARY( ${FN}MODULE ${FN}.cpp)103 set_target_properties( ${FN}PROPERTIES102 ADD_LIBRARY("${FN}.${MATLAB_MEX_SUFFIX}" MODULE ${FN}.cpp) 103 set_target_properties("${FN}.${MATLAB_MEX_SUFFIX}" PROPERTIES 104 104 PREFIX "" 105 SUFFIX ${MATLAB_MEX_SUFFIX} 105 SUFFIX "" 106 COMPILE_FLAGS "-DMEX" 106 107 ) 107 TARGET_LINK_LIBRARIES( ${FN}${MATLAB_LIBRARIES} bdm itpp)108 TARGET_LINK_LIBRARIES("${FN}.${MATLAB_MEX_SUFFIX}" ${MATLAB_LIBRARIES} bdm itpp) 108 109 ENDMACRO(MEX)
