Skip to content

Commit 321add4

Browse files
author
Dominic Price
committed
Fix meld error where terms with different names but same index structure were melded
1 parent f475fbf commit 321add4

File tree

3 files changed

+295
-398
lines changed

3 files changed

+295
-398
lines changed

core/Adjform.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,15 +378,17 @@ namespace cadabra {
378378
set(adjform, value);
379379
}
380380

381-
AdjformEx::AdjformEx(Ex::iterator it, IndexMap& index_map, const Kernel& kernel)
381+
AdjformEx::AdjformEx(Ex& tr, Ex::iterator it, IndexMap& index_map, const Kernel& kernel)
382382
: prefactor(str_node("\\prod"))
383383
, tensor(str_node("\\prod"))
384384
{
385385
set(Adjform(it, index_map, kernel));
386386

387387
if (*it->name == "\\prod") {
388+
Ex_comparator comp(kernel.properties);
389+
388390
for (Ex::sibling_iterator beg = it.begin(), end = it.end(); beg != end; ++beg) {
389-
if (has_indices(kernel, beg))
391+
if (has_indices(kernel, beg) || !comp.can_move_to_front(tr, it, beg))
390392
tensor.append_child(tensor.begin(), (Ex::iterator)beg);
391393
else
392394
prefactor.append_child(prefactor.begin(), (Ex::iterator)beg);

core/Adjform.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ namespace cadabra {
9292
AdjformEx();
9393
AdjformEx(const Adjform& adjform, const rational_type& value = 1, const Ex& prefactor = Ex());
9494
AdjformEx(const Adjform& adjform, const rational_type& value, Ex::iterator prefactor);
95-
AdjformEx(Ex::iterator it, IndexMap& index_map, const Kernel& kernel);
95+
AdjformEx(Ex& tr, Ex::iterator it, IndexMap& index_map, const Kernel& kernel);
9696

9797
// Check if 'other' is a linear multiple of 'this' and return
9898
// the numeric factor if so, otherwise returns 0

0 commit comments

Comments
 (0)