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
38 class OctaSym : public std::vector<int>, public Action
39 {
40 public:
41
48 OctaSym(std::initializer_list<int> s);
49
56 OctaSym(const std::vector<int>& s);
57
63 OctaSym invert() const;
64
71 OctaSym operator*(const OctaSym& s) const;
72
79
86 template<typename Derived>
87 requires (Derived::ColsAtCompileTime == 1)
88 Mat<typename Derived::Scalar,-1,1> operator()(const Eigen::MatrixBase<Derived>& x) const
89 {
90 assert_release(x.size() == (Index)size());
91 Mat<typename Derived::Scalar,-1,1> x_(x);
92 for(size_t i = 0 ; i < size() ; i++)
93 x_[i] = sign((*this)[i])*x[std::abs((*this)[i])-1];
94 return x_;
95 }
96
103 template<typename C>
104 requires IsCtcBaseOrPtr<C,IntervalVector>
105 CtcAction operator()(const C& c) const;
106 // -> is defined in CtcAction class
107
114 template<typename S>
115 requires is_sep_v<S>
116 SepAction operator()(const S& s) const;
117 // -> is defined in SepAction class
118
125 std::shared_ptr<SetExpr> operator()(const std::shared_ptr<SetExpr>& x1) const;
126 // -> is defined in set operations file
127
128 template<typename T>
129 SampledTraj<T> operator()(const SampledTraj<T>& x) const
130 {
131 auto y = x;
132 for(auto& [ti,yi] : y)
133 yi = (*this)(yi);
134 return y;
135 }
136
143 template<typename V>
144 // To avoid ambiguity with operator()(const Eigen::MatrixBase<Derived>& x):
145 requires (std::is_same_v<V,VectorExpr> || std::is_same_v<V,VectorVar>)
146 inline VectorExpr operator()(const V& x1) const
147 {
148 if constexpr(std::is_same_v<V,VectorExpr>)
149 assert_release((Index)this->size() == x1->output_shape().first);
150 else
151 assert_release((Index)this->size() == x1.output_shape().first);
152 return { std::make_shared<AnalyticOperationExpr<OctaSymOp,VectorType,VectorType>>(*this, x1) };
153 }
154
162 friend std::ostream& operator<<(std::ostream& str, const OctaSym& s)
163 {
164 str << "(";
165 for(size_t i = 0 ; i < s.size() ; i++)
166 str << (i != 0 ? " " : "") << s[i];
167 str << ")" << std::flush;
168 return str;
169 }
170 };
171}
OctaSym operator*(const OctaSym &s) const
Composes the hyperoctahedral symmetry with another one.
OctaSym(const std::vector< int > &s)
Constructs an hyperoctahedral symmetry from a vector of integers. The vector represents the second li...
Matrix permutation_matrix() const
Computes the permutation matrix associated to the hyperoctahedral symmetry.
OctaSym invert() const
Inverts of the hyperoctahedral symmetry.
OctaSym(std::initializer_list< int > s)
Constructs an hyperoctahedral symmetry from a list of integers. The list represents the second line i...
Mat< typename Derived::Scalar,-1, 1 > operator()(const Eigen::MatrixBase< Derived > &x) const
Applies the hyperoctahedral symmetry to a vector.
Definition codac2_OctaSym.h:88
friend std::ostream & operator<<(std::ostream &str, const OctaSym &s)
Overloads the stream insertion operator to print the hyperoctahedral symmetry in a human-readable for...
Definition codac2_OctaSym.h:162
Definition codac2_OctaSym.h:21
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