Tensor operations with AbstractArrays

I think what you want here is:

@reduce P[μ, ν] := sum(λ, σ) D[λ, σ] * (G[μ, ν, σ, λ] - G[μ, λ, σ, ν] / 2)

as @cast fairly literally only does broadcasting, it won’t ever call sum without being asked to. (Maybe the error message should say this, though!) Tullio (and Einsum and TensorOperations and OMEinsum) do automatically reduce over indices not shown on the left.

This ought to work with Hermitian, but it won’t exploit it to do things more efficiently.

1 Like