Cadabra
Computer algebra system for field theory problems
meld.hh
Go to the documentation of this file.
1 #pragma once
2 
3 #include <memory>
4 #include <array>
5 #include "Algorithm.hh"
6 #include "Adjform.hh"
8 
9 namespace cadabra {
10 
11  class meld : public Algorithm
12  {
13  public:
14  meld(const Kernel& kernel, Ex& ex, bool project_as_sum = false);
15  virtual ~meld();
16 
17  virtual bool can_apply(iterator it) override;
18  virtual result_t apply(iterator& it) override;
19 
20  private:
22 
23  struct ProjectedTerm {
24  ProjectedTerm(const Kernel& kernel, IndexMap& index_map, Ex& ex, Ex::iterator it);
25  // Return 'true' if the tensor parts are identical up to index structure
26  bool compare(const Kernel& kernel, const ProjectedTerm& other);
27 
31  Ex::iterator it;
32  bool changed;
33  };
34 
35  struct symmetrizer_t {
37  std::vector<size_t> indices;
39  };
40 
41  // Return the tableaux associated with the expression, offsetting
42  // cells with how many indices *deep* it is
43  std::vector<tab_t> collect_tableaux(Ex& ex) const;
44 
45  // Collects all the columns and rows of the tableaux starting at node 'it' and combines
46  // similar columns where possible. Returns 'true' if the symmetrizers mean the term is
47  // identically 0
48  bool collect_symmetries(const std::vector<tab_t>& tabs, std::vector<symmetrizer_t>& symmetrizers) const;
49  bool collect_symmetries_as_product(const std::vector<tab_t>& tabs, std::vector<symmetrizer_t>& symmetrizers) const;
50  bool collect_symmetries_as_sum(const std::vector<tab_t>& tabs, std::vector<symmetrizer_t>& symmetrizers) const;
51 
52  void symmetrize(ProjectedTerm& adj, const std::vector<symmetrizer_t>& symmetries);
53  void symmetrize_as_product(ProjectedTerm& adj, const std::vector<symmetrizer_t>& symmetrizers);
54  void symmetrize_as_sum(ProjectedTerm& adj, const std::vector<symmetrizer_t>& symmetries);
56 
57  // Remove non-diagonal terms of diagonal objects
59  bool apply_diagonals(iterator it);
60 
61  // Remove terms which contain contractions of traceless objects
63  bool apply_traceless(iterator it);
64 
65  // Apply the symmetry Tr(ABC) = Tr(BCA) = Tr(CAB)
68 
69  // Compare Young projections of each term for symmetry
71  bool apply_tableaux(iterator it);
72 
73  //bool can_apply_side_relations(iterator it);
74  //bool apply_side_relations(iterator it);
75  //Ex side_relations;
76 
79  };
80 
81 }
Representation of the index structure of a tensor monomial, using a storage format which resembles an...
Definition: Adjform.hh:30
Base class for all algorithms, containing generic routines and in particular the logic for index clas...
Definition: Algorithm.hh:59
Ex::iterator iterator
Definition: Algorithm.hh:70
Basic storage class for symbolic mathemematical expressions.
Definition: Storage.hh:142
result_t
Keeping track of what algorithms have done to this expression.
Definition: Storage.hh:164
const Kernel & kernel
Definition: IndexClassifier.hh:76
To ensure consistency when creating adjforms out of two different Ex objects an IndexMap object is re...
Definition: Adjform.hh:121
Definition: Kernel.hh:15
Representation of a sum of tensor monomials, each having the same tensor names, but with different in...
Definition: Adjform.hh:140
yngtab::filled_tableau< unsigned int > tab_t
Definition: TableauBase.hh:12
Definition: meld.hh:12
void symmetrize_as_sum(ProjectedTerm &adj, const std::vector< symmetrizer_t > &symmetries)
Definition: meld.cc:1113
std::vector< tab_t > collect_tableaux(Ex &ex) const
Definition: meld.cc:718
bool can_apply_traceless(iterator it)
Definition: meld.cc:128
bool collect_symmetries_as_product(const std::vector< tab_t > &tabs, std::vector< symmetrizer_t > &symmetrizers) const
Definition: meld.cc:768
bool apply_tableaux(iterator it)
Definition: meld.cc:208
virtual result_t apply(iterator &it) override
Definition: meld.cc:50
virtual ~meld()
Definition: meld.cc:37
bool can_apply_diagonals(iterator it)
Definition: meld.cc:97
void symmetrize(ProjectedTerm &adj, const std::vector< symmetrizer_t > &symmetries)
Definition: meld.cc:987
IndexMap index_map
Definition: meld.hh:77
bool can_apply_tableaux(iterator it)
Definition: meld.cc:191
bool project_as_sum
Definition: meld.hh:78
bool can_apply_cycle_traces(iterator it)
Definition: meld.cc:1199
bool apply_traceless(iterator it)
Definition: meld.cc:134
void symmetrize_idents(ProjectedTerm &sym)
Definition: meld.cc:1165
bool collect_symmetries(const std::vector< tab_t > &tabs, std::vector< symmetrizer_t > &symmetrizers) const
Definition: meld.cc:760
virtual bool can_apply(iterator it) override
Definition: meld.cc:41
bool apply_diagonals(iterator it)
Definition: meld.cc:103
bool apply_cycle_traces(iterator it)
Definition: meld.cc:1287
void symmetrize_as_product(ProjectedTerm &adj, const std::vector< symmetrizer_t > &symmetrizers)
Definition: meld.cc:995
meld(const Kernel &kernel, Ex &ex, bool project_as_sum=false)
Definition: meld.cc:30
bool collect_symmetries_as_sum(const std::vector< tab_t > &tabs, std::vector< symmetrizer_t > &symmetrizers) const
Definition: meld.cc:870
Definition: sym.hh:9
Functions to handle the exchange properties of two or more symbols in a product.
Definition: Adjform.cc:83
Definition: meld.hh:23
Ex::iterator it
Definition: meld.hh:31
Ex tensor
Definition: meld.hh:28
bool changed
Definition: meld.hh:32
Adjform ident
Definition: meld.hh:30
Ex scalar
Definition: meld.hh:28
ProjectedTerm(const Kernel &kernel, IndexMap &index_map, Ex &ex, Ex::iterator it)
Definition: meld.cc:482
ProjectedAdjform projection
Definition: meld.hh:29
bool compare(const Kernel &kernel, const ProjectedTerm &other)
Definition: meld.cc:561
Definition: meld.hh:35
bool antisymmetric
Definition: meld.hh:38
std::vector< size_t > indices
Definition: meld.hh:37
symmetrizer_t(bool antisymmetric, bool independent)
Definition: meld.hh:36
bool independent
Definition: meld.hh:38