numpy 1.22.4 Pypi GitHub Homepage
Other Docs
ParametersReturnsBackRef

Parameters

in1, in2, ... : array_like

Input parameters.

Returns

b : broadcast object

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.

Produce an object that mimics broadcasting.

See Also

broadcast_arrays
broadcast_shapes
broadcast_to

Examples

Manually adding two vectors, using broadcasting:

>>> 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]])
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

numpy.broadcast_to numpy.broadcast_shapes numpy.broadcast_arrays

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /numpy/__init__.py#None
type: <class 'type'>
Commit: