Changeset 429 for applications/bdmtoolbox/mex
- Timestamp:
- 07/27/09 13:12:23 (15 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
applications/bdmtoolbox/mex/merger.cpp
r411 r429 118 118 119 119 // save results 120 Array<vec> source_vals(Sources.length()); 121 for (int i=0;i<Sources.length();i++){ 122 datalink_m2e dl; 123 dl.set_connection(Sources(i)->_rv(), Sources(i)->_rvc(), Merger->_rv()); 124 125 vec ll(Merger->_Smp()._samples().length()); 126 for(int j=0; j<Merger->_Smp()._samples().length(); j++){ 127 vec dt=dl.pushdown(Merger->_Smp()._samples()(j)); 128 vec dtc=dl.get_cond(Merger->_Smp()._samples()(j)); 129 ll(j)=Sources(i)->evallogcond(dt,dtc); 130 } 131 132 vec sll = exp(ll); 133 134 source_vals(i)=sll/sum(sll); 135 } 136 137 vec ll(Merger->_Smp()._samples().length()); 138 for(int j=0; j<Merger->_Smp()._samples().length(); j++){ 139 ll(j)=Merger->evallog(Merger->_Smp()._samples()(j)); 140 } 141 142 vec sll = exp(ll); 143 144 vec mix_val=sll/sum(sll); 145 120 146 121 147 #ifdef MEX … … 137 163 vec2mxArray(w,fldw); 138 164 mxReplaceFieldNM(tmp, "weights", fldw); 165 166 //mixture values 167 mxArray* fldm=mxCreateDoubleMatrix(1, w.length(), mxREAL); 168 vec2mxArray(mix_val,fldm); 169 mxReplaceFieldNM(tmp, "mix", fldm); 139 170 140 171 // sources … … 142 173 for (int i=0;i<Sources.length();i++){ 143 174 sprintf(srcstr,"source%d",i+1); 144 vec sll=exp(Sources(i)->evallogcond_m(Merger->_Smp()._samples(),vec(0))); 145 146 mxArray* fldw=mxCreateDoubleMatrix(1, sll.length(), mxREAL); 147 vec2mxArray(sll/sum(sll),fldw); 175 mxArray* fldw=mxCreateDoubleMatrix(1, source_vals(i).length(), mxREAL); 176 vec2mxArray(source_vals(i),fldw); 148 177 mxReplaceFieldNM(tmp, srcstr, fldw); 149 178 }