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.
ResourceFunction["AntidiagonalTotals"][mat] is equal to ResourceFunction["AntidiagonalTotals"][Transpose[mat]].

Examples

Basic Examples (2) 

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[3]=
In[4]:=
ResourceFunction["AntidiagonalTotals"][mat]
Out[4]=

Properties and Relations (3) 

The direction of the antidiagonals:

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

AntidiagonalTotals[mat] is equal to AntidiagonalTotals[Transpose[mat]]:

In[6]:=
mat = RandomInteger[{-5, 5}, {3, 3}]
Out[6]=
In[7]:=
a1 = ResourceFunction["AntidiagonalTotals"][mat]
Out[7]=
In[8]:=
a2 = ResourceFunction["AntidiagonalTotals"][Transpose[mat]]
Out[8]=
In[9]:=
a1 == a2
Out[9]=

Pascal’s triangle:

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

The Fibonacci sequence:

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

Publisher

George Beck

Requirements

Wolfram Language 11.3 (March 2018) or above

Version History

  • 1.0.0 – 11 February 2019

License Information