On 3/15/07, David Koch <[EMAIL PROTECTED]> 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 :-/
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to