Skip to content

Commit 9c9f04c

Browse files
committed
Make Trace inherit explicit indices.
1 parent 3ba44d4 commit 9c9f04c

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

core/algorithms/sort_product.cc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
using namespace cadabra;
66

7+
#define DEBUG 1
8+
79
sort_product::sort_product(const Kernel&k, Ex& tr)
810
: Algorithm(k, tr), cleanup(true)
911
{
@@ -63,9 +65,13 @@ Algorithm::result_t sort_product::apply(iterator& st)
6365
compare.clear();
6466
auto es = compare.equal_subtree(one, two);
6567
if(compare.should_swap(one, es)) {
66-
// std::cerr << "should swap " << *(one->name) << " with " << *(two->name) << std::endl;
68+
#ifdef DEBUG
69+
std::cerr << "should swap " << *(one->name) << " with " << *(two->name) << std::endl;
70+
#endif
6771
int canswap=compare.can_swap(one, two, es);
68-
// std::cerr << "can swap? " << *(one->name) << " with " << *(two->name) << std::endl;
72+
#ifdef DEBUG
73+
std::cerr << "can swap? " << *(one->name) << " with " << *(two->name) << std::endl;
74+
#endif
6975
if(canswap!=0) {
7076
// std::cerr << "swapping " << Ex(one) << " with " << Ex(two) << std::endl;
7177
tr.swap(one);

core/properties/Trace.hh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
#include "Props.hh"
55
#include "properties/Symmetric.hh"
66
#include "properties/Distributable.hh"
7+
#include "properties/IndexInherit.hh"
78

89
namespace cadabra {
910

10-
class Trace : public Distributable, virtual public property {
11+
class Trace : public Distributable, public IndexInherit, virtual public property {
1112
public:
1213
Trace();
1314
virtual std::string name() const override;

tests/explicit_implicit.cdb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,18 @@ test05()
8383
#ex:= \chi \psi \sigma^{n} \chi;
8484
#explicit_indices(_);
8585

86+
# Normally index contraction aims for adjacent indices.
87+
# With 'eager=True', contractions are generated as much
88+
# as possible, even if that does not lead to adjacent indices.
89+
90+
91+
#
92+
# {m,n,p}::Indices(spacetime, position=fixed);
93+
# {a,b,c,d,e,f,g,h}::Indices(spinor, position=fixed);
94+
# \sigma^{p}::ImplicitIndex(\sigma^{p}_{a b});
95+
# \tau^{p}::ImplicitIndex(\tau^{p a b});
96+
# \theta::ImplicitIndex(\theta^{a});
97+
#
98+
# ex := \sigma^{p} \theta \tau^{m};
99+
# tst:= \sigma^{p}_{a b} \theta^{b} \tau^{m a c};
100+
#

0 commit comments

Comments
 (0)