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

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)}'.
 
- Public Member Functions inherited from creativity::data::UnaryExpr
virtual unsigned int size () const override
 Returns the size of the unary expression, if the variable has a size. More...
 
- 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< Exponentialcreate (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).
 
- Protected Member Functions inherited from creativity::data::UnaryExpr
 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.
 
- Protected Attributes inherited from creativity::data::UnaryExpr
std::shared_ptr< const Variablevar_
 The underlying unary variable.
 

Detailed Description

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.

Constructor & Destructor Documentation

§ Exponential()

creativity::data::Exponential::Exponential ( double  base,
const std::shared_ptr< const Variable > &  var 
)
protected

Wraps around a Variable to provide exponentiation of the variable's values.

Member Function Documentation

§ name()

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

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

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