この質問を例で説明しましょう。
import numpy
matrix = numpy.identity(5, dtype=bool) #Using identity as a convenient way to create an array with the invariant that there will only be one True value per row, the solution should apply to any array with this invariant
base = numpy.arange(5,30,5) #This could be any 1-d array, provided its length is the same as the length of axis=1 of matrix from above
result = numpy.array([ base[line] for line in matrix ])
resultこれで目的の結果が得られましたが、明示的な反復を回避するこれを行うための numpy 固有の方法があると確信しています。それは何ですか?