3
$\begingroup$

I've been using Carl Woll's einsum function, but it's missing the ability to handle repeated indices.

For instance np.einsum('i,i->i',w, w) will perform a Hadamard product, so it makes sense for Mathematica's einsum to do the same for einsum[{{1}, {1}} -> {1}, a, a].

Another example, the following einsum in Python produces outer product of diagonal of A with $a\odot b$

np.einsum('ii,j,j->ij', A, b, c)

In Mathematica syntax this could look like this:

einsum[{{1,1}, {2}, {2} -> {1,2}, A, b, c]

Jacob Biamonte visualizes this kind of structure using "COPY-tensor", but it's really just an edge with more than 2 endpoints - a hyper-edge, so it would be useful to have it supported

enter image description here

$\endgroup$
1
  • $\begingroup$ +1 would be nice to have this. I've made a version of EinsteinSummation that can do this EinsteinSummation. It replaces TensorContract with SymbolicTensors`ArrayContract, but it no longer works with the Inactive tensor product, so it doesn't compute optimal contraction order anymore. $\endgroup$
    – swish
    Commented Apr 6, 2023 at 13:10

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.