Movatterモバイル変換


[0]ホーム

URL:


SciPy

numpy.broadcast_arrays

numpy.broadcast_arrays(*args,**kwargs)[source]

Broadcast any number of arrays against each other.

Parameters:
`*args`:array_likes

The arrays to broadcast.

subok:bool, optional

If True, then sub-classes will be passed-through, otherwisethe returned arrays will be forced to be a base-class array (default).

Returns:
broadcasted:list of arrays

These arrays are views on the original arrays. They are typicallynot contiguous. Furthermore, more than one element of abroadcasted array may refer to a single memory location. If youneed to write to the arrays, make copies first.

Examples

>>>x=np.array([[1,2,3]])>>>y=np.array([[1],[2],[3]])>>>np.broadcast_arrays(x,y)[array([[1, 2, 3],       [1, 2, 3],       [1, 2, 3]]), array([[1, 1, 1],       [2, 2, 2],       [3, 3, 3]])]

Here is a useful idiom for getting contiguous copies instead ofnon-contiguous views.

>>>[np.array(a)forainnp.broadcast_arrays(x,y)][array([[1, 2, 3],       [1, 2, 3],       [1, 2, 3]]), array([[1, 1, 1],       [2, 2, 2],       [3, 3, 3]])]

Previous topic

numpy.broadcast_to

Next topic

numpy.expand_dims

Quick search

  • © Copyright 2008-2018, The SciPy community.
  • Last updated on Jul 24, 2018.
  • Created usingSphinx 1.6.6.

[8]ページ先頭

©2009-2025 Movatter.jp