CASM  1.1.0
A Clusters Approach to Statistical Mechanics
VectorSymCompare.hh
Go to the documentation of this file.
1 #ifndef CASM_VectorSymCompare
2 #define CASM_VectorSymCompare
3 
6 namespace CASM {
7 
8 template <typename Base>
10 
12  public:
13  VectorInvariants(Eigen::VectorXcd const &vector);
14 
15  double cols() const;
16  double norm() const;
17 
18  private:
19  double m_cols;
20  double m_norm;
21 };
22 
24 bool almost_equal(VectorInvariants const &A_invariants,
25  VectorInvariants const &B_invariants, double tol);
26 
28 bool compare(VectorInvariants const &A_invariants,
29  VectorInvariants const &B_invariants, double tol);
30 
31 template <typename Element, typename SymApply>
33 
35 template <typename _Element, typename _SymApply>
36 struct traits<DirectionSymCompare<_Element, _SymApply>> {
37  typedef _Element Element;
38  typedef _SymApply SymApply;
41 };
42 
43 template <typename Element, typename SymApply>
44 class SubspaceSymCompare;
45 
47 template <typename _Element, typename _SymApply>
48 struct traits<SubspaceSymCompare<_Element, _SymApply>> {
49  typedef _Element Element;
50  typedef _SymApply SymApply;
53 };
54 
57 template <typename Base>
58 struct traits<VectorSymCompare<Base>> : public traits<Base> {};
59 
81 template <typename _Base>
82 class EigenSymCompare : public _Base {
83  public:
85  /*
86  typedef typename traits<Derived>::MostDerived MostDerived;
87  typedef typename traits<Derived>::Element Element;
88  typedef Element VectorType;
89  typedef typename traits<Element>::InvariantsType InvariantsType;
90  */
91 
92  using Base = _Base;
93  using MostDerived = typename Base::MostDerived;
96  using Base::derived;
97  using typename Base::InvariantsType;
98 
100  double tol() const;
101 
102  protected:
103  friend _Base;
104 
109  template <typename... Args>
110  EigenSymCompare(double tol, Args &&... args)
111  : m_tol(tol), m_apply(std::forward<Args>(args)...) {}
112 
114  InvariantsType make_invariants_impl(Element const &obj) const;
115 
117  bool invariants_compare_impl(InvariantsType const &A_invariants,
118  InvariantsType const &B_invariants) const;
119 
121  bool compare_impl(const Element &A, const Element &B) const;
122 
125  // For now, this is the the sorting permutation
126  std::unique_ptr<SymOpRepresentation> canonical_transform_impl(
127  Element const &obj) const;
128 
129  Element copy_apply_impl(SymOp const &op, Element obj) const {
130  return m_apply(op, obj);
131  }
132 
135 
137  SymOp const &spatial_transform_impl() const;
138 
139  private:
140  double m_tol;
141 
143 
147 };
148 
149 template <typename Element>
151  public:
152  EigenSymRepApply(SymGroupRep const &_rep) : m_rep(_rep) {}
153 
154  Element operator()(SymOp const &op, Element obj) const {
155  return (*m_rep.MatrixXd(op.index())) * obj;
156  }
157 
158  private:
160 };
161 
162 template <typename Element, typename SymApply>
164  : public EigenSymCompare<
165  SymCompare<CRTPBase<DirectionSymCompare<Element, SymApply>>>> {
166  public:
169 
174  template <typename... Args>
175  DirectionSymCompare(Args &&... args) : Base(std::forward<Args>(args)...) {}
176 
177  protected:
178  friend class EigenSymCompare<
181 
183  Element representation_prepare_impl(Element obj) const { return obj; }
184 };
185 
186 template <typename Element, typename SymApply>
188  : public EigenSymCompare<
189  SymCompare<CRTPBase<SubspaceSymCompare<Element, SymApply>>>> {
190  public:
193 
198  template <typename... Args>
199  SubspaceSymCompare(Args &&... args) : Base(std::forward<Args>(args)...) {}
200 
201  protected:
202  friend class EigenSymCompare<
205 
209 };
210 
211 } // namespace CASM
212 
213 #endif
Element representation_prepare_impl(Element obj) const
Prepare an element for comparison (by doing nothing)
DirectionSymCompare(Args &&... args)
Constructor.
CRTP Base class for Vector comparisons.
double tol() const
Return tolerance.
InvariantsType make_invariants_impl(Element const &obj) const
Make orbit invariants from one element in the orbit.
typename traits< MostDerived >::Element Element
bool invariants_compare_impl(InvariantsType const &A_invariants, InvariantsType const &B_invariants) const
Orders 'prepared' elements in the same orbit.
bool compare_impl(const Element &A, const Element &B) const
Compares 'prepared' elements.
typename traits< MostDerived >::SymApply SymApply
Element copy_apply_impl(SymOp const &op, Element obj) const
std::unique_ptr< SymOpRepresentation > canonical_transform_impl(Element const &obj) const
Returns transformation that takes 'obj' to its prepared (canonical) form.
_Base Base
Element refers to Vector, not element of Vector.
SymOp const & spatial_transform_impl() const
Spatial prepare does not apply – transform is always identity.
typename Base::MostDerived MostDerived
EigenSymCompare(double tol, Args &&... args)
Constructor.
Element spatial_prepare_impl(Element obj) const
Spatial prepare does not apply – element is returned unchanged.
Element operator()(SymOp const &op, Element obj) const
EigenSymRepApply(SymGroupRep const &_rep)
SubspaceSymCompare(Args &&... args)
Constructor.
Element representation_prepare_impl(Element obj) const
Prepare an element for comparison by rotating, sorting, and changing sign of column vectors.
CRTP base class for implementing element and orbit comparison.
Definition: SymCompare.hh:52
typename traits< MostDerived >::Element Element
Definition: SymCompare.hh:57
SymGroupRep is an alternative representation of a SymGroup for something other than real space....
Definition: SymGroupRep.hh:31
Eigen::MatrixXd const * MatrixXd(Index i) const
pointer to MatrixXd corresponding to SymOpRepresentation at entry 'i' of this SymGroupRep Returns nul...
Definition: SymGroupRep.cc:144
SymOp is the Coordinate representation of a symmetry operation it keeps fraction (FRAC) and Cartesian...
Definition: SymOp.hh:28
VectorInvariants(Eigen::VectorXcd const &vector)
Base class for CRTP pattern.
Definition: CRTPBase.hh:8
Main CASM namespace.
Definition: APICommand.hh:8
bool almost_equal(ClusterInvariants const &A, ClusterInvariants const &B, double tol)
Check if ClusterInvariants are equal.
bool compare(ClusterInvariants const &A, ClusterInvariants const &B, double tol)
Compare ClusterInvariants.
Definition: stream_io.hh:24
DirectionSymCompare< _Element, _SymApply > MostDerived
SubspaceSymCompare< _Element, _SymApply > MostDerived