Function Repository Resource:

# Antidiagonal

Give the antidiagonal of a matrix

Contributed by: Sander Huisman
 ResourceFunction["Antidiagonal"][m] gives the list of elements on the leading antidiagonal of the matrix m. ResourceFunction["Antidiagonal"][m,k] gives the elements on the kth antidiagonal of m.

## Details and Options

An antidiagonal is defined as a list of elements for which the sum of the indices are equal, where the first element is in the top-right of a matrix:
ResourceFunction["Antidiagonal"][m] works even if m is not square.
For positive k, ResourceFunction["Antidiagonal"][m,k] gives antidiagonals above the leading antidiagonal while ResourceFunction["Antidiagonal"][m,-k] gives antidiagonals below.
ResourceFunction["Antidiagonal"] works on SparseArray matrices and will return a SparseArray list.

## Examples

### Basic Examples (3)

Give the antidiagonal elements of a matrix:

 In[1]:=
 Out[1]=

Give antidiagonals one element above and below the leading diagonal:

 In[2]:=
 Out[2]=
 In[3]:=
 Out[3]=

Give an antidiagonal of a nonsquare matrix:

 In[4]:=
 Out[4]=

### Properties and Relations (1)

Antidiagonal and Diagonal are related to each other:

 In[5]:=
 Out[6]=

### Possible Issues (1)

If k is too high or too low, an empty list is returned:

 In[7]:=
 Out[7]=

### Neat Examples (1)

Rotate a matrix by 45 degrees:

 In[8]:=
 Out[8]=

SHuisman

## Version History

• 1.0.0 – 24 June 2019