[SciPy-dev] Comments on API for Matlab's eigs equivalent (computing a few eigenvalues only)

Charles R Harris charlesr.harris at gmail.com
Thu Feb 4 02:06:20 EST 2010


On Wed, Feb 3, 2010 at 11:49 PM, David Cournapeau <david at silveregg.co.jp>wrote:

> Charles R Harris wrote:
> >
> >
> > On Wed, Feb 3, 2010 at 11:27 PM, David Cournapeau <david at silveregg.co.jp
> > <mailto:david at silveregg.co.jp>> wrote:
> >
> >     Hi,
> >
> >     I have played a bit with adding support for computing a few
> eigenvalues
> >     of full symmetric matrices. I would like some comments on the
> >     current API:
> >
> >     import numpy as np
> >     from scipy.linalg import eigs
> >     x = np.random.randn(10, 10)
> >     x = np.dot(x.T, x)
> >     # Retrieve the 3 biggest eigenvalues
> >     eigs(x, 3)[0]
> >     # Retrieve the 3 smallest eigenvalues
> >     eigs(x, -3)[0]
> >     # Retrieve the 3 biggest eigenvalues
> >     eigs(x, [0, 3], mode="index")[0]
> >     # Retrieve the 2nd and 3rd biggest
> >     eigs(x, [1, 3], mode="index")[0]
> >     # Retrieve all the eigenvalues in the range [1.5, 3.5[
> >     eigs(x, [1.5, 3.5], mode="range")[0]
> >
> >     One thing which does not feel right is that that the range in the
> >     "index" mode is exactly inverted compared to the output (i.e. if you
> ask
> >
> >
> > Why not use separate keywords for index and range.
>
> Then I am not sure how to handle the "give me the k biggest/smallest"
> case, which is the most common I think (that's the only one I care
> personally :) ).
>
>
That would be eigs(x, index=3) or eigs(x, index=-3) respectively, the
default value of both range and index would be None, which could possibly
return all eigenvalues. I'm not sure that index is the best word but I can't
think of a better at the moment.

<snip>

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scipy-dev/attachments/20100204/a1b3fd4f/attachment.html>


More information about the SciPy-Dev mailing list