Friday, 28 November 2025

ufunc in numpy - understanding universal functions

It operates on ndarrays. Here's the lowdown.

ufuncs operate on ndarrays in an element-by-element function. Several features are supported such as array broadcasting and type casting. 

Broadcasting is when a smaller array is spread over a bigger one. For example. a single number can be "broadcast" to every element of an array.  Analogously, a 1D array can be "broadcast" across the rows and columns of a 2D array.

The idea of "broadcasting" predates NumPy and was first implemented in an array-focused scientific programming language called Yorick from the 1990s.

No comments: