Combinations from range of values for given sizes

后端 未结 3 534
误落风尘
误落风尘 2021-01-14 18:39

I\'m using the following code to create a list of indices for an array. However, I would like the index to run in Fortran order i.e. the inner loop being the faster varying

3条回答
  •  不要未来只要你来
    2021-01-14 19:30

    Is this what you are after?

    a = np.transpose(np.nonzero(np.ones([32,30])))  
    a.reshape(32,30,2).transpose(1,0,2).reshape(-1,2)
    Out[2197]: 
    array([[ 0,  0],
           [ 1,  0],
           [ 2,  0],
           ..., 
           [29, 29],
           [30, 29],
           [31, 29]], dtype=int64)
    

提交回复
热议问题