3 ms·
Maths notation can be wonderfully concise and precise, so it worth thinking about following it closely when programming. One of my favorite examples of this is
by jpeanuts 7y ago
Maths notation can be wonderfully concise and precise, so it worth thinking about following it closely when programming. One of my favorite examples of this is the numpy `einsum` call [1]. It implements Einstein summation convention [2] - thereby making working with the many dimensions of high-rank tensors feasible.
E.g. this (Latex):
$C_{ml} = A_{ijkl} B_{ijkm}$
becomes (in Python):
C = einsum('ijkl,ijkm->ml', A, B)
[1] https://docs.scipy.org/doc/numpy/reference/generated/numpy.einsum.html https://docs.scipy.org/doc/numpy/reference/generated/numpy.e...
[2] https://en.wikipedia.org/wiki/Einstein_notation https://en.wikipedia.org/wiki/Einstein_notation