[Numpy-discussion] Matlab -> NumPy translation and indexing
David Koch
ogdude at googlemail.com
Thu Mar 15 09:49:53 EDT 2007
On 3/15/07, David Koch <ogdude at googlemail.com> wrote:
>
> ... NumPy equiv for Matlab B(A_idx, A_Idx)
Ok, I did like this:
A_Idx = array([1, 0])
B = random.randn(3,3)
rowInd = kron(ones((1, len(A_Idx)), int), A_Idx[:, newaxis])
colInd = kron(ones((len(A_Idx), 1), int), A_Idx)
B[rowInd, colInd] - returns the equivalent of Matlabs B(A_Idx, A_Idx)
... that cannot possibly be the easiest way :-/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20070315/66e42d8b/attachment.html>
More information about the NumPy-Discussion
mailing list