Harald Schilly wrote:
> This is from the notebook's "report a problem" bugtracker, there are
> *two* different problems reported. Machine is Linux/32bit on Sage
> 4.0.2.
> 
> 
> Quote:
> 
> different formatting of output of eigenvectors_left depending on which
> space the matrix is over      A = matrix(QQ,3,3,range(9))
> B = matrix(RDF,3,3,range(9))
> 
> A.eigenvectors_left()
> [(0, [
> (1, -2, 1)
> ], 1), (-1.348469228349535?, [(1, 0.3101020514433644?,
> -0.3797958971132713?)], 1), (13.34846922834954?, [(1,
> 1.289897948556636?, 1.579795897113272?)], 1)]
> i.e. a list (eigenvalue, [corresponding eigenspace], multiplicity)
> 
> whereas
> B.eigenvectors_left()
> ([13.3484692283, -1.34846922835, -1.1327908706e-15], [ 0.440242867236
> 0.567868371314 0.695493875393]
> [ 0.897878732262 0.278434036822 -0.341010658618]
> [ 0.408248290464 -0.816496580928 0.408248290464])
> i.e. a list of eigenvalues and then a matrix whose rows are the
> eigenvectors
> 
> this is a bit confusing and it would be nicer if the output formatting
> was the same in both cases.


Yep, I agree.  That's been on my TODO list for a while.  The difference 
is that scipy computes the RDF eigenvectors, and its format is not 
massaged into the more normal Sage format.  Similar observations apply 
to the other RDF eigen functions.  I hope someone beats me to it :).



> 
> *******************
> second one:
> *******************
> 
> Also, I noticed that the eigenvalues for the matrix over RDF are a bit
> inaccurate, leading to very different eigenvectors. Using
> B.charpoly.roots()
> [(-1.34846922835, 1), (0.0, 1), (13.3484692283, 1)]
> the zero eigenvalue is actually zero
> 
> could the output of the eigenvectors_left method be standardised over
> the different fields? (same goes for eigenvectors_right, of course)
> 
> About the values of eigenvalues and -vectors, is that an intrinsic
> problem with using RDF or can it be improved?


The RDF uses scipy, which in turn uses the standard fortran libraries to 
compute these things.  We could maybe make a bigger cutoff for deciding 
when the returned value is zero.  But I think we still ought to call 
scipy/fortran for the RDF functions.  In general, RDF things are 
machine-precision things, and that is what scipy/fortran specializes in.

Note that there is also a speed difference:

sage: %timeit B.charpoly().roots()
1000 loops, best of 3: 764 µs per loop
sage: %timeit B.eigenvalues()
1000 loops, best of 3: 382 µs per loop
sage: C = random_matrix(RDF,100)
sage: %timeit d=C.eigenvalues()
10 loops, best of 3: 126 ms per loop
sage: %timeit d=C.charpoly().roots()
10 loops, best of 3: 180 ms per loop


Interestingly, it also goes the other way for certain matrices:

sage: D = matrix(RDF,100,range(100^2))
sage: %timeit d=D.eigenvalues()
10 loops, best of 3: 111 ms per loop
sage: %timeit d=D.charpoly().roots()
10 loops, best of 3: 2.84 ms per loop


Thanks,

Jason


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to