Port of SymPy's TensExpr.replace_with_arrays(). replacement_dict is
a list of pairs list(key, array), where key is a tensor such as
A(i, j) (its indices fix the meaning of the array axes) or a
TensorIndexType (its covariant metric). The result is an Array()
with axes ordered as indices (default: the free indices of expr), or
an expression when no free index is left.
Examples
L <- TensorIndexType("L", dim = 2)
i <- TensorIndex("i", L); j <- TensorIndex("j", L)
A <- TensorHead("A", list(L))
replace_with_arrays(A(i) * A(j), list(list(A(i), Array(list(1, 2)))), list(i, j))
#> [[1, 2], [2, 4]]