Changeset 593 for library/bdm/mex/mex_datasource.h
- Timestamp:
- 08/31/09 23:13:25 (15 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
library/bdm/mex/mex_datasource.h
r565 r593 1 #ifndef MXDS_H 2 #define MXDS_H 3 4 1 5 #include "../bdm/bdmerror.h" 2 #include "../bdm/ stat/datasources.h"6 #include "../bdm/base/datasources.h" 3 7 #include "mex_parser.h" 4 8 … … 11 15 The data can be loaded from a file. 12 16 */ 13 class MexDS : public MemDS { 17 class mxArrayDS : public MemDS { 18 public: 14 19 //!Default constructor 15 MexDS() {};20 mxArrayDS ():MemDS() {}; 16 21 17 22 /*! \brief Create memory data source from mxArray … … 20 25 system={ 21 26 type="mexDS"; 22 varname=""; // name of workspace variable 23 rids=[1 1 1]; // numbers of data rows 24 tds =[0 1 2]; // time delays 27 varname=""; // name of workspace variable 28 row_rv = {class='RV',...} // definition of 25 29 }; 26 30 \endcode … … 28 32 MemDS with the above fields will be created; 29 33 30 \todo Very memory inefficient implementation. The data file is copied 2 times!31 For better implementatin we would need MemDS with pointer to the raw data. Then it could operate directly inside mxArray.32 33 34 */ 34 35 void from_setting ( const Setting &set ) { 35 36 Data = mxArray2mat ( mexGetVariable ( "base", set["varname"] ) ); 36 UI::get ( rowid, set, "rids" , UI::compulsory );37 /* UI::get ( rowid, set, "rids" , UI::compulsory ); 37 38 bdm_assert_debug ( max ( rowid ) <= Data.rows(), "MemDS rowid is too high for given Dat." ); 38 39 … … 40 41 time = max ( delays ); 41 42 bdm_assert_debug ( time < Data.cols(), "MemDS delays are too high." ); 42 43 shared_ptr<RV> r = UI::build<RV> ( set, "rv", UI::compulsory ); 43 */ 44 //set MemDS 45 rowid = linspace(0,Data.rows()-1); 46 delays = zeros_i(Data.rows()); 47 dtsize=rowid.length(); 48 utsize=0; 49 50 shared_ptr<RV> r = UI::build<RV> ( set, "rv", UI::optional ); 44 51 RV ru = RV(); 45 set_rvs ( *r, ru ); 52 if (r){ 53 set_rvs ( *r, ru ); 54 } else { 55 RV def((const char*)set["varname"],Data.rows()); 56 set_rvs(def, ru); 57 } 46 58 } 47 59 … … 50 62 }; 51 63 52 UIREGISTER ( MexDS );53 SHAREDPTR ( MexDS );64 UIREGISTER ( mxArrayDS ); 65 SHAREDPTR ( mxArrayDS ); 54 66 55 67 } 68 #endif //MXDS_H