Revision 342, 1.0 kB
(checked in by smidl, 15 years ago)
|
Barcelona
|
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"])); |
---|
[314] | 29 | rids=getivec(S["rids"]); |
---|
| 30 | tds = getivec(S["tds"]); |
---|
[313] | 31 | } |
---|
| 32 | catch UICATCH ; |
---|
| 33 | |
---|
[314] | 34 | MemDS* M=new MemDS(Data,rids,tds); |
---|
| 35 | RV* r; UIbuild(S["rv"],r); |
---|
| 36 | RV ru=RV(); |
---|
| 37 | M->set_rvs(*r,ru); |
---|
| 38 | return M; |
---|
[313] | 39 | }; |
---|
| 40 | }; |
---|
[342] | 41 | UIREGISTER(UImexDS); |
---|