Class representing variables, most often random variables. More...
#include <bdmbase.h>
Public Member Functions | |
void | from_setting (const Setting &set) |
UI for class RV (description of data vectors). | |
string | show_all () |
function for debugging RV related stuff | |
virtual void | to_setting (Setting &set) const |
This method save all the instance properties into the Setting structure. | |
virtual void | validate () |
This method TODO. | |
Constructors | |
RV (const Array< std::string > &in_names, const ivec &in_sizes, const ivec &in_times) | |
Full constructor. | |
RV (const Array< std::string > &in_names, const ivec &in_sizes) | |
Constructor with times=0. | |
RV (const Array< std::string > &in_names) | |
Constructor with sizes=1, times=0. | |
RV () | |
Constructor of empty RV. | |
RV (string name, int sz, int tm=0) | |
Constructor of a single RV with given id. | |
Algebra on Random Variables | |
ivec | findself (const RV &rv2) const |
Find indices of self in another rv,. | |
ivec | findself_ids (const RV &rv2) const |
Find indices of self in another rv, ignore time,. | |
bool | equal (const RV &rv2) const |
Compare if rv2 is identical to this RV . | |
bool | add (const RV &rv2) |
Add (concat) another variable to the current one,. | |
RV | subt (const RV &rv2) const |
Subtract another variable from the current one. | |
RV | subselect (const ivec &ind) const |
Select only variables at indices ind. | |
RV | operator() (const ivec &ind) const |
Select only variables at indices ind. | |
RV | operator() (int di1, int di2) const |
Select from data vector starting at di1 to di2. | |
void | t_plus (int delta) |
Shift time by delta. | |
Time manipulation functions | |
RV | remove_time () const |
RV | copy_t (int dt) const |
create new RV from the current one with time shifted by given value | |
RV | expand_delayes () const |
return rvs with expanded delayes and sorted in the order of: | |
Relation to vectors | |
str | tostr () const |
generate str from rv, by expanding sizes | |
ivec | dataind (const RV &crv) const |
when this rv is a part of bigger rv, this function returns indices of self in the data vector of the bigger crv. Then, data can be copied via: data_of_this = cdata(ind); | |
ivec | dataind_part (const RV &crv) const |
same as dataind but this time crv should not be complete supperset of rv. | |
void | dataind (const RV &rv2, ivec &selfi, ivec &rv2i) const |
generate mutual indices when copying data between self and crv. Data are copied via: data_of_this(selfi) = data_of_rv2(rv2i) | |
int | mint () const |
Minimum time-offset. | |
Static Public Member Functions | |
static void | clear_all () |
Invalidate all named RVs. Use before initializing any RV instances, with care... | |
Protected Attributes | |
int | dsize |
size of the data vector | |
int | len |
number of individual rvs | |
ivec | ids |
Vector of unique IDs. | |
ivec | times |
Vector of shifts from current time. | |
Access functions | |
| |
string | to_string () |
This method returns a basic info about the current instance. | |
int | _dsize () const |
total size of a random variable | |
const ivec & | _ids () const |
access function | |
int | countsize () const |
Recount size of the corresponding data vector. | |
ivec | cumsizes () const |
Vector of cumulative sizes of RV. | |
int | length () const |
Number of named parts. | |
int | id (int at) const |
int | size (int at) const |
int | time (int at) const |
std::string | name (int at) const |
std::string | scalarname (int scalat) const |
returns name of a scalar at position scalat, i.e. it can be in the middle of vector name, in that case it adds "_%d" to it | |
void | set_time (int at, int time0) |
std::ostream & | operator<< (std::ostream &os, const RV &rv) |
State output, e.g. for debugging. |
Class representing variables, most often random variables.
The purpose of this class is to decribe a vector of data. Such description is used for connecting various vectors between each other, see class datalink.
The class is implemented using global variables to assure uniqueness of description:
In is a vector
bool bdm::RV::add | ( | const RV & | rv2 | ) |
Add (concat) another variable to the current one,.
References countsize(), dsize, findself(), ids, len, and times.
Referenced by bdm::StateCanonical::connect_mlnorm(), expand_delayes(), bdm::ArxDS::set_drv(), bdm::mprod::set_elements(), bdm::eprod::set_parameters(), and bdm::merger_base::set_sources().
ivec bdm::RV::findself | ( | const RV & | rv2 | ) | const |
ivec bdm::RV::findself_ids | ( | const RV & | rv2 | ) | const |
Find indices of self in another rv, ignore time,.
Referenced by bdm::datalink_buffered::set_connection().
void bdm::RV::from_setting | ( | const Setting & | set | ) | [virtual] |
UI for class RV (description of data vectors).
rv = { class = "RV"; // class name // UNIQUE IDENTIFIER same names = same variable names = ( "a", "b", "c", ...); // which will be used e.g. in loggers //optional arguments sizes = [1, 2, 3, ...]; // (optional) default = ones() times = [-1, -2, 0, ...]; // time shifts with respect to current time (optional) default = zeros() }
Reimplemented from bdm::root.
References bdm::UI::get().