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::Power Class Reference

Raises a Variable's values to a power. 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 raised values.
 
virtual std::string name () const override
 Returns the concatenation the underlying Variable name() with "^" and the power. More...
 
- 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.
 
virtual std::string nameBracketed (const std::string &bracketL="(", const std::string &bracketR=")") const
 Returns a name for this variable, but with surrounding brackets if this variable needs it–for example, for a multiplication of two variables. More...
 
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< Powercreate (Args... args)
 Forwards arguments to the protected constructor and returns a shared_ptr to the created object.
 

Protected Member Functions

 Power ()=delete
 Not default constructible.
 
 Power (const std::shared_ptr< const Variable > &var, double power)
 Wraps around a Variable to provide exponentiation of the variable's values. More...
 
- 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 power_
 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 Variable's values to a power.

This is done using std::pow unless the power is one of the special values -1, 0.5, 1, 2, or 3.

The class can be used explicitly, but a specialization of std::pow(var, power) and an overload of var ^ double are also available.

Constructor & Destructor Documentation

§ Power()

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

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

Member Function Documentation

§ name()

virtual std::string creativity::data::Power::name ( ) const
overridevirtual

Returns the concatenation the underlying Variable name() with "^" and the power.

If V is something other than SimpleVariable or ConstantVariable, the underlying name is also surrounded by parentheses.

Implements creativity::data::Variable.

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

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