Changeset 422 for library/bdm/base/bdmbase.h
- Timestamp:
- 07/20/09 12:41:12 (15 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
library/bdm/base/bdmbase.h
r412 r422 32 32 extern Array<string> RV_NAMES; 33 33 34 //! Structure of RV (used internally), i.e. expanded RVs - TODO tak proc je ve verejnem prostoru jmen? upravit34 //! Structure of RV, i.e. RVs expanded into a flat list of IDs, used for debugging. 35 35 class str 36 36 { … … 98 98 private: 99 99 //! auxiliary function used in constructor 100 void init( Array<std::string> in_names, ivec in_sizes, ivecin_times);101 int init(const 100 void init(const Array<std::string> &in_names, const ivec &in_sizes, const ivec &in_times); 101 int init(const string &name, int size); 102 102 public: 103 103 //! \name Constructors … … 105 105 106 106 //! Full constructor 107 RV(Array<std::string> in_names, ivec in_sizes, ivec in_times) {init(in_names, in_sizes, in_times);}; 107 RV(const Array<std::string> &in_names, const ivec &in_sizes, const ivec &in_times) { init(in_names, in_sizes, in_times); } 108 108 109 //! Constructor with times=0 109 RV(Array<std::string> in_names, ivec in_sizes) {init(in_names, in_sizes, zeros_i(in_names.length()));}; 110 RV(const Array<std::string> &in_names, const ivec &in_sizes) { init(in_names, in_sizes, zeros_i(in_names.length())); } 111 110 112 //! Constructor with sizes=1, times=0 111 RV(Array<std::string> in_names) {init(in_names, ones_i(in_names.length()), zeros_i(in_names.length()));} 113 RV(const Array<std::string> &in_names) { init(in_names, ones_i(in_names.length()), zeros_i(in_names.length())); } 114 112 115 //! Constructor of empty RV 113 RV() : dsize(0), len(0), ids(0), times(0) {} ;116 RV() : dsize(0), len(0), ids(0), times(0) {} 114 117 //! Constructor of a single RV with given id 115 118 RV(string name, int sz, int tm = 0); … … 119 122 //!@{ 120 123 121 //! Printing outpute.g. for debugging.124 //! State output, e.g. for debugging. 122 125 friend std::ostream &operator<< (std::ostream &os, const RV &rv); 123 int _dsize() const {return dsize;} ; 126 127 int _dsize() const { return dsize; } 128 124 129 //! Recount size of the corresponding data vector 125 130 int countsize() const; 126 131 ivec cumsizes() const; 127 int length() const {return len;} ;128 int id(int at) const {return ids(at);} ;129 int size(int at) const { return RV_SIZES(ids(at));};130 int time(int at) const { return times(at);};131 std::string name(int at) const { return RV_NAMES(ids(at));};132 void set_time(int at, int time0) { times(at) = time0;};132 int length() const {return len;} 133 int id(int at) const {return ids(at);} 134 int size(int at) const { return RV_SIZES(ids(at)); } 135 int time(int at) const { return times(at); } 136 std::string name(int at) const { return RV_NAMES(ids(at)); } 137 void set_time(int at, int time0) { times(at) = time0; } 133 138 //!@} 134 139 … … 146 151 //! Subtract another variable from the current one 147 152 RV subt(const RV &rv2) const; 148 //! Select only variables at ind eces ind153 //! Select only variables at indices ind 149 154 RV subselect(const ivec &ind) const; 150 //! Select only variables at indeces ind 151 RV operator()(const ivec &ind) const {return subselect(ind);}; 155 156 //! Select only variables at indices ind 157 RV operator()(const ivec &ind) const { return subselect(ind); } 158 152 159 //! Select from data vector starting at di1 to di2 153 RV operator()(int di1, int di2) const { 154 ivec sz = cumsizes(); 155 int i1 = 0; 156 while (sz(i1) < di1) i1++; 157 int i2 = i1; 158 while (sz(i2) < di2) i2++; 159 return subselect(linspace(i1, i2)); 160 }; 161 //! Shift \c time shifted by delta. 160 RV operator()(int di1, int di2) const; 161 162 //! Shift \c time by delta. 162 163 void t(int delta); 163 164 //!@} … … 168 169 //! generate \c str from rv, by expanding sizes TODO to_string.. 169 170 str tostr() const; 170 //! when this rv is a part of bigger rv, this function returns ind eces of self in the data vector of the bigger crv.171 //! when this rv is a part of bigger rv, this function returns indices of self in the data vector of the bigger crv. 171 172 //! Then, data can be copied via: data_of_this = cdata(ind); 172 173 ivec dataind(const RV &crv) const; 173 //! generate mutual ind eces when copying data betwenn self and crv.174 //! generate mutual indices when copying data between self and crv. 174 175 //! Data are copied via: data_of_this(selfi) = data_of_rv2(rv2i) 175 176 void dataind(const RV &rv2, ivec &selfi, ivec &rv2i) const; 176 177 //! Minimum time-offset 177 int mint() const {return min(times);} ;178 int mint() const {return min(times);} 178 179 //!@} 179 180