1#ifndef PSCF_SYMMETRY_GROUP_TPP
2#define PSCF_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 template <
class Symmetry>
61 for (
int i = 0; i < other.
size(); ++i) {
62 elements_.push_back(other.elements_[i]);
73 template <
class Symmetry>
77 for (
int i=0; i < size(); ++i) {
78 if (symmetry == elements_[i]) {
79 return &(elements_[i]);
89 template <
class Symmetry>
93 const Symmetry* ptr = find(symmetry);
98 elements_.push_back(symmetry);
109 template <
class Symmetry>
114 bool added, complete;
118 for (i = 0; i < n; ++i) {
119 a = elements_[i].inverse();
128 for (i = 0; i < n; ++i) {
130 for (j = 0; j < n; ++j) {
151 template <
class Symmetry>
155 identity_ = Symmetry::identity();
156 elements_.push_back(identity_);
162 template <
class Symmetry>
167 if (size() != other.
size()) {
170 Symmetry
const * ptr = 0;
171 for (
int i = 0; i < size(); ++i) {
172 ptr = other.
find(elements_[i]);
173 if (ptr == 0)
return false;
175 for (
int i = 0; i < other.
size(); ++i) {
176 ptr = find(other.elements_[i]);
177 if (ptr == 0)
return false;
186 template <
class Symmetry>
190 {
return !(*
this == other); }
195 template <
class Symmetry>
202 c = Symmetry::identity();
204 UTIL_THROW(
"Identity element is not in group");
209 for (i = 0; i < n; ++i) {
213 UTIL_THROW(
"Inverse of element not in group");
215 for (j = 0; j < n; ++j) {
219 UTIL_THROW(
"An element of the group is not unique");
224 UTIL_THROW(
"Product of two element is not in group");
Class template for a group of elements.
const Symmetry & identity() const
Return a reference to the identity element.
void clear()
Remove all elements except the identity.
~SymmetryGroup()
Destructor.
SymmetryGroup()
Default constructor.
const Symmetry * find(const Symmetry &symmetry) const
Find a symmetry within a group.
bool isValid() const
Return true if valid complete group, or throw an Exception.
int size() const
Return number of elements in group (i.e., the order of the group).
SymmetryGroup< Symmetry > & operator=(const SymmetryGroup< Symmetry > &other)
Assignment operator.
bool add(Symmetry &symmetry)
Add a new element to the group.
void makeCompleteGroup()
Generate a complete group from the current elements.
File containing preprocessor macros for error handling.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
C++ namespace for polymer self-consistent field theory (PSCF).
Utility classes for scientific computation.