Function Repository Resource:

# AntidiagonalMatrixQ

Tests whether a matrix is an antidiagonal matrix

Contributed by: Sander Huisman
 ResourceFunction["AntidiagonalMatrixQ"][m] gives True if m is antidiagonal, and False otherwise. ResourceFunction["AntidiagonalMatrixQ"][m,k] gives True if m has nonzero elements only on the kth antidiagonal, and False otherwise.

## Details and Options

An antidiagonal matrix is defined as a matrix whose elements are zero except for its antidiagonal:

ResourceFunction["AntidiagonalMatrixQ"][m] works even if m is not square.
For positive k, ResourceFunction["AntidiagonalMatrixQ"][m,k] tests whether the antidiagonal is above the leading antidiagonal. ResourceFunction["AntidiagonalMatrixQ"][m,-k] tests whether the antidiagonal is below.
ResourceFunction["AntidiagonalMatrixQ"] works on SparseArray matrices.

## Examples

### Basic Examples

Check if a matrix is an antidiagonal matrix:

 In[1]:=
 Out[1]=

Test if the antidiagonal is above the leading antidiagonal one:

 In[2]:=
 Out[2]=

An example of a matrix that is not antidiagonal:

 In[3]:=
 Out[3]=

### Scope

A complex matrix:

 In[4]:=
 Out[4]=

Test a rectangular matrix:

 In[5]:=
 Out[5]=

Test a SparseArray matrix:

 In[6]:=
 Out[6]=

### Options

#### Tolerance

Check if the off-antidiagonal elements are zero within a certain tolerance:

 In[7]:=
 Out[7]=

### Properties and Relations

If the expression is not a matrix it will return false:

 In[8]:=
 Out[8]=
 In[9]:=
 Out[9]=