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

eigenmatrix_right totally broken #4756

Closed
williamstein opened this issue Dec 11, 2008 · 18 comments
Closed

eigenmatrix_right totally broken #4756

williamstein opened this issue Dec 11, 2008 · 18 comments

Comments

@williamstein
Copy link
Contributor

sage: a = matrix(CDF,2,[1,2,4,7])
sage: a.eigenmatrix_right()
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)

/Users/wstein/sage/build/sage-3.2.2.alpha0/<ipython console> in <module>()

/Users/wstein/sage/build/sage-3.2.2.alpha0/local/lib/python2.5/site-packages/sage/matrix/matrix2.so in sage.matrix.matrix2.Matrix.eigenmatrix_right (sage/matrix/matrix2.c:18170)()

/Users/wstein/sage/build/sage-3.2.2.alpha0/local/lib/python2.5/site-packages/sage/matrix/matrix2.so in sage.matrix.matrix2.Matrix.eigenmatrix_left (sage/matrix/matrix2.c:17965)()

IndexError: list index out of range

CC: @jasongrout

Component: linear algebra

Author: Rob Beezer

Reviewer: Alex Ghitza

Merged: sage-4.4.alpha0

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

@williamstein williamstein added this to the sage-4.4 milestone Dec 11, 2008
@williamstein williamstein self-assigned this Dec 11, 2008
@mwhansen
Copy link
Contributor

comment:1

This is because the eigenvectors_left and eigenvectors_right for CDF and RDF matrices returns the data in a way that is totally incompatible with what the parent is expecting.

I can make a patch for this once I have a 3.2.2alpha1 build. Otherwise, if Jason would like to do this, I wouldn't object :-)

@rbeezer
Copy link
Mannequin

rbeezer mannequin commented Jan 19, 2010

comment:2

Patch causes left_eigenvectors() and right_eigenvectors() for CDF and RDF to return eigenvalues and eigenvectors in the same format as for exact matrices. Then eigenmatrices for these matrices behave as they should. No attempt is made to identify eigenvalues with multiplicity greater than one.

Patch is failing doctests in the modular form code right now, so will need some more work.

@rbeezer rbeezer mannequin added the s: needs work label Jan 19, 2010
@rbeezer
Copy link
Mannequin

rbeezer mannequin commented Jan 19, 2010

Attachment: trac_4756_eigenmatrices_double.patch.gz

@rbeezer
Copy link
Mannequin

rbeezer mannequin commented Jan 23, 2010

Self-contained patch, apply only this

@rbeezer
Copy link
Mannequin

rbeezer mannequin commented Jan 23, 2010

Author: Rob Beezer

@rbeezer
Copy link
Mannequin

rbeezer mannequin commented Jan 23, 2010

comment:3

Attachment: trac_4756-double-eigen.patch.gz

This patch fixes the bug and generally brings double-precision eigenvectors up-to-date.

left_eigenvectors and right_eigenvectors now return their results in the same format as for exact matrices, so routines like eigenmatrix_right can digest the results properly.

Consequently, eigenspaces_left was adjusted for this new format. There was no eigenspaces_right, now there is.

The changed code in modular/modform/numerical.py simply adjusts for the new format to allow doctests to pass and is probably sub-optimal. There is a bug nearby, so this will be addressed on #8018.

Doctests: I had some strange behavior for zero eigenvalues (ie very, very small eigenvalues), so the doctests avoid these. For these eigenvalues, the tests would fail on a first run, but would pass on all subsequent runs (or vice-versa). This was observed on my own machine and boxen.math.washington.edu. So I've avoided these eigenvalues by selecting certain ones in the doctests.

Documentation: documentation was tested for these four functions via notebook introspection. The rest of the file needs attention before it can go into the documentation, see #8046.

@rbeezer rbeezer mannequin added s: needs review and removed s: needs work labels Jan 24, 2010
@jasongrout
Copy link
Member

comment:5

Great job!

I think these changes would make the code easier to read:

 	662	        for k in range(len(spectrum)): 
 	663	            evalue = spectrum[k][0] 
 	664	            evector = spectrum[k][1][0] 
 	665	            pairs.append((evalue, evector.parent().span_of_basis([evector],check=False))) 

changed to

for eval,evectors in spectrum:
    evec = evectors[0]
    evector = evec.parent().span_of_basis([evec],check=False)
    pairs.append((evalue, evector))

(similarly on lines 722-725)

Also:

B = matrix(CDF, [spectrum[i][1][0] for i in range(len(spectrum))]).transpose() 

changed to

B = matrix(CDF, [evecs[0] for _,evecs in spectrum]).transpose() 

@rbeezer
Copy link
Mannequin

rbeezer mannequin commented Jan 24, 2010

comment:7

Jason,

Thanks for helping me be more Pythonic.

The bit in the modular form module is going to be replaced in #8018 by totally different code, so I didn't change that. First suggestion (in spirit) has been incorporated in updated patch.

Rob

@rbeezer rbeezer mannequin added s: needs review and removed s: needs work labels Jan 24, 2010
@rbeezer
Copy link
Mannequin

rbeezer mannequin commented Jan 24, 2010

Self-contained patch, apply only this.

@rbeezer
Copy link
Mannequin

rbeezer mannequin commented Jan 24, 2010

comment:8

Attachment: trac_4756-double-eigen.2.patch.gz

I've got some doctests failing on another machine due to "zero" eigenvalues, so I'm going to rework some of the doctests.

@rbeezer rbeezer mannequin added s: needs work and removed s: needs review labels Jan 24, 2010
@rbeezer
Copy link
Mannequin

rbeezer mannequin commented Jan 24, 2010

Attachment: trac_4756-double-eigen.3.patch.gz

Self conatined

@rbeezer
Copy link
Mannequin

rbeezer mannequin commented Jan 24, 2010

comment:9

dot-3 patch has better doctests in it, totally avoiding "zero" eigenvalues and "zero" entries of eigenvectors. Apply just this one patch.

@rbeezer rbeezer mannequin added s: needs review and removed s: needs work labels Jan 24, 2010
@sagetrac-drkirkby
Copy link
Mannequin

sagetrac-drkirkby mannequin commented Feb 22, 2010

comment:10

Has this been checked on Solaris?

There's general information about building on Solaris at

http://wiki.sagemath.org/solaris

Information specifically for 't2' at

http://wiki.sagemath.org/devel/Building-Sage-on-the-T5240-t2

Both the source (4.3.0.1 is the latest to build on Solaris) and a binary which will run on any SPARC can be found at http://www.sagemath.org/download-source.html

Dave

@rbeezer
Copy link
Mannequin

rbeezer mannequin commented Mar 17, 2010

comment:11

Replying to @sagetrac-drkirkby:

Has this been checked on Solaris?

Hi Dave,

Not that I know of. I develop with KUbuntu.

Maybe a reviewer with Solaris experience can put it through its paces. Totally Python, so I'd guess numerical issues might be the only distinction.

Thanks,
Rob

@rbeezer rbeezer mannequin added s: needs review and removed s: needs info labels Mar 17, 2010
@aghitza
Copy link

aghitza commented Apr 3, 2010

comment:12

Looks good to me.

@aghitza
Copy link

aghitza commented Apr 3, 2010

Reviewer: Alex Ghitza

@jhpalmieri
Copy link
Member

comment:13

Merged "trac_4756-double-eigen.3.patch" in 4.4.alpha0

@jhpalmieri
Copy link
Member

Merged: sage-4.4.alpha0

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