reduce-shaped ( array axes keepdims? identity quot -- result count )


Vocabulary
arrays.shaped.private

Inputs
arrayan object
axesan object
keepdims?an object
identityan object
quotan object


Outputs
resultan object
countan object


Definition


:: reduce-shaped
( array axes keepdims? identity quot -- result count )
array >shaped-array :> shaped shaped shape>> :> dimensions
axes dimensions length normalize-axes
:> normalized normalized [ dimensions nth ] map
product :> count identity not count zero? and
[ dimensions normalized empty-shaped-reduction ] when
dimensions normalized keepdims? reduction-shape
:> result-shape result-shape row-major-strides :> strides
result-shape product identity <array>
:> storage shaped underlying>> [| value index |
index dimensions flat-coordinate
normalized keepdims? reduction-coordinate
strides coordinate-offset :> target target storage nth
[ value quot call ] [ value ] if* target storage set-nth
] each-index storage result-shape <shaped-array> count ;
inline