codac 1.5.6
|
A base class for functions (either analytic functions, or set functions). More...
#include <codac2_FunctionBase.h>
Public Member Functions | |
FunctionBase (const std::vector< std::reference_wrapper< VarBase > > &args, const std::shared_ptr< E > &y) | |
Constructs a FunctionBase with a list of arguments and a shared pointer to an output expression. | |
FunctionBase (const FunctionArgsList &args, const std::shared_ptr< E > &y) | |
Constructs a FunctionBase with a list of arguments and a shared pointer to an output expression. | |
FunctionBase (const FunctionBase< E > &f) | |
Copy constructor. | |
virtual | ~FunctionBase () |
Virtual destructor. | |
const FunctionArgsList & | args () const |
Returns the arguments of the function. | |
const std::shared_ptr< E > & | expr () const |
Returns the expression associated with the function. | |
template<typename... X> | |
std::shared_ptr< E > | operator() (const X &... x) const |
Applies this function to the arguments and returns the resulting expression. | |
std::shared_ptr< E > | operator() (const std::vector< std::shared_ptr< ExprBase > > &x) const |
Applies this function to the arguments and returns the resulting expression. | |
Index | input_size () const |
Calculates the total size of the function arguments, as the sum of the sizes of each argument. | |
Protected Member Functions | |
template<typename X> | |
std::shared_ptr< X > | __get_copy (std::shared_ptr< X > x) const |
Helper function to get a copy of a an expression. | |
template<typename X> | |
std::shared_ptr< ExprBase > | __get_copy (const AnalyticExprWrapper< X > &x) const |
Helper function to get a copy of an AnalyticExprWrapper . | |
template<typename A> | |
auto | __get_copy (const A &x) const |
Helper function to get a copy of various expression types. | |
Protected Attributes | |
const std::shared_ptr< E > | _y |
expression that defines the function | |
const FunctionArgsList | _args |
arguments of the function | |
A base class for functions (either analytic functions, or set functions).
The FunctionBase
class represents a generic function that operates on expressions. It allows defining functions that take a list of arguments and apply a specific expression to those arguments.
This class serves as a base for creating specific types of functions by providing the mechanism to handle arguments and perform the function application.
Note that a function may be invoked in another expression, by using the operator()
which allows compositions of functions. For such call, the arguments of this operator are either other function variables or any expressions.
E | The type of the output expression of this function. |
|
inline |
Constructs a FunctionBase
with a list of arguments and a shared pointer to an output expression.
The arguments are stored as a FunctionArgsList
, and the expression is deep-copied.
args | A reference to a vector of VarBase references representing the function's arguments. |
y | A shared pointer to the expression that defines the function. |
|
inline |
Constructs a FunctionBase
with a list of arguments and a shared pointer to an output expression.
The expression is deep-copied.
args | A FunctionArgsList containing the function's arguments. |
y | A shared pointer to the function's expression. |
|
inline |
Copy constructor.
The expression is deep-copied.
f | The FunctionBase instance to copy. |
|
inlinevirtual |
Virtual destructor.
The destructor is virtual to ensure proper cleanup of derived classes when an object of a derived class is deleted through a pointer to FunctionBase
.
|
inline |
Returns the arguments of the function.
FunctionArgsList
containing the function's arguments.
|
inline |
Returns the expression associated with the function.
|
inline |
Applies this function to the arguments and returns the resulting expression.
The method deep-copies the expressions provided as arguments and replaces the arguments in the expression with the provided ones.
x | The arguments to apply to the function, for instance expressions or variables. |
|
inline |
Applies this function to the arguments and returns the resulting expression.
The method deep-copies the expressions provided as arguments and replaces the arguments in the expression with the provided ones.
This method is mainly used for Python binding.
x | A vector of shared pointers to arguments to apply to the function, for instance expressions or variables. |
|
inline |
Calculates the total size of the function arguments, as the sum of the sizes of each argument.
|
inlineprotected |
Helper function to get a copy of a an expression.
X | The type of the expression to copy. |
x | A shared pointer to the expression to copy. |
|
inlineprotected |
Helper function to get a copy of an AnalyticExprWrapper
.
X | The type of the expression to copy. |
x | The AnalyticExprWrapper to copy. |
|
inlineprotected |
Helper function to get a copy of various expression types.
A | The type of the expression. |
x | The expression to copy. |