Comment

Comment by jpeanuts

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.e... [2] https://en.wikipedia.org/wiki/Einstein_notation

parent jpeanuts 6 years ago

No comments yet

Be the first to share your thoughts.

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton