NumPy-style shaped-array operations


Shaped arrays support broadcast elementwise arithmetic, scalar arrays, reshape, writable basic views, axis reductions, and batched matrix multiplication. They use Factor numbers and sequence storage; they do not implement NumPy's dtype system or its full API.
>shaped-array ( array -- shaped-array )

reshape ( array shape -- result )

shaped-slice-view ( array selectors -- view )

shaped-permute ( array axes -- view )

shaped-transpose ( array -- view )

shaped-sum ( array axes keepdims? -- result )

shaped-mean ( array axes keepdims? -- result )

shaped-min ( array axes keepdims? -- result )

shaped-max ( array axes keepdims? -- result )

shaped-matmul ( a b -- result )


A shaped array is a flat sequence for Factor's sequence protocol: length is its total element count. Access shape for dimensions. Reduction and vector-dot results remain shaped arrays, with an empty shape for scalars. Ordinary reshape shares data but creates new shape metadata; reshaping a virtual view materializes its logical row-major elements. Basic views share data. Cloning copies storage and shape metadata; cloning a view materializes its logical row-major elements. Arithmetic and reductions allocate fresh output. Zero-rank axis reductions use f or an empty axis sequence. Slicing currently excludes advanced indexing, ellipsis, and new-axis insertion. Numeric dtype selection, out/where/initial reduction arguments, Fortran-order reshape, and optimized BLAS kernels are outside this API.