CASM  1.1.0
A Clusters Approach to Statistical Mechanics
SimpleOrbit_impl.hh
Go to the documentation of this file.
1 #ifndef CASM_symmetry_SimpleOrbit_impl
2 #define CASM_symmetry_SimpleOrbit_impl
3 
4 #include <map>
5 
6 #include "casm/global/errors.hh"
8 
9 namespace CASM {
10 
12 template <typename SymCompareType>
13 template <typename GroupIterator>
15  typename SymCompareType::Element const &_generating_element,
16  GroupIterator _group_begin, GroupIterator _group_end,
17  SymCompareType const &_sym_compare)
18  : m_sym_compare(_sym_compare),
19  m_invariants(_sym_compare.make_invariants(_generating_element)) {
20  auto compare = [&](const Element &A, const Element &B) {
21  return m_sym_compare.compare(A, B);
22  };
23 
24  typedef typename GroupIterator::value_type SymOpRepType;
25  std::map<Element, std::set<SymOpRepType>, decltype(compare)> tmp{compare};
26  for (auto it = _group_begin; it != _group_end; ++it) {
27  tmp[m_sym_compare.prepare(
28  m_sym_compare.copy_apply(*it, _generating_element))]
29  .insert(*it);
30  }
31 
32  // sanity check equivalence map is rectangular
33  for (auto const &pair : tmp) {
34  if (tmp.begin()->second.size() != pair.second.size()) {
36  "Error in SimpleOrbit constructor: equivalence map is not "
37  "rectangular");
38  }
39  }
40 
41  m_element.reserve(tmp.size());
42  for (auto const &pair : tmp) {
43  m_element.push_back(pair.first);
44  }
45 }
46 
48 template <typename SymCompareType>
50  return m_sym_compare.inter_orbit_compare(prototype(), invariants(),
51  B.prototype(), B.invariants());
52 }
53 
54 } // namespace CASM
55 
56 #endif
InvariantsType const & invariants() const
Definition: SimpleOrbit.hh:87
SimpleOrbit(typename SymCompareType::Element const &_generating_element, GroupIterator _group_begin, GroupIterator _group_end, SymCompareType const &_sym_compare)
Construct a SimpleOrbit using a range of SymOp or PermuteIterator.
typename _SymCompareType::Element Element
Definition: SimpleOrbit.hh:32
std::vector< Element > m_element
Definition: SimpleOrbit.hh:95
_SymCompareType SymCompareType
Definition: SimpleOrbit.hh:31
bool operator<(const SimpleOrbit &B) const
Compare orbits, using SymCompareType::inter_orbit_compare.
Element const & prototype() const
Identical to element(0)
Definition: SimpleOrbit.hh:53
SymCompareType m_sym_compare
Definition: SimpleOrbit.hh:93
Main CASM namespace.
Definition: APICommand.hh:8
bool compare(ClusterInvariants const &A, ClusterInvariants const &B, double tol)
Compare ClusterInvariants.