This is probably the most asked single question.
Use ``ix_``. Example below.

Cheers,
Alan Isaac

>>> import numpy as np
>>> a=np.floor(np.random.rand(5,5)*10)
>>> ind=[1,3]
>>> a[np.ix_(ind,ind)]+=100
>>> a
array([[   9.,    1.,    2.,    8.,    5.],
       [   2.,  102.,    7.,  109.,    0.],
       [   8.,    0.,    2.,    2.,    2.],
       [   1.,  103.,    5.,  101.,    7.],
       [   1.,    4.,    7.,    2.,    3.]])
>>>


_______________________________________________
Numpy-discussion mailing list
[email protected]
http://projects.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to