creativity
v1.3.0
Agent-based model of creativity and piracy
|
Special Variable subclass for representing a constant value. More...
#include <creativity/data/Variable.hpp>
Public Member Functions | |
virtual void | populate (Eigen::Ref< Eigen::VectorXd > column, unsigned int offset=0, unsigned int trim=0) const override |
Copies the constant into the given column positions. | |
virtual std::string | name () const override |
Returns a name. More... | |
virtual std::string | nameBracketed (const std::string &="(", const std::string &=")") const override |
Overridden to not bracket the name. | |
const double & | value () const |
Accesses the constant value. | |
unsigned int | size () const override |
Throws a SizeError exception (a ConstantVariable has no intrinsic size) | |
![]() | |
virtual | ~Variable ()=default |
Virtual destructor. | |
Eigen::VectorXd | values (unsigned int rows=0, unsigned int offset=0, unsigned int trim=0) const |
Shortcut wrapper around populate that creates a new column of the given size, calls populate() with it, then returns it. More... | |
Static Public Member Functions | |
template<class... Args> | |
static std::shared_ptr< ConstantVariable > | create (Args... args) |
Forwards arguments to the protected constructor and returns a shared_ptr to the created object. | |
Protected Member Functions | |
ConstantVariable ()=default | |
Default constructor creates a constant with the value 1.0. | |
ConstantVariable (double c) | |
Creates a constant with the given value (this constructor also allows implicit conversion of a double to a ConstantVariable). | |
Special Variable subclass for representing a constant value.
When populating, the constant will be copied into every requested position of the given column.
|
overridevirtual |
Returns a name.
If the constant is 1.0, returns "const"; if 0.0, returns "noconst"; otherwise returns to_string(constant)
.
Implements creativity::data::Variable.