Changeset 613 for library/bdm/base/datasources.h
- Timestamp:
- 09/13/09 23:14:31 (15 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
library/bdm/base/datasources.h
r611 r613 128 128 iepdf=UI::build<epdf> ( set,"epdf",UI::compulsory ); 129 129 bdm_assert(iepdf->isnamed(), "Input epdf must be named, check if RV is given correctly"); 130 dt = iepdf->sample();130 dt = zeros(iepdf->dimension()); 131 131 dtsize=dt.length(); 132 132 set_drv(iepdf->_rv(),RV()); 133 133 utsize =0; 134 } 135 void validate() { 136 dt = iepdf->sample(); 134 137 } 135 138 }; … … 172 175 \code 173 176 class = "MpdfDS"; 174 mpdf = {class="mpdf_offspring", ...}// mpdf to simulate 177 mpdf = {class="mpdf_offspring", ...}; // mpdf to simulate 178 --- optional --- 179 init_rv = {class="RV",names=...}; // define what rv to initialize - typically delayed values! 180 init_values = [...]; // vector of initial values corresponding to init_rv 175 181 \endcode 176 182 183 If init_rv is not given, init_values are set to zero. 177 184 */ 178 185 void from_setting ( const Setting &set ) { … … 188 195 ut2rgr.set_connection(impdf->_rvc(), Urv); 189 196 yt2rgr.set_connection(impdf->_rvc(), Yrv); 197 198 //set history - if given 199 shared_ptr<RV> rv_ini=UI::build<RV>(set,"init_rv",UI::optional); 200 if(rv_ini){ // check if 201 vec val; 202 UI::get(val, set, "init_values", UI::optional); 203 if (val.length()!=rv_ini->_dsize()){ 204 bdm_error("init_rv and init_values fields have incompatible sizes"); 205 } else { 206 ut2rgr.set_history(*rv_ini, val); 207 yt2rgr.set_history(*rv_ini, val); 208 } 209 } 190 210 191 211 yt = zeros ( impdf->dimension() ); … … 196 216 utsize=ut.length(); 197 217 dtsize = ytsize+utsize; 218 validate(); 219 } 220 void validate() { 221 //taken from sample() - shift of history is not done here 222 ut2rgr.filldown ( ut,rgr ); 223 yt2rgr.filldown ( yt,rgr ); 224 yt=impdf->samplecond ( rgr ); 198 225 } 199 226 };