owl
owl copied to clipboard
fold_list generalization of scan? inplace version?
the signature
val scan: ?axis:int ->
('a -> 'a -> 'a) ->
('a, 'b) Dense.Ndarray.Generic.t -> ('a, 'b) Dense.Ndarray.Generic.t
is not the most general. a more general one would be a list of intermediate fold results,
val fold_list: ?axis:int ->
('a -> 'b -> 'a) ->
'a ->
('b, 'c) Dense.Ndarray.Generic.t -> ('a, 'c) Dense.Ndarray.Generic.t
but maybe the use case of producing a different bigarray compatible element type is not so common? an intermediate version would be to add an optional initializer to scan
:
val scan: ?axis:int ->
('a -> 'a -> 'a) ->
?init:'a ->
('a, 'b) Dense.Ndarray.Generic.t -> ('a, 'b) Dense.Ndarray.Generic.t
where the folding function is called with init
and the first array element first, instead of just repeating the first element of the array as it is done now, and reverts to the current semantics if init
is not given.
not sure this is worth it? but it might be worth it to add an in-place version (which it have not found)