root/library/bdm/mex/mex_datasource.h @ 384

Revision 384, 1.4 kB (checked in by mido, 15 years ago)

possibly broken?

Line 
1#include "../bdm/stat/datasources.h"
2#include "mex_parser.h"
3
4namespace bdm {
5/*!
6* \brief Memory storage of off-line data column-wise
7
8The 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 indices \c rowid and \c delays.
9
10The data can be loaded from a file.
11*/
12class MexDS : public MemDS {
13                //!Default constructor
14        MexDS () {};
15
16        /*! \brief Create memory data source from mxArray
17
18        \code
19        system={
20                type="mexDS";
21                varname="";            // name of workspace variable
22                rids=[1 1 1];          // numbers of data rows
23                tds =[0 1 2];          // time delays
24                };
25        \endcode
26
27        MemDS with the above fields will be created;
28
29        \todo Very memory inefficient implementation. The data file is copied 2 times!
30        For better implementatin we would need MemDS with pointer to the raw data. Then it could operate directly inside mxArray.
31
32        */
33        void from_setting( const Setting &set )
34        {       
35                Data = mxArray2mat(mexGetVariable("base",set["varname"]));
36                UI::get( rowid, set, "rids" );
37                it_assert_debug ( max ( rowid ) <=Data.rows(),"MemDS rowid is too high for given Dat." );
38
39                UI::get( delays, set, "tds" );
40                time = max ( delays );
41                it_assert_debug ( time < Data.cols(),"MemDS delays are too high." );
42
43                RV* r = UI::build<RV>(set,"rv");
44                RV ru=RV();
45                set_rvs(*r,ru);
46        }
47
48
49        // TODO dodelat void to_setting( Setting &set ) const;
50};
51
52UIREGISTER(MexDS);
53
54}
Note: See TracBrowser for help on using the browser.