proxsuite-nlp  0.11.0
A primal-dual augmented Lagrangian-type solver for nonlinear programming on manifolds.
 
Loading...
Searching...
No Matches
cost-sum.hxx
Go to the documentation of this file.
1
3#pragma once
4
6
7namespace proxsuite {
8namespace nlp {
9
10template <typename Scalar>
11auto operator+(const shared_ptr<CostFunctionBaseTpl<Scalar>> &left,
12 const shared_ptr<CostFunctionBaseTpl<Scalar>> &right) {
13 assert((left->nx() == right->nx()) && (left->ndx() == right->ndx()) &&
14 "Left and right should have the same input spaces.");
15 auto out = std::make_shared<CostSumTpl<Scalar>>(left->nx(), left->ndx());
16 *out += left;
17 *out += right;
18 return out;
19}
20
21// left is rvalue reference, so we modify it, return a move of the left after
22// adding right
23template <typename Scalar>
24auto &&operator+(shared_ptr<CostSumTpl<Scalar>> &&left,
25 const shared_ptr<CostFunctionBaseTpl<Scalar>> &right) {
26 *left += right;
27 return std::move(left);
28}
29
30// create a CostSum object with the desired weight
31template <typename Scalar>
32auto operator*(Scalar left,
33 const shared_ptr<CostFunctionBaseTpl<Scalar>> &right) {
34 auto out = std::make_shared<CostSumTpl<Scalar>>(right->nx(), right->ndx());
35 out->addComponent(right, left);
36 return out;
37}
38} // namespace nlp
39} // namespace proxsuite
Main package namespace.
Definition bcl-params.hpp:5
Base class for differentiable cost functions.
Defines the sum of one or more cost functions .
Definition cost-sum.hpp:12