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

#include <RandomVar.h>

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

List of all members.

Public Member Functions

 RVInstanceArray ()
 RVInstanceArray.
 RVInstanceArray (int n, int n_extra_allocated=0)
 RVInstanceArray (const Array< RVInstance > &a)
 RVInstanceArray (const RVInstance &v, int n_extra_allocated=0)
 RVInstanceArray (const RVInstance &v1, const RVInstance &v2, int n_extra_allocated=0)
 RVInstanceArray (const RVInstance &v1, const RVInstance &v2, const RVInstance &v3, int n_extra_allocated=0)
int length () const
 total length of all the RV's in the array, this is generally != size()
RVInstanceArray operator&& (RVInstance rhs)
 Build a chain of (RV,value) pairs.
ConditionalExpression operator| (RVInstanceArray rhs)
RVArray random_variables () const
 put all the RVs in the list in a RVarray
VarArray values () const
 put all the values of the variables (array[i].V->value) in a VarArray
VarArray instances () const
 put all the instance values of the variables (array[i].v) in a VarArray
void swap_v_and_Vvalue ()
 swap the v's with the V->value's
void sort ()
 sorts in-place the elements by V->rv_number (topological order of the graphical model) (in the order: ancestors -> descendants)

Static Public Member Functions

static int compareRVnumbers (const RVInstance *rvi1, const RVInstance *rvi2)

Detailed Description

Definition at line 480 of file RandomVar.h.


Constructor & Destructor Documentation

PLearn::RVInstanceArray::RVInstanceArray ( )

RVInstanceArray.

Definition at line 793 of file RandomVar.cc.

    : Array<RVInstance>(0,0)
{}
PLearn::RVInstanceArray::RVInstanceArray ( int  n,
int  n_extra_allocated = 0 
)

Definition at line 797 of file RandomVar.cc.

    : Array<RVInstance>(n,n_extra)
{}
PLearn::RVInstanceArray::RVInstanceArray ( const Array< RVInstance > &  a)

Definition at line 801 of file RandomVar.cc.

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

Definition at line 804 of file RandomVar.cc.

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

Definition at line 808 of file RandomVar.cc.

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

Definition at line 815 of file RandomVar.cc.

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

Member Function Documentation

int PLearn::RVInstanceArray::compareRVnumbers ( const RVInstance rvi1,
const RVInstance rvi2 
) [static]

Definition at line 864 of file RandomVar.cc.

References PLearn::RVInstance::V.

Referenced by sort().

{
    return rvi1->V->rv_number - rvi2->V->rv_number;
}

Here is the caller graph for this function:

VarArray PLearn::RVInstanceArray::instances ( ) const

put all the instance values of the variables (array[i].v) in a VarArray

Definition at line 838 of file RandomVar.cc.

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

Referenced by PLearn::EM(), and operator|().

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

Here is the call graph for this function:

Here is the caller graph for this function:

int PLearn::RVInstanceArray::length ( ) const

total length of all the RV's in the array, this is generally != size()

Reimplemented from PLearn::TVec< RVInstance >.

Definition at line 824 of file RandomVar.cc.

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

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

Here is the call graph for this function:

RVInstanceArray PLearn::RVInstanceArray::operator&& ( RVInstance  rhs)

Build a chain of (RV,value) pairs.

It is used to build expressions of the form (X==x && Y==y && Z==z).

Definition at line 852 of file RandomVar.cc.

References PLearn::operator&().

{
    return PLearn::operator&(*this,(RVInstanceArray)rvi);
    //return this->operator&((RVInstanceArray)rvi);
}

Here is the call graph for this function:

ConditionalExpression PLearn::RVInstanceArray::operator| ( RVInstanceArray  rhs)

This operator is used for expressions of the form (Y==y)|(X==x && Z==z) and it acts like &&. If the expression is (Y==y && Z==z)|(X==x && U==u) then the LHS RVInstance list will be coerced into a single (RV,value) pair, with RV = Y&&Z (their joint) and value = vconcat(y & z).

Definition at line 858 of file RandomVar.cc.

References instances(), random_variables(), and PLearn::vconcat().

{ 
    return ConditionalExpression(RVInstance(random_variables(),
                                            vconcat(instances())),RHS);
}

Here is the call graph for this function:

RVArray PLearn::RVInstanceArray::random_variables ( ) const

put all the RVs in the list in a RVarray

Definition at line 845 of file RandomVar.cc.

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

Referenced by PLearn::FunctionalRandomVariable::logP(), and operator|().

                                                {
    RVArray vars(size());
    for (int i=0;i<size();i++)
        vars[i]=(*this)[i].V;
    return vars;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void PLearn::RVInstanceArray::sort ( )

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

Definition at line 872 of file RandomVar.cc.

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

Referenced by PLearn::FunctionalRandomVariable::logP().

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

Here is the call graph for this function:

Here is the caller graph for this function:

void PLearn::RVInstanceArray::swap_v_and_Vvalue ( ) [inline]

swap the v's with the V->value's

Definition at line 517 of file RandomVar.h.

References i.

Referenced by PLearn::MixtureRandomVariable::ElogP().

    { for (int i=0;i<size();i++) (*this)[i].swap_v_and_Vvalue(); }

Here is the caller graph for this function:

VarArray PLearn::RVInstanceArray::values ( ) const

put all the values of the variables (array[i].V->value) in a VarArray

Definition at line 831 of file RandomVar.cc.

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

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

Here is the call 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