Simpatico  v1.10
PointSymmetry.h
1 #ifndef UTIL_POINT_SYMMETRY_H
2 #define UTIL_POINT_SYMMETRY_H
3 
4 #include <util/space/Dimension.h>
5 #include <util/containers/FMatrix.h>
6 
7 #include <iostream>
8 
9 namespace Util {
10 
11  class IntVector;
12 
23  {
24 
25  public:
26 
29 
35  PointSymmetry();
36 
40  PointSymmetry(const PointSymmetry& other);
41 
46 
50  PointSymmetry inverse() const;
51 
55  int& R(int i, int j);
56 
60  int R(int i, int j) const;
61 
62  // Static method
63 
67  static const PointSymmetry& identity();
68 
69  private:
70 
78  Matrix R_;
79 
81  static PointSymmetry identity_;
82 
84  static bool hasIdentity_;
85 
87  static void makeIdentity();
88 
89  // friends:
90 
91  friend bool operator==(const PointSymmetry& A, const PointSymmetry& B);
92 
93  friend bool operator!=(const PointSymmetry& A, const PointSymmetry& B);
94 
95  friend PointSymmetry
96  operator * (const PointSymmetry& A, const PointSymmetry& B);
97 
98  friend IntVector operator * (const PointSymmetry& S, const IntVector& V);
99 
100  friend IntVector operator * (const IntVector& V, const PointSymmetry& S);
101 
102  friend std::ostream& operator << (std::ostream& out, const PointSymmetry& A);
103 
104  };
105 
106  // Friend function declarations
107 
115  bool operator == (const PointSymmetry& A, const PointSymmetry& B);
116 
124  bool operator != (const PointSymmetry& A, const PointSymmetry& B);
125 
134 
142  IntVector operator * (const PointSymmetry& S, const IntVector& V);
143 
151  IntVector operator * (const IntVector& V, const PointSymmetry& S);
152 
160  std::ostream& operator << (std::ostream& out, const PointSymmetry& A);
161 
162  // Inline method definitions
163 
164  inline bool operator != (const PointSymmetry& A, const PointSymmetry& B)
165  { return !(A == B); }
166 
167  /*
168  * Return an element of the matrix by reference.
169  */
170  inline int& PointSymmetry::R(int i, int j)
171  { return R_(i, j); }
172 
173  /*
174  * Return an element of the matrix by value
175  */
176  inline int PointSymmetry::R(int i, int j) const
177  { return R_(i, j); }
178 
179  /*
180  * Return identity element.
181  */
183  {
184  if (!hasIdentity_) makeIdentity();
185  return identity_;
186  }
187 
188 }
189 #endif
friend bool operator!=(const PointSymmetry &A, const PointSymmetry &B)
Are two PointSymmetry objects not equivalent?
PointSymmetry & operator=(const PointSymmetry &other)
Assignment operator.
friend PointSymmetry operator*(const PointSymmetry &A, const PointSymmetry &B)
Return the product A*B of two symmetry objects.
FMatrix< int, Dimension, Dimension > Matrix
Typedef for internal matrix.
Definition: PointSymmetry.h:28
static const PointSymmetry & identity()
Return the identity element.
PointSymmetry inverse() const
Return the inverse of this symmetry element.
Utility classes for scientific computation.
Definition: accumulators.mod:1
int & R(int i, int j)
Return an element of the matrix by reference.
PointSymmetry()
Default constructor.
friend std::ostream & operator<<(std::ostream &out, const PointSymmetry &A)
Output stream inserter for a PointSymmetry.
An IntVector is an integer Cartesian vector.
Definition: IntVector.h:73
friend bool operator==(const PointSymmetry &A, const PointSymmetry &B)
Are two PointSymmetry objects equivalent?
A PointSymmetry represents a crystallographic point group symmetry.
Definition: PointSymmetry.h:22