1#ifndef PRDC_SYMMETRY_GROUP_TPP
2#define PRDC_SYMMETRY_GROUP_TPP
11#include "SymmetryGroup.h"
24 template <
class Symmetry>
27 identity_ = Symmetry::identity();
28 elements_.push_back(identity_);
34 template <
class Symmetry>
39 for (
int i = 0; i < other.
size(); ++i) {
40 elements_.push_back(other.elements_[i]);
47 template <
class Symmetry>
54 for (
int i = 0; i < other.
size(); ++i) {
55 elements_.push_back(other.elements_[i]);
66 template <
class Symmetry>
70 for (
int i=0; i <
size(); ++i) {
71 if (symmetry == elements_[i]) {
72 return &(elements_[i]);
82 template <
class Symmetry>
86 const Symmetry* ptr =
find(symmetry);
91 elements_.push_back(symmetry);
102 template <
class Symmetry>
107 bool added, complete;
111 for (i = 0; i < n; ++i) {
112 a = elements_[i].inverse();
121 for (i = 0; i < n; ++i) {
123 for (j = 0; j < n; ++j) {
144 template <
class Symmetry>
148 identity_ = Symmetry::identity();
149 elements_.push_back(identity_);
155 template <
class Symmetry>
160 if (
size() != other.size()) {
163 Symmetry
const * ptr = 0;
164 for (
int i = 0; i <
size(); ++i) {
165 ptr = other.find(elements_[i]);
166 if (ptr == 0)
return false;
168 for (
int i = 0; i < other.size(); ++i) {
169 ptr =
find(other.elements_[i]);
170 if (ptr == 0)
return false;
179 template <
class Symmetry>
183 {
return !(*
this == other); }
188 template <
class Symmetry>
195 c = Symmetry::identity();
197 UTIL_THROW(
"Identity element is not in group");
202 for (i = 0; i < n; ++i) {
206 UTIL_THROW(
"Inverse of element not in group");
208 for (j = 0; j < n; ++j) {
212 UTIL_THROW(
"An element of the group is not unique");
217 UTIL_THROW(
"Product of two element is not in group");
void makeCompleteGroup()
Generate a complete group from the current elements.
const Symmetry * find(const Symmetry &symmetry) const
Find a symmetry within a group.
bool add(Symmetry &symmetry)
Add a new element to the group.
SymmetryGroup< Symmetry > & operator=(const SymmetryGroup< Symmetry > &other)
Assignment operator.
void clear()
Remove all elements except the identity.
bool isValid() const
Return true if valid complete group, or throw an Exception.
SymmetryGroup()
Default constructor.
int size() const
Return number of elements in group (i.e., the order of the group).
const Symmetry & identity() const
Return a reference to the identity element.
File containing preprocessor macros for error handling.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
void add(fftw_complex &z, fftw_complex const &a, fftw_complex const &b)
Addition of fftw_complex numbers, z = a + b.
Periodic fields and crystallography.
PSCF package top-level namespace.