Zm.hh

Go to the documentation of this file.
1 
6 #ifndef Zm_h
7 #define Zm_h
8 
9 #include "typedefs.hh"
10 
11 namespace concepts {
12  // ******************************************************************** Z2 **
13 
16  class Z2 {
19  public:
21  Z2() : i_(0) {}
23  Z2(uint i) : i_(i&1) {}
24 
26  operator int() const { return i_; }
27 
29  int operator=(int i) { return i_ = i & 1; }
31  int operator++() { return i_ ^= 1; }
33  Z2 succ() const { return i_ ^ 1; }
34  };
35 
36  // ******************************************************************** Z3 **
37 
40  class Z3 {
43  public:
45  Z3() : i_(0) {}
47  Z3(uint i) : i_(i - 3 * (i / 3)) {}
48 
50  operator int() const { return i_; }
51 
53  int operator=(int i) { return i_ = i - 3 * (i / 3); }
55  int operator++() { return i_ = i_ == 2 ? 0 : i_ + 1; }
57  int operator--() { return i_ = i_ ? i_ - 1 : 2; }
59  Z3 succ() const { return i_ == 2 ? 0 : i_ + 1; }
61  Z3 pred() const { return i_ ? i_ - 1 : 2; }
62  };
63 
64  // ******************************************************************** Z4 **
65 
68  class Z4 {
71  public:
73  Z4() : i_(0) {}
75  Z4(uint i) : i_(i & 3) {}
76 
78  operator int() const { return i_; }
79 
81  int operator=(int i) { return i_ = i & 3; }
83  int operator++() { ++i_; return i_ &= 3; }
85  int operator--() { --i_; return i_ &= 3; }
87  Z4 succ() const { return (i_ + 1) & 3; }
89  Z4 pred() const { return (i_ - 1) & 3; }
90  };
91 
92 } // namespace concepts
93 
94 #endif // Zm_h
int operator=(int i)
Assignment operator.
Definition: Zm.hh:81
int operator++()
Increment operator.
Definition: Zm.hh:55
Z4 succ() const
Returns the successor.
Definition: Zm.hh:87
unsigned char uchar
Abbreviation for unsigned char.
Definition: typedefs.hh:45
int operator--()
Decrement operator.
Definition: Zm.hh:57
uchar i_
Data.
Definition: Zm.hh:42
int operator++()
Increment operator.
Definition: Zm.hh:31
Z3 succ() const
Returns the successor.
Definition: Zm.hh:59
Z4(uint i)
Constructor.
Definition: Zm.hh:75
Z2()
Default constructor. Initialises to 0.
Definition: Zm.hh:21
Z2 succ() const
Returns the successor.
Definition: Zm.hh:33
uchar i_
Data.
Definition: Zm.hh:70
int operator=(int i)
Assignment operator.
Definition: Zm.hh:29
Z3(uint i)
Constructor.
Definition: Zm.hh:47
Z3 pred() const
Returns the predecessor.
Definition: Zm.hh:61
int operator--()
Decrement operator.
Definition: Zm.hh:85
int operator++()
Increment operator.
Definition: Zm.hh:83
int operator=(int i)
Assignment operator.
Definition: Zm.hh:53
Algebraic group with three elements: 0, 1 and 2.
Definition: Zm.hh:40
Z4 pred() const
Returns the predecessor.
Definition: Zm.hh:89
Binary group (algebraic): only the values 0 and 1 are represented.
Definition: Zm.hh:16
Algebraic group with four elements: 0, 1, 2 and 3.
Definition: Zm.hh:68
Z2(uint i)
Constructor.
Definition: Zm.hh:23
Z3()
Default constructor. Initialises to 0.
Definition: Zm.hh:45
uchar i_
Data.
Definition: Zm.hh:18
Basic namespace for Concepts-2.
Definition: pml_formula.h:16
Z4()
Default constructor. Initialises to 0.
Definition: Zm.hh:73
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich