- nlcpy.broadcast_arrays(*args, **kwargs)
Broadcasts any number of arrays against each other.
The arrays to broadcast.
- subokbool, optional
- broadcastedlist of arrays
These arrays are views on the original arrays. They are typically not contiguous. Furthermore, more than one element of a broadcasted array may refer to a single memory location. If you need to write to the arrays, make copies first. While you can set the
writableflag True, writing to a single output value may end up changing more than one location in the output array.
>>> import nlcpy as vp >>> x = vp.array([[1,2,3]]) >>> y = vp.array([,]) >>> vp.broadcast_arrays(x, y) [array([[1, 2, 3], [1, 2, 3]]), array([[4, 4, 4], [5, 5, 5]])]
Here is a useful idiom for getting contiguous copies instead of non-contiguous views.
>>> [vp.array(a) for a in vp.broadcast_arrays(x, y)] [array([[1, 2, 3], [1, 2, 3]]), array([[4, 4, 4], [5, 5, 5]])]