Produce an object that mimics broadcasting.
Input parameters.
Broadcast the input parameters against one another, and return an object that encapsulates the result. Amongst others, it has shape and nd properties, and may be used as an iterator.
See also
Manually adding two vectors, using broadcasting:
>>> import numpy as np >>> x = np.array([[1], [2], [3]]) >>> y = np.array([4, 5, 6]) >>> b = np.broadcast(x, y)
>>> out = np.empty(b.shape)
>>> out.flat = [u+v for (u,v) in b]
>>> out
array([[5., 6., 7.],
[6., 7., 8.],
[7., 8., 9.]])
Compare against built-in broadcasting:
>>> x + y
array([[5, 6, 7],
[6, 7, 8],
[7, 8, 9]])
indexcurrent index in broadcasted result
iterstuple of iterators along self’s “components.”
ndNumber of dimensions of broadcasted result.
ndimNumber of dimensions of broadcasted result.
numiterNumber of iterators possessed by the broadcasted result.
shapeShape of broadcasted result.
sizeTotal size of broadcasted result.
| Reset the broadcasted result's iterator(s). |
© 2005–2024 NumPy Developers
Licensed under the 3-clause BSD License.
https://numpy.org/doc/2.4/reference/generated/numpy.broadcast.html