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 }
Algorithm.hh
cadabra::meld::collect_symmetries_as_sum
bool collect_symmetries_as_sum(const std::vector< tab_t > &tabs, std::vector< symmetrizer_t > &symmetrizers) const
Definition: meld.cc:840
cadabra::meld::symmetrize_as_sum
void symmetrize_as_sum(ProjectedTerm &adj, const std::vector< symmetrizer_t > &symmetries)
Definition: meld.cc:1074
cadabra::Adjform
Representation of the index structure of a tensor monomial, using a storage format which resembles an...
Definition: Adjform.hh:29
cadabra::meld::apply_tableaux
bool apply_tableaux(iterator it)
Definition: meld.cc:194
cadabra::meld::can_apply_cycle_traces
bool can_apply_cycle_traces(iterator it)
Definition: meld.cc:1160
TableauBase.hh
cadabra::Kernel
Definition: Kernel.hh:15
cadabra::meld::can_apply
virtual bool can_apply(iterator it) override
Definition: meld.cc:41
cadabra::meld::can_apply_tableaux
bool can_apply_tableaux(iterator it)
Definition: meld.cc:177
cadabra::sym
Definition: sym.hh:9
cadabra::meld::apply_cycle_traces
bool apply_cycle_traces(iterator it)
Definition: meld.cc:1248
cadabra::meld::index_map
IndexMap index_map
Definition: meld.hh:77
cadabra::meld::apply_traceless
bool apply_traceless(iterator it)
Definition: meld.cc:119
cadabra::meld::symmetrize_as_product
void symmetrize_as_product(ProjectedTerm &adj, const std::vector< symmetrizer_t > &symmetrizers)
Definition: meld.cc:965
cadabra::meld::ProjectedTerm::tensor
Ex tensor
Definition: meld.hh:28
cadabra::meld::symmetrize_idents
void symmetrize_idents(ProjectedTerm &sym)
Definition: meld.cc:1126
cadabra::TableauBase::tab_t
yngtab::filled_tableau< unsigned int > tab_t
Definition: TableauBase.hh:11
cadabra::meld::symmetrizer_t::symmetrizer_t
symmetrizer_t(bool antisymmetric, bool independent)
Definition: meld.hh:36
cadabra::meld::symmetrize
void symmetrize(ProjectedTerm &adj, const std::vector< symmetrizer_t > &symmetries)
Definition: meld.cc:957
cadabra::meld::ProjectedTerm
Definition: meld.hh:23
cadabra::meld::ProjectedTerm::changed
bool changed
Definition: meld.hh:32
cadabra::meld
Definition: meld.hh:11
cadabra::meld::ProjectedTerm::ProjectedTerm
ProjectedTerm(const Kernel &kernel, IndexMap &index_map, Ex &ex, Ex::iterator it)
Definition: meld.cc:452
cadabra::meld::ProjectedTerm::ident
Adjform ident
Definition: meld.hh:30
cadabra::meld::apply
virtual result_t apply(iterator &it) override
Definition: meld.cc:50
yngtab::filled_tableau< unsigned int >
cadabra::meld::collect_symmetries
bool collect_symmetries(const std::vector< tab_t > &tabs, std::vector< symmetrizer_t > &symmetrizers) const
Definition: meld.cc:730
cadabra::Algorithm::iterator
Ex::iterator iterator
Definition: Algorithm.hh:70
cadabra::meld::ProjectedTerm::projection
ProjectedAdjform projection
Definition: meld.hh:29
cadabra::Algorithm
Definition: Algorithm.hh:59
cadabra::meld::symmetrizer_t::indices
std::vector< size_t > indices
Definition: meld.hh:37
cadabra
Functions to handle the exchange properties of two or more symbols in a product.
Definition: Adjform.cc:83
cadabra::Ex
Definition: Storage.hh:140
cadabra::meld::symmetrizer_t::independent
bool independent
Definition: meld.hh:38
cadabra::meld::~meld
virtual ~meld()
Definition: meld.cc:36
cadabra::meld::ProjectedTerm::scalar
Ex scalar
Definition: meld.hh:28
cadabra::meld::symmetrizer_t
Definition: meld.hh:35
cadabra::meld::project_as_sum
bool project_as_sum
Definition: meld.hh:78
Adjform.hh
cadabra::meld::symmetrizer_t::antisymmetric
bool antisymmetric
Definition: meld.hh:38
cadabra::meld::can_apply_diagonals
bool can_apply_diagonals(iterator it)
Definition: meld.cc:82
cadabra::meld::can_apply_traceless
bool can_apply_traceless(iterator it)
Definition: meld.cc:113
cadabra::ProjectedAdjform
Representation of a sum of tensor monomials, each having the same tensor names, but with different in...
Definition: Adjform.hh:135
cadabra::meld::ProjectedTerm::compare
bool compare(const Kernel &kernel, const ProjectedTerm &other)
Definition: meld.cc:531
cadabra::IndexClassifier::kernel
const Kernel & kernel
Definition: IndexClassifier.hh:76
cadabra::Ex::result_t
result_t
Keeping track of what algorithms have done to this expression.
Definition: Storage.hh:159
cadabra::meld::collect_tableaux
std::vector< tab_t > collect_tableaux(Ex &ex) const
Definition: meld.cc:688
cadabra::meld::meld
meld(const Kernel &kernel, Ex &ex, bool project_as_sum=false)
Definition: meld.cc:28
cadabra::meld::apply_diagonals
bool apply_diagonals(iterator it)
Definition: meld.cc:88
cadabra::IndexMap
To ensure consistency when creating adjforms out of two different Ex objects an IndexMap object is re...
Definition: Adjform.hh:116
cadabra::meld::ProjectedTerm::it
Ex::iterator it
Definition: meld.hh:31
cadabra::meld::collect_symmetries_as_product
bool collect_symmetries_as_product(const std::vector< tab_t > &tabs, std::vector< symmetrizer_t > &symmetrizers) const
Definition: meld.cc:738