May 2017
Intermediate to advanced
270 pages
6h 18m
English
The true power of NumPy lies in its fast mathematical operations. The approach used by NumPy is to avoid stepping into the Python interpreter by performing element-wise calculation using optimized C code. Broadcasting is a clever set of rules that enables fast array calculations for arrays of similar (but not equal!) shape.
Whenever you do an arithmetic operation on two arrays (like a product), if the two operands have the same shape, the operation will be applied in an element-wise fashion. For example, upon multiplying two shape (2,2) arrays, the operation will be done between pairs of corresponding elements, producing another (2, 2) array, as shown in the following code:
A = np.array([[1, 2], [3, 4]]) B = np.array([[5, 6], ...Read now
Unlock full access