Changeset 263 for bdm/stat/libDS.h

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

UIArxDS test

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • bdm/stat/libDS.h

    r254 r263  
    1414#define DS_H 
    1515 
    16 #include <itpp/itbase.h> 
     16 
    1717#include "libBM.h" 
     18#include "libEF.h" 
    1819 
    19 namespace bdm{ 
    20 /*! 
    21 * \brief Class representing off-line data stored in memory 
    2220 
    23 The data are stored in an internal matrix \c Data . Each column of Data corresponds to one discrete time observation \f$t\f$. Access to this matrix is via indexes \c rowid and \c delays. 
     21namespace bdm { 
     22        /*! 
     23        * \brief Memory storage of off-line data column-wise 
    2424 
    25 The data can be loaded from a file. 
    26 */ 
    27 class MemDS : public DS { 
    28 mat Data; 
    29 int time; 
    30 ivec rowid; 
    31 ivec delays; 
     25        The data are stored in an internal matrix \c Data . Each column of Data corresponds to one discrete time observation \f$t\f$. Access to this matrix is via indexes \c rowid and \c delays. 
    3226 
    33 public: 
    34         void getdata(vec &dt); 
    35         void getdata(vec &dt, ivec &indeces); 
    36         void linkrvs(RV &drv, RV &urv); 
    37         void write(vec &ut){it_error("MemDS::write is not supported");} 
    38         void write(vec &ut,ivec &indexes){it_error("MemDS::write is not supported");} 
    39         void step(); 
    40         //!Default constructor 
    41         MemDS(mat &Dat, ivec &rowid, ivec &delays); 
    42 }; 
     27        The data can be loaded from a file. 
     28        */ 
     29        class MemDS : public DS { 
     30                //! internal matrix of data 
     31                mat Data; 
     32                //! active column in the Data matrix 
     33                int time; 
     34                //!  vector of rows that are presented in Dt 
     35                ivec rowid; 
     36                //! vector of delays that are presented in Dt 
     37                ivec delays; 
     38 
     39        public: 
     40                void getdata ( vec &dt ); 
     41                void getdata ( vec &dt, const ivec &indeces ); 
     42                void linkrvs ( RV &drv, RV &urv ); 
     43                void write ( vec &ut ) {it_error ( "MemDS::write is not supported" );} 
     44                void write ( vec &ut,ivec &indexes ) {it_error ( "MemDS::write is not supported" );} 
     45                void step(); 
     46                //!Default constructor 
     47                MemDS ( mat &Dat, ivec &rowid, ivec &delays ); 
     48        }; 
     49 
     50        /*! 
     51        \brief Generator of ARX data 
     52 
     53        */ 
     54        class ArxDS : public DS { 
     55                //! Rv of the regressor 
     56                RV Rrv; 
     57                //! Rv of the history (full regressor) 
     58                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$  
     62                vec H; 
     63                //! temporary variable for regressor 
     64                vec rgr; 
     65                //! data link: val = y, cond = u; local = rgr; 
     66                datalink_e2e rgrlnk; 
     67                //! model of Y - linear Gaussian  
     68                mlnorm<chmat> model; 
     69                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);}; 
     75                void step(); 
     76                //!Default constructor 
     77                ArxDS ( RV &drv, RV &urv, RV &rrv); 
     78                //! 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); }; 
     81        }; 
    4382 
    4483}; //namespace