deed936ca0bfa5998af0225fab99c47bd2bc4b6d,mathics/builtin/linalg.py,Eigenvalues,apply,#Eigenvalues#Any#Any#,715
Before Change
if matrix.cols != matrix.rows or matrix.cols == 0:
return evaluation.message("Eigenvalues", "matsq", m)
eigenvalues = matrix.eigenvals().items()
try:
eigenvalues = sorted(eigenvalues,
key=lambda v_c: (abs(v_c[0]), -v_c[0]),
reverse=True)
// Try to sort the results as complex numbers
except TypeError:
try:
eigenvalues = sorted(eigenvalues,
key=lambda v_c: -abs(v_c[0]))
// Don"t sort the results at all
except TypeError:
pass
return from_sympy([v for (v, c) in eigenvalues for _ in range(c)])
class Eigensystem(Builtin):
After Change
eigenvalues = list(matrix.eigenvals().items())
// Sort the eigenvalues in the Mathematica convention
if all(v.is_complex for (v, _) in eigenvalues):
eigenvalues.sort(key=lambda v: (abs(v[0]), - re(v[0]), - im(v[0])),
reverse=True)
eigenvalues = [from_sympy(v) for (v, c) in eigenvalues
for _ in range(c)]
// Sort the eigenvalues in an arbitrary yet deterministic order
else:
eigenvalues = [(from_sympy(v), c) for (v, c) in eigenvalues]
eigenvalues.sort(key=lambda v: v[0].get_sort_key())
eigenvalues = [v for (v, c) in eigenvalues for _ in range(c)]
return Expression("List", *eigenvalues)
class Eigensystem(Builtin):
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 8
Instances
Project Name: mathics/Mathics
Commit Name: deed936ca0bfa5998af0225fab99c47bd2bc4b6d
Time: 2020-09-06
Author: pablo-escobar@riseup.net
File Name: mathics/builtin/linalg.py
Class Name: Eigenvalues
Method Name: apply
Project Name: DistrictDataLabs/yellowbrick
Commit Name: ca14cf72e3e4bd3a6136cafad8701ac41f48f09b
Time: 2018-08-25
Author: davidwaterman@gmail.com
File Name: yellowbrick/cluster/elbow.py
Class Name: KElbowVisualizer
Method Name: __init__
Project Name: mathics/Mathics
Commit Name: d6e00edb6b5e23c0aafc7b169f7517fe39da0fd6
Time: 2020-09-06
Author: pablo-escobar@riseup.net
File Name: mathics/builtin/linalg.py
Class Name: Eigenvectors
Method Name: apply