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=getivec(S["rids"]); |
30 | | tds = getivec(S["tds"]); |
31 | | } |
32 | | catch UICATCH ; |
33 | | |
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; |
| 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 |
| 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; |