codac 2.0.0
Loading...
Searching...
No Matches
codac2_OctaSym.h
Go to the documentation of this file.
1
9
10#pragma once
11
12#include <vector>
13#include "codac2_matrices.h"
14#include "codac2_Matrix.h"
16#include "codac2_CtcWrapper.h"
18#include "codac2_SampledTraj.h"
19
20namespace codac2
21{
22 class CtcAction;
23 class SepBase;
24 class SepAction;
25 class SetExpr;
26 class OctaSymOp;
27
31 class Action
32 { };
33
37 class OctaSym : public std::vector<int>, public Action
38 {
39 public:
40
41 OctaSym(std::initializer_list<int> s);
42 OctaSym(const std::vector<int>& s);
43
44 OctaSym invert() const;
45
46 OctaSym operator*(const OctaSym& s) const;
47
48 Matrix permutation_matrix() const;
49
50 template<typename Derived>
51 requires (Derived::ColsAtCompileTime == 1)
52 Mat<typename Derived::Scalar,-1,1> operator()(const Eigen::MatrixBase<Derived>& x) const
53 {
54 assert_release(x.size() == (Index)size());
55 Mat<typename Derived::Scalar,-1,1> x_(x);
56 for(size_t i = 0 ; i < size() ; i++)
57 x_[i] = sign((*this)[i])*x[std::abs((*this)[i])-1];
58 return x_;
59 }
60
61 template<typename C>
62 requires IsCtcBaseOrPtr<C,IntervalVector>
63 CtcAction operator()(const C& c) const;
64 // -> is defined in CtcAction class
65
66 template<typename S>
67 requires is_sep_v<S>
68 SepAction operator()(const S& s) const;
69 // -> is defined in SepAction class
70
71 std::shared_ptr<SetExpr> operator()(const std::shared_ptr<SetExpr>& x1) const;
72 // -> is defined in set operations file
73
74 template<typename T>
75 SampledTraj<T> operator()(const SampledTraj<T>& x) const
76 {
77 auto y = x;
78 for(auto& [ti,yi] : y)
79 yi = (*this)(yi);
80 return y;
81 }
82
83 template<typename V>
84 // To avoid ambiguity with operator()(const Eigen::MatrixBase<Derived>& x):
85 requires (std::is_same_v<V,VectorExpr> || std::is_same_v<V,VectorVar>)
86 inline VectorExpr operator()(const V& x1) const
87 {
88 if constexpr(std::is_same_v<V,VectorExpr>)
89 assert_release((Index)this->size() == x1->output_shape().first);
90 else
91 assert_release((Index)this->size() == x1.output_shape().first);
92 return { std::make_shared<AnalyticOperationExpr<OctaSymOp,VectorType,VectorType>>(*this, x1) };
93 }
94
95 friend std::ostream& operator<<(std::ostream& str, const OctaSym& s)
96 {
97 str << "(";
98 for(size_t i = 0 ; i < s.size() ; i++)
99 str << (i != 0 ? " " : "") << s[i];
100 str << ")" << std::flush;
101 return str;
102 }
103 };
104}
Scalar & operator()(Index i, Index j)
Accesses a matrix element (modifiable) by its row and column indices.
Definition codac2_Matrix_addons_Base.h:27
Definition codac2_OctaSym.h:21
Interval operator*(const Interval &x, double y)
Returns with .
Definition codac2_Interval_impl.h:435
std::ostream & operator<<(std::ostream &os, const BoolInterval &x)
Streams out a BoolInterval.
Definition codac2_BoolInterval.h:64
Eigen::Matrix< double,-1,-1 > Matrix
Alias for a dynamic-size matrix of doubles.
Definition codac2_Matrix.h:26
Interval sign(const Interval &x)
Returns .
Definition codac2_Interval_operations_impl.h:279