toy-lib-0.1.0.0
Safe HaskellSafe-Inferred
LanguageHaskell2010

Algorithm.SlideMin

Description

Sliding minimum.

Synopsis

Documentation

slideMinIndicesOn :: (Vector v a, Ord b) => (a -> b) -> Int -> v a -> Vector Int #

\(O(N)\) https://qiita.com/kuuso1/items/318d42cd089a49eeb332

Returns indices of elements of the minimum values in corresponding spans. Drop the first len - 1 elements if you don't need spans shorter than the len.

slideMinIndices :: Int -> Vector Int -> Vector Int #

\(O(N)\)

>>> slideMinIndices 3 (U.fromList [0 .. 5])
[0,1,2,3,4,5]
>>> slideMinIndices 3 (U.fromList [5, 4 .. 0])
[0,0,0,1,2,3]

slideMaxIndices :: Int -> Vector Int -> Vector Int #

\(O(N)\)

>>> slideMaxIndices 3 (U.fromList [0 .. 5])
[0,0,0,1,2,3]
>>> slideMaxIndices 3 (U.fromList [5, 4 .. 0])
[0,1,2,3,4,5]