Ravel/Unravel Index

360 views
Skip to first unread message

Christoph Ortner

unread,
Dec 16, 2014, 3:57:49 PM12/16/14
to julia...@googlegroups.com
Does Julia have an analogue of Python's   `numpy.unravel_index`  and  `numpy.ravel_multi_index`   ; see
     http://docs.scipy.org/doc/numpy/reference/generated/numpy.unravel_index.html

Probably easy to write, but if there is an existing efficient implementation then I'd like to use it.

My application is that I have an array A,  of which I do not know the dimensionality beforehand. Hence I loop

for n = 1:length(A)
     . . .
end
    
but can still access the multi-index corresponding to n inside the loop.

Thank you,
     Christoph


Isaiah Norton

unread,
Dec 16, 2014, 4:12:25 PM12/16/14
to julia...@googlegroups.com
I think the equivalents are ind2sub and sub2ind

Stefan Karpinski

unread,
Dec 16, 2014, 4:32:33 PM12/16/14
to Julia Users
For once I think that Matlab has the better names.

Christoph Ortner

unread,
Dec 17, 2014, 12:51:55 AM12/17/14
to julia...@googlegroups.com
Thank you. 
    Christoph

Reply all
Reply to author
Forward
0 new messages