[SciPy-user] Matlab to scipy
Pearu Peterson
pearu at scipy.org
Fri Oct 24 10:35:38 EDT 2003
On Fri, 24 Oct 2003, Nils Wagner wrote:
> [y,i] = max(X) stores the indices of the maximum values in
> vector i. If there are several identical maximum values, the
> index of the first one found is returned.
> So
> y = MLab.max(abs(A[k:n,k:n]))
> But, how can I evaluate i in scipy ?
Try i?amax functions from linalg.fblas, For example,
>>> A
array([[ 3., 4., 1.],
[ 1., 2., 3.],
[-2., -1., 0.]])
>>> i=map(linalg.fblas.idamax,transpose(A))
>>> y=map(lambda a,j:a[j],transpose(A),i)
>>> y,i
([3.0, 4.0, 3.0], [0, 0, 1])
while in Matlab:
>> [y,i]=max(A)
y =
3 4 3
i =
1 1 2
HTH,
Pearu
More information about the SciPy-User
mailing list