22 using FunctionSliceXpr = FunctionSliceXprTpl<Scalar, Base>;
24 bp::register_ptr_to_python<shared_ptr<FunctionSliceXpr>>();
25 bp::class_<FunctionSliceXpr, bp::bases<Base>>(
27 "Represents a slice of an expression according to either a single index "
28 "or an array of indices.",
29 bp::init<shared_ptr<Base>, std::vector<int>
const &>(
30 bp::args(
"self",
"func",
"indices")))
31 .def(bp::init<shared_ptr<Base>,
const int>(
32 "Constructor from a single index.", bp::args(
"self",
"func",
"idx")))
33 .def_readonly(
"func", &FunctionSliceXpr::func,
"Underlying function.")
34 .def_readonly(
"indices", &FunctionSliceXpr::indices,
35 "Indices of the slice.");
70 exposeSliceExpression<StageFunction>(
"StageFunctionSliceXpr");
71 exposeSliceExpression<UnaryFunction>(
"UnaryFunctionSliceXpr");
73 using FunctionSliceData = FunctionSliceDataTpl<Scalar>;
74 bp::class_<FunctionSliceData, bp::bases<StageFunctionData>,
75 boost::noncopyable>(
"FunctionSliceData", bp::no_init)
76 .def_readonly(
"sub_data", &FunctionSliceData::sub_data,
77 "Underlying function's data.");
81 using LinearFunctionComposition = LinearFunctionCompositionTpl<Scalar>;
82 using LinearUnaryFunctionComposition =
83 LinearUnaryFunctionCompositionTpl<Scalar>;
85 bp::register_ptr_to_python<shared_ptr<LinearFunctionComposition>>();
86 bp::class_<LinearFunctionComposition, bp::bases<StageFunction>>(
87 "LinearFunctionComposition",
88 "Function composition :math:`r(x) = Af(x, u, y) + b`.", bp::no_init)
89 .def(LinFunctionCompositionVisitor<LinearFunctionComposition>());
91 bp::register_ptr_to_python<shared_ptr<LinearUnaryFunctionComposition>>();
92 bp::class_<LinearUnaryFunctionComposition, bp::bases<UnaryFunction>>(
93 "LinearUnaryFunctionComposition",
94 "Function composition for unary functions: :math:`r(x) = Af(x) + b`.",
96 .def(LinFunctionCompositionVisitor<LinearUnaryFunctionComposition>());
StageFunctionTpl< Scalar > StageFunction
UnaryFunctionTpl< Scalar > UnaryFunction
StageFunctionDataTpl< Scalar > StageFunctionData
auto linear_compose(shared_ptr< StageFunctionTpl< Scalar > > func, const typename math_types< Scalar >::ConstMatrixRef A, const typename math_types< Scalar >::ConstVectorRef b)
Create a linear composition of the input function func.