A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.scipy.org/doc/numpy/reference/generated/numpy.broadcast.html below:

numpy.broadcast — NumPy v2.3 Manual

numpy.broadcast#
class numpy.broadcast[source]#

Produce an object that mimics broadcasting.

Parameters:
in1, in2, …array_like

Input parameters.

Returns:
bbroadcast 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
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]])
Attributes:
index

current index in broadcasted result

iters

tuple of iterators along self’s “components.”

nd

Number of dimensions of broadcasted result.

ndim

Number of dimensions of broadcasted result.

numiter

Number of iterators possessed by the broadcasted result.

shape

Shape of broadcasted result.

size

Total size of broadcasted result.

Methods


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4