Search code examples
pythonpython-2.7linear-algebrasympyeigenvalue

How to determine the eigenvalues of sympy.matrices.dense.MutableDenseMatrix?


The Python SymPy Matrix API has a method to determine the eigenvalue. I would like to do similar thing with SymPy MutableDenseMatrix. Unfortunately, the API doesn't allow me to do it.

Is there any way to do it?


Solution

  • As suggested in my comment, it must of course be a square matrix, but then simply construct a Matrix out of your MutableDenseMatrix:

    >>> from sympy.matrices.dense import MutableDenseMatrix
    >>> from sympy.matrices import Matrix
    >>> a = MutableDenseMatrix([[1,0,0], [0,0,0], [2, -2, 3]])
    >>> b = Matrix(a)
    >>> b.eigenvals()
    {0: 1, 1: 1, 3: 1}