finitediff
SNpermutation.h
Go to the documentation of this file.
1 /*
2 Copyright 2017 Laurent Claessens
3 contact : laurent@claessens-donadello.eu
4 
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #ifndef __SNPERMUTATION_H_060431__
20 #define __SNPERMUTATION_H_060431__
21 
22 #include <array>
23 
24 #include "Mpermutation.h"
25 
26 /*
27  This class represents a permutation matrix.
28 
29  The permutation is recorded in a `Mpermutation` object.
30 
31 */
32 
33 // THE CLASS HEADER -----------------------------------------
34 
35 template <class T,unsigned int tp_size>
36 class SNpermutation : public SNgeneric<T,tp_size>
37 {
38  template <class V,unsigned int s>
39  friend std::ostream& operator<<(std::ostream&, SNpermutation<V,s>);
40 
41  private:
43 
44  T& _at(const m_num i,const m_num j) override;
45  T _get(const m_num i,const m_num j) const override;
46  public :
49 
51  SNpermutation();
52 
54 
57 };
58 
59 // CONSTRUCTORS -------------------------------
60 
61 
62 template <class T,unsigned int tp_size>
64  data(d)
65 {}
66 
67 template <class T,unsigned int tp_size>
69  data(d)
70 {}
71 
72 template <class T,unsigned int tp_size>
74 
75 
76 // OPERATORS -------------------------------
77 
78 template <class T,unsigned int s>
79 std::ostream& operator<<(std::ostream& stream, SNpermutation<T,s> perm)
80 {
81  for (unsigned int l=0;l<s;l++)
82  {
83  stream<<perm.data.at(l);
84  }
85  return stream;
86 }
87 
88 // _AT AND _GET -------------------------------
89 
90 template <class T,unsigned int tp_size>
92 {
93  throw SNchangeNotAllowedException(i,j);
94 };
95 
96 template <class T,unsigned int tp_size>
97 T SNpermutation<T,tp_size>::_get(const m_num i,const m_num j) const
98 {
99  if (getMpermutation().image(j)==i)
100  {
101  return 1;
102  }
103  return 0;
104 };
105 
106 template <class T,unsigned int tp_size>
108 {
109  return data;
110 }
111 
112 // MATHEMATICS -------------------------------
113 
114 template <class T,unsigned int tp_size>
116 {
118  return inv;
119 }
120 
121 #endif
SNpermutation()
Definition: SNpermutation.h:73
SNpermutation< T, tp_size > inverse() const
Definition: SNpermutation.h:115
T _get(const m_num i, const m_num j) const override
Definition: SNpermutation.h:97
This is the base class for the other matrices types.
Definition: MathUtilities.h:32
Definition: m_num.h:34
Mpermutation< tp_size > getMpermutation() const
Definition: SNpermutation.h:107
Mpermutation< tp_size > data
Definition: SNpermutation.h:42
Definition: MelementaryPermutation.h:34
T & _at(const m_num i, const m_num j) override
Definition: SNpermutation.h:91
Definition: SNpermutation.h:36
This class represents a permutation (not a matrix).
Definition: MelementaryPermutation.h:26
Definition: SNexceptions.cpp:81