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

Charles R Harris charlesr.harris@gmail....
Thu Feb 4 00:37:59 CST 2010

On Wed, Feb 3, 2010 at 11:27 PM, David Cournapeau <david@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. Changing the meaning of
an argument using another keyword is just weird. I've seen it used
elsewhere, but still... At some point you might even want the largest three
in a range. So something like

eigs(x, index=3)
eigs(x, range=[1,4])

Why the index on the end? Is the return a list?

> for the range [0, 3], you get the last three items from what you would
> get if you asked for the full range [0, 10]), but this is because I kept
> compatibility with Octave (always showing from biggest to smallest). It
>

Why follow Octave, isn't Octave like Matlab? Matlab functions are a mess.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-dev/attachments/20100203/26491538/attachment.html