DiagonalMatrixQ

DiagonalMatrixQ[m]

gives True if m is diagonal, and False otherwise.

DiagonalMatrixQ[m,k]

gives True if m has nonzero elements only on the k^(th) diagonal, and False otherwise.

Details and Options

Examples

open all close all

Basic Examples  (3)

Test if a matrix is diagonal:

In[1]:=
Click for copyable input
Out[1]//MatrixForm=
In[2]:=
Click for copyable input
Out[2]=
In[3]:=
Click for copyable input
Out[3]//MatrixForm=
In[4]:=
Click for copyable input
Out[4]=

Test a superdiagonal matrix:

In[1]:=
Click for copyable input
Out[1]//MatrixForm=
In[2]:=
Click for copyable input
Out[2]=

Test a subdiagonal matrix:

In[1]:=
Click for copyable input
Out[1]//MatrixForm=
In[2]:=
Click for copyable input
Out[2]=

Scope  (7)

Options  (1)

Applications  (2)

Properties & Relations  (10)

Introduced in 2019
(12.0)