creativity
v1.3.0
Agent-based model of creativity and piracy
|
Raises a base value to a Variable's 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 |
Calculates and stores the exponential values. | |
virtual std::string | name () const override |
Returns a string representation of the variable. More... | |
virtual std::string | nameBracketed (const std::string &bracketL="(", const std::string &bracketR=")") const override |
Returns the name of the variable such as '{2^name}' or 'exp(name)' or '{2^log(name)}'. | |
![]() | |
virtual unsigned int | size () const override |
Returns the size of the unary expression, if the variable has a size. More... | |
![]() | |
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< Exponential > | create (Args... args) |
Forwards arguments to the protected constructor and returns a shared_ptr to the created object. | |
Protected Member Functions | |
Exponential (double base, const std::shared_ptr< const Variable > &var) | |
Wraps around a Variable to provide exponentiation of the variable's values. More... | |
Exponential (const std::shared_ptr< const Variable > &var) | |
Wraps around a Variable to provide exponentiation of the variable's values using Euler's number (e). | |
![]() | |
UnaryExpr ()=delete | |
Not default-constructible. | |
UnaryExpr (const std::shared_ptr< const Variable > &var) | |
Constructs a unary variable. | |
Protected Attributes | |
double | base_ |
The power to which to raise the variable. | |
![]() | |
std::shared_ptr< const Variable > | var_ |
The underlying unary variable. | |
Raises a base value to a Variable's value.
This uses std::pow for exponentiation except in the special cases where base == std::exp(1)
and base == 2
, where std::exp and std::exp2 are used instead.
The class can be used explicitly, but a specializations of std::pow(base, var)
, std::exp(var)
, and std::exp2(var)
and an overload of double ^ var
are also available.
|
protected |
Wraps around a Variable to provide exponentiation of the variable's values.
|
overridevirtual |
Returns a string representation of the variable.
If the base equals std::exp(1)
, this is "exp(name)"; otherwise the name is "base^name", with parentheses added to name if it is a complex variable.
Implements creativity::data::Variable.