Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RDF/CDF eigenvalues: symmetric matrices, multiplicities #11608

Closed
rbeezer mannequin opened this issue Jul 18, 2011 · 23 comments
Closed

RDF/CDF eigenvalues: symmetric matrices, multiplicities #11608

rbeezer mannequin opened this issue Jul 18, 2011 · 23 comments

Comments

@rbeezer
Copy link
Mannequin

rbeezer mannequin commented Jul 18, 2011

As the summary says, this patch improves eigenvalues of matrices with double-precision floating-point entries.

  1. Uses SciPy's eigh routine for symmetric and Hermitian matrices.
  2. Allows grouping of "equal" eigenvalues, based on a tolerance parameter.

Apply:

  1. attachment: trac_11608-eigenvalues-symmetric-multiplicity-rebase.patch
  2. attachment: trac_11608-eigenvalues-symmetric-multiplicity-update-v2.patch

CC: @jasongrout

Component: linear algebra

Keywords: sd40.5

Author: Rob Beezer

Reviewer: Volker Braun

Merged: sage-5.1.beta4

Issue created by migration from https://trac.sagemath.org/ticket/11608

@rbeezer rbeezer mannequin added this to the sage-5.0 milestone Jul 18, 2011
@rbeezer rbeezer mannequin assigned jasongrout and williamstein Jul 18, 2011
@rbeezer
Copy link
Mannequin Author

rbeezer mannequin commented Jul 18, 2011

Author: Rob Beezer

@rbeezer

This comment has been minimized.

@rbeezer rbeezer mannequin added the s: needs review label Jul 18, 2011
@loefflerd
Copy link
Mannequin

loefflerd mannequin commented Mar 13, 2012

Work Issues: rebase

@loefflerd
Copy link
Mannequin

loefflerd mannequin commented Mar 13, 2012

comment:3

Patch does not apply to 5.0.beta7 (see patchbot logs)

@loefflerd loefflerd mannequin added s: needs work and removed s: needs review labels Mar 13, 2012
@rbeezer
Copy link
Mannequin Author

rbeezer mannequin commented May 3, 2012

Attachment: trac_11608-eigenvalues-symmetric-multiplicity-rebase.patch.gz

Rebased on 5.0-beta10

@rbeezer

This comment has been minimized.

@rbeezer
Copy link
Mannequin Author

rbeezer mannequin commented May 3, 2012

Changed work issues from rebase to none

@rbeezer rbeezer mannequin added s: needs review and removed s: needs work labels May 3, 2012
@dimpase
Copy link
Member

dimpase commented May 4, 2012

comment:5

it's kind of weird that one coerces a complex matrix into real symmetric, but then treats it as a Hermitian one...
Surely with real symmetric matrices there might be better options, no?

@vbraun
Copy link
Member

vbraun commented May 4, 2012

comment:6

Despite the name, scipy.linalg.eigh will call lapack syevr / heevr depending on whether the field is real / complex.

@rbeezer
Copy link
Mannequin Author

rbeezer mannequin commented May 4, 2012

comment:7

The algorithm='symmetric' keyword is meant to allow the routine accomodate both base rings (RDF/CDF) while also allowing a user to specify that a matrix is known to be symmetric. In this case, the conversion from CDF to RDF is made by the routine and then the SciPy behavior that Volker notes will take place.

Any suggestions on making the docstring clearer? Maybe saying "then applies the algorithm for Hermitian matrices" should be stated differently?

@vbraun
Copy link
Member

vbraun commented May 5, 2012

comment:8

On Fedora 16 x86_64, I get

sage -t  devel/sage-main/sage/matrix/matrix_double_dense.pyx
**********************************************************************
File "/home/vbraun/opt/sage-5.0.rc0/devel/sage-main/sage/matrix/matrix_double_dense.pyx", line 1570:
    sage: A.eigenvalues(algorithm='symmetric', tol=1.0e-20)
Expected:
    [(-2.0, 1), (-2.0, 2), (-2.0, 1), (1.0, 1), (1.0, 1), (1.0, 1), (1.0, 1), (1.0, 1), (3.0, 1)]
Got:
    [(-2.0, 1), (-2.0, 2), (-2.0, 1), (1.0, 1), (1.0, 1), (1.0, 2), (1.0, 1), (3.0, 1)]

ATLAS is from Fedora, CPU is a Sandy-Bridge i7 quad-core.

Minor nitpicks while we are at it:

  • Can you return a tuple (=immutable) instead of a list?
  • the symmetric docstring, how about: "converts self to a real matrix and applies the algorithm for Hermitian matrices". Note: technically you convert (explicit), not coerce (implicit).
  • in the hermitian docstring, how about: "uses the :meth:~scipy.linalg.eigh method from SciPy, which applies only to real symmetric or complex Hermitian matrices. Since...". This would make it clear that the syevr implementation is used if possible.
  • the ".. warning::" block is not indented, so it is not typeset correctly.

@vbraun
Copy link
Member

vbraun commented May 5, 2012

Reviewer: Volker Braun

@rbeezer
Copy link
Mannequin Author

rbeezer mannequin commented May 5, 2012

comment:9

Replying to @vbraun:

On Fedora 16 x86_64, I get...

Thanks, I'll increase the tolerance and that should work better across platforms. You'd think I'd get the hang of this numerical stuff...

Minor nitpicks while we are at it:

  • Can you return a tuple (=immutable) instead of a list?

I'm not opposed, but other eigenvalue routines return mutable objects. I'd prefer to do one grand change across all matrix types, on a single-purpose ticket of its own.

sage: A = matrix(QQ, [[1]])
sage: ev=A.eigenvalues()   
sage: type(ev)
<class 'sage.structure.sequence.Sequence_generic'>
sage: ev[0]=5
sage: ev
[5]
  • the symmetric docstring, how about: "converts self to a real matrix and applies the algorithm for Hermitian matrices". Note: technically you convert (explicit), not coerce (implicit).
  • in the hermitian docstring, how about: "uses the :meth:~scipy.linalg.eigh method from SciPy, which applies only to real symmetric or complex Hermitian matrices. Since...". This would make it clear that the syevr implementation is used if possible.
  • the ".. warning::" block is not indented, so it is not typeset correctly.

Thanks for the nits. I'll make some changes right now.

Rob

@rbeezer
Copy link
Mannequin Author

rbeezer mannequin commented May 5, 2012

comment:10

"Update" patch:

  1. Removes the 10^-20 tolerance doctest. Not really needed and will only cause trouble. (It was suppose to illustrate how a very small tolerance would split up "equal" eigenvalues.)
  2. Adjusts documentation according to suggestions above.
  3. Includes new pointers to routines to check symmetric and Hermitian properties.
  4. No code changes.

Rob

@rbeezer

This comment has been minimized.

@rbeezer rbeezer mannequin added s: needs review and removed s: needs work labels May 5, 2012
@vbraun
Copy link
Member

vbraun commented May 5, 2012

comment:11

Looks great!

@rbeezer
Copy link
Mannequin Author

rbeezer mannequin commented May 5, 2012

comment:12

Replying to @vbraun:

Looks great!

Thanks, Volker!

This was built on various 5.0-beta's, so I just double-checked that it applies, tests and builds on 5.0-rc0.

Rob

@jdemeyer jdemeyer modified the milestones: sage-5.0, sage-5.1 May 5, 2012
@jdemeyer
Copy link

jdemeyer commented May 7, 2012

comment:14

The warning in the docstring is misformatted, see http://sagemath.org/doc/developer/conventions.html#documentation-strings

@rbeezer
Copy link
Mannequin Author

rbeezer mannequin commented May 24, 2012

comment:15

Attachment: trac_11608-eigenvalues-symmetric-multiplicity-update-v2.patch.gz

I thought this was OK and I just triple-checked, and I think it is OK. One change: made "warning" all capital letters, this is the only change to the v2 version of the update patch.

The HTML documentation renders the warning blocks as they should. I'm going to move this back to positive review.

Jeroen - please let me know if I am really missing something here. Thanks.

Rob

@rbeezer

This comment has been minimized.

@rbeezer rbeezer mannequin added s: positive review and removed s: needs work labels May 24, 2012
@jdemeyer
Copy link

Changed keywords from none to sd40.5

@jdemeyer
Copy link

comment:16

Yes, it looks okay now. I don't remember what precisely was wrong before.

@jdemeyer
Copy link

Merged: sage-5.1.beta4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants