I've been working on writing eigenvalue/eigenvector functions, as
mentioned here:
http://groups.google.com/group/sage-devel/browse_thread/thread/c8d2001f2b19a9bc/2585039efd2fbd2f?lnk=gst&q=kernel#2585039efd2fbd2f
Here is the interface as it now stands. Does anyone have any comments
or questions?
* eigenspaces_left, eigenspaces_right: Like the current eigenspaces
function, but returns the algebraic multiplicity of the eigenvalue as
well in tuples like: (eigenvalue, eigenspace, algebraic multiplicity).
This way, existing code that depends on the first two elements of a
returned tuple being what they are still works. In the future, we might
consider using a dictionary like {"eigenvalue": eigenvaxill works. It
prints a deprecation warning and then calls eigenspaces_left.
Also, the even_if_inexact argument is deprecated. Instead, a warning
message is printed if the function is called with an inexact base ring.
Note that the eigenspace functions still return the eigenvalues up to
Galois conjugation, and the algebraic multiplicity applies to each
galois conjugate of the returned eigenvalue (at least, I think that's
how the math should work, right?)
* eigenvalues: This function returns all the eigenvalues as elements of
QQbar: i.e., it returns all the galois conjugates of eigenvalues
returned in eigenspaces_left. For an nxn matrix, it returns n
eigenvalues, so the algebraic multiplicity is not explicitly returned,
but is implicit in the list.
* eigenvectors_left, eigenvectors_right: These functions return tuples
of the form: (eigenvalue, list of eigenvectors, algebraic multiplicity).
The eigenvalues are elements of QQbar and are all distinct
eigenvalues. The list of eigenvectors is found by taking the basis of
the space returned in eigenspaces_* and then mapping it to QQbar^n by
the map that takes the eigenvalue to a particular galois conjugate.
* eigenmatrix_left, eigenmatrix_right: This mimics the eig command in
Matlab: it returns a matrix D and a matrix P, where D is a diagonal
matrix of eigenvalues and P is a matrix of rows or columns corresponding
eigenvectors or zero vectors so that AP=PD or PA=DP (depending on left
or right).
I'm also trying to get the kernel and image and other functions that
depend on left/right notions to signify they side they are computing.
Right now I changed them to *_left and *_right (instead of left_* and
right_*) and deprecating the left_* and right_* functions. I realize
that the *_left/right functions don't read as naturally as left/right_*
functions, but they make a lot more sense in tab completion; if someone
is looking to compute the kernel of a matrix, then it's harder to find
the function if it is called left/right_kernel than if it is called
kernel_left/right. For tab completion, I think it's better in general
to do an index-style noun_modifier than modifier_noun (as would be more
naturally spoken).
Also, to address another point: there would be a lot functions with the
above changes. I'm following the philosophy expressed, I believe, by
Nick: that each function should clearly indicate what it is returning
and that arguments should not change the mathematical content of what is
being returned. I see left eigenvectors and right eigenvectors as
fundamentally different things, i.e., I wouldn't ever want to confuse
the two (well, I guess unless the matrix was symmetric :). That's why I
have two different functions instead of one eigenvectors(left=True) or
eigenvectors(right=True).
I'm trying hard to get this done for 3.0.6 in time for an AIM workshop
on undergraduate linear algebra research that is introducing the
participants to Sage. Otherwise, I'm afraid that Sage won't be very
suitable for the workshop, not having an eigenvalues function, for example.
Thanks,
Jason
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---