Handbook
Glossary
shaped-permute ( array axes -- view )
NumPy-style shaped-array operations
Prev:
shaped-slice-view ( array selectors -- view )
Next:
shaped-transpose ( array -- view )
Vocabulary
arrays
.
shaped
Inputs
array
a
shaped-array
, a
sequence
, or a
number
axes
a
sequence
Outputs
view
a
shaped-array
Word description
Returns a writable view with axes in the specified order. Each axis must occur exactly once; negative axis numbers count from the end. Element storage is shared, and shape metadata is copied.
Definition
USING:
accessors
arrays.shaped.private
kernel
sequences
;
IN:
arrays.shaped
::
shaped-permute
( array axes -- view )
array
>shaped-array
:>
shaped shaped
shape>>
:>
dimensions
axes dimensions
length
normalize-axes
:>
permutation permutation
length
dimensions
length
=
[
axes dimensions
length
invalid-shaped-permutation
]
unless
dimensions
row-major-strides
:>
strides shaped
underlying>>
permutation
[
dimensions
nth
]
map
permutation
[
strides
nth
]
map
0
<shaped-view>
;