diff --git a/dynare++/tl/cc/int_sequence.cc b/dynare++/tl/cc/int_sequence.cc index 4177d337d..8756a6d58 100644 --- a/dynare++/tl/cc/int_sequence.cc +++ b/dynare++/tl/cc/int_sequence.cc @@ -20,26 +20,6 @@ IntSequence::unfold(const Symmetry &sy) const return r; } -/* This constructs an implied symmetry (implemented as |IntSequence| - from a more general symmetry and equivalence class (implemented as - |vector|). For example, let the general symmetry be $y^3u^2$ and - the equivalence class is $\{0,4\}$ picking up first and fifth - variable, we calculate symmetry (at this point only |IntSequence|) - corresponding to the picked variables. These are $yu$. Thus the - constructed sequence must be $(1,1)$, meaning that we picked one $y$ - and one $u$. */ - -IntSequence::IntSequence(const Symmetry &sy, const std::vector &se) - : data{new int[sy.num()]}, length{sy.num()} -{ - TL_RAISE_IF(sy.dimen() <= se[se.size()-1], - "Sequence is not reachable by symmetry in IntSequence()"); - for (int i = 0; i < length; i++) - operator[](i) = 0; - - for (int i : se) - operator[](sy.findClass(i))++; -} /* This constructs an ordered integer sequence from the given ordered sequence inserting the given number to the sequence. */ diff --git a/dynare++/tl/cc/int_sequence.hh b/dynare++/tl/cc/int_sequence.hh index 8c66afa2f..54c2b380c 100644 --- a/dynare++/tl/cc/int_sequence.hh +++ b/dynare++/tl/cc/int_sequence.hh @@ -88,9 +88,6 @@ public: { std::copy_n(s.data+i1, length, data); } - /* Constructor used for calculating implied symmetry from a more general - symmetry and one equivalence class */ - IntSequence(const Symmetry &sy, const std::vector &se); /* Unfolds a given integer sequence with respect to a given symmetry. If for example the sequence is $(a,b)$ and the symmetry is $(2,3)$, then the result is $(a,a,b,b,b)$. */ diff --git a/dynare++/tl/cc/symmetry.cc b/dynare++/tl/cc/symmetry.cc index 23a7e878c..fc56b4112 100644 --- a/dynare++/tl/cc/symmetry.cc +++ b/dynare++/tl/cc/symmetry.cc @@ -2,6 +2,7 @@ #include "symmetry.hh" #include "permutation.hh" +#include "tl_exception.hh" #include @@ -21,6 +22,26 @@ Symmetry::Symmetry(const IntSequence &s) } } +/* This constructs an implied symmetry from a more general symmetry and + equivalence class. For example, let the general symmetry be $y^3u^2$ and the + equivalence class is $\{0,4\}$ picking up first and fifth variable, we + calculate symmetry corresponding to the picked variables. These are $yu$. + Thus the constructed sequence must be $(1,1)$, meaning that we picked one + $y$ and one $u$. */ + +Symmetry::Symmetry(const Symmetry &sy, const OrdSequence &cl) + : IntSequence(sy.num()) +{ + const std::vector &se = cl.getData(); + TL_RAISE_IF(sy.dimen() <= se[se.size()-1], + "Sequence is not reachable by symmetry in IntSequence()"); + for (int i = 0; i < size(); i++) + operator[](i) = 0; + + for (int i : se) + operator[](sy.findClass(i))++; +} + /* Find a class of the symmetry containing a given index. */ int diff --git a/dynare++/tl/cc/symmetry.hh b/dynare++/tl/cc/symmetry.hh index 414acc580..1670c7560 100644 --- a/dynare++/tl/cc/symmetry.hh +++ b/dynare++/tl/cc/symmetry.hh @@ -72,10 +72,7 @@ public: { } // Constructor of implied symmetry for a symmetry and an equivalence class - Symmetry(const Symmetry &s, const OrdSequence &cl) - : IntSequence(s, cl.getData()) - { - } + Symmetry(const Symmetry &s, const OrdSequence &cl); /* Subsymmetry, which takes the given length of symmetry from the end (shares data pointer) */ Symmetry(Symmetry &s, int len)