anti-diagonal ( matrix -- seq )

Matrix operations

Matrix operations

Prev: | main-diagonal ( matrix -- seq ) |

Next: | matrix-l1-norm ( m -- n ) |

Vocabulary

math.matrices

Inputs

Outputs

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

Examples

The operation is simple on a square-matrix:

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.

Definition

math.matrices

Inputs

matrix | a matrix |

Outputs

seq | a 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 }

{ 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 }

{ 0 2 4 }

Definition

This documentation was generated offline from a
`load-all`

image. If you want, you can also
browse the documentation from within the UI developer tools. See
the Factor website
for more information.

Factor 0.101 x86.64 (2284, heads/master-4a32b2801d, Nov 5 2024 16:06:40)