# Ticket #4756: trac_4756-double-eigen.patch

File trac_4756-double-eigen.patch, 13.6 KB (added by Rob Beezer, 13 years ago)

Self-contained patch, apply only this

• ## sage/matrix/matrix_double_dense.pyx

```# HG changeset patch
# User Rob Beezer <beezer@ups.edu>
# Date 1264132569 28800
# Node ID 95c1b7c2c217532638ff93d59f609116ea09581f
# Parent  4498ef979fc42b03037970223b0873b07d63b96b
[mq]: eigen

diff -r 4498ef979fc4 -r 95c1b7c2c217 sage/matrix/matrix_double_dense.pyx```
 a def eigenspaces_left(self, var='a', algebraic_multiplicity=False): r""" Return a list of pairs (e, V) where e runs through all complex eigenvalues of this matrix, and V is the corresponding left eigenspace (always a 1-dimensional complex vector space). Computes the left eigenspaces of a matrix of double precision real or complex numbers (i.e. RDF or CDF). INPUT Both the var and the algebraic_multiplicity arguments are ignored.  They do not make much sense in a numerical situation. INPUT: EXAMPLES: sage: m = matrix(RDF, 3, range(9)); m [0.0 1.0 2.0] [3.0 4.0 5.0] [6.0 7.0 8.0] sage: es = m.eigenspaces_left() sage: es # random [(13.3484692283, Vector space of degree 3 and dimension 1 over Real Double Field - ``var`` - ignored for numerical matrices - ``algebraic_multiplicity`` - must be set to ``False`` for numerical matrices, and will raise an error otherwise. OUTPUT: Return a list of pairs ``(e, V)`` where ``e`` is a (complex) eigenvalue and ``V`` is the associated left eigenspace as a vector space. No attempt is made to determine if an eigenvalue has multiplicity greater than one, so all the eigenspaces returned have dimension one. EXAMPLES:: sage: m = matrix(RDF, 3, range(9)) sage: spectrum = m.eigenspaces_left() sage: spectrum[0] (13.3484692283, Vector space of degree 3 and dimension 1 over Real Double Field User basis matrix: [-0.440242867236 -0.567868371314 -0.695493875393]), (-1.34846922835, Vector space of degree 3 and dimension 1 over Real Double Field User basis matrix: [-0.897878732262 -0.278434036822  0.341010658618]), (-9.10854412047e-16, Vector space of degree 3 and dimension 1 over Real Double Field User basis matrix: [ 0.408248290464 -0.816496580928  0.408248290464])] [0.440242867236 0.567868371314 0.695493875393]) sage: e, v = es[0] sage: e, v = spectrum[0] sage: v = v.basis()[0] sage: a = v * m sage: b = e * v sage: diff # random -- very small numbers (-2.6645352591e-15, -7.1054273576e-15, -3.5527136788e-15) TESTS: TESTS:: sage: m.eigenspaces_left(algebraic_multiplicity=True) Traceback (most recent call last): ... ValueError: algebraic_multiplicity can only be False for double precision matrices ValueError: algebraic_multiplicity must be set to False for double precision matrices """ # Raise an error if algebraic_multiplicity is True since that # would normally change the format of the return value. # For numerical values we leave decisions about # multiplicity to the calling routine if algebraic_multiplicity: raise ValueError, "algebraic_multiplicity can only be False for double precision matrices" e, v = self.left_eigenvectors() v = v.rows() raise ValueError, "algebraic_multiplicity must be set to False for double precision matrices" spectrum = self.left_eigenvectors() pairs = [] for l from 0<=l
• ## sage/modular/modform/numerical.py

`diff -r 4498ef979fc4 -r 95c1b7c2c217 sage/modular/modform/numerical.py`
 a t += randint(-50,50)*M.T(p).matrix() self._hecke_matrix = t evals, B = t.change_ring(CDF).right_eigenvectors() # evals, B = t.change_ring(CDF).right_eigenvectors() from sage.matrix.constructor import matrix spectrum = t.change_ring(CDF).right_eigenvectors() evals = [spectrum[i][0] for i in range(len(spectrum))] B = matrix(CDF, [spectrum[i][1][0] for i in range(len(spectrum))]).transpose() # Find the eigenvalues that occur with multiplicity 1 up # to the given eps.