mixpp: bdm::RV Class Reference

bdm::RV Class Reference

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

#include <bdmbase.h>

Inheritance diagram for bdm::RV:

bdm::root List of all members.

Access functions

string to_string () const
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.

Public Member Functions

void from_setting (const Setting &set)
 UI for class RV (description of data vectors).
void to_setting (Setting &set) const
string show_all ()
 function for debugging RV related stuff
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.
 RV (int sz, int tm=0)
 Constructor of a single nameless RV.
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
returns rvs with time set to 0 and removed duplicates

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: $ [ rv_{0}, rv_{-1},\ldots rv_{max_delay}]$
Relation to vectors
str tostr () const
 generate str from rv, by expanding sizes
ivec dataind (const RV &crv) const
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
int mint () const
 Minimum time-offset.
int mint (const RV &rv) const
 Minimum time-offset of ids of given RVs.

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.

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

inline_dotgraph_4

RV name may be empty string! In that case, it is not a valid name but only a size holder. It will fail in comparison.


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

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)

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);

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

Find indices of self in another rv,.

Returns:
ivec of the same size as self.

ivec bdm::RV::findself_ids ( const RV rv2  )  const

Find indices of self in another rv, ignore time,.

Returns:
ivec of the same size as self.

void bdm::RV::from_setting ( const Setting &  set  )  [virtual]

UI for class RV (description of data vectors).

    class = 'RV';
    names = {'a', 'b', 'c', ...};   // UNIQUE IDENTIFIER same names = same variable
                                    // names are also used when storing results
    --- optional ---
    sizes = [1, 2, 3, ...];         // size of each name. default = ones()
                                    // if size = -1, it is found out from previous instances of the same name
    times = [-1, -2, 0, ...];       // time shifts with respect to current time, default = zeros()

Reimplemented from bdm::root.


The documentation for this class was generated from the following files:
Generated on 2 Dec 2013 for mixpp by  doxygen 1.4.7