Revision 313, 0.9 kB
(checked in by smidl, 16 years ago)
|
mexds
|
Rev | Line | |
---|
[313] | 1 | #include "../bdm/stat/libDS_ui.h" |
---|
| 2 | |
---|
| 3 | /*! \brief Create memory data source from mxArray |
---|
| 4 | |
---|
| 5 | \code |
---|
| 6 | system={ |
---|
| 7 | type="mexDS"; |
---|
| 8 | varname=""; // name of workspace variable |
---|
| 9 | rids=[1 1 1]; // numbers of data rows |
---|
| 10 | tds =[0 1 2]; // time delays |
---|
| 11 | }; |
---|
| 12 | \endcode |
---|
| 13 | |
---|
| 14 | MemDS with the above fields will be created; |
---|
| 15 | |
---|
| 16 | \todo Very memory inefficient implementation. The data file is copied 2 times! |
---|
| 17 | For better implementatin we would need MemDS with pointer to the raw data. Then it could operate directly inside mxArray. |
---|
| 18 | |
---|
| 19 | */ |
---|
| 20 | class UImexDS: public UIbuilder{ |
---|
| 21 | public: |
---|
| 22 | UImexDS():UIbuilder("mexDS"){}; |
---|
| 23 | bdmroot* build(Setting &S) const{ |
---|
| 24 | mat Data; |
---|
| 25 | ivec rids; |
---|
| 26 | ivec tds; |
---|
| 27 | try{ |
---|
| 28 | Data = mxArray2mat(mexGetVariable("base",S["varname"])); |
---|
| 29 | rids=mxArray2ivec(mexGetVariable("base",S["rids"])); |
---|
| 30 | tds = mxArray2ivec(mexGetVariable("base",S["tds"])); |
---|
| 31 | } |
---|
| 32 | catch UICATCH ; |
---|
| 33 | |
---|
| 34 | return new MemDS(Data,rids,tds); |
---|
| 35 | }; |
---|
| 36 | }; |
---|
| 37 | UIREGISTER(UImexDS); |
---|