| 5110 | Computation of the eigenvalues over the field ``RR`` or ``CC`` |
| 5111 | defaults to computing over ``RDF`` or ``CDF``, respectively, |
| 5112 | instead. A warning is provided about this change.:: |
| 5113 | |
| 5114 | sage: M = matrix([[1.2, 2],[2, 3]]) |
| 5115 | sage: M.eigenvalues() |
| 5116 | doctest:1: UserWarning: Computing the eigenvalues over the RDF field since the generic algorithm for the inexact ring RR may give incorrect results due to numerical precision issues. |
| 5117 | [-0.0931712199461, 4.29317121995] |
| 5118 | sage: M = matrix(CC, [[1.2, I],[2, 3]]) |
| 5119 | sage: M.eigenvalues() |
| 5120 | doctest:1: UserWarning: Computing the eigenvalues over the CDF field since the generic algorithm for the inexact ring CC may give incorrect results due to numerical precision issues. |
| 5121 | [0.881845698329 - 0.820914065343*I, 3.31815430167 + 0.820914065343*I] |
| 5122 | |
5123 | | warn("Using generic algorithm for an inexact ring, which will probably give incorrect results due to numerical precision issues.") |
| 5137 | from sage.rings.real_mpfr import RealField_class |
| 5138 | from sage.rings.complex_field import ComplexField_class |
| 5139 | if isinstance(self_ring, RealField_class): |
| 5140 | warn("Computing the eigenvalues over the RDF field since " |
| 5141 | "the generic algorithm for the inexact ring RR may give " |
| 5142 | "incorrect results due to numerical precision issues.") |
| 5143 | # Over RDF we get both real and complex eigenvalues |
| 5144 | V = self.change_ring(RDF).eigenvalues() |
| 5145 | self.cache('eigenvalues', V) |
| 5146 | return V |
| 5147 | elif isinstance(self_ring, ComplexField_class): |
| 5148 | warn("Computing the eigenvalues over the CDF field since " |
| 5149 | "the generic algorithm for the inexact ring CC may give " |
| 5150 | "incorrect results due to numerical precision issues.") |
| 5151 | # Over CDF we get both real and complex eigenvalues |
| 5152 | V = self.change_ring(CDF).eigenvalues() |
| 5153 | self.cache('eigenvalues', V) |
| 5154 | return V |
| 5155 | else: |
| 5156 | warn("Using generic algorithm for an inexact ring, which " |
| 5157 | "will probably give incorrect results due to numerical " |
| 5158 | "precision issues.") |
| 5239 | Computation of the eigenvectors over the field ``RR`` or ``CC`` |
| 5240 | defaults to computing over ``RDF`` or ``CDF``, respectively, |
| 5241 | instead. A warning is provided about this change.:: |
| 5242 | |
| 5243 | sage: M = matrix([[1.2, 2],[2, 3]]) |
| 5244 | sage: M.eigenvectors_left() |
| 5245 | doctest:1: UserWarning: Computing the eigenvectors over the RDF field since the generic algorithm for the inexact ring RR may give incorrect results due to numerical precision issues. |
| 5246 | [(-0.0931712199461, [(-0.839751355262, 0.542971142268)], 1), |
| 5247 | (4.29317121995, [(-0.542971142268, -0.839751355262)], 1)] |
| 5248 | sage: M = matrix(CC, [[1.2, I],[2, 3]]) |
| 5249 | sage: M.eigenvectors_left() |
| 5250 | doctest:1: UserWarning: Computing the eigenvectors over the CDF field since the generic algorithm for the inexact ring CC may give incorrect results due to numerical precision issues. |
| 5251 | [(0.881845698329 - 0.820914065343*I, [(0.915245825866, -0.145594698293 + 0.37566908585*I)], 1), |
| 5252 | (3.31815430167 + 0.820914065343*I, [(0.616145932705 + 0.238794153033*I, 0.750560818381)], 1)] |
| 5253 | |
5208 | | warn("Using generic algorithm for an inexact ring, which may result in garbage from numerical precision issues.") |
| 5262 | from sage.rings.real_mpfr import RealField_class |
| 5263 | from sage.rings.complex_field import ComplexField_class |
| 5264 | if isinstance(self_ring, RealField_class): |
| 5265 | warn("Computing the eigenvectors over the RDF field since " |
| 5266 | "the generic algorithm for the inexact ring RR may give " |
| 5267 | "incorrect results due to numerical precision issues.") |
| 5268 | # Over RDF we get both real and complex eigenvalues |
| 5269 | evec_eval_list = self.change_ring(RDF).eigenvectors_left() |
| 5270 | self.cache('eigenvectors_left', evec_eval_list) |
| 5271 | return evec_eval_list |
| 5272 | elif isinstance(self_ring, ComplexField_class): |
| 5273 | warn("Computing the eigenvectors over the CDF field since " |
| 5274 | "the generic algorithm for the inexact ring CC may give " |
| 5275 | "incorrect results due to numerical precision issues.") |
| 5276 | # Over CDF we get both real and complex eigenvalues |
| 5277 | evec_eval_list = self.change_ring(CDF).eigenvectors_left() |
| 5278 | self.cache('eigenvectors_left', evec_eval_list) |
| 5279 | return evec_eval_list |
| 5280 | else: |
| 5281 | warn("Using generic algorithm for an inexact ring, which " |
| 5282 | "may result in garbage from numerical " |
| 5283 | "precision issues.") |