| 105 | /*! Pseudovirtual class for reading data from files |
| 106 | |
| 107 | */ |
| 108 | class FileDS: public MemDS { |
| 109 | |
| 110 | public: |
| 111 | void getdata ( vec &dt ) { |
| 112 | dt = Data.get_col ( time ); |
| 113 | } |
| 114 | |
| 115 | void getdata ( vec &dt, const ivec &indices ) { |
| 116 | vec tmp = Data.get_col ( time ); |
| 117 | dt = tmp ( indices ); |
| 118 | } |
| 119 | |
| 120 | //! returns number of data in the file; |
| 121 | int ndat() { |
| 122 | return Data.cols(); |
| 123 | } |
| 124 | //! no sense to log this type |
| 125 | void log_register ( logger &L, const string &prefix ) {}; |
| 126 | //! no sense to log this type |
| 127 | void log_write ( ) const {}; |
| 128 | }; |
| 129 | |
| 130 | /*! |
| 131 | * \brief Read Data Matrix from an IT file |
| 132 | |
| 133 | The constructor creates an internal matrix \c Data from an IT++ file. The file is binary and can be made using the IT++ library or the Matlab/Octave function itsave. NB: the data are stored columnwise, i.e. each column contains the data for time \f$t\f$! |
| 134 | |
| 135 | */ |
| 136 | class ITppFileDS: public FileDS { |
| 137 | |
| 138 | public: |
| 139 | //! Convenience constructor |
| 140 | ITppFileDS ( const string &fname, const string &varname ) : FileDS() { |
| 141 | it_file it ( fname ); |
| 142 | it << Name ( varname ); |
| 143 | it >> Data; |
| 144 | time = 0; |
| 145 | //rowid and delays are ignored |
| 146 | }; |
| 147 | |
| 148 | ITppFileDS () : FileDS() { |
| 149 | }; |
| 150 | |
| 151 | void from_setting ( const Setting &set ); |
| 152 | |
| 153 | // TODO dodelat void to_setting( Setting &set ) const; |
| 154 | |
| 155 | }; |
| 156 | |
| 157 | UIREGISTER ( ITppFileDS ); |
| 158 | SHAREDPTR ( ITppFileDS ); |
| 159 | |
| 160 | /*! |
| 161 | * \brief CSV file data storage |
| 162 | The constructor creates \c Data matrix from the records in a CSV file \c fname. The orientation can be of two types: |
| 163 | 1. \c BY_COL which is default - the data are stored in columns; one column per time \f$t\f$, one row per data item. |
| 164 | 2. \c BY_ROW if the data are stored the classical CSV style. Then each column stores the values for data item, for ex. \f$[y_{t} y_{t-1} ...]\f$, one row for each discrete time instant. |
| 165 | |
| 166 | */ |
| 167 | class CsvFileDS: public FileDS { |
| 168 | |
| 169 | public: |
| 170 | //! Constructor - create DS from a CSV file. |
| 171 | CsvFileDS ( const string& fname, const string& orientation = "BY_COL" ); |
| 172 | }; |
| 173 | |
| 174 | |
| 175 | |
| 176 | // ARXDs - DELETED |
| 177 | |
254 | | /*! Pseudovirtual class for reading data from files |
255 | | |
256 | | */ |
257 | | class FileDS: public MemDS { |
258 | | |
259 | | public: |
260 | | void getdata ( vec &dt ) { |
261 | | dt = Data.get_col ( time ); |
262 | | } |
263 | | |
264 | | void getdata ( vec &dt, const ivec &indices ) { |
265 | | vec tmp = Data.get_col ( time ); |
266 | | dt = tmp ( indices ); |
267 | | } |
268 | | |
269 | | //! returns number of data in the file; |
270 | | int ndat() { |
271 | | return Data.cols(); |
272 | | } |
273 | | //! no sense to log this type |
274 | | void log_register ( logger &L, const string &prefix ) {}; |
275 | | //! no sense to log this type |
276 | | void log_write ( ) const {}; |
277 | | }; |
278 | | |
279 | | /*! |
280 | | * \brief Read Data Matrix from an IT file |
281 | | |
282 | | The constructor creates an internal matrix \c Data from an IT++ file. The file is binary and can be made using the IT++ library or the Matlab/Octave function itsave. NB: the data are stored columnwise, i.e. each column contains the data for time \f$t\f$! |
283 | | |
284 | | */ |
285 | | class ITppFileDS: public FileDS { |
286 | | |
287 | | public: |
288 | | //! Convenience constructor |
289 | | ITppFileDS ( const string &fname, const string &varname ) : FileDS() { |
290 | | it_file it ( fname ); |
291 | | it << Name ( varname ); |
292 | | it >> Data; |
293 | | time = 0; |
294 | | //rowid and delays are ignored |
295 | | }; |
296 | | |
297 | | ITppFileDS () : FileDS() { |
298 | | }; |
299 | | |
300 | | void from_setting ( const Setting &set ); |
301 | | |
302 | | // TODO dodelat void to_setting( Setting &set ) const; |
303 | | |
304 | | }; |
305 | | |
306 | | UIREGISTER ( ITppFileDS ); |
307 | | SHAREDPTR ( ITppFileDS ); |
308 | | |
309 | | /*! |
310 | | * \brief CSV file data storage |
311 | | The constructor creates \c Data matrix from the records in a CSV file \c fname. The orientation can be of two types: |
312 | | 1. \c BY_COL which is default - the data are stored in columns; one column per time \f$t\f$, one row per data item. |
313 | | 2. \c BY_ROW if the data are stored the classical CSV style. Then each column stores the values for data item, for ex. \f$[y_{t} y_{t-1} ...]\f$, one row for each discrete time instant. |
314 | | |
315 | | */ |
316 | | class CsvFileDS: public FileDS { |
317 | | |
318 | | public: |
319 | | //! Constructor - create DS from a CSV file. |
320 | | CsvFileDS ( const string& fname, const string& orientation = "BY_COL" ); |
321 | | }; |
322 | | |
323 | | |
324 | | |
325 | | // ARXDs - DELETED |
326 | | |