proxsuite-nlp  0.10.0
A primal-dual augmented Lagrangian-type solver for nonlinear programming on manifolds.
Loading...
Searching...
No Matches
vector-space.hpp
Go to the documentation of this file.
1#pragma once
2
4
5#include <type_traits>
6
7namespace proxsuite {
8namespace nlp {
9
11template <typename _Scalar, int _Dim, int _Options>
12struct VectorSpaceTpl : public ManifoldAbstractTpl<_Scalar, _Options> {
13 using Scalar = _Scalar;
14 enum { Dim = _Dim, Options = _Options };
17
18 int dim_;
19
21 template <int N = Dim,
22 typename = typename std::enable_if_t<N == Eigen::Dynamic>>
23 VectorSpaceTpl(const int dim) : dim_(dim) {}
24
28 template <int N = Dim,
29 typename = typename std::enable_if_t<N != Eigen::Dynamic>>
31
32 inline int nx() const { return dim_; }
33 inline int ndx() const { return dim_; }
34
36
37 /* Integrate */
38
39 void integrate_impl(const ConstVectorRef &x, const ConstVectorRef &v,
40 VectorRef out) const {
41 out = x + v;
42 }
43
44 void Jintegrate_impl(const ConstVectorRef &, const ConstVectorRef &,
45 MatrixRef Jout, int) const {
46 Jout.setIdentity();
47 }
48
49 void JintegrateTransport(const ConstVectorRef &, const ConstVectorRef &,
50 MatrixRef, int) const {}
51
52 /* Difference */
53
54 void difference_impl(const ConstVectorRef &x0, const ConstVectorRef &x1,
55 VectorRef out) const {
56 out = x1 - x0;
57 }
58
59 void Jdifference_impl(const ConstVectorRef &, const ConstVectorRef &,
60 MatrixRef Jout, int arg) const {
61 switch (arg) {
62 case 0:
63 Jout = -MatrixXs::Identity(ndx(), ndx());
64 break;
65 case 1:
66 Jout.setIdentity();
67 break;
68 default:
69 throw std::runtime_error("Wrong arg value.");
70 }
71 }
72
73 void interpolate_impl(const ConstVectorRef &x0, const ConstVectorRef &x1,
74 const Scalar &u, VectorRef out) const {
75 out = u * x1 + (static_cast<Scalar>(1.) - u) * x0;
76 }
77};
78
79} // namespace nlp
80} // namespace proxsuite
#define PROXSUITE_NLP_DYNAMIC_TYPEDEFS(Scalar)
Definition math.hpp:26
Main package namespace.
Definition bcl-params.hpp:5
Standard Euclidean vector space.
void JintegrateTransport(const ConstVectorRef &, const ConstVectorRef &, MatrixRef, int) const
Perform the parallel transport operation.
int nx() const
Get manifold representation dimension.
void interpolate_impl(const ConstVectorRef &x0, const ConstVectorRef &x1, const Scalar &u, VectorRef out) const
Interpolation operation.
void Jintegrate_impl(const ConstVectorRef &, const ConstVectorRef &, MatrixRef Jout, int) const
void difference_impl(const ConstVectorRef &x0, const ConstVectorRef &x1, VectorRef out) const
Implementation of the manifold retraction operation.
void Jdifference_impl(const ConstVectorRef &, const ConstVectorRef &, MatrixRef Jout, int arg) const
VectorSpaceTpl(const int dim)
Default constructor where the dimension is supplied.
int ndx() const
Get manifold tangent space dimension.
void integrate_impl(const ConstVectorRef &x, const ConstVectorRef &v, VectorRef out) const
Perform the manifold integration operation.
VectorSpaceTpl()
Default constructor without arguments.