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
arraya shaped-array, a sequence, or a number
axesa sequence


Outputs
viewa 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


:: 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> ;