This NumPy Array Broadcasting example is inspired by this SciPy Lecture Chapter on Array Broadcasting.
Code:
Note the use of y[:, np.newaxis]
.
Note also that this example might be made much simplier with np.ogrid
and np.mgrid
. (See the SciPy-Lectures chapter on broadcasting)