Handbook
Glossary
anti-transpose ( matrix -- newmatrix )
Matrix operations
Prev:
transpose ( matrix -- newmatrix )
Next:
matrix-nth ( pair matrix -- elt )
Vocabulary
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 } }
Definition
USING:
kernel
math.matrices.private
sequences
;
IN:
math.matrices
:
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
;