codac 1.5.6
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
19
20namespace codac2
21{
22 class CtcAction;
23 class SepBase;
24 class SepAction;
25 class SetExpr;
26
30 class Action
31 { };
32
36 class OctaSym : public std::vector<int>, public Action
37 {
38 public:
39
40 OctaSym(std::initializer_list<int> s);
41 OctaSym(const std::vector<int>& s);
42
43 OctaSym invert() const;
44
45 OctaSym operator*(const OctaSym& s) const;
46
47 Matrix permutation_matrix() const;
48
49 int _sign(int a) const
50 {
51 return (a > 0) ? 1 : ((a < 0) ? -1 : 0);
52 }
53
54 template<typename T>
55 Mat<T,-1,1> operator()(const Mat<T,-1,1>& x) const
56 {
57 assert_release(x.size() == (Index)size());
58 Mat<T,-1,1> x_(size());
59 for(size_t i = 0 ; i < size() ; i++)
60 x_[i] = _sign((*this)[i])*x[std::abs((*this)[i])-1];
61 return x_;
62 }
63
64 template<typename C>
65 requires IsCtcBaseOrPtr<C,IntervalVector>
66 CtcAction operator()(const C& c) const;
67 // -> is defined in CtcAction class
68
69 template<typename S>
70 requires is_sep_v<S>
71 SepAction operator()(const S& s) const;
72 // -> is defined in SepAction class
73
74 std::shared_ptr<SetExpr> operator()(const std::shared_ptr<SetExpr>& x1) const;
75 // -> is defined in set operations file
76
77 friend std::ostream& operator<<(std::ostream& str, const OctaSym& s)
78 {
79 str << "(";
80 for(size_t i = 0 ; i < s.size() ; i++)
81 str << (i != 0 ? " " : "") << s[i];
82 str << ")" << std::flush;
83 return str;
84 }
85 };
86}