anti-transpose ( matrix -- newmatrix )

Matrix operations

Matrix operations

Prev: | transpose ( matrix -- newmatrix ) |

Next: | matrix-nth ( pair matrix -- elt ) |

Vocabulary

math.matrices

Inputs

Outputs

Word description

Like transpose except that the matrix is transposed over the anti-diagonal, so that the anti-diagonal itself is preserved and the main-diagonal is reversed.

Notes

This word is the opposite variant of transpose.

Examples

Definition

math.matrices

Inputs

matrix | a matrix |

Outputs

newmatrix | a matrix |

Word description

Like transpose except that the matrix is transposed over the anti-diagonal, so that the anti-diagonal itself is preserved and the main-diagonal is reversed.

Notes

This word is the opposite variant of transpose.

Examples

USING: math.matrices sequences prettyprint ;
5 <iota> <diagonal-matrix> anti-transpose .

{ { 4 0 0 0 0 } { 0 3 0 0 0 } { 0 0 2 0 0 } { 0 0 0 1 0 } { 0 0 0 0 0 } }

{ { 4 0 0 0 0 } { 0 3 0 0 0 } { 0 0 2 0 0 } { 0 0 0 1 0 } { 0 0 0 0 0 } }

Definition

: anti-transpose ( matrix -- newmatrix )

dup empty?

[ ] [

[

dup regular-matrix?

[ matrix-cols-iota ] [ unshaped-cols-iota ] if

] keep dup array-matrix?

[ array-anti-transpose-unsafe ]

[ generic-anti-transpose-unsafe ] if

] if ;

dup empty?

[ ] [

[

dup regular-matrix?

[ matrix-cols-iota ] [ unshaped-cols-iota ] if

] keep dup array-matrix?

[ array-anti-transpose-unsafe ]

[ generic-anti-transpose-unsafe ] if

] if ;

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 (2282, heads/master-74be1555ff, Sep 25 2024 19:43:38)