PLearn 0.1
Public Member Functions | Static Public Member Functions
PLearn::RVArray Class Reference

An RVArray stores a table of RandomVar's. More...

#include <RandomVar.h>

Inheritance diagram for PLearn::RVArray:
Inheritance graph
[legend]
Collaboration diagram for PLearn::RVArray:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 RVArray ()
 RVArray.
 RVArray (int n, int n_extra_allocated=0)
 RVArray (const Array< RandomVar > &va)
 RVArray (const RandomVar &v, int n_extra_allocated=0)
 RVArray (const RandomVar &v1, const RandomVar &v2, int n_extra_allocated=0)
 RVArray (const RandomVar &v1, const RandomVar &v2, const RandomVar &v3, int n_extra_allocated=0)
int length () const
VarArray values () const
 return the VarArray of values of the RV's
RandomVar operator[] (RandomVar index)
 make a long array of RV's, as in expressions like X&Y&Z RVArray operator&(const RandomVar& v); //!< already built-in Arrays
RandomVaroperator[] (int i)
const RandomVaroperator[] (int i) const
void sort ()
 sorts in-place the elements by rv_number (topological order of the graphical model) (in the order: ancestors -> descendants)

Static Public Member Functions

static int compareRVnumbers (const RandomVar *v1, const RandomVar *v2)

Detailed Description

An RVArray stores a table of RandomVar's.

Definition at line 422 of file RandomVar.h.


Constructor & Destructor Documentation

PLearn::RVArray::RVArray ( )

RVArray.

Definition at line 880 of file RandomVar.cc.

    : Array<RandomVar>(0,0)
{}
PLearn::RVArray::RVArray ( int  n,
int  n_extra_allocated = 0 
)

Definition at line 884 of file RandomVar.cc.

    : Array<RandomVar>(n,n_extra)
{}
PLearn::RVArray::RVArray ( const Array< RandomVar > &  va)

Definition at line 888 of file RandomVar.cc.

    : Array<RandomVar>(va) {} 
PLearn::RVArray::RVArray ( const RandomVar v,
int  n_extra_allocated = 0 
)

Definition at line 891 of file RandomVar.cc.

    : Array<RandomVar>(1,n_extra)
{ (*this)[0] = v; }
PLearn::RVArray::RVArray ( const RandomVar v1,
const RandomVar v2,
int  n_extra_allocated = 0 
)

Definition at line 895 of file RandomVar.cc.

    : Array<RandomVar>(2,n_extra)
{ 
    (*this)[0] = v1; 
    (*this)[1] = v2; 
}
PLearn::RVArray::RVArray ( const RandomVar v1,
const RandomVar v2,
const RandomVar v3,
int  n_extra_allocated = 0 
)

Definition at line 902 of file RandomVar.cc.

    : Array<RandomVar>(3,n_extra)
{ 
    (*this)[0] = v1; 
    (*this)[1] = v2; 
    (*this)[2] = v3; 
}

Member Function Documentation

int PLearn::RVArray::compareRVnumbers ( const RandomVar v1,
const RandomVar v2 
) [static]

Definition at line 930 of file RandomVar.cc.

Referenced by sort().

{
    return (*v1)->rv_number - (*v2)->rv_number;
}

Here is the caller graph for this function:

int PLearn::RVArray::length ( ) const

Reimplemented from PLearn::TVec< RandomVar >.

Definition at line 911 of file RandomVar.cc.

References i, and PLearn::TVec< RandomVar >::size().

Referenced by PLearn::ExtendedRandomVariable::EMBprop(), PLearn::JointRandomVariable::EMBprop(), PLearn::JointRandomVariable::invertible(), and PLearn::RVArrayRandomElementRandomVariable::RVArrayRandomElementRandomVariable().

{
    int l=0;
    for (int i=0;i<size();i++)
        l += (*this)[i]->length();
    return l;
}

Here is the call graph for this function:

Here is the caller graph for this function:

RandomVar& PLearn::RVArray::operator[] ( int  i) [inline]

Definition at line 447 of file RandomVar.h.

const RandomVar& PLearn::RVArray::operator[] ( int  i) const [inline]

Reimplemented from PLearn::TVec< RandomVar >.

Definition at line 450 of file RandomVar.h.

RandomVar PLearn::RVArray::operator[] ( RandomVar  index)

make a long array of RV's, as in expressions like X&Y&Z RVArray operator&(const RandomVar& v); //!< already built-in Arrays

Note that casting a RVArray to RandomVar makes a JointRandomVariable because of RandomVar(RVAarray) constructor. return a new RVArrayRandomElementRandomVariable

Definition at line 927 of file RandomVar.cc.

{ return new RVArrayRandomElementRandomVariable(*this, index); }
void PLearn::RVArray::sort ( )

sorts in-place the elements by rv_number (topological order of the graphical model) (in the order: ancestors -> descendants)

Definition at line 937 of file RandomVar.cc.

References compareRVnumbers(), PLearn::TVec< RandomVar >::data(), and PLearn::TVec< RandomVar >::size().

{
    RandomVar* array = data();
    qsort(array,size(),sizeof(RandomVar),(compare_function)compareRVnumbers);
}

Here is the call graph for this function:

VarArray PLearn::RVArray::values ( ) const

return the VarArray of values of the RV's

Definition at line 919 of file RandomVar.cc.

References i, and PLearn::TVec< RandomVar >::size().

Referenced by PLearn::EM(), PLearn::ConcatColumnsRandomVariable::setValueFromParentsValue(), and PLearn::MixtureRandomVariable::setValueFromParentsValue().

{
    VarArray vals(size());
    for (int i=0;i<size();i++)
        vals[i]=(*this)[i]->value;
    return vals;
}

Here is the call graph for this function:

Here is the caller graph for this function:


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines