Skip to content

Commit 8a41782

Browse files
committed
Fix for untrace of traces with single-factor argument.
1 parent 0d435a0 commit 8a41782

File tree

3 files changed

+33
-19
lines changed

3 files changed

+33
-19
lines changed

core/Algorithm.cc

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <boost/core/demangle.hpp>
3030
#endif
3131

32+
#include "properties/Accent.hh"
3233
#include "properties/Derivative.hh"
3334
#include "properties/Indices.hh"
3435
#include "properties/Coordinate.hh"
@@ -807,9 +808,12 @@ bool Algorithm::is_single_term(iterator it)
807808
&& *it->name!="\\comma" && *it->name!="\\equals" && *it->name!="\\arrow") {
808809

809810
if(tr.is_head(it) || *tr.parent(it)->name=="\\equals" || *tr.parent(it)->name=="\\int") return true;
810-
else {
811-
if(*tr.parent(it)->name=="\\sum")
812-
return true;
811+
else if(*tr.parent(it)->name=="\\sum")
812+
return true;
813+
else if(*tr.parent(it)->name!="\\prod" && it->fl.parent_rel==str_node::parent_rel_t::p_none
814+
&& kernel.properties.get<Accent>(tr.parent(it))==0 ) {
815+
std::cerr << "Found single term in " << tr.parent(it) << std::endl;
816+
return true;
813817
}
814818
}
815819
return false;

core/algorithms/untrace.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ bool untrace::can_apply(iterator st)
1919
auto sib=tr.begin(st);
2020
if(sib==tr.end(st)) return false;
2121
if(*sib->name=="\\prod") return true;
22-
if(is_single_term(sib)) return true;
22+
if(is_single_term(sib)) return true;
2323
}
2424
return false;
2525
}

tests/implicit.cdb

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,31 @@ def test01():
1414

1515
test01()
1616

17-
{a,b,c,d}::Indices(spinor);
18-
Tr{#}::Trace(indices=spinor);
19-
#A::ImplicitIndex(A_{a b});
20-
#B::ImplicitIndex(B_{a b});
21-
ex:= Tr( A B A C B );
22-
untrace(_);
23-
17+
def test02():
18+
__cdbkernel__=create_scope()
19+
{a,b,c,d}::Indices(spinor);
20+
Tr{#}::Trace(indices=spinor);
21+
A::ImplicitIndex(A_{a b});
22+
B::ImplicitIndex(B_{a b});
23+
ex:= Tr( A B A C B ) - Tr( C );
24+
untrace(_);
25+
tst:= C Tr( A B A B ) - C Tr(1) - @(ex);
26+
assert(tst==0)
27+
print("Test 02 passed")
2428

25-
{a,b,c,d}::Indices(spinor);
26-
\sigma^{\mu}::ImplicitIndex(\sigma^{\mu a}_{b});
27-
Tr{#}::Trace(indices=spinor);
28-
ex:= Tr( \sigma^{\mu} q \sigma^{\nu} );
29-
untrace(_);
30-
29+
test02()
30+
31+
def test03():
32+
__cdbkernel__=create_scope()
33+
{a,b,c,d}::Indices(spinor);
34+
\sigma^{\mu}::ImplicitIndex(\sigma^{\mu a}_{b});
35+
Tr{#}::Trace(indices=spinor);
36+
ex:= Tr( \sigma^{\mu} q \sigma^{\nu} );
37+
untrace(_);
38+
tst:= q Tr( \sigma^{\mu} \sigma^{\nu} ) - @(ex);
39+
assert(tst==0)
40+
print("Test 03 passed")
3141

32-
33-
42+
test03()
43+
3444

0 commit comments

Comments
 (0)