12template <
typename Base>
struct slice_impl_tpl;
20template <
typename Scalar,
typename Base = StageFunctionTpl<Scalar>>
23template <
typename Scalar>
26 detail::slice_impl_tpl<StageFunctionTpl<Scalar>> {
30 using SliceImpl = detail::slice_impl_tpl<StageFunctionTpl<Scalar>>;
34 std::vector<int>
const &indices)
35 :
Base(func->
ndx1, func->
nu, (int)indices.size())
41 void evaluate(
const ConstVectorRef &x,
const ConstVectorRef &u,
44 this->evaluate_impl(data, x, u);
49 this->computeJacobians_impl(data, x, u);
53 const ConstVectorRef &u,
54 const ConstVectorRef &lbda,
56 this->computeVectorHessianProducts_impl(data, lbda, x, u);
60 return std::make_shared<Data>(*
this);
64template <
typename Scalar>
67 detail::slice_impl_tpl<UnaryFunctionTpl<Scalar>> {
72 using SliceImpl = detail::slice_impl_tpl<UnaryFunctionTpl<Scalar>>;
75 std::vector<int>
const &indices)
76 :
Base(func->
ndx1, func->
nu, (int)indices.size())
84 this->evaluate_impl(data, x);
89 this->computeJacobians_impl(data, x);
93 const ConstVectorRef &lbda,
95 this->computeVectorHessianProducts_impl(data, lbda, x);
99 return std::make_shared<Data>(*
this);
103template <
typename Scalar>
111 template <
typename Base>
120template <
typename Base>
struct slice_impl_tpl {
121 using Scalar =
typename Base::Scalar;
123 using BaseData = StageFunctionDataTpl<Scalar>;
125 using Data = FunctionSliceDataTpl<Scalar>;
127 xyz::polymorphic<Base> func;
129 std::vector<int> indices;
131 slice_impl_tpl(xyz::polymorphic<Base> func, std::vector<int>
const &indices);
132 slice_impl_tpl(xyz::polymorphic<Base> func,
int idx);
135 template <
typename... Args>
136 void evaluate_impl(BaseData &data, Args &&...args)
const;
138 template <
typename... Args>
139 void computeJacobians_impl(BaseData &data, Args &&...args)
const;
141 template <
typename... Args>
142 void computeVectorHessianProducts_impl(BaseData &data,
143 const ConstVectorRef &lbda,
144 Args &&...args)
const;
150#include "aligator/modelling/function-xpr-slice.hxx"
152#ifdef ALIGATOR_ENABLE_TEMPLATE_INSTANTIATION
153#include "aligator/modelling/function-xpr-slice.txx"
Base definitions for ternary functions.
#define ALIGATOR_DYNAMIC_TYPEDEFS(Scalar)
ALIGATOR_DYNAMIC_TYPEDEFS(Scalar)
shared_ptr< BaseData > sub_data
FunctionSliceDataTpl(FunctionSliceXprTpl< Scalar, Base > const &obj)
StageFunctionDataTpl< Scalar > BaseData
Base residual's data object.
FunctionSliceXprTpl(xyz::polymorphic< Base > func, const int idx)
void computeVectorHessianProducts(const ConstVectorRef &x, const ConstVectorRef &u, const ConstVectorRef &lbda, BaseData &data) const override
Compute the vector-hessian products of this function.
StageFunctionTpl< Scalar > Base
FunctionSliceDataTpl< Scalar > Data
shared_ptr< BaseData > createData() const override
Instantiate a Data object.
void evaluate(const ConstVectorRef &x, const ConstVectorRef &u, BaseData &data) const override
Evaluate the function.
void computeJacobians(const ConstVectorRef &x, const ConstVectorRef &u, BaseData &data) const override
Compute Jacobians of this function.
ALIGATOR_DYNAMIC_TYPEDEFS(Scalar)
FunctionSliceXprTpl(xyz::polymorphic< Base > func, std::vector< int > const &indices)
StageFunctionDataTpl< Scalar > BaseData
detail::slice_impl_tpl< StageFunctionTpl< Scalar > > SliceImpl
ALIGATOR_UNARY_FUNCTION_INTERFACE(Scalar)
void computeJacobians(const ConstVectorRef &x, BaseData &data) const override
detail::slice_impl_tpl< UnaryFunctionTpl< Scalar > > SliceImpl
StageFunctionDataTpl< Scalar > BaseData
FunctionSliceXprTpl(xyz::polymorphic< Base > func, const int idx)
ALIGATOR_DYNAMIC_TYPEDEFS(Scalar)
void evaluate(const ConstVectorRef &x, BaseData &data) const override
FunctionSliceDataTpl< Scalar > Data
void computeVectorHessianProducts(const ConstVectorRef &x, const ConstVectorRef &lbda, BaseData &data) const override
FunctionSliceXprTpl(xyz::polymorphic< Base > func, std::vector< int > const &indices)
shared_ptr< BaseData > createData() const override
Instantiate a Data object.
Represents a function of which the output is a subset of another function, for instance where is gi...
Base struct for function data.
StageFunctionDataTpl(const int ndx, const int nu, const int nr)
StageFunctionTpl(const int ndx, const int nu, const int nr)
Represents unary functions of the form , with no control (or next-state) arguments.
StageFunctionTpl< Scalar > Base