Comment by sundarurfriend
11 hours ago
> D = 1/(LM) np.einsum('klm,ln,km->kn', A, B, C)
The first time I came across Einsums was via the Tullio.jl package, and it seemed like magic to me. I believe the equivalent of this would be:
@tullio D[k, n] = 1/(L*M) * A[k, l, m] * B[l, n] * C[k, m]
which is really close to the mathematical notation.
To my understanding, template strings from PEP 750 will allow for something like:
D = 1/(L*M) * np.einsum(t'{A}[k,l,m] * {B}[l,n] * {C}[k,m]')
right? If so, that'd be pretty neat to have.
No comments yet
Contribute on Hacker News ↗