Managing high dimensions in Numpy -
i want write function of 4 variables : f(x1,x2,x3,x4)
, each in different dimension.
this can achieved f(x1,x2[newaxis],x3[newaxis,newaxis],x4[newaxis,newaxis,newaxis])
.
do know smarter way ?
you're looking np.ix_
1:
f(*np.ix_(x1, x2, x3, x4))
for example:
>>> np.ix_([1, 2, 3], [4, 5]) (array([[1], [2], [3]]), array([[4, 5]]))
1or equivalently, np.meshgrid(..., sparse=true, indexing='ij')
Comments
Post a Comment