Matrix Kind#

class sympy.matrices.kind.MatrixKind(element_kind=NumberKind)[source]#

Kind for all matrices in SymPy.

Basic class for this kind is MatrixBase and MatrixExpr, but any expression representing the matrix can have this.


element_kind : Kind

Kind of the element. Default is sympy.core.kind.NumberKind, which means that the matrix contains only numbers.


Any instance of matrix class has kind MatrixKind:

>>> from sympy import MatrixSymbol
>>> A = MatrixSymbol('A', 2, 2)
>>> A.kind

An expression representing a matrix may not be an instance of the Matrix class, but it will have kind MatrixKind:

>>> from sympy import MatrixExpr, Integral
>>> from import x
>>> intM = Integral(A, x)
>>> isinstance(intM, MatrixExpr)
>>> intM.kind

Use isinstance() to check for MatrixKind without specifying the element kind. Use is to check the kind including the element kind:

>>> from sympy import Matrix
>>> from sympy.core import NumberKind
>>> from sympy.matrices import MatrixKind
>>> M = Matrix([1, 2])
>>> isinstance(M.kind, MatrixKind)
>>> M.kind is MatrixKind(NumberKind)

list of weak references to the object