Show
Ignore:
Timestamp:
07/20/09 12:41:12 (15 years ago)
Author:
vbarta
Message:

RV partial cleanup: more arguments passed by reference, less inline functions, tests integrated into the testsuite

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • library/bdm/base/bdmbase.h

    r412 r422  
    3232extern Array<string> RV_NAMES; 
    3333 
    34 //! Structure of RV (used internally), i.e. expanded RVs - TODO tak proc je ve verejnem prostoru jmen? upravit 
     34//! Structure of RV, i.e. RVs expanded into a flat list of IDs, used for debugging. 
    3535class str 
    3636{ 
     
    9898private: 
    9999  //! auxiliary function used in constructor 
    100   void init(Array<std::string> in_names, ivec in_sizes, ivec in_times); 
    101   int init(const  string &name, int size); 
     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); 
    102102public: 
    103103  //! \name Constructors 
     
    105105 
    106106  //! 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 
    108109  //! 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 
    110112  //! 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 
    112115  //! Constructor of empty RV 
    113   RV() : dsize(0), len(0), ids(0), times(0) {}; 
     116  RV() : dsize(0), len(0), ids(0), times(0) {} 
    114117  //! Constructor of a single RV with given id 
    115118  RV(string name, int sz, int tm = 0); 
     
    119122  //!@{ 
    120123 
    121   //! Printing output e.g. for debugging. 
     124  //! State output, e.g. for debugging. 
    122125  friend std::ostream &operator<< (std::ostream &os, const RV &rv); 
    123   int _dsize() const {return dsize;} ; 
     126 
     127  int _dsize() const { return dsize; } 
     128 
    124129  //! Recount size of the corresponding data vector 
    125130  int countsize() const; 
    126131  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; } 
    133138  //!@} 
    134139 
     
    146151  //! Subtract  another variable from the current one 
    147152  RV subt(const RV &rv2) const; 
    148   //! Select only variables at indeces ind 
     153  //! Select only variables at indices ind 
    149154  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 
    152159  //! 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. 
    162163  void t(int delta); 
    163164  //!@} 
     
    168169  //! generate \c str from rv, by expanding sizes TODO to_string.. 
    169170  str tostr() const; 
    170   //! when this rv is a part of bigger rv, this function returns indeces 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. 
    171172  //! Then, data can be copied via: data_of_this = cdata(ind); 
    172173  ivec dataind(const RV &crv) const; 
    173   //! generate mutual indeces when copying data betwenn self and crv. 
     174  //! generate mutual indices when copying data between self and crv. 
    174175  //! Data are copied via: data_of_this(selfi) = data_of_rv2(rv2i) 
    175176  void dataind(const RV &rv2, ivec &selfi, ivec &rv2i) const; 
    176177  //! Minimum time-offset 
    177   int mint() const {return min(times);}; 
     178  int mint() const {return min(times);} 
    178179  //!@} 
    179180