creativity  v1.3.0
Agent-based model of creativity and piracy
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
creativity::data::ConstantVariable Class Referencefinal

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)
 
- Public Member Functions inherited from creativity::data::Variable
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< ConstantVariablecreate (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).
 

Detailed Description

Special Variable subclass for representing a constant value.

When populating, the constant will be copied into every requested position of the given column.

Member Function Documentation

§ name()

virtual std::string creativity::data::ConstantVariable::name ( ) const
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.

Inheritance diagram for creativity::data::ConstantVariable:
[legend]
Collaboration diagram for creativity::data::ConstantVariable:
[legend]

The documentation for this class was generated from the following file: