You are viewing an older version (2.4.3). Go to latest (2.4.4)
{ } Raw JSON

bundles / numpy 2.4.3 / numpy / broadcast

class

numpy:broadcast

source: /numpy/__init__.py

Signature

class   broadcast ( * arrays )

Summary

Produce an object that mimics broadcasting.

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.

Examples

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
Compare against built-in broadcasting:
x + y

See also

broadcast_arrays
broadcast_shapes
broadcast_to

Aliases

  • numpy.broadcast

Referenced by