sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.34k stars 454 forks source link

Left eigenvectors for CBF #33652

Closed a67c9e2f-a36c-4a8e-80bb-0c82631d944f closed 2 years ago

a67c9e2f-a36c-4a8e-80bb-0c82631d944f commented 2 years ago

For matrices over ComplexBallField, one can get right eigenvectors but asking for left eigenvectors triggers a not-implemented error.

sage: M = random_matrix(CBF, 2, 2)
sage: right = M.eigenvectors_right()
sage: left = M.eigenvectors_left()
NotImplementedError: eigenspaces cannot be computed reliably for inexact rings such as Complex ball field with 256 bits of precision,
consult numerical or symbolic matrix classes for other options

Here we make eigenvectors_left return the right eigenvectors of the transpose.

CC: @videlec @mezzarobba @seblabbe

Component: linear algebra

Keywords: ComplexBallField, thursdaysbdx

Author: Vincent Delecroix

Branch/Commit: c02327f

Reviewer: Marc Mezzarobba

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

videlec commented 2 years ago
comment:2

The problem is that in the generic code (matrix2.pyx) it is implemented the other way around : there is a default implementation for eigenvectors_left and eigenvectors_right calls eigenvectors_left with the transposed matrix.

videlec commented 2 years ago

New commits:

c63723133652: transpose and left eigenvectors for acb_mat
videlec commented 2 years ago

Author: Vincent Delecroix

videlec commented 2 years ago

Changed keywords from ComplexBallField to ComplexBallField, thursdaysbdx

videlec commented 2 years ago

Branch: u/vdelecroix/33652

videlec commented 2 years ago

Commit: c637231

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Changed commit from c637231 to bac4ef1

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

bac4ef133652: transpose and left eigenvectors for acb_mat
mezzarobba commented 2 years ago
comment:5

Lgtm except for one occurrence of eigenvectors_right_approx that should be `eigenvectors_left_approxin the doc ofeigenvectors_left``.

mezzarobba commented 2 years ago

Reviewer: Marc Mezzarobba

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Changed commit from bac4ef1 to 4012cd2

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

46ee55833625: _new_matrix -> _new
4012cd233625: fix in the doc `_right_` -> _left_
videlec commented 2 years ago
comment:7

Thanks for having a look. Indeed I was not very careful when copying the doc.

seblabbe commented 2 years ago
comment:8

Patchbot says:

========== blocks ==========
git checkout patchbot/ticket_merged
inside file:  b/src/sage/matrix/matrix_complex_ball_dense.pyx
@@ -551,6 +551,26 @@ cdef class Matrix_complex_ball_dense(Matrix_dense):
+        Returns the transpose of ``self``.
wrong syntax for blocks (INPUT, OUTPUT, EXAMPLES, NOTE, etc) inserted on 1 non-empty lines
blocks -- 0 seconds
========== end blocks ==========

It should be Return with no s.

seblabbe commented 2 years ago
comment:10

Other issues on the patchbot seems unrelated to this branch. Only the issue with blocks remain.

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Changed commit from 4012cd2 to c02327f

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

c02327f33652: returns -> return
slel commented 2 years ago

Description changed:

--- 
+++ 
@@ -1,13 +1,14 @@
-When computing left eigenvectors for ComplexBallField matrices, sage raises a not implemented error, whereas right eigenvectors are working.
-
-Example :
+For matrices over `ComplexBallField`, one can get
+right eigenvectors but asking for left eigenvectors
+triggers a not-implemented error.

-M = random_matrix(CBF,2,2) -print(M.eigenvectors_right()) -print(M.eigenvectors_left())

+sage: M = random_matrix(CBF, 2, 2) +sage: right = M.eigenvectors_right() +sage: left = M.eigenvectors_left() NotImplementedError: eigenspaces cannot be computed reliably for inexact rings such as Complex ball field with 256 bits of precision, consult numerical or symbolic matrix classes for other options


+Here we make `eigenvectors_left` return
+the right eigenvectors of the transpose.
vbraun commented 2 years ago

Changed branch from u/vdelecroix/33652 to c02327f