Changeset 388 for applications
- Timestamp:
- 06/19/09 11:43:48 (16 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
applications/bdmtoolbox/mex/merger_mx.cpp
r384 r388 10 10 { 11 11 // Check the number of inputs and output arguments 12 if(n_input!=1) mexErrMsgTxt("Configuration structure expected in the form:\n" 13 "S.sources = { }; % cell of pdfs (epdfs or mpdfs) to be merged,\n" 14 "S.merger= struct('class','merger_*'); % object to be used for merging,\n\n" 12 if(n_input!=3) mexErrMsgTxt("Usage:\n" 13 "result=merger(sources, support, merger)\n" 14 " sources= { struct('class','epdf'),... }; % cell of pdfs (epdfs or mpdfs) to be merged,\n" 15 " support= struct(\n" 16 " grid = {[dim1_start,dim1_end], [dim2_start, dim2_end]...} %support boundary \n" 17 " nbins = [bins_in_dim1, bins_in_dim2,...] %fixed \n" 18 " === OR ==\n" 19 " pdf = struct('class','epdf'); % pdf to draw samples from\n" 20 " nsamples= 100; % number of samples\n" 21 " );\n" 22 " If all elements are present, (grid,nbins) is used;\n" 23 " merger = struct('class','merger_*'); % object to be used for merging,\n\n" 15 24 "see documentation of classes epdf, mpdf, merger_base and their offsprings in BDM."); 16 25 17 26 // LOAD CONFIG 18 UImxArray F (input[0]); 27 UImxArray Src; 28 Src.addList(input[0],"Sources"); 29 30 UImxArray Sup (input[1]); 31 UImxArray Mer (input[2]); 32 // Sources 33 Array<mpdf*> Sources; 34 //abuse Mer to store sources 19 35 20 Array<mpdf*> Sources; 21 22 Setting& _Sources=F.lookup("sources"); 36 Setting& _Sources=Src.lookup("Sources"); 23 37 int Slen=_Sources.getLength(); 24 38 Sources.set_size(Slen); … … 35 49 36 50 } 51 52 merger_base* Merger=UI::build<merger_base>(Mer.getRoot()); 53 54 // Support 55 Setting & _Supp=Sup.getRoot(); 37 56 38 merger_base* Merger=UI::build<merger_base>(F.getRoot(),"merger"); 39 57 Array<vec> bounds (0); 58 UI::get (bounds, _Supp, "grid"); 59 ivec nbins(0); 60 UI::get (nbins, _Supp, "nbins"); 61 62 epdf *g0=UI::build<epdf> (_Supp, "pdf"); 63 int npoints=100; 64 _Supp.lookupValue("nsamples",npoints); 65 40 66 // COMPUTE RESULTS 41 67 Merger->set_sources(Sources,true); // takes care of deletion of sources 68 if (bounds.length() > 0 && nbins.length()>0) { 69 Merger->set_support (bounds,nbins); 70 } else { 71 if (g0) { 72 Merger->set_support (*g0,npoints); 73 delete g0; 74 } 75 } 42 76 Merger->merge(); 43 77 78 // Save results 44 79 if (n_output>0){ 45 80 mxArray* tmp = mxCreateStructMatrix(1,1,0,NULL);