Wolfram Research

Function Repository Resource:

AntidiagonalTotals

Source Notebook

Give the totals of the entries on the rising diagonals of a square matrix

Contributed by: George Beck

ResourceFunction["AntidiagonalTotals"][mat]

gives the first n totals along the antidiagonals of the n×n matrix mat.

Details and Options

The matrix must be square.
The result for the matrix is the same as for its transpose.

Examples

Basic Examples

Get the totals for a 3×3 matrix:

In[1]:=
ResourceFunction["AntidiagonalTotals"][Array[a, {3, 3}]]
Out[1]=

Get the totals for a random matrix:

In[2]:=
mat = RandomInteger[{-10, 10}, {4, 4}]
Out[2]=
In[3]:=
ResourceFunction["AntidiagonalTotals"][mat]
Out[3]=

Properties and Relations

The direction of the antidiagonals:

In[4]:=
Table[Style["\[UpperRightArrow]", 24], {m, 3}, {n, 3}] // Grid
Out[4]=

Pascal’s triangle:

In[5]:=
(b = Table[Binomial[m, n], {m, 0, 10}, {n, 0, m}]) // Grid
Out[5]=

The Fibonacci sequence:

In[6]:=
ResourceFunction["AntidiagonalTotals"]@PadRight@b
Out[6]=
In[7]:=
Fibonacci@Range@11
Out[7]=

Requirements

Wolfram Language 11.3 (March 2018) or above

Resource History

License Information