nlcpy.broadcast_arrays

nlcpy.broadcast_arrays(*args, **kwargs)[ソース]

Broadcasts any number of arrays against each other.

Parameters
*argsarray_likes

The arrays to broadcast.

subokbool, optional

Not implemented.

Returns
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 writable flag True, writing to a single output value may end up changing more than one location in the output array.

Examples

>>> import nlcpy as vp
>>> x = vp.array([[1,2,3]])
>>> y = vp.array([[4],[5]])
>>> 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]])]