anti-diagonal ( matrix -- seq )
Matrix operations

Prev:main-diagonal ( matrix -- seq )
Next:matrix-l1-norm ( m -- n )


Vocabulary
math.matrices

Inputs
matrixa matrix


Outputs
seqa sequence


Word description
Find the anti-diagonal of a matrix.

This diagonal begins in the upper right of the matrix, continuing downward and leftward for all indices in the square-matrix subset of the input (see <square-rows>).

Notes
If the number of rows in the square subset of the input is even, then this diagonal will not contain elements found in the main-diagonal. However, if the size of the square subset is odd, then this diagonal will share at most one element with main-diagonal.
This diagonal is sometimes called the second diagonal.
This word is the opposite variant of main-diagonal.


Examples
The operation is simple on a square-matrix:
USING: math.matrices prettyprint ; { { 7 2 11 } { 9 7 7 } { 1 8 0 } } anti-diagonal .
{ 11 7 1 }

The square subset of the following input matrix consists of all rows but the last. The anti-diagonal does not include the last row because it has no fourth element.
USING: math.matrices prettyprint ; { { 6 5 0 } { 7 2 6 } { 4 3 9 } { 3 3 3 } } anti-diagonal .
{ 0 2 4 }


Definition