massiv-0.4.2.0: Massiv (Массив) is an Array Library.

Copyright(c) Alexey Kuleshevich 2019
LicenseBSD3
MaintainerAlexey Kuleshevich <lehins@yandex.ru>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Data.Massiv.Array.Mutable.Algorithms

Description

 
Synopsis

Documentation

quicksortM_ :: (Ord e, Mutable r Ix1 e, PrimMonad m) => Scheduler m () -> MArray (PrimState m) r Ix1 e -> m () Source #

Mutable version of quicksort

Since: 0.3.2

unstablePartitionM Source #

Arguments

:: (Mutable r Ix1 e, PrimMonad m) 
=> MArray (PrimState m) r Ix1 e 
-> (e -> Bool)

Predicate

-> m Ix1 

Partition elements of the supplied mutable vector according to the predicate.

Example

Expand
>>> import Data.Massiv.Array as A
>>> import Data.Massiv.Array.Mutable.Algorithms
>>> m <- thaw ([2,1,50,10,20,8] :: Array P Ix1 Int)
>>> unstablePartitionM m (<= 10)
4
>>> freeze Seq m
Array P Seq (Sz1 6)
  [ 2, 1, 8, 10, 20, 50 ]

Since: 0.3.2

iterateUntilM Source #

Arguments

:: (Load r' ix e, Mutable r ix e, PrimMonad m, MonadIO m, PrimState m ~ RealWorld) 
=> (Int -> Array r ix e -> MArray (PrimState m) r ix e -> m Bool)

Convergence condition. Accepts current iteration counter, pure array at previous state and a mutable at the current state, therefore after each iteration its contents can be modifed if necessary.

-> (Int -> Array r ix e -> Array r' ix e)

A modifying function to apply at each iteration. The size of resulting array may differ if necessary.

-> Array r ix e

Initial source array

-> m (Array r ix e) 

Monadic version of iterateUntil where at each iteration mutable version of an array is available.

Since: 0.3.6