Broadcast an array to a new shape.
The array to broadcast.
The shape of the desired array. A single integer i is interpreted as (i,).
If True, then sub-classes will be passed-through, otherwise the returned array will be forced to be a base-class array (default).
A readonly view on the original array with the given shape. It is typically not contiguous. Furthermore, more than one element of a broadcasted array may refer to a single memory location.
If the array is not compatible with the new shape according to NumPy’s broadcasting rules.
See also
>>> import numpy as np
>>> x = np.array([1, 2, 3])
>>> np.broadcast_to(x, (3, 3))
array([[1, 2, 3],
[1, 2, 3],
[1, 2, 3]])
© 2005–2024 NumPy Developers
Licensed under the 3-clause BSD License.
https://numpy.org/doc/2.4/reference/generated/numpy.broadcast_to.html