Hi, I absolutely do not know perl, so I do not know what the expression you posted does.
However, the key is just to understand indexing in numpy: if you have a matrix mat and index arrays index1, index2 with, lets say, index1 = array([ 17, 19, 29]) index2 = array([ 12, 3, 9]) then the entries of the index arrays are used as row and column indices respectively, and the result will be an array shaped like the index arrays. So doing mat[index1, index2] will give you --> array([ mat[17, 12], mat[19, 3], mat[29, 9]]). Now if you want the diagonal of a 3x3-mat, you need index1=index2=array([ 0, 1, 2]). mat[index1, index2] --> array([ mat[0,0], mat[1,1], mat[2,2]]) That is what my code does. If you need other, arbitrary subsets of mat, you just have to fill the index arrays accordingly. Johannes ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion