Changeset 613

Show
Ignore:
Timestamp:
09/13/09 23:14:31 (15 years ago)
Author:
smidl
Message:

documentation

Files:
5 added
2 removed
4 modified
5 moved

Legend:

Unmodified
Added
Removed
  • library/bdm/base/bdmbase.h

    r610 r613  
    710710        //! push current data to history 
    711711        void step ( const vec &val_up ) { 
    712                 if ( Hrv._dsize() > 0 ) { 
    713                         history.shift_right ( 0, Hrv._dsize() ); 
    714                   history.set_subvector ( 0, val_up(v2h_up) ); // write U after Drv 
     712                if ( v2h_up.length() > 0 ) { 
     713                        history.shift_right ( 0, v2h_up.length() ); 
     714                  history.set_subvector ( 0, val_up(v2h_up) );  
    715715                } 
    716716        } 
     
    748748                downsize = v2v_down.length() + h2v_down.length(); 
    749749                upsize = v2v_up.length(); 
     750        } 
     751        //! set history of variable given by \c rv1 to values of \c hist. 
     752        void set_history(const RV& rv1, const vec &hist0){ 
     753                bdm_assert(rv1._dsize()==hist0.length(),"hist is not compatible with given rv1"); 
     754                ivec ind_H; 
     755                ivec ind_h0; 
     756                Hrv.dataind(rv1, ind_H, ind_h0); // find indeces of rv in  
     757                set_subvector(history, ind_H, hist0(ind_h0)); // copy given hist to appropriate places 
    750758        } 
    751759}; 
     
    964972                bdm_error ( "abstract class" ); 
    965973        } 
    966  
    967974        //! Returns data records at indeces. 
    968975        virtual void getdata ( vec &dt, const ivec &indeces ) { 
  • library/bdm/base/datasources.h

    r611 r613  
    128128                        iepdf=UI::build<epdf> ( set,"epdf",UI::compulsory ); 
    129129                        bdm_assert(iepdf->isnamed(), "Input epdf must be named, check if RV is given correctly"); 
    130                         dt =  iepdf->sample(); 
     130                        dt =  zeros(iepdf->dimension()); 
    131131                        dtsize=dt.length(); 
    132132                        set_drv(iepdf->_rv(),RV()); 
    133133                        utsize =0; 
     134                } 
     135                void validate() { 
     136                        dt = iepdf->sample(); 
    134137                } 
    135138}; 
     
    172175                \code 
    173176                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 
    175181                \endcode 
    176182 
     183                If init_rv is not given, init_values are set to zero. 
    177184                */ 
    178185                void from_setting ( const Setting &set ) { 
     
    188195                        ut2rgr.set_connection(impdf->_rvc(), Urv);  
    189196                        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                        } 
    190210 
    191211                        yt = zeros ( impdf->dimension() ); 
     
    196216                        utsize=ut.length(); 
    197217                        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 ); 
    198225                } 
    199226}; 
  • library/bdm/mex/mex_parser.h

    r599 r613  
    5151                        mexErrMsgTxt ( "Given mxArray is not numeric." ); 
    5252                }; 
    53                 mat val = mxArray2mat ( value ); 
     53                //treat empty matrices independently 
     54                mat val; 
     55                if (mxGetM(value)>0) { 
     56                        val = mxArray2mat ( value ); 
     57                } 
    5458                if ( ( val.rows() == 1 ) && ( val.cols() == 1 ) ) { 
    5559                        Setting &child = ( key == "" ) ? setting.add ( Setting::TypeFloat ) 
  • library/bdm/stat/exp_family.h

    r612 r613  
    561561                        bdm_assert_debug (A0.rows() == mu0.length(), "mlnorm: A vs. mu mismatch"); 
    562562                        bdm_assert_debug (A0.rows() == R0.rows(), "mlnorm: A vs. R mismatch"); 
    563  
     563                         
    564564                        this->iepdf.set_parameters (zeros (A0.rows()), R0); 
    565565                        A = A0; 
     
    684684                //! constructor function 
    685685                void set_parameters (const mat &A0, const vec &mu0, const ldmat &R0, const ldmat& Lambda0) { 
    686                         bdm_assert_debug (A0.rows() == mu0.length(), "mlstudent: A vs. mu mismatch"); 
    687                         bdm_assert_debug (R0.rows() == A0.rows(), "mlstudent: A vs. R mismatch"); 
    688  
    689686                        iepdf.set_parameters (mu0, R0);// was Lambda, why? 
    690687                        A = A0; 
     
    706703                }; 
    707704 
     705                void validate() { 
     706                        bdm_assert_debug (A.rows() == mu_const.length(), "mlstudent: A vs. mu mismatch"); 
     707                        bdm_assert_debug (_R.rows() == A.rows(), "mlstudent: A vs. R mismatch"); 
     708                         
     709                } 
    708710}; 
    709711/*!