Changeset 265 for bdm/stat/libDS.h

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

UI in matlab

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • bdm/stat/libDS.h

    r263 r265  
    5353        */ 
    5454        class ArxDS : public DS { 
     55        protected: 
    5556                //! Rv of the regressor 
    5657                RV Rrv; 
    5758                //! Rv of the history (full regressor) 
    5859                RV Hrv; 
    59                 //! Internal storage of results 
    60                 vec Y; 
    61                 //! History, ordered as \f$[u_t, y_{t-1 }, u_{t-1}, \ldots]\f$  
     60                //! History, ordered as \f$[y_t, u_t, y_{t-1 }, u_{t-1}, \ldots]\f$ 
    6261                vec H; 
     62                //! (future) input 
     63                vec U; 
    6364                //! temporary variable for regressor 
    6465                vec rgr; 
    65                 //! data link: val = y, cond = u; local = rgr; 
     66                //! data link: H -> rgr 
    6667                datalink_e2e rgrlnk; 
    67                 //! model of Y - linear Gaussian  
     68                //! model of Y - linear Gaussian 
    6869                mlnorm<chmat> model; 
     70                //! options 
     71                bool opt_L_theta; 
     72                //! loggers 
     73                int L_theta; 
     74                int L_R; 
    6975                public: 
    70                 void getdata ( vec &dt ){it_assert_debug(dt.length()==Y.length(),"ArxDS");  
    71                         dt=concat(Y,H.left(Urv.count()));}; 
    72                 void getdata ( vec &dt, const ivec &indexes ){it_assert_debug(dt.length()==Y.length(),"ArxDS"); dt=Y(indexes);}; 
    73                 void write ( vec &ut ){it_assert_debug(ut.length()==Urv.count(),"ArxDS"); H.set_subvector(0,ut);}; 
    74                 void write ( vec &ut, const ivec &indexes ){it_assert_debug(ut.length()==Urv.count(),"ArxDS"); set_subvector(H,indexes,ut);}; 
     76                void getdata ( vec &dt ) { 
     77                        it_assert_debug ( dt.length() ==Drv.count(),"ArxDS" ); 
     78                        dt=H.left ( Urv.count() +Drv.count() ); 
     79                }; 
     80                void getdata ( vec &dt, const ivec &indexes ) { 
     81                        it_assert_debug ( dt.length() ==indeces.length(),"ArxDS" ); 
     82                        dt=H ( indexes ); 
     83                }; 
     84                void write ( vec &ut ) { 
     85                        it_assert_debug ( ut.length() ==Urv.count(),"ArxDS" ); 
     86                        U=ut; 
     87                }; 
     88                void write ( vec &ut, const ivec &indexes ) { 
     89                        it_assert_debug ( ut.length() ==indeces.length(),"ArxDS" ); 
     90                        set_subvector ( U, indexes,ut ); 
     91                }; 
    7592                void step(); 
    7693                //!Default constructor 
    77                 ArxDS ( RV &drv, RV &urv, RV &rrv); 
     94                ArxDS ( RV &drv, RV &urv, RV &rrv ); 
    7895                //! Set parameters of the internal model 
    79                 void set_parameters(const mat &Th0, const vec mu0, const chmat &sqR0) 
    80                 {model.set_parameters(Th0, mu0, sqR0); }; 
     96                void set_parameters ( const mat &Th0, const vec mu0, const chmat &sqR0 ) 
     97                { model.set_parameters ( Th0, mu0, sqR0 ); }; 
     98                //! set options from a string 
     99                void set_options ( const string &s ) { 
     100                        opt_L_theta= ( s.find ( "L_theta" ) !=string::npos ); 
     101                }; 
     102                virtual void log_add ( logger &L ) { 
     103                        DS::log_add ( L ); 
     104                        mat &A =model._A(); 
     105                        mat R =model._R(); 
     106                        if ( opt_L_theta ) {L_theta=L.add ( RV("{theta }", vec_1(A.rows() *A.cols())),"t" );} 
     107                        if ( opt_L_theta ) {L_R=L.add ( RV("{R }", vec_1(R.rows() *R.cols())),"r" );} 
     108                } 
     109                virtual void logit ( logger &L ) { 
     110                        DS::logit ( L ); 
     111                        mat &A =model._A(); 
     112                        mat R =model._R(); 
     113                        if ( opt_L_theta ) {L.logit ( L_theta,vec ( A._data(), A.rows() *A.cols() ) );}; 
     114                        if ( opt_L_theta ) {L.logit ( L_R, vec ( R._data(), R.rows() *R.rows() ) );}; 
     115                } 
     116 
    81117        }; 
    82118 
     119        class ARXDS : public ArxDS { 
     120        public: 
     121                ARXDS ( RV &drv, RV &urv, RV &rrv ) : ArxDS ( drv,urv,rrv ) {} 
     122 
     123                void getdata ( vec &dt ) {dt=H;} 
     124                void getdata ( vec &dt, const ivec &indeces ) {dt=H ( indeces );} 
     125                virtual RV _drv() const {return Hrv;} 
     126 
     127        }; 
    83128}; //namespace 
    84129