toy-lib-0.1.0.0
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Vector.IxVector

Description

Ix-based API over vector.

Synopsis

Documentation

data IxVector i v #

N-dimensional Vector or MVector with Ix.

Constructors

IxVector 

Fields

Instances

Instances details
(Num a, Unbox a) => Semigroup (Mat a) # 
Instance details

Defined in Math.Matrix

Methods

(<>) :: Mat a -> Mat a -> Mat a #

sconcat :: NonEmpty (Mat a) -> Mat a #

stimes :: Integral b => b -> Mat a -> Mat a #

(Num a, Unbox a) => SemigroupAction (Mat a) (Col a) # 
Instance details

Defined in Math.Matrix

Methods

sact :: Mat a -> Col a -> Col a #

(Show i, Show v) => Show (IxVector i v) # 
Instance details

Defined in Data.Vector.IxVector

Methods

showsPrec :: Int -> IxVector i v -> ShowS #

show :: IxVector i v -> String #

showList :: [IxVector i v] -> ShowS #

(Eq i, Eq v) => Eq (IxVector i v) # 
Instance details

Defined in Data.Vector.IxVector

Methods

(==) :: IxVector i v -> IxVector i v -> Bool #

(/=) :: IxVector i v -> IxVector i v -> Bool #

(Vector v a, Show a) => ShowGrid (IxVector (Int, Int) (v a)) # 
Instance details

Defined in ToyLib.Debug.Grid

Methods

showGrid :: IxVector (Int, Int) (v a) -> String #

showGridN :: Int -> IxVector (Int, Int) (v a) -> String #

type IxUVector i a = IxVector i (Vector a) #

Unboxed IxVector type notation.

type IxBVector i a = IxVector i (Vector a) #

Boxed IxVector type notation.

type IxMUVector s i a = IxVector i (MVector s a) #

Unboxed IxVector type notation.

type IxMBVector s i a = IxVector i (MVector s a) #

Boxed IxVector type notation.

(@!) :: (HasCallStack, Ix i, Vector v a) => IxVector i (v a) -> i -> a #

Partial IxVector accessor

(@!!) :: (Ix i, Vector v a) => IxVector i (v a) -> i -> a #

Partial unsafe IxVector accessor

(@!?) :: (HasCallStack, Ix i, Vector v a) => IxVector i (v a) -> i -> Maybe a #

\(O(1)\) Total IxVector accessor

(@!!?) :: (Ix i, Vector v a) => IxVector i (v a) -> i -> Maybe a #

Total unsafe IxVector accessor

lengthIV :: Vector v a => IxVector i (v a) -> Int #

\(O(1)\)

findIndexIV :: (Vector v a, Unindex i) => (a -> Bool) -> IxVector i (v a) -> Maybe i #

\(O(f N)\)

findIndicesIV :: (Unindex i, Vector v a, Vector v i, Vector v Int) => (a -> Bool) -> IxVector i (v a) -> v i #

\(O(f N)\)

mapIV :: (Unbox a, Unbox b) => (a -> b) -> IxVector i (Vector a) -> IxVector i (Vector b) #

\(O(f N)\)

imapIV :: (Unindex i, Unbox a, Unbox b) => (i -> a -> b) -> IxVector i (Vector a) -> IxVector i (Vector b) #

\(O(f N)\)

filterIV :: Unbox a => (a -> Bool) -> IxVector i (Vector a) -> Vector a #

\(O(f N)\)

ifilterIV :: (Unindex i, Unbox a) => (i -> a -> Bool) -> IxVector i (Vector a) -> Vector a #

\(O(f N)\)

indexedIV :: (Unindex i, Unbox a) => IxVector i (Vector a) -> Vector (i, a) #

\(O(N)\)

replicateIV :: (Unindex i, Unbox a) => (i, i) -> a -> IxUVector i a #

\(O(N)\)

zipWithIV :: (Unbox a, Unbox b, Unbox c) => (a -> b -> c) -> IxVector i (Vector a) -> IxVector i (Vector b) -> IxVector i (Vector c) #

\(O(f N)\)

accumulateIV :: (Ix i, Unbox i, Unbox a, Unbox b) => (a -> b -> a) -> IxVector i (Vector a) -> IxVector i (Vector (i, b)) -> IxVector i (Vector a) #

\(O(f X)\) Altertnative to accumulate for IxVector that share the same bounds.

createIV :: Vector v a => (forall s. ST s (IxVector i (Mutable v s a))) -> IxVector i (v a) #

generateIV :: (Unindex i, Unbox a) => (i, i) -> (i -> a) -> IxUVector i a #

\(O(f N)\) constructN for IxVector

constructIV :: (Unindex i, Unbox a) => (i, i) -> (IxUVector i a -> i -> a) -> IxUVector i a #

\(O(f N)\) constructN for IxVector

constructMIV :: forall i a m. (Unindex i, PrimMonad m, Unbox a) => (i, i) -> (IxUVector i a -> i -> m a) -> m (Vector a) #

\(O(f N)\)

thawIV :: (PrimMonad m, Vector v a) => IxVector i (v a) -> m (IxVector i (Mutable v (PrimState m) a)) #

\(O(N)\)

unsafeThawIV :: (PrimMonad m, Vector v a) => IxVector i (v a) -> m (IxVector i (Mutable v (PrimState m) a)) #

\(O(1)\)

freezeIV :: (PrimMonad m, Vector v a) => IxVector i (Mutable v (PrimState m) a) -> m (IxVector i (v a)) #

\(O(N)\)

unsafeFreezeIV :: (PrimMonad m, Vector v a) => IxVector i (Mutable v (PrimState m) a) -> m (IxVector i (v a)) #

\(O(1)\)

newIV :: (Ix i, PrimMonad m, Unbox a) => (i, i) -> a -> m (IxMUVector (PrimState m) i a) #

\(O(N)\) | Creates a new IxVector with initial value.

readIV :: (HasCallStack, Ix i, PrimMonad m, MVector v a) => IxVector i (v (PrimState m) a) -> i -> m a #

\(O(1)\) Reads a value from IxVector.

readMaybeIV :: (HasCallStack, Ix i, PrimMonad m, MVector v a) => IxVector i (v (PrimState m) a) -> i -> m (Maybe a) #

\(O(1)\) Reads a value from IxVector.

unsafeReadIV :: (Ix i, PrimMonad m, MVector v a) => IxVector i (v (PrimState m) a) -> i -> m a #

\(O(1)\)

writeIV :: (HasCallStack, Ix i, PrimMonad m, MVector v a) => IxVector i (v (PrimState m) a) -> i -> a -> m () #

\(O(1)\) | Writes a value to IxVector.

unsafeWriteIV :: (Ix i, PrimMonad m, MVector v a) => IxVector i (v (PrimState m) a) -> i -> a -> m () #

\(O(1)\)

modifyIV :: (HasCallStack, Ix i, PrimMonad m, MVector v a) => IxVector i (v (PrimState m) a) -> (a -> a) -> i -> m () #

\(O(1)\)

unsafeModifyIV :: (Ix i, PrimMonad m, MVector v a) => IxVector i (v (PrimState m) a) -> (a -> a) -> i -> m () #

\(O(1)\)

modifyMIV :: (HasCallStack, Ix i, PrimMonad m, MVector v a) => IxVector i (v (PrimState m) a) -> (a -> m a) -> i -> m () #

\(O(1)\)

unsafeModifyMIV :: (Ix i, PrimMonad m, MVector v a) => IxVector i (v (PrimState m) a) -> (a -> m a) -> i -> m () #

\(O(1)\)

swapIV :: (HasCallStack, Ix i, PrimMonad m, MVector v a) => IxVector i (v (PrimState m) a) -> i -> i -> m () #

\(O(1)\)

unsafeSwapIV :: (Ix i, PrimMonad m, MVector v a) => IxVector i (v (PrimState m) a) -> i -> i -> m () #

\(O(1)\)

exchangeIV :: (HasCallStack, Ix i, PrimMonad m, MVector v a) => IxVector i (v (PrimState m) a) -> i -> a -> m a #

\(O(1)\)

unsafeExchangeIV :: (Ix i, PrimMonad m, MVector v a) => IxVector i (v (PrimState m) a) -> i -> a -> m a #

\(O(1)\)

cloneIV :: (PrimMonad m, MVector v a) => IxVector i (v (PrimState m) a) -> m (IxVector i (v (PrimState m) a)) #

\(O(N)\) Cloning

csum2D :: (HasCallStack, Num a, Unbox a) => IxUVector (Int, Int) a -> IxUVector (Int, Int) a #

\(O(HW)\) Calculates two-dimensional cumulative sum.

WARNING: Can you really allocate/run \(O(HW)\) algorithm?

NOTE: Returns a 2D graph with one-based index with a zero row and a column inserted.

Typical problems

(@+!) :: (HasCallStack, Num a, Unbox a) => IxUVector (Int, Int) a -> ((Int, Int), (Int, Int)) -> a #

\(O(1)\) Returns cumulative sum in the given 2D range. - - * * * - - * * * = = # # # = = # # # = = # # #