NumPy arrays are essentially treated as mathematical functions. This is in particular true for operations. Consider two functions, and , defined on the same domain and taking real values. The product of those two functions is defined as the pointwise product, that is,
Note that this construction is possible for any operation between two functions. For an arbitrary operation defined on two scalars, which we denote here by , we could define as follows:
This innocuous remark allows us to understand NumPy's stance on operations; all operations are elementwise in arrays. For instance, the product between two matrices, and , is defined, as with functions, as follows: