# bdm::RV Class Reference

Class representing variables, most often random variables. More...

`#include <bdmbase.h>`

List of all members.

## Public Member Functions
void | from_setting (const Setting &set)
| UI for class RV (description of data vectors).
virtual string | to_string ()
| This method returns a basic info about the current instance.
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,.
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 (int delta)
| Shift `time` by delta.
Relation to vectors
str | tostr () const
| generate `str` from rv, by expanding sizes
ivec | dataind (const RV &crv) const
void | dataind (const RV &rv2, ivec &selfi, ivec &rv2i) const
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
int | _dsize () const
const ivec & | _ids () const
| access function
int | countsize () const
| Recount size of the corresponding data vector.
ivec | cumsizes () const
int | length () const
int | id (int at) const
int | size (int at) const
int | time (int at) const
std::string | name (int at) const
void | set_time (int at, int time0)
std::ostream & | operator<< (std::ostream &os, const RV &rv)
| State output, e.g. for debugging.

## Detailed Description

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

## Member Function Documentation

bool bdm::RV::add | ( | const RV & | rv2 | ) |

Add (concat) another variable to the current one,.

Returns:
  true if all rv2 were added, false if rv2 is in conflict

References countsize(), dsize, findself(), ids, len, and times.

Referenced by bdm::ArxDS::set_drv(), bdm::mprod::set_elements(), bdm::eprod::set_parameters(), and bdm::merger_base::set_sources().

void bdm::RV::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)

References bdm_assert_debug, findself(), ids, bdm::str::ids, times, bdm::str::times, and tostr().

ivec bdm::RV::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);

References bdm_assert_debug, dsize, ids, bdm::str::ids, times, bdm::str::times, and tostr().

Referenced by bdm::datalink_m2m::set_connection(), bdm::datalink_m2e::set_connection(), and bdm::datalink::set_connection().

ivec bdm::RV::findself | ( | const RV & | rv2 | ) | const

Find indices of self in another rv,.

Returns:
  ivec of the same size as self.

References ids, and times.

Referenced by add(), dataind(), and subt().

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().

The documentation for this class was generated from the following files:

- bdmbase.h
- bdmbase.cpp