|
PLearn 0.1
|
#include <SampleVariable.h>


Public Member Functions | |
| DiagonalNormalSampleVariable (Variable *mu, Variable *sigma) | |
| virtual DiagonalNormalSampleVariable * | deepCopy (CopiesMap &copies) const |
| virtual string | classname () const |
| virtual void | fprop () |
| compute output given input | |
Definition at line 117 of file SampleVariable.h.
| PLearn::DiagonalNormalSampleVariable::DiagonalNormalSampleVariable | ( | Variable * | mu, |
| Variable * | sigma | ||
| ) |
Definition at line 169 of file SampleVariable.cc.
References PLearn::Variable::isScalar(), PLearn::Variable::length(), PLERROR, and PLearn::Variable::width().
Referenced by deepCopy().
:BinarySampleVariable(mu, sigma, mu->length(), mu->width()) { if (!sigma->isScalar() && (mu->length()!=sigma->length() || mu->width()!=sigma->width()) ) PLERROR("DiagonalNormalSampleVariable: mu(%d,%d) incompatible with sigma(%d,%d)", mu->length(),mu->width(),sigma->length(),sigma->width()); }


| string PLearn::DiagonalNormalSampleVariable::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::BinarySampleVariable.
Definition at line 165 of file SampleVariable.cc.
{ return "DiagonalNormalSampleVariable"; }
| DiagonalNormalSampleVariable * PLearn::DiagonalNormalSampleVariable::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::BinaryVariable.
Definition at line 177 of file SampleVariable.cc.
References DiagonalNormalSampleVariable(), and PLearn::BinaryVariable::makeDeepCopyFromShallowCopy().
{
CopiesMap::iterator it = copies.find(this);
if (it!=copies.end()) // a copy already exists, so return it
return (DiagonalNormalSampleVariable*)it->second;
// Otherwise call the copy constructor to obtain a SHALLOW copy
DiagonalNormalSampleVariable* deep_copy = new DiagonalNormalSampleVariable(*this);
// Put the copy in the map
copies[this] = deep_copy;
// Transform the shallow copy into a deep copy
deep_copy->makeDeepCopyFromShallowCopy(copies);
// return the completed deep_copy
return deep_copy;
}

| void PLearn::DiagonalNormalSampleVariable::fprop | ( | ) | [virtual] |
compute output given input
Implements PLearn::Variable.
Definition at line 193 of file SampleVariable.cc.
References PLearn::gaussian_mu_sigma(), PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, PLearn::Variable::length(), and PLearn::Variable::valuedata.
{
if (input2->isScalar())
{
real sigma = input2->valuedata[0];
for (int k=0;k<length();k++)
valuedata[k] = gaussian_mu_sigma(input1->valuedata[k],
sigma);
}
else
for (int k=0;k<length();k++)
valuedata[k] = gaussian_mu_sigma(input1->valuedata[k],
input2->valuedata[k]);
}

1.7.4