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

Revision 529, 1.6 kB (checked in by vbarta, 15 years ago)

defined *_ptr wrappers of shared pointers

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                Data = mxArray2mat ( mexGetVariable ( "base", set["varname"] ) );
35                UI::get ( rowid, set, "rids" , UI::compulsory );
36                it_assert_debug ( max ( rowid ) <= Data.rows(), "MemDS rowid is too high for given Dat." );
37
38                UI::get ( delays, set, "tds", UI::compulsory );
39                time = max ( delays );
40                it_assert_debug ( time < Data.cols(), "MemDS delays are too high." );
41
42                shared_ptr<RV> r = UI::build<RV> ( set, "rv", UI::compulsory );
43                RV ru = RV();
44                set_rvs ( *r, ru );
45        }
46
47
48        // TODO dodelat void to_setting( Setting &set ) const;
49};
50
51UIREGISTER ( MexDS );
52SHAREDPTR ( MexDS );
53
54}
Note: See TracBrowser for help on using the browser.