Handbook
Glossary
reduce-shaped ( array axes keepdims? identity quot -- result count )
Vocabulary
arrays
.
shaped
.
private
Inputs
array
an
object
axes
an
object
keepdims?
an
object
identity
an
object
quot
an
object
Outputs
result
an
object
count
an
object
Definition
USING:
accessors
arrays
arrays.shaped
kernel
math
sequences
;
IN:
arrays.shaped.private
::
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