Amount and Indices of Skew Diagonals in n-dimensional structures

40 Views Asked by At

Suppose you have an $n ^ m$ matrix, in this example $3 ^ 2$.

Each of those will have a $1$ at the "start", then increase linearly.

$\left( \begin{array}{rrr} 1 & 2 & 3 \\ 2 & 3 & 4 \\ 3 & 4 & 5 \\ \end{array}\right)$

The skew diagonals, going from top-left, in this example are (in no particular order):

$\left(3\right)\\ \left(2,4\right)\\ \left(1,3,5\right)\\ \left(2,4\right)\\ \left(3\right)$

Is there a way to get these from some formula? For this example, to know that I have

  • 1 Diagonal of size $3$, starting from $1$
  • 2 Diagonals of size $2$, starting from $2$
  • 2 Diagonals of size $1$, starting from $3$

Of course, it seems to get a bit more tricky as the dimension of the matrix increases. In the $3^3$ case, there is 3x $\left(3\right)$ and 3x $\left(3,6\right)$, for example.