#include <config.h>
#include <graph/ConstantNode.h>
#include <graph/NodeNameTab.h>
#include <sstream>
#include <cmath>
using std::string;
using std::ostringstream;
using std::floor;
ConstantNode::ConstantNode(double value)
: Node(Index(1))
{
data.setValue(&value, 1);
data.setFixed(true);
if (value == floor(value)) {
data.setDiscreteValued(true);
}
}
void ConstantNode::forwardSample()
{
}
string ConstantNode::name(NodeNameTab const &name_table) const
{
string name = name_table.getName(this);
if (!name.empty())
return name;
ostringstream os;
os << *data.value();
return os.str();
}
bool ConstantNode::isStochastic() const { return true; }
syntax highlighted by Code2HTML, v. 0.9.1