Skip to content

Commit

Permalink
Fix another issue with component evaluation where indices are explici…
Browse files Browse the repository at this point in the history
…tly fixed to an integer value.
  • Loading branch information
Kasper Peeters committed Dec 27, 2024
1 parent 0658ac3 commit e5e0e85
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
7 changes: 5 additions & 2 deletions core/algorithms/evaluate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,11 @@ Ex::iterator evaluate::handle_factor(sibling_iterator sib, const index_map_t& fu

// Attempt to apply each component substitution rule on this term.
Ex repl("\\components");
for(auto& ind: ind_free)
repl.append_child(repl.begin(), ind.second);
// Add the names of the free indices (if they are truly free, not integers).
for(auto& ind: ind_free) {
if(ind.second->is_integer()==false)
repl.append_child(repl.begin(), ind.second);
}
// If there are no free indices, add an empty first child anyway,
// otherwise we need special cases in various other places.
auto vl = repl.append_child(repl.begin(), str_node("\\comma"));
Expand Down
15 changes: 15 additions & 0 deletions tests/components.cdb
Original file line number Diff line number Diff line change
Expand Up @@ -836,3 +836,18 @@ def test41():
print("Test 41 passed")

test41()

def test42():
__cdbkernel__=create_scope()
{k,l,m,n}::Indices(rotation, values={1..3}).
\epsilon{#}::EpsilonTensor.
ex := (K_{1})_{m n} e_{1}_{n} = \epsilon_{1 m n} e_{1}_{n};
evaluate(ex, $e_{1}_{1} = 1, e_{1}_{2} = a, e_{1}_{3} = b$, rhsonly=True);
ex = rhs(ex)
tst:= \components_{m}{\comma{\comma{2}=b}{\comma{3}=-a}} - @(ex);
collect_components(tst)
assert(tst==0)
print("Test 42 passed")

test42()

0 comments on commit e5e0e85

Please sign in to comment.