ac-library-hs-1.2.6.0: Data structures and algorithms
Safe HaskellSafe-Inferred
LanguageGHC2021

AtCoder.Extra.Vector

Description

Miscellaneous vector methods.

Since: 1.2.2.0

Synopsis

Documentation

argsort :: (Ord a, Unbox a) => Vector a -> Vector Int Source #

\(O(n \log n)\) Returns indices of the vector, stably sorted by their value.

Example

>>> import Data.Vector.Algorithms.Intro qualified as VAI
>>> import Data.Vector.Unboxed qualified as VU
>>> argsort $ VU.fromList [0, 1, 0, 1, 0]
[0,2,4,1,3]

unsafePermuteInPlace :: (PrimMonad m, MVector v a) => v (PrimState m) a -> Vector Int -> m () Source #

\(O(n)\) Applies a permutation to a mutable vector in-place.

Constraints

  • The index array must be a permutation (0-based).

unsafePermuteInPlaceST :: MVector v a => v s a -> Vector Int -> ST s () Source #

\(O(n)\) Applies a permutation to a mutable vector in-place.

Constraints

  • The index array must be a permutation (0-based).