# Automatically discover the class of an arbitrary matrix

In Wolfram|Alpha it is possible to discover some specific classes to which a matrix belongs.

For instance, typing this in Wolfram|Alpha

{{a, b, c}, {c, a, b}, {b, c, a}}


returns

Properties:
normal
circulant


Is there a built-in Mathematica command which can generate the same kind of output?

As far is I can tell, there is no built-in command to do so. However, typing

?*MatrixQ


Into the front end and evaluating will give a list of the matrix properties you can test for in Mathematica. Based on the resulting list, I came up with the following simple function that you might find useful.

This is just a helper function to make the output look nice:

MatrixQtoTitle[a_] :=
StringTrim[StringReplace[ ToString[a], {"MatrixQ" -> "",
uc : CharacterRange["A", "Z"] :> " " ~~ ToLowerCase[uc]}]]


And here is the suggested function, using the output from the ?*MatrixQ line mentioned above:

MatrixPropertiesReport[mat_?MatrixQ] :=
Grid[{MatrixQtoTitle[#], #[mat]} & /@ {AntihermitianMatrixQ,
AntisymmetricMatrixQ, DiagonalizableMatrixQ, HermitianMatrixQ,
IndefiniteMatrixQ, NegativeDefiniteMatrixQ,
NegativeSemidefiniteMatrixQ, NormalMatrixQ, OrthogonalMatrixQ,
PositiveDefiniteMatrixQ, PositiveSemidefiniteMatrixQ,
SquareMatrixQ, SymmetricMatrixQ, UnitaryMatrixQ}]


antihermitian          False
antisymmetric          False
diagonalizable         True
hermitian              False
indefinite             False
negative definite      False
negative semidefinite  False
normal                 True
orthogonal             False
positive definite      False
positive semidefinite  False
square                 True
symmetric              False
unitary                False


If you wanted you could adapt this function to, for example, only show the rows that are true, much as Wolfram|Alpha does.

• ...and of course, you can call Alpha from within Mathematica if needed. (For instance, Alpha can check if a matrix is circulant.) – J. M. is away Nov 23 '15 at 0:52
• @J.M. - true, but I wanted to showcase an all-Wolfram-language solution – Verbeia Nov 23 '15 at 1:26
• Here's the variation that retains only the relevant properties: MatrixPropertiesReport[mat_?MatrixQ] := If[ToExpression[#][mat], ToLowerCase[Fold[StringReplace, #, {"MatrixQ" -> "", x_?LowerCaseQ ~~ y_?UpperCaseQ :> x <> " " <> y}]], Nothing] & /@ DeleteCases[Names["*MatrixQ"], "MatrixQ"] – J. M. is away Dec 13 '15 at 18:34