|
DRAKECORE_EXPORT std::ostream & | operator<< (std::ostream &os, FunctionalForm const &f) |
| Print a description of this form to the given stream. More...
|
|
DRAKECORE_EXPORT FunctionalForm | operator+ (FunctionalForm const &lhs, FunctionalForm const &rhs) |
| Return a copy of lhs updated to record addition of form rhs . More...
|
|
DRAKECORE_EXPORT FunctionalForm | operator+ (FunctionalForm const &lhs, double rhs) |
| Return a copy of lhs updated to record addition of a constant or zero. More...
|
|
DRAKECORE_EXPORT FunctionalForm | operator+ (double lhs, FunctionalForm const &rhs) |
| Return a copy of rhs updated to record its addition to a constant or zero. More...
|
|
DRAKECORE_EXPORT FunctionalForm & | operator+= (FunctionalForm &lhs, FunctionalForm const &rhs) |
| Update lhs to record addition of form rhs . More...
|
|
DRAKECORE_EXPORT FunctionalForm & | operator+= (FunctionalForm &lhs, double rhs) |
| Update lhs to record addition of a constant or zero. More...
|
|
DRAKECORE_EXPORT FunctionalForm | operator- (FunctionalForm const &lhs, FunctionalForm const &rhs) |
| Return a copy of lhs updated to record subtraction of form rhs . More...
|
|
DRAKECORE_EXPORT FunctionalForm | operator- (FunctionalForm const &lhs, double rhs) |
| Return a copy of lhs updated to record subtraction of a constant or zero. More...
|
|
DRAKECORE_EXPORT FunctionalForm | operator- (double lhs, FunctionalForm const &rhs) |
| Return a copy of rhs updated to record its subtraction from a constant or zero. More...
|
|
DRAKECORE_EXPORT FunctionalForm & | operator-= (FunctionalForm &lhs, FunctionalForm const &rhs) |
| Update lhs to record subtraction of form rhs . More...
|
|
DRAKECORE_EXPORT FunctionalForm & | operator-= (FunctionalForm &lhs, double rhs) |
| Update lhs to record subtraction of a constant or zero. More...
|
|
DRAKECORE_EXPORT FunctionalForm | operator* (FunctionalForm const &lhs, FunctionalForm const &rhs) |
| Return a copy of lhs updated to record multiplication by rhs . More...
|
|
DRAKECORE_EXPORT FunctionalForm | operator* (FunctionalForm const &lhs, double rhs) |
| Return a copy of lhs updated to record multiplication by a constant or zero. More...
|
|
DRAKECORE_EXPORT FunctionalForm | operator* (double lhs, FunctionalForm const &rhs) |
| Return a copy of rhs updated to record its multiplication of a constant or zero. More...
|
|
DRAKECORE_EXPORT FunctionalForm & | operator*= (FunctionalForm &lhs, FunctionalForm const &rhs) |
| Update lhs to record multiplication by rhs . More...
|
|
DRAKECORE_EXPORT FunctionalForm & | operator*= (FunctionalForm &lhs, double rhs) |
| Update lhs to record multiplication by a constant or zero. More...
|
|
DRAKECORE_EXPORT FunctionalForm | operator/ (FunctionalForm const &lhs, FunctionalForm const &rhs) |
| Return a copy of lhs updated to record division by rhs . More...
|
|
DRAKECORE_EXPORT FunctionalForm | operator/ (FunctionalForm const &lhs, double rhs) |
| Return a copy of lhs updated to record division by a constant or zero. More...
|
|
DRAKECORE_EXPORT FunctionalForm | operator/ (double lhs, FunctionalForm const &rhs) |
| Return a copy of rhs updated to record its division of a constant or zero. More...
|
|
DRAKECORE_EXPORT FunctionalForm & | operator/= (FunctionalForm &lhs, FunctionalForm const &rhs) |
| Update lhs to record division by rhs . More...
|
|
DRAKECORE_EXPORT FunctionalForm & | operator/= (FunctionalForm &lhs, double rhs) |
| Update lhs to record division by a constant or zero. More...
|
|
DRAKECORE_EXPORT FunctionalForm | abs (FunctionalForm const &x) |
| Return a copy of x updated to record application of an abs function. More...
|
|
DRAKECORE_EXPORT FunctionalForm | cos (FunctionalForm const &x) |
| Return a copy of x updated to record application of a cos function. More...
|
|
DRAKECORE_EXPORT FunctionalForm | exp (FunctionalForm const &x) |
| Return a copy of x updated to record application of a exp function. More...
|
|
DRAKECORE_EXPORT FunctionalForm | log (FunctionalForm const &x) |
| Return a copy of x updated to record application of a log function. More...
|
|
DRAKECORE_EXPORT FunctionalForm | sin (FunctionalForm const &x) |
| Return a copy of x updated to record application of a sin function. More...
|
|
DRAKECORE_EXPORT FunctionalForm | sqrt (FunctionalForm const &x) |
| Return a copy of x updated to record application of a sqrt function. More...
|
|
|
(Note that these are not member functions.)
|
template<typename MatrixL , typename MatrixR > |
std::enable_if< std::is_base_of< Eigen::MatrixBase< MatrixL >, MatrixL >::value &&std::is_base_of< Eigen::MatrixBase< MatrixR >, MatrixR >::value &&std::is_same< typename MatrixL::Scalar, FunctionalForm >::value &&std::is_same< typename MatrixR::Scalar, double >::value, typename MatrixL::PlainObject >::type | operator+ (MatrixL const &lhs, MatrixR const &rhs) |
|
template<typename MatrixL , typename MatrixR > |
std::enable_if< std::is_base_of< Eigen::MatrixBase< MatrixL >, MatrixL >::value &&std::is_base_of< Eigen::MatrixBase< MatrixR >, MatrixR >::value &&std::is_same< typename MatrixL::Scalar, double >::value &&std::is_same< typename MatrixR::Scalar, FunctionalForm >::value, typename MatrixR::PlainObject >::type | operator+ (MatrixL const &lhs, MatrixR const &rhs) |
|
template<typename MatrixL , typename MatrixR > |
std::enable_if< std::is_base_of< Eigen::MatrixBase< MatrixL >, MatrixL >::value &&std::is_base_of< Eigen::MatrixBase< MatrixR >, MatrixR >::value &&std::is_same< typename MatrixL::Scalar, FunctionalForm >::value &&std::is_same< typename MatrixR::Scalar, double >::value, MatrixL & >::type | operator+= (MatrixL &lhs, MatrixR const &rhs) |
|
template<typename MatrixL , typename MatrixR > |
std::enable_if< std::is_base_of< Eigen::MatrixBase< MatrixL >, MatrixL >::value &&std::is_base_of< Eigen::MatrixBase< MatrixR >, MatrixR >::value &&std::is_same< typename MatrixL::Scalar, FunctionalForm >::value &&std::is_same< typename MatrixR::Scalar, double >::value, typename MatrixL::PlainObject >::type | operator- (MatrixL const &lhs, MatrixR const &rhs) |
|
template<typename MatrixL , typename MatrixR > |
std::enable_if< std::is_base_of< Eigen::MatrixBase< MatrixL >, MatrixL >::value &&std::is_base_of< Eigen::MatrixBase< MatrixR >, MatrixR >::value &&std::is_same< typename MatrixL::Scalar, double >::value &&std::is_same< typename MatrixR::Scalar, FunctionalForm >::value, typename MatrixR::PlainObject >::type | operator- (MatrixL const &lhs, MatrixR const &rhs) |
|
template<typename MatrixL , typename MatrixR > |
std::enable_if< std::is_base_of< Eigen::MatrixBase< MatrixL >, MatrixL >::value &&std::is_base_of< Eigen::MatrixBase< MatrixR >, MatrixR >::value &&std::is_same< typename MatrixL::Scalar, FunctionalForm >::value &&std::is_same< typename MatrixR::Scalar, double >::value, MatrixL & >::type | operator-= (MatrixL &lhs, MatrixR const &rhs) |
|
template<typename MatrixL , typename MatrixR > |
std::enable_if< std::is_base_of< Eigen::MatrixBase< MatrixL >, MatrixL >::value &&std::is_base_of< Eigen::MatrixBase< MatrixR >, MatrixR >::value &&std::is_same< typename MatrixL::Scalar, FunctionalForm >::value &&std::is_same< typename MatrixR::Scalar, double >::value, Eigen::Matrix< FunctionalForm, MatrixL::RowsAtCompileTime, MatrixR::ColsAtCompileTime > >::type | operator* (MatrixL const &lhs, MatrixR const &rhs) |
|
template<typename MatrixL , typename MatrixR > |
std::enable_if< std::is_base_of< Eigen::MatrixBase< MatrixL >, MatrixL >::value &&std::is_base_of< Eigen::MatrixBase< MatrixR >, MatrixR >::value &&std::is_same< typename MatrixL::Scalar, double >::value &&std::is_same< typename MatrixR::Scalar, FunctionalForm >::value, Eigen::Matrix< FunctionalForm, MatrixL::RowsAtCompileTime, MatrixR::ColsAtCompileTime > >::type | operator* (MatrixL const &lhs, MatrixR const &rhs) |
|
template<typename MatrixL > |
std::enable_if< std::is_base_of< Eigen::MatrixBase< MatrixL >, MatrixL >::value &&std::is_same< typename MatrixL::Scalar, FunctionalForm >::value, typename MatrixL::PlainObject >::type | operator* (MatrixL const &lhs, double rhs) |
|
template<typename MatrixR > |
std::enable_if< std::is_base_of< Eigen::MatrixBase< MatrixR >, MatrixR >::value &&std::is_same< typename MatrixR::Scalar, FunctionalForm >::value, typename MatrixR::PlainObject >::type | operator* (double lhs, MatrixR const &rhs) |
|
template<typename MatrixL > |
std::enable_if< std::is_base_of< Eigen::MatrixBase< MatrixL >, MatrixL >::value &&std::is_same< typename MatrixL::Scalar, FunctionalForm >::value, MatrixL & >::type | operator*= (MatrixL &lhs, double rhs) |
|
template<typename MatrixL > |
std::enable_if< std::is_base_of< Eigen::MatrixBase< MatrixL >, MatrixL >::value &&std::is_same< typename MatrixL::Scalar, FunctionalForm >::value, typename MatrixL::PlainObject >::type | operator/ (MatrixL const &lhs, double rhs) |
|
template<typename MatrixL > |
std::enable_if< std::is_base_of< Eigen::MatrixBase< MatrixL >, MatrixL >::value &&std::is_same< typename MatrixL::Scalar, FunctionalForm >::value, MatrixL & >::type | operator/= (MatrixL &lhs, double rhs) |
|
Represent an abstract form of a function of zero or more variables.
We define a functional form to be a set of input variables along with an abstract description of how the variables are combined to express the output. The form may be one of:
- A zero value with no variables (
0
).
- A constant value with no variables (
c
).
- A linear combination of one or more variables (
b'*x
).
- An affine combination of one or more variables (
b'*x + c
).
- A polynomial combination of one or more variables (
... + x'*A*x + b'*x + c
).
- A differentiable (almost everywhere) combination of one or more variables (
f(x)
such that f'(x)
exists for almost all x
in the domain of interest).
- An arbitrary combination of one or more variables (
f(x)
).
- An undefined combination of zero or more variables (
f(x)
where f
contains an undefined operation).
Each variable is represented by an instance of the Variable class which serves as a placeholder providing a distinguishing identifier. We do not represent any details about how an individual variable appears in the combination of one of the above forms, only that it participates.
FunctionalForm instances may be used in mathematical expressions to form new instances representing the form of the combined expression. For example:
std::cout << (
x *
x) <<
"\n";
std::cout << (
x + c) <<
"\n";
std::cout << (
x * c) <<
"\n";
std::cout << (
x + 2) <<
"\n";
std::cout << (
x * 2) <<
"\n";
std::cout << (
x + 0) <<
"\n";
std::cout << (
x * 0) <<
"\n";
This class is therefore suitable for use as a scalar type to call a function template to extract its functional form with respect to some set of its inputs. For example:
template <
typename S> S f(S
x, S y) {
return x + y; }
template <
typename S> S g(S
x, S y) {
return x * y; }
std::cout << f(2, 3) << "\n";
std::cout << f(x, y) << "\n";
std::cout << f(x, c) << "\n";
std::cout << g(2, 3) << "\n";
std::cout << g(x, y) << "\n";
std::cout << g(x, c) << "\n";
Composition is supported naturally:
std::cout << f(g(x,c), y) << "\n";
std::cout << f(g(x,c), c) << "\n";
std::cout << f(g(x,y), c) << "\n";
std::cout << f(g(c,c), c) << "\n";
A few basic mathematical functions are also supported:
std::cout <<
sin(x) <<
"\n";
See documentation of associated functions for those supported.
FunctionalForm may also be used as the scalar type of an Eigen::Matrix<>
. Basic matrix and vector expressions are supported.