problems with duplicating and slicing an array
beliavsky at aol.com
beliavsky at aol.com
Fri Jan 21 11:41:51 EST 2005
Yun Mao wrote:
>Thanks for the help. numarray doesn't provide what I look for either.
e.g.
>a = array( [[1,2,3],[4,5,6]] )
>I sometimes what this: a[ [1,0], :], or even
>a[ [1,0], [0,1] ] , which should give me
>[[4, 5], [1,2]]
I think Fortran 90 and 95 have the array slicing you want. For example,
if
imat =
11 12 13
21 22 23
then imat([2,1,2],:)) =
21 22 23
11 12 13
21 22 23
and imat([2,1,2],[1,3]) =
21 23
11 13
21 23
Like Matlab, Fortran arrays by default start with 1, and x(i:j) gives a
slice of elements including x(j). There are free compilers g95 (in
beta) and gfortran (in alpha).
More information about the Python-list
mailing list