diagonalQ[m_List]/;ArrayDepth[m]===2&&Equal@@Dimensions[m]:=
And@@Flatten[MapIndexed[#1===0||Equal@@#2&,m,{2}]];
diagonalQ[m_]:=Return[False];
matA = {{1, 2},
{2, 4}};
matB = {{1, 0},
{0, 2}};
matC = {{1, 0, 2},
{0, 2, 4}};
diagonalQ[matA]
diagonalQ[matB]
diagonalQ[matC]
|
Out[59]= False
Out[60]= True
Out[61]= False
|