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

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

Data.Massiv.Array

Contents

Description

Massiv is a library, that allows creation and manipulation of arrays in parallel and sequentially. Depending on the representation (r), an Array r ix e will have certain properties that are unique to that particular representation, but all of them will share the same trait, that an array is simply a mapping from an index (ix) of an arbitrary dimension to an element (e) of some value. Which means that some of the array types are pretty classic and are represented by a contiguous chunk of memory reserved for the elements, namely arrays with Manifest representations:

  • B - The most basic type of array that can hold any type of element in a boxed form, i.e. each element is a pointer to the actual value, therefore it is also the slowest representation. Elements are kept in a Weak Head Normal Form (WHNF).
  • N - Similar to B, is also a boxed type, except it's elements are always kept in a Normal Form (NF). This property is very useful for parallel processing, i.e. when calling compute you do want all of your elements to be fully evaluated.
  • S - Is a type of array that is backed by pinned memory, therefore pointers to those arrays can be passed to FFI calls, because Garbage Collector (GC) is guaranteed not to move it. Elements must be an instance of Storable class. It is just as efficient as P and U arrays, except it is subject to fragmentation.
  • U - Unboxed representation. Elements must be an instance of Unbox class.
  • P - Array that can hold Haskell primitives, such as Int, Word, Double, etc. Any element must be an instance of Prim class.
  • M - General manifest array type, that any of the above representations can be converted to in constant time using toManifest.

While at the same time, there are arrays that only describe how values for it's elements can be computed, and have no memory overhead on their own.

  • D - delayed array that is a mere function from an index to an element. Crucial representation for fusing computation. Use computeAs in order to load array into Manifest representation.
  • DI - delayed interleaved array. Same as D, but performced better with unbalanced computation, when evaluation one element takes much longer than it's neighbor.
  • DW - delayed windowed array. This peculiar representation allows for very fast Stencil computation.

Other Array types:

  • L and LN - those types aren't particularly useful on their own, but because of their unique ability to be converted to and from nested lists in constant time, provide an amazing intermediary for list/array conversion.

Most of the Manifest arrays are capable of in-place mutation. Check out Data.Massiv.Array.Mutable module for available functionality.

Many of the function names exported by this package will clash with the ones from Prelude, hence it can be more convenient to import like this:

import Prelude as P
import Data.Massiv.Array as A
Synopsis

Construct

makeArray Source #

Arguments

:: Construct r ix e 
=> Comp

Computation strategy. Useful constructors are Seq and Par

-> ix

Size of the result array. Negative values will result in an empty array.

-> (ix -> e)

Function to generate elements at a particular index

-> Array r ix e 

Create an Array. Resulting type either has to be unambiguously inferred or restricted manually, like in the example below.

>>> makeArray Seq (3 :. 4) (\ (i :. j) -> if i == j then i else 0) :: Array D Ix2 Int
(Array D Seq (3 :. 4)
[ [ 0,0,0,0 ]
, [ 0,1,0,0 ]
, [ 0,0,2,0 ]
])

makeArrayR :: Construct r ix e => r -> Comp -> ix -> (ix -> e) -> Array r ix e Source #

Just like makeArray but with ability to specify the result representation as an argument. Note the Unboxed type constructor in the below example.

>>> makeArrayR U Par (2 :> 3 :. 4) (\ (i :> j :. k) -> i * i + j * j == k * k)
(Array U Par (2 :> 3 :. 4)
  [ [ [ True,False,False,False ]
    , [ False,True,False,False ]
    , [ False,False,True,False ]
    ]
  , [ [ False,True,False,False ]
    , [ False,False,False,False ]
    , [ False,False,False,False ]
    ]
  ])

makeVectorR :: Construct r Ix1 e => r -> Comp -> Ix1 -> (Ix1 -> e) -> Array r Ix1 e Source #

Same as makeArrayR, but restricted to 1-dimensional arrays.

singleton Source #

Arguments

:: Construct r ix e 
=> Comp

Computation strategy

-> e

The element

-> Array r ix e 

Create an Array with a single element.

range :: Comp -> Int -> Int -> Array D Ix1 Int Source #

Create a vector with a range of Ints incremented by 1. range k0 k1 == rangeStep k0 k1 1

>>> range Seq 1 6
(Array D Seq (5)
  [ 1,2,3,4,5 ])
>>> range Seq (-2) 3
(Array D Seq (5)
  [ -2,-1,0,1,2 ])

rangeStep Source #

Arguments

:: Comp

Computation strategy

-> Int

Start

-> Int

Step (Can't be zero)

-> Int

End

-> Array D Ix1 Int 

Same as range, but with a custom step.

>>> rangeStep Seq 1 2 6
(Array D Seq (3)
  [ 1,3,5 ])

enumFromN Source #

Arguments

:: Num e 
=> Comp 
-> e

x - start value

-> Int

n - length of resulting vector.

-> Array D Ix1 e 

Same as enumFromStepN with step delta = 1.

>>> enumFromN Seq (5 :: Double) 3
(Array D Seq (3)
  [ 5.0,6.0,7.0 ])

enumFromStepN Source #

Arguments

:: Num e 
=> Comp 
-> e

x - start value

-> e

delta - step value

-> Int

n - length of resulting vector

-> Array D Ix1 e 

Create a vector with length n that has it's 0th value set to x and gradually increasing with step delta until the end. Similar to: fromList' Seq $ take n [x, x + delta ..]. Major difference is that fromList constructs an Array with manifest representation, while enumFromStepN is delayed.

>>> enumFromStepN Seq 1 (0.1 :: Double) 5
(Array D Seq (5)
  [ 1.0,1.1,1.2,1.3,1.4 ])

Compute

getComp :: Construct r ix e => Array r ix e -> Comp Source #

Get computation strategy of this array

setComp :: Construct r ix e => Comp -> Array r ix e -> Array r ix e Source #

Set computation strategy for this array

compute :: (Load r' ix e, Mutable r ix e) => Array r' ix e -> Array r ix e Source #

Ensure that Array is computed, i.e. represented with concrete elements in memory, hence is the Mutable type class restriction. Use setComp if you'd like to change computation strategy before calling compute

computeAs :: (Load r' ix e, Mutable r ix e) => r -> Array r' ix e -> Array r ix e Source #

Just as compute, but let's you supply resulting representation type as an argument.

Examples

Expand
>>> computeAs P $ range Seq 0 10
(Array P Seq (10)
  [ 0,1,2,3,4,5,6,7,8,9 ])

computeProxy :: (Load r' ix e, Mutable r ix e) => proxy r -> Array r' ix e -> Array r ix e Source #

Same as compute and computeAs, but let's you supply resulting representation type as a proxy argument.

Examples

Expand

Useful for cases when representation constructor isn't available for some reason:

>>> computeProxy (Nothing :: Maybe P) $ range Seq 0 10
(Array P Seq (10)
  [ 0,1,2,3,4,5,6,7,8,9 ])

Since: massiv-0.1.1

computeSource :: forall r' r ix e. (Source r' ix e, Mutable r ix e) => Array r' ix e -> Array r ix e Source #

This is just like compute, but can be applied to Source arrays and will be a noop if resulting type is the same as the input.

computeWithStride :: (Load r' ix e, Mutable r ix e) => Stride ix -> Array r' ix e -> Array r ix e Source #

Same as compute, but with Stride.

computeWithStrideAs :: (Load r' ix e, Mutable r ix e) => r -> Stride ix -> Array r' ix e -> Array r ix e Source #

Same as computeWithStride, but with ability to specify resulting array representation.

clone :: Mutable r ix e => Array r ix e -> Array r ix e Source #

O(n) - Make an exact immutable copy of an Array.

convert :: (Manifest r' ix e, Mutable r ix e) => Array r' ix e -> Array r ix e Source #

O(n) - conversion between manifest types, except when source and result arrays are of the same representation, in which case it is an O(1) operation.

convertAs :: (Manifest r' ix e, Mutable r ix e) => r -> Array r' ix e -> Array r ix e Source #

Same as convert, but let's you supply resulting representation type as an argument.

convertProxy :: (Manifest r' ix e, Mutable r ix e) => proxy r -> Array r' ix e -> Array r ix e Source #

Same as convert and convertAs, but let's you supply resulting representation type as a proxy argument.

Since: massiv-0.1.1

fromRaggedArray :: (Ragged r' ix e, Mutable r ix e) => Array r' ix e -> Either ShapeError (Array r ix e) Source #

Convert a ragged array into a usual rectangular shaped one.

fromRaggedArray' :: (Ragged r' ix e, Mutable r ix e) => Array r' ix e -> Array r ix e Source #

Same as fromRaggedArray, but will throw an error if its shape is not rectangular.

Size

size :: Size r ix e => Array r ix e -> ix Source #

O(1) - Get the size of an array

elemsCount :: Size r ix e => Array r ix e -> Int Source #

O(1) - Get the number of elements in the array

isEmpty :: Size r ix e => Array r ix e -> Bool Source #

O(1) - Check if array has no elements.

Indexing

(!?) :: Manifest r ix e => Array r ix e -> ix -> Maybe e infixl 4 Source #

Infix version of index.

(!) :: Manifest r ix e => Array r ix e -> ix -> e infixl 4 Source #

Infix version of index'.

(??) :: Manifest r ix e => Maybe (Array r ix e) -> ix -> Maybe e infixl 4 Source #

O(1) - Lookup an element in the array, where array can itself be Nothing. This operator is useful when used together with slicing or other functions that return Maybe array:

>>> (fromList Seq [[[1,2,3]],[[4,5,6]]] :: Maybe (Array U Ix3 Int)) ??> 1 ?? (0 :. 2)
Just 6

index :: Manifest r ix e => Array r ix e -> ix -> Maybe e Source #

O(1) - Lookup an element in the array. Returns Nothing, when index is out of bounds, Just element otherwise.

index' :: Manifest r ix e => Array r ix e -> ix -> e Source #

O(1) - Lookup an element in the array. Throw an error if index is out of bounds.

defaultIndex :: Manifest r ix e => e -> Array r ix e -> ix -> e Source #

O(1) - Lookup an element in the array, while using default element when index is out of bounds.

borderIndex :: Manifest r ix e => Border e -> Array r ix e -> ix -> e Source #

O(1) - Lookup an element in the array. Use a border resolution technique when index is out of bounds.

evaluateAt :: Source r ix e => Array r ix e -> ix -> e Source #

This is just like index' function, but it allows getting values from delayed arrays as well as manifest. As the name suggests, indexing into a delayed array at the same index multiple times will cause evaluation of the value each time and can destroy the performace if used without care.

Mapping

map :: Source r ix e' => (e' -> e) -> Array r ix e' -> Array D ix e Source #

Map a function over an array

imap :: Source r ix e' => (ix -> e' -> e) -> Array r ix e' -> Array D ix e Source #

Map an index aware function over an array

Monadic

mapM_ :: (Source r ix a, Monad m) => (a -> m b) -> Array r ix a -> m () Source #

Map a monadic function over an array sequentially, while discarding the result.

Examples

Expand
>>> mapM_ print $ rangeStep 10 12 60
10
22
34
46
58

forM_ :: (Source r ix a, Monad m) => Array r ix a -> (a -> m b) -> m () Source #

Just like mapM_, except with flipped arguments.

Examples

Expand

Here is a common way of iterating N times using a for loop in an imperative language with mutation being an obvious side effect:

>>> :m + Data.IORef
>>> var <- newIORef 0 :: IO (IORef Int)
>>> forM_ (range 0 1000) $ \ i -> modifyIORef' var (+i)
>>> readIORef var
499500

imapM_ :: (Source r ix a, Monad m) => (ix -> a -> m b) -> Array r ix a -> m () Source #

Map a monadic index aware function over an array sequentially, while discarding the result.

Examples

Expand
>>> imapM_ (curry print) $ range 10 15
(0,10)
(1,11)
(2,12)
(3,13)
(4,14)

iforM_ :: (Source r ix a, Monad m) => Array r ix a -> (ix -> a -> m b) -> m () Source #

Just like imapM_, except with flipped arguments.

mapP_ :: Source r ix a => (a -> IO b) -> Array r ix a -> IO () Source #

Map an IO action, over an array in parallel, while discarding the result.

imapP_ :: Source r ix a => (ix -> a -> IO b) -> Array r ix a -> IO () Source #

Map an index aware IO action, over an array in parallel, while discarding the result.

Zipping

zip :: (Source r1 ix e1, Source r2 ix e2) => Array r1 ix e1 -> Array r2 ix e2 -> Array D ix (e1, e2) Source #

Zip two arrays

zip3 :: (Source r1 ix e1, Source r2 ix e2, Source r3 ix e3) => Array r1 ix e1 -> Array r2 ix e2 -> Array r3 ix e3 -> Array D ix (e1, e2, e3) Source #

Zip three arrays

unzip :: Source r ix (e1, e2) => Array r ix (e1, e2) -> (Array D ix e1, Array D ix e2) Source #

Unzip two arrays

unzip3 :: Source r ix (e1, e2, e3) => Array r ix (e1, e2, e3) -> (Array D ix e1, Array D ix e2, Array D ix e3) Source #

Unzip three arrays

zipWith :: (Source r1 ix e1, Source r2 ix e2) => (e1 -> e2 -> e) -> Array r1 ix e1 -> Array r2 ix e2 -> Array D ix e Source #

Zip two arrays with a function. Resulting array will be an intersection of source arrays in case their dimensions do not match.

zipWith3 :: (Source r1 ix e1, Source r2 ix e2, Source r3 ix e3) => (e1 -> e2 -> e3 -> e) -> Array r1 ix e1 -> Array r2 ix e2 -> Array r3 ix e3 -> Array D ix e Source #

Just like zipWith, except zip three arrays with a function.

izipWith :: (Source r1 ix e1, Source r2 ix e2) => (ix -> e1 -> e2 -> e) -> Array r1 ix e1 -> Array r2 ix e2 -> Array D ix e Source #

Just like zipWith, except with an index aware function.

izipWith3 :: (Source r1 ix e1, Source r2 ix e2, Source r3 ix e3) => (ix -> e1 -> e2 -> e3 -> e) -> Array r1 ix e1 -> Array r2 ix e2 -> Array r3 ix e3 -> Array D ix e Source #

Just like zipWith3, except with an index aware function.

liftArray2 :: (Source r1 ix a, Source r2 ix b) => (a -> b -> e) -> Array r1 ix a -> Array r2 ix b -> Array D ix e Source #

Similar to zipWith, except dimensions of both arrays either have to be the same, or at least one of the two array must be a singleton array, in which case it will behave as a map.

Since: massiv-0.1.4

Folding

All folding is done in a row-major order.

Unstructured folds

Functions in this section will fold any Source array with respect to the inner Computation strategy setting.

fold Source #

Arguments

:: Source r ix e 
=> (e -> e -> e)

Folding function (like with left fold, first argument is an accumulator)

-> e

Initial element. Has to be neutral with respect to the folding function.

-> Array r ix e

Source array

-> e 

O(n) - Unstructured fold of an array.

foldMono Source #

Arguments

:: (Source r ix e, Monoid m) 
=> (e -> m)

Convert each element of an array to an appropriate Monoid.

-> Array r ix e

Source array

-> m 

O(n) - Monoidal fold over an array. Also known as reduce.

Since: massiv-0.1.4

foldSemi Source #

Arguments

:: (Source r ix e, Semigroup m) 
=> (e -> m)

Convert each element of an array to an appropriate Semigroup.

-> m

Initial element that must be neutral to the (<>) function.

-> Array r ix e

Source array

-> m 

O(n) - Semigroup fold over an array.

Since: massiv-0.1.6

minimum :: (Source r ix e, Ord e) => Array r ix e -> e Source #

O(n) - Compute minimum of all elements.

maximum :: (Source r ix e, Ord e) => Array r ix e -> e Source #

O(n) - Compute maximum of all elements.

sum :: (Source r ix e, Num e) => Array r ix e -> e Source #

O(n) - Compute sum of all elements.

product :: (Source r ix e, Num e) => Array r ix e -> e Source #

O(n) - Compute product of all elements.

and :: Source r ix Bool => Array r ix Bool -> Bool Source #

O(n) - Compute conjunction of all elements.

or :: Source r ix Bool => Array r ix Bool -> Bool Source #

O(n) - Compute disjunction of all elements.

all :: Source r ix e => (e -> Bool) -> Array r ix e -> Bool Source #

Determines whether all element of the array satisfy the predicate.

any :: Source r ix e => (e -> Bool) -> Array r ix e -> Bool Source #

Determines whether any element of the array satisfies the predicate.

Sequential folds

Functions in this section will fold any Source array sequentially, regardless of the inner Computation strategy setting.

foldlS :: Source r ix e => (a -> e -> a) -> a -> Array r ix e -> a Source #

O(n) - Left fold, computed sequentially.

foldrS :: Source r ix e => (e -> a -> a) -> a -> Array r ix e -> a Source #

O(n) - Right fold, computed sequentially.

ifoldlS :: Source r ix e => (a -> ix -> e -> a) -> a -> Array r ix e -> a Source #

O(n) - Left fold with an index aware function, computed sequentially.

ifoldrS :: Source r ix e => (ix -> e -> a -> a) -> a -> Array r ix e -> a Source #

O(n) - Right fold with an index aware function, computed sequentially.

Monadic

foldlM :: (Source r ix e, Monad m) => (a -> e -> m a) -> a -> Array r ix e -> m a Source #

O(n) - Monadic left fold.

foldrM :: (Source r ix e, Monad m) => (e -> a -> m a) -> a -> Array r ix e -> m a Source #

O(n) - Monadic right fold.

foldlM_ :: (Source r ix e, Monad m) => (a -> e -> m a) -> a -> Array r ix e -> m () Source #

O(n) - Monadic left fold, that discards the result.

foldrM_ :: (Source r ix e, Monad m) => (e -> a -> m a) -> a -> Array r ix e -> m () Source #

O(n) - Monadic right fold, that discards the result.

ifoldlM :: (Source r ix e, Monad m) => (a -> ix -> e -> m a) -> a -> Array r ix e -> m a Source #

O(n) - Monadic left fold with an index aware function.

ifoldrM :: (Source r ix e, Monad m) => (ix -> e -> a -> m a) -> a -> Array r ix e -> m a Source #

O(n) - Monadic right fold with an index aware function.

ifoldlM_ :: (Source r ix e, Monad m) => (a -> ix -> e -> m a) -> a -> Array r ix e -> m () Source #

O(n) - Monadic left fold with an index aware function, that discards the result.

ifoldrM_ :: (Source r ix e, Monad m) => (ix -> e -> a -> m a) -> a -> Array r ix e -> m () Source #

O(n) - Monadic right fold with an index aware function, that discards the result.

Special folds

foldrFB :: Source r ix e => (e -> b -> b) -> b -> Array r ix e -> b Source #

Version of foldr that supports foldr/build list fusion implemented by GHC.

lazyFoldlS :: Source r ix e => (a -> e -> a) -> a -> Array r ix e -> a Source #

O(n) - Left fold, computed sequentially with lazy accumulator.

lazyFoldrS :: Source r ix e => (e -> a -> a) -> a -> Array r ix e -> a Source #

O(n) - Right fold, computed sequentially with lazy accumulator.

Parallel folds

Note It is important to compile with -threaded -with-rtsopts=-N flags, otherwise there will be no parallelization.

Functions in this section will fold any Source array in parallel, regardless of the inner Computation strategy setting. All of the parallel structured folds are performed inside IO monad, because referential transparency can't generally be preserved and results will depend on the number of cores/capabilities that computation is being performed on.

In contrast to sequential folds, each parallel folding function accepts two functions and two initial elements as arguments. This is necessary because an array is first split into chunks, which folded individually on separate cores with the first function, and the results of those folds are further folded with the second function.

foldlP Source #

Arguments

:: Source r ix e 
=> (a -> e -> a)

Folding function g.

-> a

Accumulator. Will be applied to g multiple times, thus must be neutral.

-> (b -> a -> b)

Chunk results folding function f.

-> b

Accumulator for results of chunks folding.

-> Array r ix e 
-> IO b 

O(n) - Left fold, computed in parallel. Parallelization of folding is implemented in such a way that an array is split into a number of chunks of equal length, plus an extra one for the left over. Number of chunks is the same as number of available cores (capabilities) plus one, and each chunk is individually folded by a separate core with a function g. Results from folding each chunk are further folded with another function f, thus allowing us to use information about the structure of an array during folding.

Examples

Expand
>>> foldlP (flip (:)) [] (flip (:)) [] $ makeArrayR U Seq (Ix1 11) id
[[10,9,8,7,6,5,4,3,2,1,0]]

And this is how the result would look like if the above computation would be performed in a program executed with +RTS -N3, i.e. with 3 capabilities:

>>> foldlOnP [1,2,3] (flip (:)) [] (flip (:)) [] $ makeArrayR U Seq (Ix1 11) id
[[10,9],[8,7,6],[5,4,3],[2,1,0]]

foldrP :: Source r ix e => (e -> a -> a) -> a -> (a -> b -> b) -> b -> Array r ix e -> IO b Source #

O(n) - Right fold, computed in parallel. Same as foldlP, except directed from the last element in the array towards beginning.

Examples

Expand
>>> foldrP (++) [] (:) [] $ makeArray2D (3,4) id
[(0,0),(0,1),(0,2),(0,3),(1,0),(1,1),(1,2),(1,3),(2,0),(2,1),(2,2),(2,3)]

ifoldlP :: Source r ix e => (a -> ix -> e -> a) -> a -> (b -> a -> b) -> b -> Array r ix e -> IO b Source #

O(n) - Left fold with an index aware function, computed in parallel. Just like foldlP, except that folding function will receive an index of an element it is being applied to.

ifoldrP :: Source r ix e => (ix -> e -> a -> a) -> a -> (a -> b -> b) -> b -> Array r ix e -> IO b Source #

Just like ifoldrOnP, but allows you to specify which cores to run computation on.

foldlOnP :: Source r ix e => [Int] -> (a -> e -> a) -> a -> (b -> a -> b) -> b -> Array r ix e -> IO b Source #

Just like foldlP, but allows you to specify which cores (capabilities) to run computation on. The order in which chunked results will be supplied to function f is guaranteed to be consecutive and aligned with the folding direction.

ifoldlIO Source #

Arguments

:: Source r ix e 
=> [Int]

List of capabilities

-> (a -> ix -> e -> IO a)

Index aware folding IO action

-> a

Accumulator

-> (b -> a -> IO b)

Folding action that is applied to results of parallel fold

-> b

Accumulator for chunks folding

-> Array r ix e 
-> IO b 

Parallel left fold.

foldrOnP :: Source r ix e => [Int] -> (e -> a -> a) -> a -> (a -> b -> b) -> b -> Array r ix e -> IO b Source #

Just like foldrP, but allows you to specify which cores to run computation on.

Examples

Expand

Number of wokers dictate the result structure:

>>> foldrOnP [1,2,3] (:) [] (:) [] $ makeArray1D 9 id
[[0,1,2],[3,4,5],[6,7,8]]
>>> foldrOnP [1,2,3] (:) [] (:) [] $ makeArray1D 10 id
[[0,1,2],[3,4,5],[6,7,8],[9]]
>>> foldrOnP [1,2,3] (:) [] (:) [] $ makeArray1D 12 id
[[0,1,2,3],[4,5,6,7],[8,9,10,11]]

But most of the time that structure is of no importance:

>>> foldrOnP [1,2,3] (++) [] (:) [] $ makeArray1D 10 id
[0,1,2,3,4,5,6,7,8,9]

Same as foldlOnP, order is guaranteed to be consecutive and in proper direction:

>>> fmap snd $ foldrOnP [1,2,3] (\x (i, acc) -> (i + 1, (i, x):acc)) (1, []) (:) [] $ makeArray1D 11 id
[(4,[0,1,2]),(3,[3,4,5]),(2,[6,7,8]),(1,[9,10])]
>>> fmap (P.zip [4,3..]) <$> foldrOnP [1,2,3] (:) [] (:) [] $ makeArray1D 11 id
[(4,[0,1,2]),(3,[3,4,5]),(2,[6,7,8]),(1,[9,10])]

ifoldlOnP :: Source r ix e => [Int] -> (a -> ix -> e -> a) -> a -> (b -> a -> b) -> b -> Array r ix e -> IO b Source #

Just like ifoldlP, but allows you to specify which cores to run computation on.

ifoldrOnP :: Source r ix e => [Int] -> (ix -> e -> a -> a) -> a -> (a -> b -> b) -> b -> Array r ix e -> IO b Source #

O(n) - Right fold with an index aware function, computed in parallel. Same as ifoldlP, except directed from the last element in the array towards beginning.

ifoldrIO :: Source r ix e => [Int] -> (ix -> e -> a -> IO a) -> a -> (a -> b -> IO b) -> b -> Array r ix e -> IO b Source #

Parallel right fold. Differs from ifoldrP in that it accepts IO actions instead of the usual pure functions as arguments.

Transforming

Transpose

transpose :: Source r Ix2 e => Array r Ix2 e -> Array D Ix2 e Source #

Transpose a 2-dimensional array

Examples

Expand
>>> let arr = makeArrayR U Seq (2 :. 3) (toLinearIndex (2 :. 3))
>>> arr
(ArrayU Seq (2 :. 3)
  [ [ 0,1,2 ]
  , [ 3,4,5 ]
  ])
>>> transpose arr
(Array D Seq (3 :. 2)
  [ [ 0,3 ]
  , [ 1,4 ]
  , [ 2,5 ]
  ])

transposeInner :: (Index (Lower ix), Source r' ix e) => Array r' ix e -> Array D ix e Source #

Transpose inner two dimensions of at least rank-2 array.

Examples

Expand
>>> let arr = makeArrayR U Seq (2 :> 3 :. 4) fromIx3
>>> arr
(Array U Seq (2 :> 3 :. 4)
  [ [ [ (0,0,0),(0,0,1),(0,0,2),(0,0,3) ]
    , [ (0,1,0),(0,1,1),(0,1,2),(0,1,3) ]
    , [ (0,2,0),(0,2,1),(0,2,2),(0,2,3) ]
    ]
  , [ [ (1,0,0),(1,0,1),(1,0,2),(1,0,3) ]
    , [ (1,1,0),(1,1,1),(1,1,2),(1,1,3) ]
    , [ (1,2,0),(1,2,1),(1,2,2),(1,2,3) ]
    ]
  ])
>>> transposeInner arr
(Array D Seq (3 :> 2 :. 4)
  [ [ [ (0,0,0),(0,0,1),(0,0,2),(0,0,3) ]
    , [ (1,0,0),(1,0,1),(1,0,2),(1,0,3) ]
    ]
  , [ [ (0,1,0),(0,1,1),(0,1,2),(0,1,3) ]
    , [ (1,1,0),(1,1,1),(1,1,2),(1,1,3) ]
    ]
  , [ [ (0,2,0),(0,2,1),(0,2,2),(0,2,3) ]
    , [ (1,2,0),(1,2,1),(1,2,2),(1,2,3) ]
    ]
  ])

transposeOuter :: (Index (Lower ix), Source r' ix e) => Array r' ix e -> Array D ix e Source #

Transpose outer two dimensions of at least rank-2 array.

Examples

Expand
>>> let arr = makeArrayR U Seq (2 :> 3 :. 4) fromIx3
>>> arr
(Array U Seq (2 :> 3 :. 4)
  [ [ [ (0,0,0),(0,0,1),(0,0,2),(0,0,3) ]
    , [ (0,1,0),(0,1,1),(0,1,2),(0,1,3) ]
    , [ (0,2,0),(0,2,1),(0,2,2),(0,2,3) ]
    ]
  , [ [ (1,0,0),(1,0,1),(1,0,2),(1,0,3) ]
    , [ (1,1,0),(1,1,1),(1,1,2),(1,1,3) ]
    , [ (1,2,0),(1,2,1),(1,2,2),(1,2,3) ]
    ]
  ])
>>> transposeOuter arr
(Array D Seq (2 :> 4 :. 3)
  [ [ [ (0,0,0),(0,1,0),(0,2,0) ]
    , [ (0,0,1),(0,1,1),(0,2,1) ]
    , [ (0,0,2),(0,1,2),(0,2,2) ]
    , [ (0,0,3),(0,1,3),(0,2,3) ]
    ]
  , [ [ (1,0,0),(1,1,0),(1,2,0) ]
    , [ (1,0,1),(1,1,1),(1,2,1) ]
    , [ (1,0,2),(1,1,2),(1,2,2) ]
    , [ (1,0,3),(1,1,3),(1,2,3) ]
    ]
  ])

Backpermute

backpermute Source #

Arguments

:: (Source r' ix' e, Index ix) 
=> ix

Size of the result array

-> (ix -> ix')

A function that maps indices of the new array into the source one.

-> Array r' ix' e

Source array.

-> Array D ix e 

Rearrange elements of an array into a new one.

Examples

Expand
>>> let arr = makeArrayR U Seq (2 :> 3 :. 4) fromIx3
>>> arr
(Array U Seq (2 :> 3 :. 4)
  [ [ [ (0,0,0),(0,0,1),(0,0,2),(0,0,3) ]
    , [ (0,1,0),(0,1,1),(0,1,2),(0,1,3) ]
    , [ (0,2,0),(0,2,1),(0,2,2),(0,2,3) ]
    ]
  , [ [ (1,0,0),(1,0,1),(1,0,2),(1,0,3) ]
    , [ (1,1,0),(1,1,1),(1,1,2),(1,1,3) ]
    , [ (1,2,0),(1,2,1),(1,2,2),(1,2,3) ]
    ]
  ])
>>> backpermute (4 :. 3) (\(i :. j) -> 0 :> j :. i) arr
(Array D Seq (4 :. 3)
  [ [ (0,0,0),(0,1,0),(0,2,0) ]
  , [ (0,0,1),(0,1,1),(0,2,1) ]
  , [ (0,0,2),(0,1,2),(0,2,2) ]
  , [ (0,0,3),(0,1,3),(0,2,3) ]
  ])

Resize

resize :: (Index ix', Size r ix e) => ix' -> Array r ix e -> Maybe (Array r ix' e) Source #

O(1) - Changes the shape of an array. Returns Nothing if total number of elements does not match the source array.

resize' :: (Index ix', Size r ix e) => ix' -> Array r ix e -> Array r ix' e Source #

Same as resize, but will throw an error if supplied dimensions are incorrect.

Extract

extract Source #

Arguments

:: Size r ix e 
=> ix

Starting index

-> ix

Size fo the resulting array

-> Array r ix e

Source array

-> Maybe (Array (EltRepr r ix) ix e) 

Extract a sub-array from within a larger source array. Array that is being extracted must be fully encapsulated in a source array, otherwise Nothing is returned,

extract' Source #

Arguments

:: Size r ix e 
=> ix

Starting index

-> ix

Size fo the resulting array

-> Array r ix e

Source array

-> Array (EltRepr r ix) ix e 

Same as extract, but will throw an error if supplied dimensions are incorrect.

extractFromTo Source #

Arguments

:: Size r ix e 
=> ix

Starting index

-> ix

Index up to which elmenets should be extracted.

-> Array r ix e

Source array.

-> Maybe (Array (EltRepr r ix) ix e) 

Similar to extract, except it takes starting and ending index. Result array will not include the ending index.

Append/Split

append :: (Source r1 ix e, Source r2 ix e) => Dim -> Array r1 ix e -> Array r2 ix e -> Maybe (Array D ix e) Source #

Append two arrays together along a particular dimension. Sizes of both arrays must match, with an allowed exception of the dimension they are being appended along, otherwise Nothing is returned.

Examples

Expand

Append two 2D arrays along both dimensions. Note that they have the same shape.

>>> let arrA = makeArrayR U Seq (2 :. 3) (\(i :. j) -> ('A', i, j))
>>> let arrB = makeArrayR U Seq (2 :. 3) (\(i :. j) -> ('B', i, j))
>>> append 1 arrA arrB
Just (Array D Seq (2 :. 6)
  [ [ ('A',0,0),('A',0,1),('A',0,2),('B',0,0),('B',0,1),('B',0,2) ]
  , [ ('A',1,0),('A',1,1),('A',1,2),('B',1,0),('B',1,1),('B',1,2) ]
  ])
>>> append 2 arrA arrB
Just (Array D Seq (4 :. 3)
  [ [ ('A',0,0),('A',0,1),('A',0,2) ]
  , [ ('A',1,0),('A',1,1),('A',1,2) ]
  , [ ('B',0,0),('B',0,1),('B',0,2) ]
  , [ ('B',1,0),('B',1,1),('B',1,2) ]
  ])

Now appending arrays with different sizes:

>>> let arrC = makeArrayR U Seq (2 :. 4) (\(i :. j) -> ('C', i, j))
>>> append 1 arrA arrC
Just (Array D Seq (2 :. 7)
  [ [ ('A',0,0),('A',0,1),('A',0,2),('C',0,0),('C',0,1),('C',0,2),('C',0,3) ]
  , [ ('A',1,0),('A',1,1),('A',1,2),('C',1,0),('C',1,1),('C',1,2),('C',1,3) ]
  ])
>>> append 2 arrA arrC
Nothing

append' :: (Source r1 ix e, Source r2 ix e) => Dim -> Array r1 ix e -> Array r2 ix e -> Array D ix e Source #

Same as append, but will throw an error instead of returning Nothing on mismatched sizes.

splitAt Source #

Arguments

:: (Size r ix e, r' ~ EltRepr r ix) 
=> Dim

Dimension along which to split

-> Int

Index along the dimension to split at

-> Array r ix e

Source array

-> Maybe (Array r' ix e, Array r' ix e) 

O(1) - Split an array at an index along a specified dimension.

splitAt' :: (Size r ix e, r' ~ EltRepr r ix) => Dim -> Int -> Array r ix e -> (Array r' ix e, Array r' ix e) Source #

Same as splitAt, but will throw an error instead of returning Nothing on wrong dimension and index out of bounds.

Traverse

traverse Source #

Arguments

:: (Source r1 ix1 e1, Index ix) 
=> ix

Size of the result array

-> ((ix1 -> e1) -> ix -> e)

Function that will receive a source array safe index function and an index for an element it should return a value of.

-> Array r1 ix1 e1

Source array

-> Array D ix e 

Create an array by traversing a source array.

traverse2 :: (Source r1 ix1 e1, Source r2 ix2 e2, Index ix) => ix -> ((ix1 -> e1) -> (ix2 -> e2) -> ix -> e) -> Array r1 ix1 e1 -> Array r2 ix2 e2 -> Array D ix e Source #

Create an array by traversing two source arrays.

Slicing

From the outside

(!>) :: OuterSlice r ix e => Array r ix e -> Int -> Elt r ix e infixl 4 Source #

O(1) - Slices the array from the outside. For 2-dimensional array this will be equivalent of taking a row. Throws an error when index is out of bounds.

Examples

Expand

You could say that slicing from outside is synonymous to slicing from the end or slicing at the highermost dimension. For example with rank-3 arrays outer slice would be equivalent to getting a page:

>>> let arr = makeArrayR U Seq (3 :> 2 :. 4) fromIx3
>>> arr
(Array U Seq (3 :> 2 :. 4)
  [ [ [ (0,0,0),(0,0,1),(0,0,2),(0,0,3) ]
    , [ (0,1,0),(0,1,1),(0,1,2),(0,1,3) ]
    ]
  , [ [ (1,0,0),(1,0,1),(1,0,2),(1,0,3) ]
    , [ (1,1,0),(1,1,1),(1,1,2),(1,1,3) ]
    ]
  , [ [ (2,0,0),(2,0,1),(2,0,2),(2,0,3) ]
    , [ (2,1,0),(2,1,1),(2,1,2),(2,1,3) ]
    ]
  ])
>>> arr !> 2
(Array M Seq (2 :. 4)
  [ [ (2,0,0),(2,0,1),(2,0,2),(2,0,3) ]
  , [ (2,1,0),(2,1,1),(2,1,2),(2,1,3) ]
  ])

There is nothing wrong with chaining, mixing and matching slicing operators, or even using them to index arrays:

>>> arr !> 2 !> 0 !> 3
(2,0,3)
>>> arr !> 2 <! 3 ! 0
(2,0,3)
>>> arr !> 2 !> 0 !> 3 == arr ! 2 :> 0 :. 3
True

(!?>) :: OuterSlice r ix e => Array r ix e -> Int -> Maybe (Elt r ix e) infixl 4 Source #

O(1) - Just like !> slices the array from the outside, but returns Nothing when index is out of bounds.

(??>) :: OuterSlice r ix e => Maybe (Array r ix e) -> Int -> Maybe (Elt r ix e) infixl 4 Source #

O(1) - Safe slicing continuation from the outside. Similarly to (!>) slices the array from the outside, but takes Maybe array as input and returns Nothing when index is out of bounds.

Examples

Expand
>>> let arr = makeArrayR U Seq (3 :> 2 :. 4) fromIx3
>>> arr !?> 2 ??> 0 ??> 3
Just (2,0,3)
>>> arr !?> 2 ??> 0 ??> -1
Nothing
>>> arr !?> -2 ??> 0 ?? 1
Nothing

From the inside

(<!) :: InnerSlice r ix e => Array r ix e -> Int -> Elt r ix e infixl 4 Source #

O(1) - Similarly to (!>) slice an array from an opposite direction.

(<!?) :: InnerSlice r ix e => Array r ix e -> Int -> Maybe (Elt r ix e) infixl 4 Source #

O(1) - Safe slice from the inside

(<??) :: InnerSlice r ix e => Maybe (Array r ix e) -> Int -> Maybe (Elt r ix e) infixl 4 Source #

O(1) - Safe slicing continuation from the inside

From within

(<!>) :: Slice r ix e => Array r ix e -> (Dim, Int) -> Elt r ix e infixl 4 Source #

O(1) - Slices the array in any available dimension. Throws an error when index is out of bounds or dimensions is invalid.

arr !> i == arr <!> (dimensions (size arr), i)
arr <! i == arr <!> (1,i)

(<!?>) :: Slice r ix e => Array r ix e -> (Dim, Int) -> Maybe (Elt r ix e) infixl 4 Source #

O(1) - Same as (<!>), but fails gracefully with a Nothing, instead of an error

(<??>) :: Slice r ix e => Maybe (Array r ix e) -> (Dim, Int) -> Maybe (Elt r ix e) infixl 4 Source #

O(1) - Safe slicing continuation from within.

Conversion

List

fromList Source #

Arguments

:: (Nested LN Ix1 e, Nested L Ix1 e, Ragged L Ix1 e, Mutable r Ix1 e) 
=> Comp

Computation startegy to use

-> [e]

Nested list

-> Array r Ix1 e 

Convert a flat list into a vector

fromLists :: (Nested LN ix e, Nested L ix e, Ragged L ix e, Mutable r ix e) => Comp -> [ListItem ix e] -> Maybe (Array r ix e) Source #

O(n) - Convert a nested list into an array. Nested list must be of a rectangular shape, otherwise a runtime error will occur. Also, nestedness must match the rank of resulting array, which should be specified through an explicit type signature.

Note: This function is almost the same (modulo customizable computation strategy) if you would turn on {--}. For that reason you can also use fromList.

Examples

Expand
>>> fromLists Seq [[1,2],[3,4]] :: Maybe (Array U Ix2 Int)
Just (Array U Seq (2 :. 2)
  [ [ 1,2 ]
  , [ 3,4 ]
  ])
>>> fromLists Par [[[1,2,3]],[[4,5,6]]] :: Maybe (Array U Ix3 Int)
Just (Array U Par (2 :> 1 :. 3)
  [ [ [ 1,2,3 ]
    ]
  , [ [ 4,5,6 ]
    ]
  ])

Elements of a boxed array could be lists themselves if necessary, but cannot be ragged:

>>> fromLists Seq [[[1,2,3]],[[4,5]]] :: Maybe (Array B Ix2 [Int])
Just (Array B Seq (2 :. 1)
  [ [ [1,2,3] ]
  , [ [4,5] ]
  ])
>>> fromLists Seq [[[1,2,3]],[[4,5]]] :: Maybe (Array B Ix3 Int)
Nothing

fromLists' Source #

Arguments

:: (Nested LN ix e, Nested L ix e, Ragged L ix e, Mutable r ix e) 
=> Comp

Computation startegy to use

-> [ListItem ix e]

Nested list

-> Array r ix e 

Same as fromLists, but will throw an error on irregular shaped lists.

Examples

Expand

Convert a list of lists into a 2D Array

>>> fromLists' Seq [[1,2],[3,4]] :: Array U Ix2 Int
(Array U Seq (2 :. 2)
  [ [ 1,2 ]
  , [ 3,4 ]
  ])

Above example implemented using GHC's OverloadedLists extension:

>>> :set -XOverloadedLists
>>> [[1,2],[3,4]] :: Array U Ix2 Int
(Array U Seq (2 :. 2)
  [ [ 1,2 ]
  , [ 3,4 ]
  ])

Example of failure on ceonversion of an irregular nested list.

>>> fromLists' Seq [[1],[3,4]] :: Array U Ix2 Int
(Array U *** Exception: Too many elements in a row

toList :: Source r ix e => Array r ix e -> [e] Source #

Convert any array to a flat list.

Examples

Expand
>>> toList $ makeArrayR U Seq (2 :. 3) fromIx2
[(0,0),(0,1),(0,2),(1,0),(1,1),(1,2)]

toLists :: (Nested LN ix e, Nested L ix e, Construct L ix e, Source r ix e) => Array r ix e -> [ListItem ix e] Source #

O(n) - Convert an array into a nested list. Array rank and list nestedness will always match, but you can use toList, toLists2, etc. if flattening of inner dimensions is desired.

Note: This function is almost the same as toList.

Examples

Expand
>>> let arr = makeArrayR U Seq (2 :> 1 :. 3) fromIx3
>>> print arr
(Array U Seq (2 :> 1 :. 3)
  [ [ [ (0,0,0),(0,0,1),(0,0,2) ]
    ]
  , [ [ (1,0,0),(1,0,1),(1,0,2) ]
    ]
  ])
>>> toLists arr
[[[(0,0,0),(0,0,1),(0,0,2)]],[[(1,0,0),(1,0,1),(1,0,2)]]]

toLists2 :: (Source r ix e, Index (Lower ix)) => Array r ix e -> [[e]] Source #

Convert an array with at least 2 dimensions into a list of lists. Inner dimensions will get flattened.

Examples

Expand
>>> toList2 $ makeArrayR U Seq (2 :. 3) fromIx2
[[(0,0),(0,1),(0,2)],[(1,0),(1,1),(1,2)]]
>>> toList2 $ makeArrayR U Seq (2 :> 1 :. 3) fromIx3
[[(0,0,0),(0,0,1),(0,0,2)],[(1,0,0),(1,0,1),(1,0,2)]]

toLists3 :: (Index (Lower (Lower ix)), Index (Lower ix), Source r ix e) => Array r ix e -> [[[e]]] Source #

Convert an array with at least 3 dimensions into a 3 deep nested list. Inner dimensions will get flattened.

toLists4 :: (Index (Lower (Lower (Lower ix))), Index (Lower (Lower ix)), Index (Lower ix), Source r ix e) => Array r ix e -> [[[[e]]]] Source #

Convert an array with at least 4 dimensions into a 4 deep nested list. Inner dimensions will get flattened.

Mutable

Core

data family MVector s a :: * #

Instances
MVector MVector Bool 
Instance details

Defined in Data.Vector.Unboxed.Base

MVector MVector Char 
Instance details

Defined in Data.Vector.Unboxed.Base

MVector MVector Double 
Instance details

Defined in Data.Vector.Unboxed.Base

MVector MVector Float 
Instance details

Defined in Data.Vector.Unboxed.Base

MVector MVector Int 
Instance details

Defined in Data.Vector.Unboxed.Base

MVector MVector Int8 
Instance details

Defined in Data.Vector.Unboxed.Base

MVector MVector Int16 
Instance details

Defined in Data.Vector.Unboxed.Base

MVector MVector Int32 
Instance details

Defined in Data.Vector.Unboxed.Base

MVector MVector Int64 
Instance details

Defined in Data.Vector.Unboxed.Base

MVector MVector Word 
Instance details

Defined in Data.Vector.Unboxed.Base

MVector MVector Word8 
Instance details

Defined in Data.Vector.Unboxed.Base

MVector MVector Word16 
Instance details

Defined in Data.Vector.Unboxed.Base

MVector MVector Word32 
Instance details

Defined in Data.Vector.Unboxed.Base

MVector MVector Word64 
Instance details

Defined in Data.Vector.Unboxed.Base

MVector MVector () 
Instance details

Defined in Data.Vector.Unboxed.Base

Methods

basicLength :: MVector s () -> Int #

basicUnsafeSlice :: Int -> Int -> MVector s () -> MVector s () #

basicOverlaps :: MVector s () -> MVector s () -> Bool #

basicUnsafeNew :: PrimMonad m => Int -> m (MVector (PrimState m) ()) #

basicInitialize :: PrimMonad m => MVector (PrimState m) () -> m () #

basicUnsafeReplicate :: PrimMonad m => Int -> () -> m (MVector (PrimState m) ()) #

basicUnsafeRead :: PrimMonad m => MVector (PrimState m) () -> Int -> m () #

basicUnsafeWrite :: PrimMonad m => MVector (PrimState m) () -> Int -> () -> m () #

basicClear :: PrimMonad m => MVector (PrimState m) () -> m () #

basicSet :: PrimMonad m => MVector (PrimState m) () -> () -> m () #

basicUnsafeCopy :: PrimMonad m => MVector (PrimState m) () -> MVector (PrimState m) () -> m () #

basicUnsafeMove :: PrimMonad m => MVector (PrimState m) () -> MVector (PrimState m) () -> m () #

basicUnsafeGrow :: PrimMonad m => MVector (PrimState m) () -> Int -> m (MVector (PrimState m) ()) #

MVector MVector Ix2 # 
Instance details

Defined in Data.Massiv.Core.Index.Ix

Unbox a => MVector MVector (Complex a) 
Instance details

Defined in Data.Vector.Unboxed.Base

(3 <= n, Unbox (Ix (n - 1))) => MVector MVector (IxN n) # 
Instance details

Defined in Data.Massiv.Core.Index.Ix

Methods

basicLength :: MVector s (IxN n) -> Int #

basicUnsafeSlice :: Int -> Int -> MVector s (IxN n) -> MVector s (IxN n) #

basicOverlaps :: MVector s (IxN n) -> MVector s (IxN n) -> Bool #

basicUnsafeNew :: PrimMonad m => Int -> m (MVector (PrimState m) (IxN n)) #

basicInitialize :: PrimMonad m => MVector (PrimState m) (IxN n) -> m () #

basicUnsafeReplicate :: PrimMonad m => Int -> IxN n -> m (MVector (PrimState m) (IxN n)) #

basicUnsafeRead :: PrimMonad m => MVector (PrimState m) (IxN n) -> Int -> m (IxN n) #

basicUnsafeWrite :: PrimMonad m => MVector (PrimState m) (IxN n) -> Int -> IxN n -> m () #

basicClear :: PrimMonad m => MVector (PrimState m) (IxN n) -> m () #

basicSet :: PrimMonad m => MVector (PrimState m) (IxN n) -> IxN n -> m () #

basicUnsafeCopy :: PrimMonad m => MVector (PrimState m) (IxN n) -> MVector (PrimState m) (IxN n) -> m () #

basicUnsafeMove :: PrimMonad m => MVector (PrimState m) (IxN n) -> MVector (PrimState m) (IxN n) -> m () #

basicUnsafeGrow :: PrimMonad m => MVector (PrimState m) (IxN n) -> Int -> m (MVector (PrimState m) (IxN n)) #

(Unbox a, Unbox b) => MVector MVector (a, b) 
Instance details

Defined in Data.Vector.Unboxed.Base

Methods

basicLength :: MVector s (a, b) -> Int #

basicUnsafeSlice :: Int -> Int -> MVector s (a, b) -> MVector s (a, b) #

basicOverlaps :: MVector s (a, b) -> MVector s (a, b) -> Bool #

basicUnsafeNew :: PrimMonad m => Int -> m (MVector (PrimState m) (a, b)) #

basicInitialize :: PrimMonad m => MVector (PrimState m) (a, b) -> m () #

basicUnsafeReplicate :: PrimMonad m => Int -> (a, b) -> m (MVector (PrimState m) (a, b)) #

basicUnsafeRead :: PrimMonad m => MVector (PrimState m) (a, b) -> Int -> m (a, b) #

basicUnsafeWrite :: PrimMonad m => MVector (PrimState m) (a, b) -> Int -> (a, b) -> m () #

basicClear :: PrimMonad m => MVector (PrimState m) (a, b) -> m () #

basicSet :: PrimMonad m => MVector (PrimState m) (a, b) -> (a, b) -> m () #

basicUnsafeCopy :: PrimMonad m => MVector (PrimState m) (a, b) -> MVector (PrimState m) (a, b) -> m () #

basicUnsafeMove :: PrimMonad m => MVector (PrimState m) (a, b) -> MVector (PrimState m) (a, b) -> m () #

basicUnsafeGrow :: PrimMonad m => MVector (PrimState m) (a, b) -> Int -> m (MVector (PrimState m) (a, b)) #

(Unbox a, Unbox b, Unbox c) => MVector MVector (a, b, c) 
Instance details

Defined in Data.Vector.Unboxed.Base

Methods

basicLength :: MVector s (a, b, c) -> Int #

basicUnsafeSlice :: Int -> Int -> MVector s (a, b, c) -> MVector s (a, b, c) #

basicOverlaps :: MVector s (a, b, c) -> MVector s (a, b, c) -> Bool #

basicUnsafeNew :: PrimMonad m => Int -> m (MVector (PrimState m) (a, b, c)) #

basicInitialize :: PrimMonad m => MVector (PrimState m) (a, b, c) -> m () #

basicUnsafeReplicate :: PrimMonad m => Int -> (a, b, c) -> m (MVector (PrimState m) (a, b, c)) #

basicUnsafeRead :: PrimMonad m => MVector (PrimState m) (a, b, c) -> Int -> m (a, b, c) #

basicUnsafeWrite :: PrimMonad m => MVector (PrimState m) (a, b, c) -> Int -> (a, b, c) -> m () #

basicClear :: PrimMonad m => MVector (PrimState m) (a, b, c) -> m () #

basicSet :: PrimMonad m => MVector (PrimState m) (a, b, c) -> (a, b, c) -> m () #

basicUnsafeCopy :: PrimMonad m => MVector (PrimState m) (a, b, c) -> MVector (PrimState m) (a, b, c) -> m () #

basicUnsafeMove :: PrimMonad m => MVector (PrimState m) (a, b, c) -> MVector (PrimState m) (a, b, c) -> m () #

basicUnsafeGrow :: PrimMonad m => MVector (PrimState m) (a, b, c) -> Int -> m (MVector (PrimState m) (a, b, c)) #

(Unbox a, Unbox b, Unbox c, Unbox d) => MVector MVector (a, b, c, d) 
Instance details

Defined in Data.Vector.Unboxed.Base

Methods

basicLength :: MVector s (a, b, c, d) -> Int #

basicUnsafeSlice :: Int -> Int -> MVector s (a, b, c, d) -> MVector s (a, b, c, d) #

basicOverlaps :: MVector s (a, b, c, d) -> MVector s (a, b, c, d) -> Bool #

basicUnsafeNew :: PrimMonad m => Int -> m (MVector (PrimState m) (a, b, c, d)) #

basicInitialize :: PrimMonad m => MVector (PrimState m) (a, b, c, d) -> m () #

basicUnsafeReplicate :: PrimMonad m => Int -> (a, b, c, d) -> m (MVector (PrimState m) (a, b, c, d)) #

basicUnsafeRead :: PrimMonad m => MVector (PrimState m) (a, b, c, d) -> Int -> m (a, b, c, d) #

basicUnsafeWrite :: PrimMonad m => MVector (PrimState m) (a, b, c, d) -> Int -> (a, b, c, d) -> m () #

basicClear :: PrimMonad m => MVector (PrimState m) (a, b, c, d) -> m () #

basicSet :: PrimMonad m => MVector (PrimState m) (a, b, c, d) -> (a, b, c, d) -> m () #

basicUnsafeCopy :: PrimMonad m => MVector (PrimState m) (a, b, c, d) -> MVector (PrimState m) (a, b, c, d) -> m () #

basicUnsafeMove :: PrimMonad m => MVector (PrimState m) (a, b, c, d) -> MVector (PrimState m) (a, b, c, d) -> m () #

basicUnsafeGrow :: PrimMonad m => MVector (PrimState m) (a, b, c, d) -> Int -> m (MVector (PrimState m) (a, b, c, d)) #

(Unbox a, Unbox b, Unbox c, Unbox d, Unbox e) => MVector MVector (a, b, c, d, e) 
Instance details

Defined in Data.Vector.Unboxed.Base

Methods

basicLength :: MVector s (a, b, c, d, e) -> Int #

basicUnsafeSlice :: Int -> Int -> MVector s (a, b, c, d, e) -> MVector s (a, b, c, d, e) #

basicOverlaps :: MVector s (a, b, c, d, e) -> MVector s (a, b, c, d, e) -> Bool #

basicUnsafeNew :: PrimMonad m => Int -> m (MVector (PrimState m) (a, b, c, d, e)) #

basicInitialize :: PrimMonad m => MVector (PrimState m) (a, b, c, d, e) -> m () #

basicUnsafeReplicate :: PrimMonad m => Int -> (a, b, c, d, e) -> m (MVector (PrimState m) (a, b, c, d, e)) #

basicUnsafeRead :: PrimMonad m => MVector (PrimState m) (a, b, c, d, e) -> Int -> m (a, b, c, d, e) #

basicUnsafeWrite :: PrimMonad m => MVector (PrimState m) (a, b, c, d, e) -> Int -> (a, b, c, d, e) -> m () #

basicClear :: PrimMonad m => MVector (PrimState m) (a, b, c, d, e) -> m () #

basicSet :: PrimMonad m => MVector (PrimState m) (a, b, c, d, e) -> (a, b, c, d, e) -> m () #

basicUnsafeCopy :: PrimMonad m => MVector (PrimState m) (a, b, c, d, e) -> MVector (PrimState m) (a, b, c, d, e) -> m () #

basicUnsafeMove :: PrimMonad m => MVector (PrimState m) (a, b, c, d, e) -> MVector (PrimState m) (a, b, c, d, e) -> m () #

basicUnsafeGrow :: PrimMonad m => MVector (PrimState m) (a, b, c, d, e) -> Int -> m (MVector (PrimState m) (a, b, c, d, e)) #

(Unbox a, Unbox b, Unbox c, Unbox d, Unbox e, Unbox f) => MVector MVector (a, b, c, d, e, f) 
Instance details

Defined in Data.Vector.Unboxed.Base

Methods

basicLength :: MVector s (a, b, c, d, e, f) -> Int #

basicUnsafeSlice :: Int -> Int -> MVector s (a, b, c, d, e, f) -> MVector s (a, b, c, d, e, f) #

basicOverlaps :: MVector s (a, b, c, d, e, f) -> MVector s (a, b, c, d, e, f) -> Bool #

basicUnsafeNew :: PrimMonad m => Int -> m (MVector (PrimState m) (a, b, c, d, e, f)) #

basicInitialize :: PrimMonad m => MVector (PrimState m) (a, b, c, d, e, f) -> m () #

basicUnsafeReplicate :: PrimMonad m => Int -> (a, b, c, d, e, f) -> m (MVector (PrimState m) (a, b, c, d, e, f)) #

basicUnsafeRead :: PrimMonad m => MVector (PrimState m) (a, b, c, d, e, f) -> Int -> m (a, b, c, d, e, f) #

basicUnsafeWrite :: PrimMonad m => MVector (PrimState m) (a, b, c, d, e, f) -> Int -> (a, b, c, d, e, f) -> m () #

basicClear :: PrimMonad m => MVector (PrimState m) (a, b, c, d, e, f) -> m () #

basicSet :: PrimMonad m => MVector (PrimState m) (a, b, c, d, e, f) -> (a, b, c, d, e, f) -> m () #

basicUnsafeCopy :: PrimMonad m => MVector (PrimState m) (a, b, c, d, e, f) -> MVector (PrimState m) (a, b, c, d, e, f) -> m () #

basicUnsafeMove :: PrimMonad m => MVector (PrimState m) (a, b, c, d, e, f) -> MVector (PrimState m) (a, b, c, d, e, f) -> m () #

basicUnsafeGrow :: PrimMonad m => MVector (PrimState m) (a, b, c, d, e, f) -> Int -> m (MVector (PrimState m) (a, b, c, d, e, f)) #

NFData (MVector s a) 
Instance details

Defined in Data.Vector.Unboxed.Base

Methods

rnf :: MVector s a -> () #

data MVector s Ix2 # 
Instance details

Defined in Data.Massiv.Core.Index.Ix

data MVector s Bool 
Instance details

Defined in Data.Vector.Unboxed.Base

data MVector s Char 
Instance details

Defined in Data.Vector.Unboxed.Base

data MVector s Double 
Instance details

Defined in Data.Vector.Unboxed.Base

data MVector s Float 
Instance details

Defined in Data.Vector.Unboxed.Base

data MVector s Word64 
Instance details

Defined in Data.Vector.Unboxed.Base

data MVector s Word32 
Instance details

Defined in Data.Vector.Unboxed.Base

data MVector s Word16 
Instance details

Defined in Data.Vector.Unboxed.Base

data MVector s Word8 
Instance details

Defined in Data.Vector.Unboxed.Base

data MVector s Word 
Instance details

Defined in Data.Vector.Unboxed.Base

data MVector s Int64 
Instance details

Defined in Data.Vector.Unboxed.Base

data MVector s Int32 
Instance details

Defined in Data.Vector.Unboxed.Base

data MVector s Int16 
Instance details

Defined in Data.Vector.Unboxed.Base

data MVector s Int8 
Instance details

Defined in Data.Vector.Unboxed.Base

data MVector s Int 
Instance details

Defined in Data.Vector.Unboxed.Base

data MVector s () 
Instance details

Defined in Data.Vector.Unboxed.Base

data MVector s () = MV_Unit Int
data MVector s (Complex a) 
Instance details

Defined in Data.Vector.Unboxed.Base

data MVector s (Complex a) = MV_Complex (MVector s (a, a))
data MVector s (IxN n) # 
Instance details

Defined in Data.Massiv.Core.Index.Ix

data MVector s (IxN n) = MV_IxN (MVector s Int, MVector s (Ix (n - 1)))
data MVector s (a, b) 
Instance details

Defined in Data.Vector.Unboxed.Base

data MVector s (a, b) = MV_2 !Int !(MVector s a) !(MVector s b)
data MVector s (a, b, c) 
Instance details

Defined in Data.Vector.Unboxed.Base

data MVector s (a, b, c) = MV_3 !Int !(MVector s a) !(MVector s b) !(MVector s c)
data MVector s (a, b, c, d) 
Instance details

Defined in Data.Vector.Unboxed.Base

data MVector s (a, b, c, d) = MV_4 !Int !(MVector s a) !(MVector s b) !(MVector s c) !(MVector s d)
data MVector s (a, b, c, d, e) 
Instance details

Defined in Data.Vector.Unboxed.Base

data MVector s (a, b, c, d, e) = MV_5 !Int !(MVector s a) !(MVector s b) !(MVector s c) !(MVector s d) !(MVector s e)
data MVector s (a, b, c, d, e, f) 
Instance details

Defined in Data.Vector.Unboxed.Base

data MVector s (a, b, c, d, e, f) = MV_6 !Int !(MVector s a) !(MVector s b) !(MVector s c) !(MVector s d) !(MVector s e) !(MVector s f)

data family Vector a :: * #

Instances
Vector Vector Bool 
Instance details

Defined in Data.Vector.Unboxed.Base

Vector Vector Char 
Instance details

Defined in Data.Vector.Unboxed.Base

Vector Vector Double 
Instance details

Defined in Data.Vector.Unboxed.Base

Vector Vector Float 
Instance details

Defined in Data.Vector.Unboxed.Base

Vector Vector Int 
Instance details

Defined in Data.Vector.Unboxed.Base

Vector Vector Int8 
Instance details

Defined in Data.Vector.Unboxed.Base

Vector Vector Int16 
Instance details

Defined in Data.Vector.Unboxed.Base

Vector Vector Int32 
Instance details

Defined in Data.Vector.Unboxed.Base

Vector Vector Int64 
Instance details

Defined in Data.Vector.Unboxed.Base

Vector Vector Word 
Instance details

Defined in Data.Vector.Unboxed.Base

Vector Vector Word8 
Instance details

Defined in Data.Vector.Unboxed.Base

Vector Vector Word16 
Instance details

Defined in Data.Vector.Unboxed.Base

Vector Vector Word32 
Instance details

Defined in Data.Vector.Unboxed.Base

Vector Vector Word64 
Instance details

Defined in Data.Vector.Unboxed.Base

Vector Vector () 
Instance details

Defined in Data.Vector.Unboxed.Base

Methods

basicUnsafeFreeze :: PrimMonad m => Mutable Vector (PrimState m) () -> m (Vector ()) #

basicUnsafeThaw :: PrimMonad m => Vector () -> m (Mutable Vector (PrimState m) ()) #

basicLength :: Vector () -> Int #

basicUnsafeSlice :: Int -> Int -> Vector () -> Vector () #

basicUnsafeIndexM :: Monad m => Vector () -> Int -> m () #

basicUnsafeCopy :: PrimMonad m => Mutable Vector (PrimState m) () -> Vector () -> m () #

elemseq :: Vector () -> () -> b -> b #

Vector Vector Ix2 # 
Instance details

Defined in Data.Massiv.Core.Index.Ix

Unbox a => Vector Vector (Complex a) 
Instance details

Defined in Data.Vector.Unboxed.Base

(3 <= n, Unbox (Ix (n - 1))) => Vector Vector (IxN n) # 
Instance details

Defined in Data.Massiv.Core.Index.Ix

Methods

basicUnsafeFreeze :: PrimMonad m => Mutable Vector (PrimState m) (IxN n) -> m (Vector (IxN n)) #

basicUnsafeThaw :: PrimMonad m => Vector (IxN n) -> m (Mutable Vector (PrimState m) (IxN n)) #

basicLength :: Vector (IxN n) -> Int #

basicUnsafeSlice :: Int -> Int -> Vector (IxN n) -> Vector (IxN n) #

basicUnsafeIndexM :: Monad m => Vector (IxN n) -> Int -> m (IxN n) #

basicUnsafeCopy :: PrimMonad m => Mutable Vector (PrimState m) (IxN n) -> Vector (IxN n) -> m () #

elemseq :: Vector (IxN n) -> IxN n -> b -> b #

(Unbox a, Unbox b) => Vector Vector (a, b) 
Instance details

Defined in Data.Vector.Unboxed.Base

Methods

basicUnsafeFreeze :: PrimMonad m => Mutable Vector (PrimState m) (a, b) -> m (Vector (a, b)) #

basicUnsafeThaw :: PrimMonad m => Vector (a, b) -> m (Mutable Vector (PrimState m) (a, b)) #

basicLength :: Vector (a, b) -> Int #

basicUnsafeSlice :: Int -> Int -> Vector (a, b) -> Vector (a, b) #

basicUnsafeIndexM :: Monad m => Vector (a, b) -> Int -> m (a, b) #

basicUnsafeCopy :: PrimMonad m => Mutable Vector (PrimState m) (a, b) -> Vector (a, b) -> m () #

elemseq :: Vector (a, b) -> (a, b) -> b0 -> b0 #

(Unbox a, Unbox b, Unbox c) => Vector Vector (a, b, c) 
Instance details

Defined in Data.Vector.Unboxed.Base

Methods

basicUnsafeFreeze :: PrimMonad m => Mutable Vector (PrimState m) (a, b, c) -> m (Vector (a, b, c)) #

basicUnsafeThaw :: PrimMonad m => Vector (a, b, c) -> m (Mutable Vector (PrimState m) (a, b, c)) #

basicLength :: Vector (a, b, c) -> Int #

basicUnsafeSlice :: Int -> Int -> Vector (a, b, c) -> Vector (a, b, c) #

basicUnsafeIndexM :: Monad m => Vector (a, b, c) -> Int -> m (a, b, c) #

basicUnsafeCopy :: PrimMonad m => Mutable Vector (PrimState m) (a, b, c) -> Vector (a, b, c) -> m () #

elemseq :: Vector (a, b, c) -> (a, b, c) -> b0 -> b0 #

(Unbox a, Unbox b, Unbox c, Unbox d) => Vector Vector (a, b, c, d) 
Instance details

Defined in Data.Vector.Unboxed.Base

Methods

basicUnsafeFreeze :: PrimMonad m => Mutable Vector (PrimState m) (a, b, c, d) -> m (Vector (a, b, c, d)) #

basicUnsafeThaw :: PrimMonad m => Vector (a, b, c, d) -> m (Mutable Vector (PrimState m) (a, b, c, d)) #

basicLength :: Vector (a, b, c, d) -> Int #

basicUnsafeSlice :: Int -> Int -> Vector (a, b, c, d) -> Vector (a, b, c, d) #

basicUnsafeIndexM :: Monad m => Vector (a, b, c, d) -> Int -> m (a, b, c, d) #

basicUnsafeCopy :: PrimMonad m => Mutable Vector (PrimState m) (a, b, c, d) -> Vector (a, b, c, d) -> m () #

elemseq :: Vector (a, b, c, d) -> (a, b, c, d) -> b0 -> b0 #

(Unbox a, Unbox b, Unbox c, Unbox d, Unbox e) => Vector Vector (a, b, c, d, e) 
Instance details

Defined in Data.Vector.Unboxed.Base

Methods

basicUnsafeFreeze :: PrimMonad m => Mutable Vector (PrimState m) (a, b, c, d, e) -> m (Vector (a, b, c, d, e)) #

basicUnsafeThaw :: PrimMonad m => Vector (a, b, c, d, e) -> m (Mutable Vector (PrimState m) (a, b, c, d, e)) #

basicLength :: Vector (a, b, c, d, e) -> Int #

basicUnsafeSlice :: Int -> Int -> Vector (a, b, c, d, e) -> Vector (a, b, c, d, e) #

basicUnsafeIndexM :: Monad m => Vector (a, b, c, d, e) -> Int -> m (a, b, c, d, e) #

basicUnsafeCopy :: PrimMonad m => Mutable Vector (PrimState m) (a, b, c, d, e) -> Vector (a, b, c, d, e) -> m () #

elemseq :: Vector (a, b, c, d, e) -> (a, b, c, d, e) -> b0 -> b0 #

(Unbox a, Unbox b, Unbox c, Unbox d, Unbox e, Unbox f) => Vector Vector (a, b, c, d, e, f) 
Instance details

Defined in Data.Vector.Unboxed.Base

Methods

basicUnsafeFreeze :: PrimMonad m => Mutable Vector (PrimState m) (a, b, c, d, e, f) -> m (Vector (a, b, c, d, e, f)) #

basicUnsafeThaw :: PrimMonad m => Vector (a, b, c, d, e, f) -> m (Mutable Vector (PrimState m) (a, b, c, d, e, f)) #

basicLength :: Vector (a, b, c, d, e, f) -> Int #

basicUnsafeSlice :: Int -> Int -> Vector (a, b, c, d, e, f) -> Vector (a, b, c, d, e, f) #

basicUnsafeIndexM :: Monad m => Vector (a, b, c, d, e, f) -> Int -> m (a, b, c, d, e, f) #

basicUnsafeCopy :: PrimMonad m => Mutable Vector (PrimState m) (a, b, c, d, e, f) -> Vector (a, b, c, d, e, f) -> m () #

elemseq :: Vector (a, b, c, d, e, f) -> (a, b, c, d, e, f) -> b0 -> b0 #

(Data a, Unbox a) => Data (Vector a) 
Instance details

Defined in Data.Vector.Unboxed.Base

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Vector a -> c (Vector a) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Vector a) #

toConstr :: Vector a -> Constr #

dataTypeOf :: Vector a -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Vector a)) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Vector a)) #

gmapT :: (forall b. Data b => b -> b) -> Vector a -> Vector a #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Vector a -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Vector a -> r #

gmapQ :: (forall d. Data d => d -> u) -> Vector a -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Vector a -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Vector a -> m (Vector a) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Vector a -> m (Vector a) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Vector a -> m (Vector a) #

NFData (Vector a) 
Instance details

Defined in Data.Vector.Unboxed.Base

Methods

rnf :: Vector a -> () #

data Vector Bool 
Instance details

Defined in Data.Vector.Unboxed.Base

data Vector Char 
Instance details

Defined in Data.Vector.Unboxed.Base

data Vector Double 
Instance details

Defined in Data.Vector.Unboxed.Base

data Vector Float 
Instance details

Defined in Data.Vector.Unboxed.Base

data Vector Int 
Instance details

Defined in Data.Vector.Unboxed.Base

data Vector Int8 
Instance details

Defined in Data.Vector.Unboxed.Base

data Vector Int16 
Instance details

Defined in Data.Vector.Unboxed.Base

data Vector Int32 
Instance details

Defined in Data.Vector.Unboxed.Base

data Vector Int64 
Instance details

Defined in Data.Vector.Unboxed.Base

data Vector Word 
Instance details

Defined in Data.Vector.Unboxed.Base

data Vector Word8 
Instance details

Defined in Data.Vector.Unboxed.Base

data Vector Word16 
Instance details

Defined in Data.Vector.Unboxed.Base

data Vector Word32 
Instance details

Defined in Data.Vector.Unboxed.Base

data Vector Word64 
Instance details

Defined in Data.Vector.Unboxed.Base

data Vector () 
Instance details

Defined in Data.Vector.Unboxed.Base

data Vector () = V_Unit Int
data Vector Ix2 # 
Instance details

Defined in Data.Massiv.Core.Index.Ix

type Mutable Vector 
Instance details

Defined in Data.Vector.Unboxed.Base

type ARepr Vector Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Vector

type ARepr Vector = U
type Item (Vector e) 
Instance details

Defined in Data.Vector.Unboxed

type Item (Vector e) = e
data Vector (Complex a) 
Instance details

Defined in Data.Vector.Unboxed.Base

data Vector (Complex a) = V_Complex (Vector (a, a))
data Vector (IxN n) # 
Instance details

Defined in Data.Massiv.Core.Index.Ix

data Vector (IxN n) = V_IxN (Vector Int, Vector (Ix (n - 1)))
data Vector (a, b) 
Instance details

Defined in Data.Vector.Unboxed.Base

data Vector (a, b) = V_2 !Int !(Vector a) !(Vector b)
data Vector (a, b, c) 
Instance details

Defined in Data.Vector.Unboxed.Base

data Vector (a, b, c) = V_3 !Int !(Vector a) !(Vector b) !(Vector c)
data Vector (a, b, c, d) 
Instance details

Defined in Data.Vector.Unboxed.Base

data Vector (a, b, c, d) = V_4 !Int !(Vector a) !(Vector b) !(Vector c) !(Vector d)
data Vector (a, b, c, d, e) 
Instance details

Defined in Data.Vector.Unboxed.Base

data Vector (a, b, c, d, e) = V_5 !Int !(Vector a) !(Vector b) !(Vector c) !(Vector d) !(Vector e)
data Vector (a, b, c, d, e, f) 
Instance details

Defined in Data.Vector.Unboxed.Base

data Vector (a, b, c, d, e, f) = V_6 !Int !(Vector a) !(Vector b) !(Vector c) !(Vector d) !(Vector e) !(Vector f)

data Comp Source #

Computation type to use.

Constructors

Seq

Sequential computation

ParOn [Int]

Use Par instead to use your CPU to the fullest. Also don't forget to compile the program with -threaded flag.

Parallel computation with a list of capabilities to run computation on. Specifying an empty list (ParOn []) or using Par will result in utilization of all available capabilities, which are set at runtime by +RTS -Nx or at compile time by GHC flag -with-rtsopts=-Nx, where x is the number of capabilities. Ommiting x in above flags defaults to number available cores.

Bundled Patterns

pattern Par :: Comp

Parallel computation using all available cores.

Instances
Eq Comp Source # 
Instance details

Defined in Data.Massiv.Core.Computation

Methods

(==) :: Comp -> Comp -> Bool #

(/=) :: Comp -> Comp -> Bool #

Show Comp Source # 
Instance details

Defined in Data.Massiv.Core.Computation

Methods

showsPrec :: Int -> Comp -> ShowS #

show :: Comp -> String #

showList :: [Comp] -> ShowS #

Semigroup Comp Source # 
Instance details

Defined in Data.Massiv.Core.Computation

Methods

(<>) :: Comp -> Comp -> Comp #

sconcat :: NonEmpty Comp -> Comp #

stimes :: Integral b => b -> Comp -> Comp #

Monoid Comp Source # 
Instance details

Defined in Data.Massiv.Core.Computation

Methods

mempty :: Comp #

mappend :: Comp -> Comp -> Comp #

mconcat :: [Comp] -> Comp #

NFData Comp Source # 
Instance details

Defined in Data.Massiv.Core.Computation

Methods

rnf :: Comp -> () #

loop :: Int -> (Int -> Bool) -> (Int -> Int) -> a -> (Int -> a -> a) -> a Source #

Efficient loop with an accumulator

loopM :: Monad m => Int -> (Int -> Bool) -> (Int -> Int) -> a -> (Int -> a -> m a) -> m a Source #

Very efficient monadic loop with an accumulator

loopM_ :: Monad m => Int -> (Int -> Bool) -> (Int -> Int) -> (Int -> m a) -> m () Source #

Efficient monadic loop. Result of each iteration is discarded.

loopDeepM :: Monad m => Int -> (Int -> Bool) -> (Int -> Int) -> a -> (Int -> a -> m a) -> m a Source #

Less efficient monadic loop with an accumulator that reverses the direction of action application

splitLinearly :: Int -> Int -> (Int -> Int -> a) -> a Source #

splitLinearlyWith_ :: Monad m => Int -> (m () -> m a) -> Int -> (Int -> b) -> (Int -> b -> m ()) -> m a Source #

class (Eq ix, Ord ix, Show ix, NFData ix) => Index ix where Source #

This is bread and butter of multi-dimensional array indexing. It is unlikely that any of the functions in this class will be useful to a regular user, unless general algorithms are being implemented that do span multiple dimensions.

Associated Types

type Dimensions ix :: Nat Source #

Methods

dimensions :: ix -> Dim Source #

Dimensions of an array that has this index type, i.e. what is the dimensionality.

totalElem :: ix -> Int Source #

Total number of elements in an array of this size.

consDim :: Int -> Lower ix -> ix Source #

Prepend a dimension to the index

unconsDim :: ix -> (Int, Lower ix) Source #

Take a dimension from the index from the outside

snocDim :: Lower ix -> Int -> ix Source #

Apppend a dimension to the index

unsnocDim :: ix -> (Lower ix, Int) Source #

Take a dimension from the index from the inside

dropDim :: ix -> Dim -> Maybe (Lower ix) Source #

Remove a dimension from the index

getIndex :: ix -> Dim -> Maybe Int Source #

Extract the value index has at specified dimension.

setIndex :: ix -> Dim -> Int -> Maybe ix Source #

Set the value for an index at specified dimension.

pureIndex :: Int -> ix Source #

Lift an Int to any index by replicating the value as many times as there are dimensions.

liftIndex2 :: (Int -> Int -> Int) -> ix -> ix -> ix Source #

Zip together two indices with a function

liftIndex :: (Int -> Int) -> ix -> ix Source #

Map a function over an index

foldlIndex :: (a -> Int -> a) -> a -> ix -> a Source #

foldlIndex :: Index (Lower ix) => (a -> Int -> a) -> a -> ix -> a Source #

isSafeIndex Source #

Arguments

:: ix

Size

-> ix

Index

-> Bool 

Check whether index is within the size.

isSafeIndex Source #

Arguments

:: Index (Lower ix) 
=> ix

Size

-> ix

Index

-> Bool 

Check whether index is within the size.

toLinearIndex Source #

Arguments

:: ix

Size

-> ix

Index

-> Int 

Convert linear index from size and index

toLinearIndex Source #

Arguments

:: Index (Lower ix) 
=> ix

Size

-> ix

Index

-> Int 

Convert linear index from size and index

toLinearIndexAcc :: Int -> ix -> ix -> Int Source #

Convert linear index from size and index with an accumulator. Currently is useless and will likley be removed in future versions.

toLinearIndexAcc :: Index (Lower ix) => Int -> ix -> ix -> Int Source #

Convert linear index from size and index with an accumulator. Currently is useless and will likley be removed in future versions.

fromLinearIndex :: ix -> Int -> ix Source #

Compute an index from size and linear index

fromLinearIndex :: Index (Lower ix) => ix -> Int -> ix Source #

Compute an index from size and linear index

fromLinearIndexAcc :: ix -> Int -> (Int, ix) Source #

Compute an index from size and linear index using an accumulator, thus trying to optimize for tail recursion while getting the index computed.

fromLinearIndexAcc :: Index (Lower ix) => ix -> Int -> (Int, ix) Source #

Compute an index from size and linear index using an accumulator, thus trying to optimize for tail recursion while getting the index computed.

repairIndex Source #

Arguments

:: ix

Size

-> ix

Index

-> (Int -> Int -> Int)

Repair when below zero

-> (Int -> Int -> Int)

Repair when higher than size

-> ix 

A way to make sure index is withing the bounds for the supplied size. Takes two functions that will be invoked whenever index (2nd arg) is outsize the supplied size (1st arg)

repairIndex Source #

Arguments

:: Index (Lower ix) 
=> ix

Size

-> ix

Index

-> (Int -> Int -> Int)

Repair when below zero

-> (Int -> Int -> Int)

Repair when higher than size

-> ix 

A way to make sure index is withing the bounds for the supplied size. Takes two functions that will be invoked whenever index (2nd arg) is outsize the supplied size (1st arg)

iter :: ix -> ix -> ix -> (Int -> Int -> Bool) -> a -> (ix -> a -> a) -> a Source #

Iterator for the index. Same as iterM, but pure.

iterM Source #

Arguments

:: Monad m 
=> ix

Start index

-> ix

End index

-> ix

Increment

-> (Int -> Int -> Bool)

Continue iterating while predicate is True (eg. until end of row)

-> a

Initial value for an accumulator

-> (ix -> a -> m a)

Accumulator function

-> m a 

This function is what makes it possible to iterate over an array of any dimension.

iterM Source #

Arguments

:: (Index (Lower ix), Monad m) 
=> ix

Start index

-> ix

End index

-> ix

Increment

-> (Int -> Int -> Bool)

Continue iterating while predicate is True (eg. until end of row)

-> a

Initial value for an accumulator

-> (ix -> a -> m a)

Accumulator function

-> m a 

This function is what makes it possible to iterate over an array of any dimension.

iterM_ :: Monad m => ix -> ix -> ix -> (Int -> Int -> Bool) -> (ix -> m a) -> m () Source #

Same as iterM, but don't bother with accumulator and return value.

iterM_ :: (Index (Lower ix), Monad m) => ix -> ix -> ix -> (Int -> Int -> Bool) -> (ix -> m a) -> m () Source #

Same as iterM, but don't bother with accumulator and return value.

Instances
Index Ix5T Source # 
Instance details

Defined in Data.Massiv.Core.Index.Class

Associated Types

type Dimensions Ix5T :: Nat Source #

Methods

dimensions :: Ix5T -> Dim Source #

totalElem :: Ix5T -> Int Source #

consDim :: Int -> Lower Ix5T -> Ix5T Source #

unconsDim :: Ix5T -> (Int, Lower Ix5T) Source #

snocDim :: Lower Ix5T -> Int -> Ix5T Source #

unsnocDim :: Ix5T -> (Lower Ix5T, Int) Source #

dropDim :: Ix5T -> Dim -> Maybe (Lower Ix5T) Source #

getIndex :: Ix5T -> Dim -> Maybe Int Source #

setIndex :: Ix5T -> Dim -> Int -> Maybe Ix5T Source #

pureIndex :: Int -> Ix5T Source #

liftIndex2 :: (Int -> Int -> Int) -> Ix5T -> Ix5T -> Ix5T Source #

liftIndex :: (Int -> Int) -> Ix5T -> Ix5T Source #

foldlIndex :: (a -> Int -> a) -> a -> Ix5T -> a Source #

isSafeIndex :: Ix5T -> Ix5T -> Bool Source #

toLinearIndex :: Ix5T -> Ix5T -> Int Source #

toLinearIndexAcc :: Int -> Ix5T -> Ix5T -> Int Source #

fromLinearIndex :: Ix5T -> Int -> Ix5T Source #

fromLinearIndexAcc :: Ix5T -> Int -> (Int, Ix5T) Source #

repairIndex :: Ix5T -> Ix5T -> (Int -> Int -> Int) -> (Int -> Int -> Int) -> Ix5T Source #

iter :: Ix5T -> Ix5T -> Ix5T -> (Int -> Int -> Bool) -> a -> (Ix5T -> a -> a) -> a Source #

iterM :: Monad m => Ix5T -> Ix5T -> Ix5T -> (Int -> Int -> Bool) -> a -> (Ix5T -> a -> m a) -> m a Source #

iterM_ :: Monad m => Ix5T -> Ix5T -> Ix5T -> (Int -> Int -> Bool) -> (Ix5T -> m a) -> m () Source #

Index Ix4T Source # 
Instance details

Defined in Data.Massiv.Core.Index.Class

Associated Types

type Dimensions Ix4T :: Nat Source #

Methods

dimensions :: Ix4T -> Dim Source #

totalElem :: Ix4T -> Int Source #

consDim :: Int -> Lower Ix4T -> Ix4T Source #

unconsDim :: Ix4T -> (Int, Lower Ix4T) Source #

snocDim :: Lower Ix4T -> Int -> Ix4T Source #

unsnocDim :: Ix4T -> (Lower Ix4T, Int) Source #

dropDim :: Ix4T -> Dim -> Maybe (Lower Ix4T) Source #

getIndex :: Ix4T -> Dim -> Maybe Int Source #

setIndex :: Ix4T -> Dim -> Int -> Maybe Ix4T Source #

pureIndex :: Int -> Ix4T Source #

liftIndex2 :: (Int -> Int -> Int) -> Ix4T -> Ix4T -> Ix4T Source #

liftIndex :: (Int -> Int) -> Ix4T -> Ix4T Source #

foldlIndex :: (a -> Int -> a) -> a -> Ix4T -> a Source #

isSafeIndex :: Ix4T -> Ix4T -> Bool Source #

toLinearIndex :: Ix4T -> Ix4T -> Int Source #

toLinearIndexAcc :: Int -> Ix4T -> Ix4T -> Int Source #

fromLinearIndex :: Ix4T -> Int -> Ix4T Source #

fromLinearIndexAcc :: Ix4T -> Int -> (Int, Ix4T) Source #

repairIndex :: Ix4T -> Ix4T -> (Int -> Int -> Int) -> (Int -> Int -> Int) -> Ix4T Source #

iter :: Ix4T -> Ix4T -> Ix4T -> (Int -> Int -> Bool) -> a -> (Ix4T -> a -> a) -> a Source #

iterM :: Monad m => Ix4T -> Ix4T -> Ix4T -> (Int -> Int -> Bool) -> a -> (Ix4T -> a -> m a) -> m a Source #

iterM_ :: Monad m => Ix4T -> Ix4T -> Ix4T -> (Int -> Int -> Bool) -> (Ix4T -> m a) -> m () Source #

Index Ix3T Source # 
Instance details

Defined in Data.Massiv.Core.Index.Class

Associated Types

type Dimensions Ix3T :: Nat Source #

Methods

dimensions :: Ix3T -> Dim Source #

totalElem :: Ix3T -> Int Source #

consDim :: Int -> Lower Ix3T -> Ix3T Source #

unconsDim :: Ix3T -> (Int, Lower Ix3T) Source #

snocDim :: Lower Ix3T -> Int -> Ix3T Source #

unsnocDim :: Ix3T -> (Lower Ix3T, Int) Source #

dropDim :: Ix3T -> Dim -> Maybe (Lower Ix3T) Source #

getIndex :: Ix3T -> Dim -> Maybe Int Source #

setIndex :: Ix3T -> Dim -> Int -> Maybe Ix3T Source #

pureIndex :: Int -> Ix3T Source #

liftIndex2 :: (Int -> Int -> Int) -> Ix3T -> Ix3T -> Ix3T Source #

liftIndex :: (Int -> Int) -> Ix3T -> Ix3T Source #

foldlIndex :: (a -> Int -> a) -> a -> Ix3T -> a Source #

isSafeIndex :: Ix3T -> Ix3T -> Bool Source #

toLinearIndex :: Ix3T -> Ix3T -> Int Source #

toLinearIndexAcc :: Int -> Ix3T -> Ix3T -> Int Source #

fromLinearIndex :: Ix3T -> Int -> Ix3T Source #

fromLinearIndexAcc :: Ix3T -> Int -> (Int, Ix3T) Source #

repairIndex :: Ix3T -> Ix3T -> (Int -> Int -> Int) -> (Int -> Int -> Int) -> Ix3T Source #

iter :: Ix3T -> Ix3T -> Ix3T -> (Int -> Int -> Bool) -> a -> (Ix3T -> a -> a) -> a Source #

iterM :: Monad m => Ix3T -> Ix3T -> Ix3T -> (Int -> Int -> Bool) -> a -> (Ix3T -> a -> m a) -> m a Source #

iterM_ :: Monad m => Ix3T -> Ix3T -> Ix3T -> (Int -> Int -> Bool) -> (Ix3T -> m a) -> m () Source #

Index Ix2T Source # 
Instance details

Defined in Data.Massiv.Core.Index.Class

Associated Types

type Dimensions Ix2T :: Nat Source #

Methods

dimensions :: Ix2T -> Dim Source #

totalElem :: Ix2T -> Int Source #

consDim :: Int -> Lower Ix2T -> Ix2T Source #

unconsDim :: Ix2T -> (Int, Lower Ix2T) Source #

snocDim :: Lower Ix2T -> Int -> Ix2T Source #

unsnocDim :: Ix2T -> (Lower Ix2T, Int) Source #

dropDim :: Ix2T -> Dim -> Maybe (Lower Ix2T) Source #

getIndex :: Ix2T -> Dim -> Maybe Int Source #

setIndex :: Ix2T -> Dim -> Int -> Maybe Ix2T Source #

pureIndex :: Int -> Ix2T Source #

liftIndex2 :: (Int -> Int -> Int) -> Ix2T -> Ix2T -> Ix2T Source #

liftIndex :: (Int -> Int) -> Ix2T -> Ix2T Source #

foldlIndex :: (a -> Int -> a) -> a -> Ix2T -> a Source #

isSafeIndex :: Ix2T -> Ix2T -> Bool Source #

toLinearIndex :: Ix2T -> Ix2T -> Int Source #

toLinearIndexAcc :: Int -> Ix2T -> Ix2T -> Int Source #

fromLinearIndex :: Ix2T -> Int -> Ix2T Source #

fromLinearIndexAcc :: Ix2T -> Int -> (Int, Ix2T) Source #

repairIndex :: Ix2T -> Ix2T -> (Int -> Int -> Int) -> (Int -> Int -> Int) -> Ix2T Source #

iter :: Ix2T -> Ix2T -> Ix2T -> (Int -> Int -> Bool) -> a -> (Ix2T -> a -> a) -> a Source #

iterM :: Monad m => Ix2T -> Ix2T -> Ix2T -> (Int -> Int -> Bool) -> a -> (Ix2T -> a -> m a) -> m a Source #

iterM_ :: Monad m => Ix2T -> Ix2T -> Ix2T -> (Int -> Int -> Bool) -> (Ix2T -> m a) -> m () Source #

Index Ix1T Source # 
Instance details

Defined in Data.Massiv.Core.Index.Class

Associated Types

type Dimensions Ix1T :: Nat Source #

Methods

dimensions :: Ix1T -> Dim Source #

totalElem :: Ix1T -> Int Source #

consDim :: Int -> Lower Ix1T -> Ix1T Source #

unconsDim :: Ix1T -> (Int, Lower Ix1T) Source #

snocDim :: Lower Ix1T -> Int -> Ix1T Source #

unsnocDim :: Ix1T -> (Lower Ix1T, Int) Source #

dropDim :: Ix1T -> Dim -> Maybe (Lower Ix1T) Source #

getIndex :: Ix1T -> Dim -> Maybe Int Source #

setIndex :: Ix1T -> Dim -> Int -> Maybe Ix1T Source #

pureIndex :: Int -> Ix1T Source #

liftIndex2 :: (Int -> Int -> Int) -> Ix1T -> Ix1T -> Ix1T Source #

liftIndex :: (Int -> Int) -> Ix1T -> Ix1T Source #

foldlIndex :: (a -> Int -> a) -> a -> Ix1T -> a Source #

isSafeIndex :: Ix1T -> Ix1T -> Bool Source #

toLinearIndex :: Ix1T -> Ix1T -> Int Source #

toLinearIndexAcc :: Int -> Ix1T -> Ix1T -> Int Source #

fromLinearIndex :: Ix1T -> Int -> Ix1T Source #

fromLinearIndexAcc :: Ix1T -> Int -> (Int, Ix1T) Source #

repairIndex :: Ix1T -> Ix1T -> (Int -> Int -> Int) -> (Int -> Int -> Int) -> Ix1T Source #

iter :: Ix1T -> Ix1T -> Ix1T -> (Int -> Int -> Bool) -> a -> (Ix1T -> a -> a) -> a Source #

iterM :: Monad m => Ix1T -> Ix1T -> Ix1T -> (Int -> Int -> Bool) -> a -> (Ix1T -> a -> m a) -> m a Source #

iterM_ :: Monad m => Ix1T -> Ix1T -> Ix1T -> (Int -> Int -> Bool) -> (Ix1T -> m a) -> m () Source #

Index Ix2 Source # 
Instance details

Defined in Data.Massiv.Core.Index.Ix

Associated Types

type Dimensions Ix2 :: Nat Source #

Methods

dimensions :: Ix2 -> Dim Source #

totalElem :: Ix2 -> Int Source #

consDim :: Int -> Lower Ix2 -> Ix2 Source #

unconsDim :: Ix2 -> (Int, Lower Ix2) Source #

snocDim :: Lower Ix2 -> Int -> Ix2 Source #

unsnocDim :: Ix2 -> (Lower Ix2, Int) Source #

dropDim :: Ix2 -> Dim -> Maybe (Lower Ix2) Source #

getIndex :: Ix2 -> Dim -> Maybe Int Source #

setIndex :: Ix2 -> Dim -> Int -> Maybe Ix2 Source #

pureIndex :: Int -> Ix2 Source #

liftIndex2 :: (Int -> Int -> Int) -> Ix2 -> Ix2 -> Ix2 Source #

liftIndex :: (Int -> Int) -> Ix2 -> Ix2 Source #

foldlIndex :: (a -> Int -> a) -> a -> Ix2 -> a Source #

isSafeIndex :: Ix2 -> Ix2 -> Bool Source #

toLinearIndex :: Ix2 -> Ix2 -> Int Source #

toLinearIndexAcc :: Int -> Ix2 -> Ix2 -> Int Source #

fromLinearIndex :: Ix2 -> Int -> Ix2 Source #

fromLinearIndexAcc :: Ix2 -> Int -> (Int, Ix2) Source #

repairIndex :: Ix2 -> Ix2 -> (Int -> Int -> Int) -> (Int -> Int -> Int) -> Ix2 Source #

iter :: Ix2 -> Ix2 -> Ix2 -> (Int -> Int -> Bool) -> a -> (Ix2 -> a -> a) -> a Source #

iterM :: Monad m => Ix2 -> Ix2 -> Ix2 -> (Int -> Int -> Bool) -> a -> (Ix2 -> a -> m a) -> m a Source #

iterM_ :: Monad m => Ix2 -> Ix2 -> Ix2 -> (Int -> Int -> Bool) -> (Ix2 -> m a) -> m () Source #

(4 <= n, KnownNat n, Index (Ix (n - 1)), IxN (n - 1) ~ Ix (n - 1)) => Index (IxN n) Source # 
Instance details

Defined in Data.Massiv.Core.Index.Ix

Associated Types

type Dimensions (IxN n) :: Nat Source #

Methods

dimensions :: IxN n -> Dim Source #

totalElem :: IxN n -> Int Source #

consDim :: Int -> Lower (IxN n) -> IxN n Source #

unconsDim :: IxN n -> (Int, Lower (IxN n)) Source #

snocDim :: Lower (IxN n) -> Int -> IxN n Source #

unsnocDim :: IxN n -> (Lower (IxN n), Int) Source #

dropDim :: IxN n -> Dim -> Maybe (Lower (IxN n)) Source #

getIndex :: IxN n -> Dim -> Maybe Int Source #

setIndex :: IxN n -> Dim -> Int -> Maybe (IxN n) Source #

pureIndex :: Int -> IxN n Source #

liftIndex2 :: (Int -> Int -> Int) -> IxN n -> IxN n -> IxN n Source #

liftIndex :: (Int -> Int) -> IxN n -> IxN n Source #

foldlIndex :: (a -> Int -> a) -> a -> IxN n -> a Source #

isSafeIndex :: IxN n -> IxN n -> Bool Source #

toLinearIndex :: IxN n -> IxN n -> Int Source #

toLinearIndexAcc :: Int -> IxN n -> IxN n -> Int Source #

fromLinearIndex :: IxN n -> Int -> IxN n Source #

fromLinearIndexAcc :: IxN n -> Int -> (Int, IxN n) Source #

repairIndex :: IxN n -> IxN n -> (Int -> Int -> Int) -> (Int -> Int -> Int) -> IxN n Source #

iter :: IxN n -> IxN n -> IxN n -> (Int -> Int -> Bool) -> a -> (IxN n -> a -> a) -> a Source #

iterM :: Monad m => IxN n -> IxN n -> IxN n -> (Int -> Int -> Bool) -> a -> (IxN n -> a -> m a) -> m a Source #

iterM_ :: Monad m => IxN n -> IxN n -> IxN n -> (Int -> Int -> Bool) -> (IxN n -> m a) -> m () Source #

Index (IxN 3) Source # 
Instance details

Defined in Data.Massiv.Core.Index.Ix

Associated Types

type Dimensions (IxN 3) :: Nat Source #

Methods

dimensions :: IxN 3 -> Dim Source #

totalElem :: IxN 3 -> Int Source #

consDim :: Int -> Lower (IxN 3) -> IxN 3 Source #

unconsDim :: IxN 3 -> (Int, Lower (IxN 3)) Source #

snocDim :: Lower (IxN 3) -> Int -> IxN 3 Source #

unsnocDim :: IxN 3 -> (Lower (IxN 3), Int) Source #

dropDim :: IxN 3 -> Dim -> Maybe (Lower (IxN 3)) Source #

getIndex :: IxN 3 -> Dim -> Maybe Int Source #

setIndex :: IxN 3 -> Dim -> Int -> Maybe (IxN 3) Source #

pureIndex :: Int -> IxN 3 Source #

liftIndex2 :: (Int -> Int -> Int) -> IxN 3 -> IxN 3 -> IxN 3 Source #

liftIndex :: (Int -> Int) -> IxN 3 -> IxN 3 Source #

foldlIndex :: (a -> Int -> a) -> a -> IxN 3 -> a Source #

isSafeIndex :: IxN 3 -> IxN 3 -> Bool Source #

toLinearIndex :: IxN 3 -> IxN 3 -> Int Source #

toLinearIndexAcc :: Int -> IxN 3 -> IxN 3 -> Int Source #

fromLinearIndex :: IxN 3 -> Int -> IxN 3 Source #

fromLinearIndexAcc :: IxN 3 -> Int -> (Int, IxN 3) Source #

repairIndex :: IxN 3 -> IxN 3 -> (Int -> Int -> Int) -> (Int -> Int -> Int) -> IxN 3 Source #

iter :: IxN 3 -> IxN 3 -> IxN 3 -> (Int -> Int -> Bool) -> a -> (IxN 3 -> a -> a) -> a Source #

iterM :: Monad m => IxN 3 -> IxN 3 -> IxN 3 -> (Int -> Int -> Bool) -> a -> (IxN 3 -> a -> m a) -> m a Source #

iterM_ :: Monad m => IxN 3 -> IxN 3 -> IxN 3 -> (Int -> Int -> Bool) -> (IxN 3 -> m a) -> m () Source #

type family Lower ix :: * Source #

This type family will always point to a type for a dimension that is one lower than the type argument.

Instances
type Lower Ix5T Source # 
Instance details

Defined in Data.Massiv.Core.Index.Class

type Lower Ix5T = Ix4T
type Lower Ix4T Source # 
Instance details

Defined in Data.Massiv.Core.Index.Class

type Lower Ix4T = Ix3T
type Lower Ix3T Source # 
Instance details

Defined in Data.Massiv.Core.Index.Class

type Lower Ix3T = Ix2T
type Lower Ix2T Source # 
Instance details

Defined in Data.Massiv.Core.Index.Class

type Lower Ix2T = Ix1T
type Lower Ix1T Source # 
Instance details

Defined in Data.Massiv.Core.Index.Class

type Lower Ix1T = Ix0
type Lower Ix2 Source # 
Instance details

Defined in Data.Massiv.Core.Index.Ix

type Lower Ix2 = Ix1
type Lower (IxN n) Source # 
Instance details

Defined in Data.Massiv.Core.Index.Ix

type Lower (IxN n) = Ix (n - 1)

type Ix5T = (Int, Int, Int, Int, Int) Source #

5-dimensional index as 5-tuple of Ints.

type Ix4T = (Int, Int, Int, Int) Source #

4-dimensional index as 4-tuple of Ints.

type Ix3T = (Int, Int, Int) Source #

3-dimensional index as 3-tuple of Ints.

type Ix2T = (Int, Int) Source #

2-dimensional index as tuple of Ints.

type Ix1T = Int Source #

1-dimensional index. Synonym for Int and Ix1.

data Ix0 Source #

Zero-dimension, i.e. a scalar. Can't really be used directly as there are no instances of Index for it, and is included for completeness.

Constructors

Ix0 
Instances
Eq Ix0 Source # 
Instance details

Defined in Data.Massiv.Core.Index.Class

Methods

(==) :: Ix0 -> Ix0 -> Bool #

(/=) :: Ix0 -> Ix0 -> Bool #

Ord Ix0 Source # 
Instance details

Defined in Data.Massiv.Core.Index.Class

Methods

compare :: Ix0 -> Ix0 -> Ordering #

(<) :: Ix0 -> Ix0 -> Bool #

(<=) :: Ix0 -> Ix0 -> Bool #

(>) :: Ix0 -> Ix0 -> Bool #

(>=) :: Ix0 -> Ix0 -> Bool #

max :: Ix0 -> Ix0 -> Ix0 #

min :: Ix0 -> Ix0 -> Ix0 #

Show Ix0 Source # 
Instance details

Defined in Data.Massiv.Core.Index.Class

Methods

showsPrec :: Int -> Ix0 -> ShowS #

show :: Ix0 -> String #

showList :: [Ix0] -> ShowS #

newtype Dim Source #

A way to select Array dimension.

Constructors

Dim Int 
Instances
Enum Dim Source # 
Instance details

Defined in Data.Massiv.Core.Index.Class

Methods

succ :: Dim -> Dim #

pred :: Dim -> Dim #

toEnum :: Int -> Dim #

fromEnum :: Dim -> Int #

enumFrom :: Dim -> [Dim] #

enumFromThen :: Dim -> Dim -> [Dim] #

enumFromTo :: Dim -> Dim -> [Dim] #

enumFromThenTo :: Dim -> Dim -> Dim -> [Dim] #

Eq Dim Source # 
Instance details

Defined in Data.Massiv.Core.Index.Class

Methods

(==) :: Dim -> Dim -> Bool #

(/=) :: Dim -> Dim -> Bool #

Integral Dim Source # 
Instance details

Defined in Data.Massiv.Core.Index.Class

Methods

quot :: Dim -> Dim -> Dim #

rem :: Dim -> Dim -> Dim #

div :: Dim -> Dim -> Dim #

mod :: Dim -> Dim -> Dim #

quotRem :: Dim -> Dim -> (Dim, Dim) #

divMod :: Dim -> Dim -> (Dim, Dim) #

toInteger :: Dim -> Integer #

Num Dim Source # 
Instance details

Defined in Data.Massiv.Core.Index.Class

Methods

(+) :: Dim -> Dim -> Dim #

(-) :: Dim -> Dim -> Dim #

(*) :: Dim -> Dim -> Dim #

negate :: Dim -> Dim #

abs :: Dim -> Dim #

signum :: Dim -> Dim #

fromInteger :: Integer -> Dim #

Ord Dim Source # 
Instance details

Defined in Data.Massiv.Core.Index.Class

Methods

compare :: Dim -> Dim -> Ordering #

(<) :: Dim -> Dim -> Bool #

(<=) :: Dim -> Dim -> Bool #

(>) :: Dim -> Dim -> Bool #

(>=) :: Dim -> Dim -> Bool #

max :: Dim -> Dim -> Dim #

min :: Dim -> Dim -> Dim #

Real Dim Source # 
Instance details

Defined in Data.Massiv.Core.Index.Class

Methods

toRational :: Dim -> Rational #

Show Dim Source # 
Instance details

Defined in Data.Massiv.Core.Index.Class

Methods

showsPrec :: Int -> Dim -> ShowS #

show :: Dim -> String #

showList :: [Dim] -> ShowS #

errorIx :: (Show ix, Show ix') => String -> ix -> ix' -> a Source #

Helper function for throwing out of bounds errors

errorSizeMismatch :: (Show ix, Show ix') => String -> ix -> ix' -> a Source #

Helper function for throwing error when sizes do not match

data Stride ix Source #

Stride provides a way to ignore elements of an array if an index is divisible by a corresponding value in a stride. So, for a Stride (i :. j) only elements with indices will be kept around:

( 0 :. 0) ( 0 :. j) ( 0 :. 2j) ( 0 :. 3j) ...
( i :. 0) ( i :. j) ( i :. 2j) ( i :. 3j) ...
(2i :. 0) (2i :. j) (2i :. 2j) (2i :. 3j) ...
...

Only positive strides make sense, so Stride pattern synonym constructor will prevent a user from creating a stride with negative or zero values, thus promoting safety of the library.

Examples:

Expand
  • Default and minimal stride of Stride (pureIndex 1) will have no affect and all elements will kept.
  • If stride is Stride 2, then every 2nd element (i.e. with index 1, 3, 5, ..) will be skipped and only elemnts with indices divisible by 2 will be kept around.
  • In case of two dimensions, if what you want is to keep all rows divisible by 5, but keep every column intact then you'd use Stride (5 :. 1).
Instances
Eq ix => Eq (Stride ix) Source # 
Instance details

Defined in Data.Massiv.Core.Index.Stride

Methods

(==) :: Stride ix -> Stride ix -> Bool #

(/=) :: Stride ix -> Stride ix -> Bool #

Ord ix => Ord (Stride ix) Source # 
Instance details

Defined in Data.Massiv.Core.Index.Stride

Methods

compare :: Stride ix -> Stride ix -> Ordering #

(<) :: Stride ix -> Stride ix -> Bool #

(<=) :: Stride ix -> Stride ix -> Bool #

(>) :: Stride ix -> Stride ix -> Bool #

(>=) :: Stride ix -> Stride ix -> Bool #

max :: Stride ix -> Stride ix -> Stride ix #

min :: Stride ix -> Stride ix -> Stride ix #

Index ix => Show (Stride ix) Source # 
Instance details

Defined in Data.Massiv.Core.Index.Stride

Methods

showsPrec :: Int -> Stride ix -> ShowS #

show :: Stride ix -> String #

showList :: [Stride ix] -> ShowS #

NFData ix => NFData (Stride ix) Source # 
Instance details

Defined in Data.Massiv.Core.Index.Stride

Methods

rnf :: Stride ix -> () #

pattern Stride :: Index ix => ix -> Stride ix Source #

A safe bidirectional pattern synonym for Stride construction that will make sure stride elements are always positive.

unStride :: Stride ix -> ix Source #

Just a helper function for unwrapping Stride.

strideStart :: Index ix => Stride ix -> ix -> ix Source #

Adjust strating index according to the stride

strideSize :: Index ix => Stride ix -> ix -> ix Source #

Adjust size according to the stride.

toLinearIndexStride Source #

Arguments

:: Index ix 
=> Stride ix

Stride

-> ix

Size

-> ix

Index

-> Int 

Compute an index with stride using the original size and index

oneStride :: Index ix => Stride ix Source #

A default stride of 1, where all elements are kept

type family Ix (n :: Nat) = r | r -> n where ... Source #

Defines n-dimensional index by relating a general IxN with few base cases.

Equations

Ix 0 = Ix0 
Ix 1 = Ix1 
Ix 2 = Ix2 
Ix n = IxN n 

data IxN (n :: Nat) Source #

n-dimensional index. Needs a base case, which is the Ix2.

Constructors

(:>) !Int !(Ix (n - 1)) infixr 5 
Instances
Bounded Ix3 Source # 
Instance details

Defined in Data.Massiv.Core.Index.Ix

Methods

minBound :: Ix3 #

maxBound :: Ix3 #

Num Ix3 Source # 
Instance details

Defined in Data.Massiv.Core.Index.Ix

Methods

(+) :: Ix3 -> Ix3 -> Ix3 #

(-) :: Ix3 -> Ix3 -> Ix3 #

(*) :: Ix3 -> Ix3 -> Ix3 #

negate :: Ix3 -> Ix3 #

abs :: Ix3 -> Ix3 #

signum :: Ix3 -> Ix3 #

fromInteger :: Integer -> Ix3 #

(3 <= n, Unbox (Ix (n - 1))) => Vector Vector (IxN n) Source # 
Instance details

Defined in Data.Massiv.Core.Index.Ix

Methods

basicUnsafeFreeze :: PrimMonad m => Mutable Vector (PrimState m) (IxN n) -> m (Vector (IxN n)) #

basicUnsafeThaw :: PrimMonad m => Vector (IxN n) -> m (Mutable Vector (PrimState m) (IxN n)) #

basicLength :: Vector (IxN n) -> Int #

basicUnsafeSlice :: Int -> Int -> Vector (IxN n) -> Vector (IxN n) #

basicUnsafeIndexM :: Monad m => Vector (IxN n) -> Int -> m (IxN n) #

basicUnsafeCopy :: PrimMonad m => Mutable Vector (PrimState m) (IxN n) -> Vector (IxN n) -> m () #

elemseq :: Vector (IxN n) -> IxN n -> b -> b #

(3 <= n, Unbox (Ix (n - 1))) => MVector MVector (IxN n) Source # 
Instance details

Defined in Data.Massiv.Core.Index.Ix

Methods

basicLength :: MVector s (IxN n) -> Int #

basicUnsafeSlice :: Int -> Int -> MVector s (IxN n) -> MVector s (IxN n) #

basicOverlaps :: MVector s (IxN n) -> MVector s (IxN n) -> Bool #

basicUnsafeNew :: PrimMonad m => Int -> m (MVector (PrimState m) (IxN n)) #

basicInitialize :: PrimMonad m => MVector (PrimState m) (IxN n) -> m () #

basicUnsafeReplicate :: PrimMonad m => Int -> IxN n -> m (MVector (PrimState m) (IxN n)) #

basicUnsafeRead :: PrimMonad m => MVector (PrimState m) (IxN n) -> Int -> m (IxN n) #

basicUnsafeWrite :: PrimMonad m => MVector (PrimState m) (IxN n) -> Int -> IxN n -> m () #

basicClear :: PrimMonad m => MVector (PrimState m) (IxN n) -> m () #

basicSet :: PrimMonad m => MVector (PrimState m) (IxN n) -> IxN n -> m () #

basicUnsafeCopy :: PrimMonad m => MVector (PrimState m) (IxN n) -> MVector (PrimState m) (IxN n) -> m () #

basicUnsafeMove :: PrimMonad m => MVector (PrimState m) (IxN n) -> MVector (PrimState m) (IxN n) -> m () #

basicUnsafeGrow :: PrimMonad m => MVector (PrimState m) (IxN n) -> Int -> m (MVector (PrimState m) (IxN n)) #

(4 <= n, KnownNat n, Index (Ix (n - 1)), IxN (n - 1) ~ Ix (n - 1)) => Bounded (IxN n) Source # 
Instance details

Defined in Data.Massiv.Core.Index.Ix

Methods

minBound :: IxN n #

maxBound :: IxN n #

Eq (Ix (n - 1)) => Eq (IxN n) Source # 
Instance details

Defined in Data.Massiv.Core.Index.Ix

Methods

(==) :: IxN n -> IxN n -> Bool #

(/=) :: IxN n -> IxN n -> Bool #

(4 <= n, KnownNat n, Index (Ix (n - 1)), IxN (n - 1) ~ Ix (n - 1)) => Num (IxN n) Source # 
Instance details

Defined in Data.Massiv.Core.Index.Ix

Methods

(+) :: IxN n -> IxN n -> IxN n #

(-) :: IxN n -> IxN n -> IxN n #

(*) :: IxN n -> IxN n -> IxN n #

negate :: IxN n -> IxN n #

abs :: IxN n -> IxN n #

signum :: IxN n -> IxN n #

fromInteger :: Integer -> IxN n #

Ord (Ix (n - 1)) => Ord (IxN n) Source # 
Instance details

Defined in Data.Massiv.Core.Index.Ix

Methods

compare :: IxN n -> IxN n -> Ordering #

(<) :: IxN n -> IxN n -> Bool #

(<=) :: IxN n -> IxN n -> Bool #

(>) :: IxN n -> IxN n -> Bool #

(>=) :: IxN n -> IxN n -> Bool #

max :: IxN n -> IxN n -> IxN n #

min :: IxN n -> IxN n -> IxN n #

Show (Ix (n - 1)) => Show (IxN n) Source # 
Instance details

Defined in Data.Massiv.Core.Index.Ix

Methods

showsPrec :: Int -> IxN n -> ShowS #

show :: IxN n -> String #

showList :: [IxN n] -> ShowS #

NFData (IxN n) Source # 
Instance details

Defined in Data.Massiv.Core.Index.Ix

Methods

rnf :: IxN n -> () #

(3 <= n, Unbox (Ix (n - 1))) => Unbox (IxN n) Source #

Unboxing of a IxN.

Instance details

Defined in Data.Massiv.Core.Index.Ix

(4 <= n, KnownNat n, Index (Ix (n - 1)), IxN (n - 1) ~ Ix (n - 1)) => Index (IxN n) Source # 
Instance details

Defined in Data.Massiv.Core.Index.Ix

Associated Types

type Dimensions (IxN n) :: Nat Source #

Methods

dimensions :: IxN n -> Dim Source #

totalElem :: IxN n -> Int Source #

consDim :: Int -> Lower (IxN n) -> IxN n Source #

unconsDim :: IxN n -> (Int, Lower (IxN n)) Source #

snocDim :: Lower (IxN n) -> Int -> IxN n Source #

unsnocDim :: IxN n -> (Lower (IxN n), Int) Source #

dropDim :: IxN n -> Dim -> Maybe (Lower (IxN n)) Source #

getIndex :: IxN n -> Dim -> Maybe Int Source #

setIndex :: IxN n -> Dim -> Int -> Maybe (IxN n) Source #

pureIndex :: Int -> IxN n Source #

liftIndex2 :: (Int -> Int -> Int) -> IxN n -> IxN n -> IxN n Source #

liftIndex :: (Int -> Int) -> IxN n -> IxN n Source #

foldlIndex :: (a -> Int -> a) -> a -> IxN n -> a Source #

isSafeIndex :: IxN n -> IxN n -> Bool Source #

toLinearIndex :: IxN n -> IxN n -> Int Source #

toLinearIndexAcc :: Int -> IxN n -> IxN n -> Int Source #

fromLinearIndex :: IxN n -> Int -> IxN n Source #

fromLinearIndexAcc :: IxN n -> Int -> (Int, IxN n) Source #

repairIndex :: IxN n -> IxN n -> (Int -> Int -> Int) -> (Int -> Int -> Int) -> IxN n Source #

iter :: IxN n -> IxN n -> IxN n -> (Int -> Int -> Bool) -> a -> (IxN n -> a -> a) -> a Source #

iterM :: Monad m => IxN n -> IxN n -> IxN n -> (Int -> Int -> Bool) -> a -> (IxN n -> a -> m a) -> m a Source #

iterM_ :: Monad m => IxN n -> IxN n -> IxN n -> (Int -> Int -> Bool) -> (IxN n -> m a) -> m () Source #

Index (IxN 3) Source # 
Instance details

Defined in Data.Massiv.Core.Index.Ix

Associated Types

type Dimensions (IxN 3) :: Nat Source #

Methods

dimensions :: IxN 3 -> Dim Source #

totalElem :: IxN 3 -> Int Source #

consDim :: Int -> Lower (IxN 3) -> IxN 3 Source #

unconsDim :: IxN 3 -> (Int, Lower (IxN 3)) Source #

snocDim :: Lower (IxN 3) -> Int -> IxN 3 Source #

unsnocDim :: IxN 3 -> (Lower (IxN 3), Int) Source #

dropDim :: IxN 3 -> Dim -> Maybe (Lower (IxN 3)) Source #

getIndex :: IxN 3 -> Dim -> Maybe Int Source #

setIndex :: IxN 3 -> Dim -> Int -> Maybe (IxN 3) Source #

pureIndex :: Int -> IxN 3 Source #

liftIndex2 :: (Int -> Int -> Int) -> IxN 3 -> IxN 3 -> IxN 3 Source #

liftIndex :: (Int -> Int) -> IxN 3 -> IxN 3 Source #

foldlIndex :: (a -> Int -> a) -> a -> IxN 3 -> a Source #

isSafeIndex :: IxN 3 -> IxN 3 -> Bool Source #

toLinearIndex :: IxN 3 -> IxN 3 -> Int Source #

toLinearIndexAcc :: Int -> IxN 3 -> IxN 3 -> Int Source #

fromLinearIndex :: IxN 3 -> Int -> IxN 3 Source #

fromLinearIndexAcc :: IxN 3 -> Int -> (Int, IxN 3) Source #

repairIndex :: IxN 3 -> IxN 3 -> (Int -> Int -> Int) -> (Int -> Int -> Int) -> IxN 3 Source #

iter :: IxN 3 -> IxN 3 -> IxN 3 -> (Int -> Int -> Bool) -> a -> (IxN 3 -> a -> a) -> a Source #

iterM :: Monad m => IxN 3 -> IxN 3 -> IxN 3 -> (Int -> Int -> Bool) -> a -> (IxN 3 -> a -> m a) -> m a Source #

iterM_ :: Monad m => IxN 3 -> IxN 3 -> IxN 3 -> (Int -> Int -> Bool) -> (IxN 3 -> m a) -> m () Source #

type Dimensions Ix3 Source # 
Instance details

Defined in Data.Massiv.Core.Index.Ix

type Dimensions Ix3 = 3
data MVector s (IxN n) Source # 
Instance details

Defined in Data.Massiv.Core.Index.Ix

data MVector s (IxN n) = MV_IxN (MVector s Int, MVector s (Ix (n - 1)))
data Vector (IxN n) Source # 
Instance details

Defined in Data.Massiv.Core.Index.Ix

data Vector (IxN n) = V_IxN (Vector Int, Vector (Ix (n - 1)))
type Dimensions (IxN n) Source # 
Instance details

Defined in Data.Massiv.Core.Index.Ix

type Dimensions (IxN n) = n
type Lower (IxN n) Source # 
Instance details

Defined in Data.Massiv.Core.Index.Ix

type Lower (IxN n) = Ix (n - 1)

type Ix5 = IxN 5 Source #

5-dimensional type synonym.

type Ix4 = IxN 4 Source #

4-dimensional type synonym.

type Ix3 = IxN 3 Source #

3-dimensional type synonym. Useful as a alternative to enabling DataKinds and using type level Nats.

data Ix2 Source #

2-dimensional index. This also a base index for higher dimensions.

Constructors

(:.) !Int !Int infixr 5 
Instances
Bounded Ix2 Source # 
Instance details

Defined in Data.Massiv.Core.Index.Ix

Methods

minBound :: Ix2 #

maxBound :: Ix2 #

Eq Ix2 Source # 
Instance details

Defined in Data.Massiv.Core.Index.Ix

Methods

(==) :: Ix2 -> Ix2 -> Bool #

(/=) :: Ix2 -> Ix2 -> Bool #

Num Ix2 Source # 
Instance details

Defined in Data.Massiv.Core.Index.Ix

Methods

(+) :: Ix2 -> Ix2 -> Ix2 #

(-) :: Ix2 -> Ix2 -> Ix2 #

(*) :: Ix2 -> Ix2 -> Ix2 #

negate :: Ix2 -> Ix2 #

abs :: Ix2 -> Ix2 #

signum :: Ix2 -> Ix2 #

fromInteger :: Integer -> Ix2 #

Ord Ix2 Source # 
Instance details

Defined in Data.Massiv.Core.Index.Ix

Methods

compare :: Ix2 -> Ix2 -> Ordering #

(<) :: Ix2 -> Ix2 -> Bool #

(<=) :: Ix2 -> Ix2 -> Bool #

(>) :: Ix2 -> Ix2 -> Bool #

(>=) :: Ix2 -> Ix2 -> Bool #

max :: Ix2 -> Ix2 -> Ix2 #

min :: Ix2 -> Ix2 -> Ix2 #

Show Ix2 Source # 
Instance details

Defined in Data.Massiv.Core.Index.Ix

Methods

showsPrec :: Int -> Ix2 -> ShowS #

show :: Ix2 -> String #

showList :: [Ix2] -> ShowS #

NFData Ix2 Source # 
Instance details

Defined in Data.Massiv.Core.Index.Ix

Methods

rnf :: Ix2 -> () #

Unbox Ix2 Source #

Unboxing of a Ix2.

Instance details

Defined in Data.Massiv.Core.Index.Ix

Index Ix2 Source # 
Instance details

Defined in Data.Massiv.Core.Index.Ix

Associated Types

type Dimensions Ix2 :: Nat Source #

Methods

dimensions :: Ix2 -> Dim Source #

totalElem :: Ix2 -> Int Source #

consDim :: Int -> Lower Ix2 -> Ix2 Source #

unconsDim :: Ix2 -> (Int, Lower Ix2) Source #

snocDim :: Lower Ix2 -> Int -> Ix2 Source #

unsnocDim :: Ix2 -> (Lower Ix2, Int) Source #

dropDim :: Ix2 -> Dim -> Maybe (Lower Ix2) Source #

getIndex :: Ix2 -> Dim -> Maybe Int Source #

setIndex :: Ix2 -> Dim -> Int -> Maybe Ix2 Source #

pureIndex :: Int -> Ix2 Source #

liftIndex2 :: (Int -> Int -> Int) -> Ix2 -> Ix2 -> Ix2 Source #

liftIndex :: (Int -> Int) -> Ix2 -> Ix2 Source #

foldlIndex :: (a -> Int -> a) -> a -> Ix2 -> a Source #

isSafeIndex :: Ix2 -> Ix2 -> Bool Source #

toLinearIndex :: Ix2 -> Ix2 -> Int Source #

toLinearIndexAcc :: Int -> Ix2 -> Ix2 -> Int Source #

fromLinearIndex :: Ix2 -> Int -> Ix2 Source #

fromLinearIndexAcc :: Ix2 -> Int -> (Int, Ix2) Source #

repairIndex :: Ix2 -> Ix2 -> (Int -> Int -> Int) -> (Int -> Int -> Int) -> Ix2 Source #

iter :: Ix2 -> Ix2 -> Ix2 -> (Int -> Int -> Bool) -> a -> (Ix2 -> a -> a) -> a Source #

iterM :: Monad m => Ix2 -> Ix2 -> Ix2 -> (Int -> Int -> Bool) -> a -> (Ix2 -> a -> m a) -> m a Source #

iterM_ :: Monad m => Ix2 -> Ix2 -> Ix2 -> (Int -> Int -> Bool) -> (Ix2 -> m a) -> m () Source #

Vector Vector Ix2 Source # 
Instance details

Defined in Data.Massiv.Core.Index.Ix

MVector MVector Ix2 Source # 
Instance details

Defined in Data.Massiv.Core.Index.Ix

Load DW Ix2 e Source # 
Instance details

Defined in Data.Massiv.Array.Delayed.Windowed

Methods

loadS :: Monad m => Array DW Ix2 e -> (Int -> m e) -> (Int -> e -> m ()) -> m () Source #

loadP :: [Int] -> Array DW Ix2 e -> (Int -> IO e) -> (Int -> e -> IO ()) -> IO () Source #

loadArrayWithStride :: Monad m => Int -> (m () -> m ()) -> Stride Ix2 -> Ix2 -> Array DW Ix2 e -> (Int -> m e) -> (Int -> e -> m ()) -> m () Source #

loadArray :: Monad m => Int -> (m () -> m ()) -> Array DW Ix2 e -> (Int -> m e) -> (Int -> e -> m ()) -> m () Source #

data Vector Ix2 Source # 
Instance details

Defined in Data.Massiv.Core.Index.Ix

type Dimensions Ix2 Source # 
Instance details

Defined in Data.Massiv.Core.Index.Ix

type Dimensions Ix2 = 2
type Lower Ix2 Source # 
Instance details

Defined in Data.Massiv.Core.Index.Ix

type Lower Ix2 = Ix1
data MVector s Ix2 Source # 
Instance details

Defined in Data.Massiv.Core.Index.Ix

type Ix1 = Int Source #

Another type synonym for 1-dimensional index, i.e. Int and Ix1T. Provided here purely for consistency.

pattern Ix5 :: Int -> Int -> Int -> Int -> Int -> Ix5 Source #

5-dimensional index constructor. (Ix5 i j k l m) = (i :> j :> k :> l :. m).

pattern Ix4 :: Int -> Int -> Int -> Int -> Ix4 Source #

4-dimensional index constructor. (Ix4 i j k l) == (i :> j :> k :. l).

pattern Ix3 :: Int -> Int -> Int -> Ix3 Source #

3-dimensional index constructor. (Ix3 i j k) == (i :> j :. k).

pattern Ix2 :: Int -> Int -> Ix2 Source #

2-dimensional index constructor. Useful when TypeOperators extension isn't enabled, or simply infix notation is inconvenient. (Ix2 i j) == (i :. j).

pattern Ix1 :: Int -> Ix1 Source #

This is a very handy pattern synonym to indicate that any arbitrary whole number is an Int, i.e. a 1-dimensional index: (Ix1 i) == (i :: Int)

toIx2 :: Ix2T -> Ix2 Source #

Convert a Int tuple to Ix2

fromIx2 :: Ix2 -> Ix2T Source #

Convert an Ix2 to Int tuple

toIx3 :: Ix3T -> Ix3 Source #

Convert a Int 3-tuple to Ix3

fromIx3 :: Ix3 -> Ix3T Source #

Convert an Ix3 to Int 3-tuple

toIx4 :: Ix4T -> Ix4 Source #

Convert a Int 4-tuple to Ix4

fromIx4 :: Ix4 -> Ix4T Source #

Convert an Ix4 to Int 4-tuple

toIx5 :: Ix5T -> Ix5 Source #

Convert a Int 5-tuple to Ix5

fromIx5 :: Ix5 -> Ix5T Source #

Convert an Ix5 to Int 5-tuple

data Border e Source #

Approach to be used near the borders during various transformations. Whenever a function needs information not only about an element of interest, but also about it's neighbors, it will go out of bounds near the array edges, hence is this set of approaches that specify how to handle such situation.

Constructors

Fill e

Fill in a constant element.

           outside |  Array  | outside
(Fill 0) : 0 0 0 0 | 1 2 3 4 | 0 0 0 0
Wrap

Wrap around from the opposite border of the array.

           outside |  Array  | outside
Wrap :     1 2 3 4 | 1 2 3 4 | 1 2 3 4
Edge

Replicate the element at the edge.

           outside |  Array  | outside
Edge :     1 1 1 1 | 1 2 3 4 | 4 4 4 4
Reflect

Mirror like reflection.

           outside |  Array  | outside
Reflect :  4 3 2 1 | 1 2 3 4 | 4 3 2 1
Continue

Also mirror like reflection, but without repeating the edge element.

           outside |  Array  | outside
Continue : 1 4 3 2 | 1 2 3 4 | 3 2 1 4
Instances
Eq e => Eq (Border e) Source # 
Instance details

Defined in Data.Massiv.Core.Index

Methods

(==) :: Border e -> Border e -> Bool #

(/=) :: Border e -> Border e -> Bool #

Show e => Show (Border e) Source # 
Instance details

Defined in Data.Massiv.Core.Index

Methods

showsPrec :: Int -> Border e -> ShowS #

show :: Border e -> String #

showList :: [Border e] -> ShowS #

NFData e => NFData (Border e) Source # 
Instance details

Defined in Data.Massiv.Core.Index

Methods

rnf :: Border e -> () #

handleBorderIndex Source #

Arguments

:: Index ix 
=> Border e

Broder resolution technique

-> ix

Size

-> (ix -> e)

Index function that produces an element

-> ix

Index

-> e 

Apply a border resolution technique to an index

zeroIndex :: Index ix => ix Source #

Index with all zeros

isSafeSize :: Index ix => ix -> Bool Source #

Checks whether the size is valid.

isNonEmpty :: Index ix => ix -> Bool Source #

Checks whether array with this size can hold at least one element.

headDim :: Index ix => ix -> Int Source #

tailDim :: Index ix => ix -> Lower ix Source #

lastDim :: Index ix => ix -> Int Source #

initDim :: Index ix => ix -> Lower ix Source #

iterLinearM Source #

Arguments

:: (Index ix, Monad m) 
=> ix

Size

-> Int

Linear start

-> Int

Linear end

-> Int

Increment

-> (Int -> Int -> Bool)

Continuation condition (continue if True)

-> a

Accumulator

-> (Int -> ix -> a -> m a) 
-> m a 

Iterate over N-dimensional space lenarly from start to end in row-major fashion with an accumulator

iterLinearM_ Source #

Arguments

:: (Index ix, Monad m) 
=> ix

Size

-> Int

Start

-> Int

End

-> Int

Increment

-> (Int -> Int -> Bool)

Continuation condition

-> (Int -> ix -> m ())

Monadic action that takes index in both forms

-> m () 

Same as iterLinearM, except without an accumulator.

class Construct r ix e => Ragged r ix e where Source #

Methods

empty :: Comp -> Array r ix e Source #

isNull :: Array r ix e -> Bool Source #

cons :: Elt r ix e -> Array r ix e -> Array r ix e Source #

uncons :: Array r ix e -> Maybe (Elt r ix e, Array r ix e) Source #

edgeSize :: Array r ix e -> ix Source #

flatten :: Array r ix e -> Array r Ix1 e Source #

loadRagged :: (IO () -> IO ()) -> (Int -> e -> IO a) -> Int -> Int -> Lower ix -> Array r ix e -> IO () Source #

raggedFormat :: (e -> String) -> String -> Array r ix e -> String Source #

Instances
(Index ix, Index (Lower ix), Ragged L (Lower ix) e, Elt L ix e ~ Array L (Lower ix) e, Elt LN ix e ~ Array LN (Lower ix) e, Coercible (Elt LN ix e) [Elt LN (Lower ix) e]) => Ragged L ix e Source # 
Instance details

Defined in Data.Massiv.Core.List

Methods

empty :: Comp -> Array L ix e Source #

isNull :: Array L ix e -> Bool Source #

cons :: Elt L ix e -> Array L ix e -> Array L ix e Source #

uncons :: Array L ix e -> Maybe (Elt L ix e, Array L ix e) Source #

unsafeGenerateM :: Monad m => Comp -> ix -> (ix -> m e) -> m (Array L ix e) Source #

edgeSize :: Array L ix e -> ix Source #

flatten :: Array L ix e -> Array L Ix1 e Source #

loadRagged :: (IO () -> IO ()) -> (Int -> e -> IO a) -> Int -> Int -> Lower ix -> Array L ix e -> IO () Source #

raggedFormat :: (e -> String) -> String -> Array L ix e -> String Source #

Ragged L Ix1 e Source # 
Instance details

Defined in Data.Massiv.Core.List

Methods

empty :: Comp -> Array L Ix1 e Source #

isNull :: Array L Ix1 e -> Bool Source #

cons :: Elt L Ix1 e -> Array L Ix1 e -> Array L Ix1 e Source #

uncons :: Array L Ix1 e -> Maybe (Elt L Ix1 e, Array L Ix1 e) Source #

unsafeGenerateM :: Monad m => Comp -> Ix1 -> (Ix1 -> m e) -> m (Array L Ix1 e) Source #

edgeSize :: Array L Ix1 e -> Ix1 Source #

flatten :: Array L Ix1 e -> Array L Ix1 e Source #

loadRagged :: (IO () -> IO ()) -> (Int -> e -> IO a) -> Int -> Int -> Lower Ix1 -> Array L Ix1 e -> IO () Source #

raggedFormat :: (e -> String) -> String -> Array L Ix1 e -> String Source #

class Nested r ix e where Source #

Minimal complete definition

fromNested, toNested

Methods

fromNested :: NestedStruct r ix e -> Array r ix e Source #

toNested :: Array r ix e -> NestedStruct r ix e Source #

Instances
Nested L ix e Source # 
Instance details

Defined in Data.Massiv.Core.List

Methods

fromNested :: NestedStruct L ix e -> Array L ix e Source #

toNested :: Array L ix e -> NestedStruct L ix e Source #

(Elt LN ix e ~ Array LN (Lower ix) e, ListItem ix e ~ [ListItem (Lower ix) e], Coercible (Elt LN ix e) (ListItem ix e)) => Nested LN ix e Source # 
Instance details

Defined in Data.Massiv.Core.List

Methods

fromNested :: NestedStruct LN ix e -> Array LN ix e Source #

toNested :: Array LN ix e -> NestedStruct LN ix e Source #

Nested LN Ix1 e Source # 
Instance details

Defined in Data.Massiv.Core.List

class Manifest r ix e => Mutable r ix e Source #

Instances
(Unbox e, Index ix) => Mutable U ix e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Unboxed

Associated Types

data MArray s U ix e :: * Source #

Methods

msize :: MArray s U ix e -> ix Source #

unsafeThaw :: PrimMonad m => Array U ix e -> m (MArray (PrimState m) U ix e) Source #

unsafeFreeze :: PrimMonad m => Comp -> MArray (PrimState m) U ix e -> m (Array U ix e) Source #

unsafeNew :: PrimMonad m => ix -> m (MArray (PrimState m) U ix e) Source #

unsafeNewZero :: PrimMonad m => ix -> m (MArray (PrimState m) U ix e) Source #

unsafeLinearRead :: PrimMonad m => MArray (PrimState m) U ix e -> Int -> m e Source #

unsafeLinearWrite :: PrimMonad m => MArray (PrimState m) U ix e -> Int -> e -> m () Source #

unsafeNewA :: Applicative f => ix -> WorldState -> f (WorldState, MArray RealWorld U ix e)

unsafeThawA :: Applicative m => Array U ix e -> WorldState -> m (WorldState, MArray RealWorld U ix e)

unsafeFreezeA :: Applicative m => Comp -> MArray RealWorld U ix e -> WorldState -> m (WorldState, Array U ix e)

unsafeLinearWriteA :: Applicative m => MArray RealWorld U ix e -> Int -> e -> WorldState -> m WorldState

(Index ix, Storable e) => Mutable S ix e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Storable

Associated Types

data MArray s S ix e :: * Source #

Methods

msize :: MArray s S ix e -> ix Source #

unsafeThaw :: PrimMonad m => Array S ix e -> m (MArray (PrimState m) S ix e) Source #

unsafeFreeze :: PrimMonad m => Comp -> MArray (PrimState m) S ix e -> m (Array S ix e) Source #

unsafeNew :: PrimMonad m => ix -> m (MArray (PrimState m) S ix e) Source #

unsafeNewZero :: PrimMonad m => ix -> m (MArray (PrimState m) S ix e) Source #

unsafeLinearRead :: PrimMonad m => MArray (PrimState m) S ix e -> Int -> m e Source #

unsafeLinearWrite :: PrimMonad m => MArray (PrimState m) S ix e -> Int -> e -> m () Source #

unsafeNewA :: Applicative f => ix -> WorldState -> f (WorldState, MArray RealWorld S ix e)

unsafeThawA :: Applicative m => Array S ix e -> WorldState -> m (WorldState, MArray RealWorld S ix e)

unsafeFreezeA :: Applicative m => Comp -> MArray RealWorld S ix e -> WorldState -> m (WorldState, Array S ix e)

unsafeLinearWriteA :: Applicative m => MArray RealWorld S ix e -> Int -> e -> WorldState -> m WorldState

(Index ix, Prim e) => Mutable P ix e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Primitive

Associated Types

data MArray s P ix e :: * Source #

Methods

msize :: MArray s P ix e -> ix Source #

unsafeThaw :: PrimMonad m => Array P ix e -> m (MArray (PrimState m) P ix e) Source #

unsafeFreeze :: PrimMonad m => Comp -> MArray (PrimState m) P ix e -> m (Array P ix e) Source #

unsafeNew :: PrimMonad m => ix -> m (MArray (PrimState m) P ix e) Source #

unsafeNewZero :: PrimMonad m => ix -> m (MArray (PrimState m) P ix e) Source #

unsafeLinearRead :: PrimMonad m => MArray (PrimState m) P ix e -> Int -> m e Source #

unsafeLinearWrite :: PrimMonad m => MArray (PrimState m) P ix e -> Int -> e -> m () Source #

unsafeNewA :: Applicative f => ix -> WorldState -> f (WorldState, MArray RealWorld P ix e)

unsafeThawA :: Applicative m => Array P ix e -> WorldState -> m (WorldState, MArray RealWorld P ix e)

unsafeFreezeA :: Applicative m => Comp -> MArray RealWorld P ix e -> WorldState -> m (WorldState, Array P ix e)

unsafeLinearWriteA :: Applicative m => MArray RealWorld P ix e -> Int -> e -> WorldState -> m WorldState

(Index ix, NFData e) => Mutable N ix e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Boxed

Associated Types

data MArray s N ix e :: * Source #

Methods

msize :: MArray s N ix e -> ix Source #

unsafeThaw :: PrimMonad m => Array N ix e -> m (MArray (PrimState m) N ix e) Source #

unsafeFreeze :: PrimMonad m => Comp -> MArray (PrimState m) N ix e -> m (Array N ix e) Source #

unsafeNew :: PrimMonad m => ix -> m (MArray (PrimState m) N ix e) Source #

unsafeNewZero :: PrimMonad m => ix -> m (MArray (PrimState m) N ix e) Source #

unsafeLinearRead :: PrimMonad m => MArray (PrimState m) N ix e -> Int -> m e Source #

unsafeLinearWrite :: PrimMonad m => MArray (PrimState m) N ix e -> Int -> e -> m () Source #

unsafeNewA :: Applicative f => ix -> WorldState -> f (WorldState, MArray RealWorld N ix e)

unsafeThawA :: Applicative m => Array N ix e -> WorldState -> m (WorldState, MArray RealWorld N ix e)

unsafeFreezeA :: Applicative m => Comp -> MArray RealWorld N ix e -> WorldState -> m (WorldState, Array N ix e)

unsafeLinearWriteA :: Applicative m => MArray RealWorld N ix e -> Int -> e -> WorldState -> m WorldState

Index ix => Mutable B ix e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Boxed

Associated Types

data MArray s B ix e :: * Source #

Methods

msize :: MArray s B ix e -> ix Source #

unsafeThaw :: PrimMonad m => Array B ix e -> m (MArray (PrimState m) B ix e) Source #

unsafeFreeze :: PrimMonad m => Comp -> MArray (PrimState m) B ix e -> m (Array B ix e) Source #

unsafeNew :: PrimMonad m => ix -> m (MArray (PrimState m) B ix e) Source #

unsafeNewZero :: PrimMonad m => ix -> m (MArray (PrimState m) B ix e) Source #

unsafeLinearRead :: PrimMonad m => MArray (PrimState m) B ix e -> Int -> m e Source #

unsafeLinearWrite :: PrimMonad m => MArray (PrimState m) B ix e -> Int -> e -> m () Source #

unsafeNewA :: Applicative f => ix -> WorldState -> f (WorldState, MArray RealWorld B ix e)

unsafeThawA :: Applicative m => Array B ix e -> WorldState -> m (WorldState, MArray RealWorld B ix e)

unsafeFreezeA :: Applicative m => Comp -> MArray RealWorld B ix e -> WorldState -> m (WorldState, Array B ix e)

unsafeLinearWriteA :: Applicative m => MArray RealWorld B ix e -> Int -> e -> WorldState -> m WorldState

class Source r ix e => Manifest r ix e Source #

Manifest arrays are backed by actual memory and values are looked up versus computed as it is with delayed arrays. Because of this fact indexing functions (!), (!?), etc. are constrained to manifest arrays only.

Minimal complete definition

unsafeLinearIndexM

Instances
Index ix => Manifest M ix e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Internal

Methods

unsafeLinearIndexM :: Array M ix e -> Int -> e Source #

(Unbox e, Index ix) => Manifest U ix e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Unboxed

Methods

unsafeLinearIndexM :: Array U ix e -> Int -> e Source #

(Index ix, Storable e) => Manifest S ix e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Storable

Methods

unsafeLinearIndexM :: Array S ix e -> Int -> e Source #

(Index ix, Prim e) => Manifest P ix e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Primitive

Methods

unsafeLinearIndexM :: Array P ix e -> Int -> e Source #

(Index ix, NFData e) => Manifest N ix e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Boxed

Methods

unsafeLinearIndexM :: Array N ix e -> Int -> e Source #

Index ix => Manifest B ix e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Boxed

Methods

unsafeLinearIndexM :: Array B ix e -> Int -> e Source #

class Size r ix e => Slice r ix e Source #

Minimal complete definition

unsafeSlice

Instances
(Index ix, Index (Lower ix), Elt D ix e ~ Array D (Lower ix) e) => Slice D ix e Source # 
Instance details

Defined in Data.Massiv.Array.Delayed.Internal

Methods

unsafeSlice :: Array D ix e -> ix -> ix -> Dim -> Maybe (Elt D ix e) Source #

(Index ix, Index (Lower ix), Elt M ix e ~ Array M (Lower ix) e) => Slice M ix e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Internal

Methods

unsafeSlice :: Array M ix e -> ix -> ix -> Dim -> Maybe (Elt M ix e) Source #

Slice M Ix1 e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Internal

Methods

unsafeSlice :: Array M Ix1 e -> Ix1 -> Ix1 -> Dim -> Maybe (Elt M Ix1 e) Source #

(Unbox e, Index ix, Index (Lower ix), Elt U ix e ~ Elt M ix e, Elt M ix e ~ Array M (Lower ix) e) => Slice U ix e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Unboxed

Methods

unsafeSlice :: Array U ix e -> ix -> ix -> Dim -> Maybe (Elt U ix e) Source #

Unbox e => Slice U Ix1 e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Unboxed

Methods

unsafeSlice :: Array U Ix1 e -> Ix1 -> Ix1 -> Dim -> Maybe (Elt U Ix1 e) Source #

(Prim e, Index ix, Index (Lower ix), Elt P ix e ~ Elt M ix e, Elt M ix e ~ Array M (Lower ix) e) => Slice P ix e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Primitive

Methods

unsafeSlice :: Array P ix e -> ix -> ix -> Dim -> Maybe (Elt P ix e) Source #

Prim e => Slice P Ix1 e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Primitive

Methods

unsafeSlice :: Array P Ix1 e -> Ix1 -> Ix1 -> Dim -> Maybe (Elt P Ix1 e) Source #

class Size r ix e => InnerSlice r ix e Source #

Minimal complete definition

unsafeInnerSlice

Instances
(Elt D ix e ~ Array D (Lower ix) e, Index ix) => InnerSlice D ix e Source # 
Instance details

Defined in Data.Massiv.Array.Delayed.Internal

Methods

unsafeInnerSlice :: Array D ix e -> (Lower ix, Int) -> Int -> Elt D ix e Source #

(Elt M ix e ~ Array M (Lower ix) e, Index ix, Index (Lower ix)) => InnerSlice M ix e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Internal

Methods

unsafeInnerSlice :: Array M ix e -> (Lower ix, Int) -> Int -> Elt M ix e Source #

InnerSlice M Ix1 e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Internal

Methods

unsafeInnerSlice :: Array M Ix1 e -> (Lower Ix1, Int) -> Int -> Elt M Ix1 e Source #

(Unbox e, Index ix, Index (Lower ix), Elt U ix e ~ Elt M ix e, Elt M ix e ~ Array M (Lower ix) e) => InnerSlice U ix e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Unboxed

Methods

unsafeInnerSlice :: Array U ix e -> (Lower ix, Int) -> Int -> Elt U ix e Source #

Unbox e => InnerSlice U Ix1 e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Unboxed

Methods

unsafeInnerSlice :: Array U Ix1 e -> (Lower Ix1, Int) -> Int -> Elt U Ix1 e Source #

(Storable e, Index ix, Index (Lower ix), Elt M ix e ~ Array M (Lower ix) e, Elt S ix e ~ Array M (Lower ix) e) => InnerSlice S ix e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Storable

Methods

unsafeInnerSlice :: Array S ix e -> (Lower ix, Int) -> Int -> Elt S ix e Source #

(Prim e, Index ix, Index (Lower ix), Elt M ix e ~ Array M (Lower ix) e, Elt P ix e ~ Array M (Lower ix) e) => InnerSlice P ix e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Primitive

Methods

unsafeInnerSlice :: Array P ix e -> (Lower ix, Int) -> Int -> Elt P ix e Source #

Prim e => InnerSlice P Ix1 e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Primitive

Methods

unsafeInnerSlice :: Array P Ix1 e -> (Lower Ix1, Int) -> Int -> Elt P Ix1 e Source #

(NFData e, Index ix, Index (Lower ix), Elt M ix e ~ Array M (Lower ix) e, Elt N ix e ~ Array M (Lower ix) e) => InnerSlice N ix e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Boxed

Methods

unsafeInnerSlice :: Array N ix e -> (Lower ix, Int) -> Int -> Elt N ix e Source #

(NFData e, Index ix, Index (Lower ix), Elt M ix e ~ Array M (Lower ix) e, Elt B ix e ~ Array M (Lower ix) e) => InnerSlice B ix e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Boxed

Methods

unsafeInnerSlice :: Array B ix e -> (Lower ix, Int) -> Int -> Elt B ix e Source #

class OuterSlice r ix e where Source #

Minimal complete definition

unsafeOuterSlice

Methods

outerLength :: Array r ix e -> Int Source #

outerLength :: Size r ix e => Array r ix e -> Int Source #

Instances
Ragged L ix e => OuterSlice L ix e Source # 
Instance details

Defined in Data.Massiv.Core.List

Methods

unsafeOuterSlice :: Array L ix e -> Int -> Elt L ix e Source #

outerLength :: Array L ix e -> Int Source #

OuterSlice L Ix1 e Source # 
Instance details

Defined in Data.Massiv.Core.List

(Elt D ix e ~ Array D (Lower ix) e, Index ix) => OuterSlice D ix e Source # 
Instance details

Defined in Data.Massiv.Array.Delayed.Internal

Methods

unsafeOuterSlice :: Array D ix e -> Int -> Elt D ix e Source #

outerLength :: Array D ix e -> Int Source #

(Elt M ix e ~ Array M (Lower ix) e, Index ix, Index (Lower ix)) => OuterSlice M ix e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Internal

Methods

unsafeOuterSlice :: Array M ix e -> Int -> Elt M ix e Source #

outerLength :: Array M ix e -> Int Source #

OuterSlice M Ix1 e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Internal

(Unbox e, Index ix, Index (Lower ix), Elt U ix e ~ Elt M ix e, Elt M ix e ~ Array M (Lower ix) e) => OuterSlice U ix e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Unboxed

Methods

unsafeOuterSlice :: Array U ix e -> Int -> Elt U ix e Source #

outerLength :: Array U ix e -> Int Source #

Unbox e => OuterSlice U Ix1 e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Unboxed

(Storable e, Index ix, Index (Lower ix), Elt M ix e ~ Array M (Lower ix) e, Elt S ix e ~ Array M (Lower ix) e) => OuterSlice S ix e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Storable

Methods

unsafeOuterSlice :: Array S ix e -> Int -> Elt S ix e Source #

outerLength :: Array S ix e -> Int Source #

(Prim e, Index ix, Index (Lower ix), Elt M ix e ~ Array M (Lower ix) e, Elt P ix e ~ Array M (Lower ix) e) => OuterSlice P ix e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Primitive

Methods

unsafeOuterSlice :: Array P ix e -> Int -> Elt P ix e Source #

outerLength :: Array P ix e -> Int Source #

Prim e => OuterSlice P Ix1 e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Primitive

(NFData e, Index ix, Index (Lower ix), Elt M ix e ~ Array M (Lower ix) e, Elt N ix e ~ Array M (Lower ix) e) => OuterSlice N ix e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Boxed

Methods

unsafeOuterSlice :: Array N ix e -> Int -> Elt N ix e Source #

outerLength :: Array N ix e -> Int Source #

(NFData e, Index ix, Index (Lower ix), Elt M ix e ~ Array M (Lower ix) e, Elt B ix e ~ Array M (Lower ix) e) => OuterSlice B ix e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Boxed

Methods

unsafeOuterSlice :: Array B ix e -> Int -> Elt B ix e Source #

outerLength :: Array B ix e -> Int Source #

class Size r ix e => Load r ix e where Source #

Any array that can be computed

Methods

loadS Source #

Arguments

:: Monad m 
=> Array r ix e

Array that is being loaded

-> (Int -> m e)

Function that reads an element from target array

-> (Int -> e -> m ())

Function that writes an element into target array

-> m () 

Load an array into memory sequentially

loadP Source #

Arguments

:: [Int]

List of capabilities to run workers on, as described in forkOn. Empty list will imply all capabilities, i.e. run on all cores available through +RTS -N.

-> Array r ix e

Array that is being loaded

-> (Int -> IO e)

Function that reads an element from target array

-> (Int -> e -> IO ())

Function that writes an element into target array

-> IO () 

Load an array into memory in parallel

loadArrayWithStride Source #

Arguments

:: Monad m 
=> Int

Total number of workers (for Seq it's always 1)

-> (m () -> m ())

A monadic action that will schedule work for the workers (for Seq it's always id)

-> Stride ix

Stride to use

-> ix

Size of the target array affected by the stride.

-> Array r ix e

Array that is being loaded

-> (Int -> m e)

Function that reads an element from target array

-> (Int -> e -> m ())

Function that writes an element into target array

-> m () 

Load an array into memory with stride. Default implementation can only handle the sequential case and only if there is an instance of Source.

loadArrayWithStride Source #

Arguments

:: (Source r ix e, Monad m) 
=> Int

Total number of workers (for Seq it's always 1)

-> (m () -> m ())

A monadic action that will schedule work for the workers (for Seq it's always id)

-> Stride ix

Stride to use

-> ix

Size of the target array affected by the stride.

-> Array r ix e

Array that is being loaded

-> (Int -> m e)

Function that reads an element from target array

-> (Int -> e -> m ())

Function that writes an element into target array

-> m () 

Load an array into memory with stride. Default implementation can only handle the sequential case and only if there is an instance of Source.

loadArray Source #

Arguments

:: Monad m 
=> Int

Total number of workers (for Seq it's always 1)

-> (m () -> m ())

A monadic action that will schedule work for the workers (for Seq it's always id)

-> Array r ix e

Array that is being loaded

-> (Int -> m e)

Function that reads an element from target array

-> (Int -> e -> m ())

Function that writes an element into target array

-> m () 

Load an array into memory. Default implementation will respect the scheduler and use Source instance to do loading in row-major fashion in parallel as well as sequentially.

loadArray Source #

Arguments

:: (Source r ix e, Monad m) 
=> Int

Total number of workers (for Seq it's always 1)

-> (m () -> m ())

A monadic action that will schedule work for the workers (for Seq it's always id)

-> Array r ix e

Array that is being loaded

-> (Int -> m e)

Function that reads an element from target array

-> (Int -> e -> m ())

Function that writes an element into target array

-> m () 

Load an array into memory. Default implementation will respect the scheduler and use Source instance to do loading in row-major fashion in parallel as well as sequentially.

Instances
Index ix => Load D ix e Source # 
Instance details

Defined in Data.Massiv.Array.Delayed.Internal

Methods

loadS :: Monad m => Array D ix e -> (Int -> m e) -> (Int -> e -> m ()) -> m () Source #

loadP :: [Int] -> Array D ix e -> (Int -> IO e) -> (Int -> e -> IO ()) -> IO () Source #

loadArrayWithStride :: Monad m => Int -> (m () -> m ()) -> Stride ix -> ix -> Array D ix e -> (Int -> m e) -> (Int -> e -> m ()) -> m () Source #

loadArray :: Monad m => Int -> (m () -> m ()) -> Array D ix e -> (Int -> m e) -> (Int -> e -> m ()) -> m () Source #

Index ix => Load M ix e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Internal

Methods

loadS :: Monad m => Array M ix e -> (Int -> m e) -> (Int -> e -> m ()) -> m () Source #

loadP :: [Int] -> Array M ix e -> (Int -> IO e) -> (Int -> e -> IO ()) -> IO () Source #

loadArrayWithStride :: Monad m => Int -> (m () -> m ()) -> Stride ix -> ix -> Array M ix e -> (Int -> m e) -> (Int -> e -> m ()) -> m () Source #

loadArray :: Monad m => Int -> (m () -> m ()) -> Array M ix e -> (Int -> m e) -> (Int -> e -> m ()) -> m () Source #

(Index ix, Load DW (Lower ix) e) => Load DW ix e Source # 
Instance details

Defined in Data.Massiv.Array.Delayed.Windowed

Methods

loadS :: Monad m => Array DW ix e -> (Int -> m e) -> (Int -> e -> m ()) -> m () Source #

loadP :: [Int] -> Array DW ix e -> (Int -> IO e) -> (Int -> e -> IO ()) -> IO () Source #

loadArrayWithStride :: Monad m => Int -> (m () -> m ()) -> Stride ix -> ix -> Array DW ix e -> (Int -> m e) -> (Int -> e -> m ()) -> m () Source #

loadArray :: Monad m => Int -> (m () -> m ()) -> Array DW ix e -> (Int -> m e) -> (Int -> e -> m ()) -> m () Source #

Load DW Ix2T e Source # 
Instance details

Defined in Data.Massiv.Array.Delayed.Windowed

Methods

loadS :: Monad m => Array DW Ix2T e -> (Int -> m e) -> (Int -> e -> m ()) -> m () Source #

loadP :: [Int] -> Array DW Ix2T e -> (Int -> IO e) -> (Int -> e -> IO ()) -> IO () Source #

loadArrayWithStride :: Monad m => Int -> (m () -> m ()) -> Stride Ix2T -> Ix2T -> Array DW Ix2T e -> (Int -> m e) -> (Int -> e -> m ()) -> m () Source #

loadArray :: Monad m => Int -> (m () -> m ()) -> Array DW Ix2T e -> (Int -> m e) -> (Int -> e -> m ()) -> m () Source #

Load DW Ix2 e Source # 
Instance details

Defined in Data.Massiv.Array.Delayed.Windowed

Methods

loadS :: Monad m => Array DW Ix2 e -> (Int -> m e) -> (Int -> e -> m ()) -> m () Source #

loadP :: [Int] -> Array DW Ix2 e -> (Int -> IO e) -> (Int -> e -> IO ()) -> IO () Source #

loadArrayWithStride :: Monad m => Int -> (m () -> m ()) -> Stride Ix2 -> Ix2 -> Array DW Ix2 e -> (Int -> m e) -> (Int -> e -> m ()) -> m () Source #

loadArray :: Monad m => Int -> (m () -> m ()) -> Array DW Ix2 e -> (Int -> m e) -> (Int -> e -> m ()) -> m () Source #

Load DW Ix1 e Source # 
Instance details

Defined in Data.Massiv.Array.Delayed.Windowed

Methods

loadS :: Monad m => Array DW Ix1 e -> (Int -> m e) -> (Int -> e -> m ()) -> m () Source #

loadP :: [Int] -> Array DW Ix1 e -> (Int -> IO e) -> (Int -> e -> IO ()) -> IO () Source #

loadArrayWithStride :: Monad m => Int -> (m () -> m ()) -> Stride Ix1 -> Ix1 -> Array DW Ix1 e -> (Int -> m e) -> (Int -> e -> m ()) -> m () Source #

loadArray :: Monad m => Int -> (m () -> m ()) -> Array DW Ix1 e -> (Int -> m e) -> (Int -> e -> m ()) -> m () Source #

Index ix => Load DI ix e Source # 
Instance details

Defined in Data.Massiv.Array.Delayed.Interleaved

Methods

loadS :: Monad m => Array DI ix e -> (Int -> m e) -> (Int -> e -> m ()) -> m () Source #

loadP :: [Int] -> Array DI ix e -> (Int -> IO e) -> (Int -> e -> IO ()) -> IO () Source #

loadArrayWithStride :: Monad m => Int -> (m () -> m ()) -> Stride ix -> ix -> Array DI ix e -> (Int -> m e) -> (Int -> e -> m ()) -> m () Source #

loadArray :: Monad m => Int -> (m () -> m ()) -> Array DI ix e -> (Int -> m e) -> (Int -> e -> m ()) -> m () Source #

class Size r ix e => Source r ix e Source #

Arrays that can be used as source to practically any manipulation function.

Instances
Index ix => Source D ix e Source # 
Instance details

Defined in Data.Massiv.Array.Delayed.Internal

Methods

unsafeIndex :: Array D ix e -> ix -> e Source #

unsafeLinearIndex :: Array D ix e -> Int -> e Source #

Index ix => Source M ix e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Internal

Methods

unsafeIndex :: Array M ix e -> ix -> e Source #

unsafeLinearIndex :: Array M ix e -> Int -> e Source #

(Unbox e, Index ix) => Source U ix e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Unboxed

Methods

unsafeIndex :: Array U ix e -> ix -> e Source #

unsafeLinearIndex :: Array U ix e -> Int -> e Source #

(Storable e, Index ix) => Source S ix e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Storable

Methods

unsafeIndex :: Array S ix e -> ix -> e Source #

unsafeLinearIndex :: Array S ix e -> Int -> e Source #

(Prim e, Index ix) => Source P ix e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Primitive

Methods

unsafeIndex :: Array P ix e -> ix -> e Source #

unsafeLinearIndex :: Array P ix e -> Int -> e Source #

(Index ix, NFData e) => Source N ix e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Boxed

Methods

unsafeIndex :: Array N ix e -> ix -> e Source #

unsafeLinearIndex :: Array N ix e -> Int -> e Source #

Index ix => Source B ix e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Boxed

Methods

unsafeIndex :: Array B ix e -> ix -> e Source #

unsafeLinearIndex :: Array B ix e -> Int -> e Source #

class Construct r ix e => Size r ix e Source #

An array that contains size information. They can be resized and new arrays extracted from it in constant time.

Minimal complete definition

size, unsafeResize, unsafeExtract

Instances
Index ix => Size D ix e Source # 
Instance details

Defined in Data.Massiv.Array.Delayed.Internal

Methods

size :: Array D ix e -> ix Source #

unsafeResize :: Index ix' => ix' -> Array D ix e -> Array D ix' e Source #

unsafeExtract :: ix -> ix -> Array D ix e -> Array (EltRepr D ix) ix e Source #

Index ix => Size M ix e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Internal

Methods

size :: Array M ix e -> ix Source #

unsafeResize :: Index ix' => ix' -> Array M ix e -> Array M ix' e Source #

unsafeExtract :: ix -> ix -> Array M ix e -> Array (EltRepr M ix) ix e Source #

(Unbox e, Index ix) => Size U ix e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Unboxed

Methods

size :: Array U ix e -> ix Source #

unsafeResize :: Index ix' => ix' -> Array U ix e -> Array U ix' e Source #

unsafeExtract :: ix -> ix -> Array U ix e -> Array (EltRepr U ix) ix e Source #

(Storable e, Index ix) => Size S ix e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Storable

Methods

size :: Array S ix e -> ix Source #

unsafeResize :: Index ix' => ix' -> Array S ix e -> Array S ix' e Source #

unsafeExtract :: ix -> ix -> Array S ix e -> Array (EltRepr S ix) ix e Source #

(Prim e, Index ix) => Size P ix e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Primitive

Methods

size :: Array P ix e -> ix Source #

unsafeResize :: Index ix' => ix' -> Array P ix e -> Array P ix' e Source #

unsafeExtract :: ix -> ix -> Array P ix e -> Array (EltRepr P ix) ix e Source #

(Index ix, NFData e) => Size N ix e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Boxed

Methods

size :: Array N ix e -> ix Source #

unsafeResize :: Index ix' => ix' -> Array N ix e -> Array N ix' e Source #

unsafeExtract :: ix -> ix -> Array N ix e -> Array (EltRepr N ix) ix e Source #

Index ix => Size B ix e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Boxed

Methods

size :: Array B ix e -> ix Source #

unsafeResize :: Index ix' => ix' -> Array B ix e -> Array B ix' e Source #

unsafeExtract :: ix -> ix -> Array B ix e -> Array (EltRepr B ix) ix e Source #

Index ix => Size DW ix e Source #

Any resize or extract on Windowed Array will loose the interior window and all other optimizations, thus hurting the performance a lot.

Instance details

Defined in Data.Massiv.Array.Delayed.Windowed

Methods

size :: Array DW ix e -> ix Source #

unsafeResize :: Index ix' => ix' -> Array DW ix e -> Array DW ix' e Source #

unsafeExtract :: ix -> ix -> Array DW ix e -> Array (EltRepr DW ix) ix e Source #

Index ix => Size DI ix e Source # 
Instance details

Defined in Data.Massiv.Array.Delayed.Interleaved

Methods

size :: Array DI ix e -> ix Source #

unsafeResize :: Index ix' => ix' -> Array DI ix e -> Array DI ix' e Source #

unsafeExtract :: ix -> ix -> Array DI ix e -> Array (EltRepr DI ix) ix e Source #

class (Typeable r, Index ix) => Construct r ix e Source #

Array types that can be constructed.

Minimal complete definition

getComp, setComp, unsafeMakeArray

Instances
(Index ix, Ragged L ix e, Ragged L (Lower ix) e, Elt L ix e ~ Array L (Lower ix) e) => Construct L ix e Source # 
Instance details

Defined in Data.Massiv.Core.List

Methods

getComp :: Array L ix e -> Comp Source #

setComp :: Comp -> Array L ix e -> Array L ix e Source #

unsafeMakeArray :: Comp -> ix -> (ix -> e) -> Array L ix e Source #

Construct L Ix1 e Source # 
Instance details

Defined in Data.Massiv.Core.List

Methods

getComp :: Array L Ix1 e -> Comp Source #

setComp :: Comp -> Array L Ix1 e -> Array L Ix1 e Source #

unsafeMakeArray :: Comp -> Ix1 -> (Ix1 -> e) -> Array L Ix1 e Source #

Index ix => Construct D ix e Source # 
Instance details

Defined in Data.Massiv.Array.Delayed.Internal

Methods

getComp :: Array D ix e -> Comp Source #

setComp :: Comp -> Array D ix e -> Array D ix e Source #

unsafeMakeArray :: Comp -> ix -> (ix -> e) -> Array D ix e Source #

Index ix => Construct M ix e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Internal

Methods

getComp :: Array M ix e -> Comp Source #

setComp :: Comp -> Array M ix e -> Array M ix e Source #

unsafeMakeArray :: Comp -> ix -> (ix -> e) -> Array M ix e Source #

(Unbox e, Index ix) => Construct U ix e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Unboxed

Methods

getComp :: Array U ix e -> Comp Source #

setComp :: Comp -> Array U ix e -> Array U ix e Source #

unsafeMakeArray :: Comp -> ix -> (ix -> e) -> Array U ix e Source #

(Storable e, Index ix) => Construct S ix e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Storable

Methods

getComp :: Array S ix e -> Comp Source #

setComp :: Comp -> Array S ix e -> Array S ix e Source #

unsafeMakeArray :: Comp -> ix -> (ix -> e) -> Array S ix e Source #

(Prim e, Index ix) => Construct P ix e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Primitive

Methods

getComp :: Array P ix e -> Comp Source #

setComp :: Comp -> Array P ix e -> Array P ix e Source #

unsafeMakeArray :: Comp -> ix -> (ix -> e) -> Array P ix e Source #

(Index ix, NFData e) => Construct N ix e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Boxed

Methods

getComp :: Array N ix e -> Comp Source #

setComp :: Comp -> Array N ix e -> Array N ix e Source #

unsafeMakeArray :: Comp -> ix -> (ix -> e) -> Array N ix e Source #

Index ix => Construct B ix e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Boxed

Methods

getComp :: Array B ix e -> Comp Source #

setComp :: Comp -> Array B ix e -> Array B ix e Source #

unsafeMakeArray :: Comp -> ix -> (ix -> e) -> Array B ix e Source #

Index ix => Construct DW ix e Source # 
Instance details

Defined in Data.Massiv.Array.Delayed.Windowed

Methods

getComp :: Array DW ix e -> Comp Source #

setComp :: Comp -> Array DW ix e -> Array DW ix e Source #

unsafeMakeArray :: Comp -> ix -> (ix -> e) -> Array DW ix e Source #

Index ix => Construct DI ix e Source # 
Instance details

Defined in Data.Massiv.Array.Delayed.Interleaved

Methods

getComp :: Array DI ix e -> Comp Source #

setComp :: Comp -> Array DI ix e -> Array DI ix e Source #

unsafeMakeArray :: Comp -> ix -> (ix -> e) -> Array DI ix e Source #

type family NestedStruct r ix e :: * Source #

Instances
type NestedStruct L ix e Source # 
Instance details

Defined in Data.Massiv.Core.List

type NestedStruct L ix e = Array LN ix e
type NestedStruct LN ix e Source # 
Instance details

Defined in Data.Massiv.Core.List

type NestedStruct LN ix e = [ListItem ix e]

type family Elt r ix e :: * where ... Source #

Equations

Elt r Ix1 e = e 
Elt r ix e = Array (EltRepr r ix) (Lower ix) e 

type family EltRepr r ix :: * Source #

Instances
type EltRepr L ix Source # 
Instance details

Defined in Data.Massiv.Core.List

type EltRepr L ix = L
type EltRepr LN ix Source # 
Instance details

Defined in Data.Massiv.Core.List

type EltRepr LN ix = LN
type EltRepr D ix Source # 
Instance details

Defined in Data.Massiv.Array.Delayed.Internal

type EltRepr D ix = D
type EltRepr M ix Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Internal

type EltRepr M ix = M
type EltRepr U ix Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Unboxed

type EltRepr U ix = M
type EltRepr S ix Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Storable

type EltRepr S ix = M
type EltRepr P ix Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Primitive

type EltRepr P ix = M
type EltRepr N ix Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Boxed

type EltRepr N ix = M
type EltRepr B ix Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Boxed

type EltRepr B ix = M
type EltRepr DW ix Source # 
Instance details

Defined in Data.Massiv.Array.Delayed.Windowed

type EltRepr DW ix = D
type EltRepr DI ix Source # 
Instance details

Defined in Data.Massiv.Array.Delayed.Interleaved

type EltRepr DI ix = DI

data family Array r ix e :: * Source #

The array family. Representations r describes how data is arranged or computed. All arrays have a common property that each index ix always maps to the same unique element, even if that element does not exist in memory and has to be computed upon lookup. Data is always arranged in a nested fasion, depth of which is controlled by Rank ix.

Instances
Functor (Array D ix) # 
Instance details

Defined in Data.Massiv.Array.Delayed.Internal

Methods

fmap :: (a -> b) -> Array D ix a -> Array D ix b #

(<$) :: a -> Array D ix b -> Array D ix a #

Functor (Array DW ix) # 
Instance details

Defined in Data.Massiv.Array.Delayed.Windowed

Methods

fmap :: (a -> b) -> Array DW ix a -> Array DW ix b #

(<$) :: a -> Array DW ix b -> Array DW ix a #

Functor (Array DI ix) # 
Instance details

Defined in Data.Massiv.Array.Delayed.Interleaved

Methods

fmap :: (a -> b) -> Array DI ix a -> Array DI ix b #

(<$) :: a -> Array DI ix b -> Array DI ix a #

Index ix => Applicative (Array D ix) # 
Instance details

Defined in Data.Massiv.Array.Delayed.Internal

Methods

pure :: a -> Array D ix a #

(<*>) :: Array D ix (a -> b) -> Array D ix a -> Array D ix b #

liftA2 :: (a -> b -> c) -> Array D ix a -> Array D ix b -> Array D ix c #

(*>) :: Array D ix a -> Array D ix b -> Array D ix b #

(<*) :: Array D ix a -> Array D ix b -> Array D ix a #

Index ix => Foldable (Array D ix) #

Row-major sequential folding over a Delayed array.

Instance details

Defined in Data.Massiv.Array.Delayed.Internal

Methods

fold :: Monoid m => Array D ix m -> m #

foldMap :: Monoid m => (a -> m) -> Array D ix a -> m #

foldr :: (a -> b -> b) -> b -> Array D ix a -> b #

foldr' :: (a -> b -> b) -> b -> Array D ix a -> b #

foldl :: (b -> a -> b) -> b -> Array D ix a -> b #

foldl' :: (b -> a -> b) -> b -> Array D ix a -> b #

foldr1 :: (a -> a -> a) -> Array D ix a -> a #

foldl1 :: (a -> a -> a) -> Array D ix a -> a #

toList :: Array D ix a -> [a] #

null :: Array D ix a -> Bool #

length :: Array D ix a -> Int #

elem :: Eq a => a -> Array D ix a -> Bool #

maximum :: Ord a => Array D ix a -> a #

minimum :: Ord a => Array D ix a -> a #

sum :: Num a => Array D ix a -> a #

product :: Num a => Array D ix a -> a #

Index ix => Foldable (Array M ix) #

Row-major sequential folding over a Manifest array.

Instance details

Defined in Data.Massiv.Array.Manifest.Internal

Methods

fold :: Monoid m => Array M ix m -> m #

foldMap :: Monoid m => (a -> m) -> Array M ix a -> m #

foldr :: (a -> b -> b) -> b -> Array M ix a -> b #

foldr' :: (a -> b -> b) -> b -> Array M ix a -> b #

foldl :: (b -> a -> b) -> b -> Array M ix a -> b #

foldl' :: (b -> a -> b) -> b -> Array M ix a -> b #

foldr1 :: (a -> a -> a) -> Array M ix a -> a #

foldl1 :: (a -> a -> a) -> Array M ix a -> a #

toList :: Array M ix a -> [a] #

null :: Array M ix a -> Bool #

length :: Array M ix a -> Int #

elem :: Eq a => a -> Array M ix a -> Bool #

maximum :: Ord a => Array M ix a -> a #

minimum :: Ord a => Array M ix a -> a #

sum :: Num a => Array M ix a -> a #

product :: Num a => Array M ix a -> a #

Index ix => Foldable (Array B ix) #

Row-major sequential folding over a Boxed array.

Instance details

Defined in Data.Massiv.Array.Manifest.Boxed

Methods

fold :: Monoid m => Array B ix m -> m #

foldMap :: Monoid m => (a -> m) -> Array B ix a -> m #

foldr :: (a -> b -> b) -> b -> Array B ix a -> b #

foldr' :: (a -> b -> b) -> b -> Array B ix a -> b #

foldl :: (b -> a -> b) -> b -> Array B ix a -> b #

foldl' :: (b -> a -> b) -> b -> Array B ix a -> b #

foldr1 :: (a -> a -> a) -> Array B ix a -> a #

foldl1 :: (a -> a -> a) -> Array B ix a -> a #

toList :: Array B ix a -> [a] #

null :: Array B ix a -> Bool #

length :: Array B ix a -> Int #

elem :: Eq a => a -> Array B ix a -> Bool #

maximum :: Ord a => Array B ix a -> a #

minimum :: Ord a => Array B ix a -> a #

sum :: Num a => Array B ix a -> a #

product :: Num a => Array B ix a -> a #

Nested LN ix e => IsList (Array L ix e) # 
Instance details

Defined in Data.Massiv.Core.List

Associated Types

type Item (Array L ix e) :: * #

Methods

fromList :: [Item (Array L ix e)] -> Array L ix e #

fromListN :: Int -> [Item (Array L ix e)] -> Array L ix e #

toList :: Array L ix e -> [Item (Array L ix e)] #

Nested LN ix e => IsList (Array LN ix e) # 
Instance details

Defined in Data.Massiv.Core.List

Associated Types

type Item (Array LN ix e) :: * #

Methods

fromList :: [Item (Array LN ix e)] -> Array LN ix e #

fromListN :: Int -> [Item (Array LN ix e)] -> Array LN ix e #

toList :: Array LN ix e -> [Item (Array LN ix e)] #

(Unbox e, IsList (Array L ix e), Nested LN ix e, Nested L ix e, Ragged L ix e) => IsList (Array U ix e) # 
Instance details

Defined in Data.Massiv.Array.Manifest.Unboxed

Associated Types

type Item (Array U ix e) :: * #

Methods

fromList :: [Item (Array U ix e)] -> Array U ix e #

fromListN :: Int -> [Item (Array U ix e)] -> Array U ix e #

toList :: Array U ix e -> [Item (Array U ix e)] #

(Storable e, IsList (Array L ix e), Nested LN ix e, Nested L ix e, Ragged L ix e) => IsList (Array S ix e) # 
Instance details

Defined in Data.Massiv.Array.Manifest.Storable

Associated Types

type Item (Array S ix e) :: * #

Methods

fromList :: [Item (Array S ix e)] -> Array S ix e #

fromListN :: Int -> [Item (Array S ix e)] -> Array S ix e #

toList :: Array S ix e -> [Item (Array S ix e)] #

(Prim e, IsList (Array L ix e), Nested LN ix e, Nested L ix e, Ragged L ix e) => IsList (Array P ix e) # 
Instance details

Defined in Data.Massiv.Array.Manifest.Primitive

Associated Types

type Item (Array P ix e) :: * #

Methods

fromList :: [Item (Array P ix e)] -> Array P ix e #

fromListN :: Int -> [Item (Array P ix e)] -> Array P ix e #

toList :: Array P ix e -> [Item (Array P ix e)] #

(NFData e, IsList (Array L ix e), Nested LN ix e, Nested L ix e, Ragged L ix e) => IsList (Array N ix e) # 
Instance details

Defined in Data.Massiv.Array.Manifest.Boxed

Associated Types

type Item (Array N ix e) :: * #

Methods

fromList :: [Item (Array N ix e)] -> Array N ix e #

fromListN :: Int -> [Item (Array N ix e)] -> Array N ix e #

toList :: Array N ix e -> [Item (Array N ix e)] #

(IsList (Array L ix e), Nested LN ix e, Nested L ix e, Ragged L ix e) => IsList (Array B ix e) # 
Instance details

Defined in Data.Massiv.Array.Manifest.Boxed

Associated Types

type Item (Array B ix e) :: * #

Methods

fromList :: [Item (Array B ix e)] -> Array B ix e #

fromListN :: Int -> [Item (Array B ix e)] -> Array B ix e #

toList :: Array B ix e -> [Item (Array B ix e)] #

(Eq e, Index ix) => Eq (Array D ix e) # 
Instance details

Defined in Data.Massiv.Array.Delayed.Internal

Methods

(==) :: Array D ix e -> Array D ix e -> Bool #

(/=) :: Array D ix e -> Array D ix e -> Bool #

(Eq e, Index ix) => Eq (Array M ix e) # 
Instance details

Defined in Data.Massiv.Array.Manifest.Internal

Methods

(==) :: Array M ix e -> Array M ix e -> Bool #

(/=) :: Array M ix e -> Array M ix e -> Bool #

(Unbox e, Eq e, Index ix) => Eq (Array U ix e) # 
Instance details

Defined in Data.Massiv.Array.Manifest.Unboxed

Methods

(==) :: Array U ix e -> Array U ix e -> Bool #

(/=) :: Array U ix e -> Array U ix e -> Bool #

(Storable e, Eq e, Index ix) => Eq (Array S ix e) # 
Instance details

Defined in Data.Massiv.Array.Manifest.Storable

Methods

(==) :: Array S ix e -> Array S ix e -> Bool #

(/=) :: Array S ix e -> Array S ix e -> Bool #

(Prim e, Eq e, Index ix) => Eq (Array P ix e) # 
Instance details

Defined in Data.Massiv.Array.Manifest.Primitive

Methods

(==) :: Array P ix e -> Array P ix e -> Bool #

(/=) :: Array P ix e -> Array P ix e -> Bool #

(Index ix, NFData e, Eq e) => Eq (Array N ix e) # 
Instance details

Defined in Data.Massiv.Array.Manifest.Boxed

Methods

(==) :: Array N ix e -> Array N ix e -> Bool #

(/=) :: Array N ix e -> Array N ix e -> Bool #

(Index ix, Eq e) => Eq (Array B ix e) # 
Instance details

Defined in Data.Massiv.Array.Manifest.Boxed

Methods

(==) :: Array B ix e -> Array B ix e -> Bool #

(/=) :: Array B ix e -> Array B ix e -> Bool #

(Index ix, Floating e) => Floating (Array D ix e) # 
Instance details

Defined in Data.Massiv.Array.Delayed.Internal

Methods

pi :: Array D ix e #

exp :: Array D ix e -> Array D ix e #

log :: Array D ix e -> Array D ix e #

sqrt :: Array D ix e -> Array D ix e #

(**) :: Array D ix e -> Array D ix e -> Array D ix e #

logBase :: Array D ix e -> Array D ix e -> Array D ix e #

sin :: Array D ix e -> Array D ix e #

cos :: Array D ix e -> Array D ix e #

tan :: Array D ix e -> Array D ix e #

asin :: Array D ix e -> Array D ix e #

acos :: Array D ix e -> Array D ix e #

atan :: Array D ix e -> Array D ix e #

sinh :: Array D ix e -> Array D ix e #

cosh :: Array D ix e -> Array D ix e #

tanh :: Array D ix e -> Array D ix e #

asinh :: Array D ix e -> Array D ix e #

acosh :: Array D ix e -> Array D ix e #

atanh :: Array D ix e -> Array D ix e #

log1p :: Array D ix e -> Array D ix e #

expm1 :: Array D ix e -> Array D ix e #

log1pexp :: Array D ix e -> Array D ix e #

log1mexp :: Array D ix e -> Array D ix e #

(Index ix, Fractional e) => Fractional (Array D ix e) # 
Instance details

Defined in Data.Massiv.Array.Delayed.Internal

Methods

(/) :: Array D ix e -> Array D ix e -> Array D ix e #

recip :: Array D ix e -> Array D ix e #

fromRational :: Rational -> Array D ix e #

(Index ix, Num e) => Num (Array D ix e) # 
Instance details

Defined in Data.Massiv.Array.Delayed.Internal

Methods

(+) :: Array D ix e -> Array D ix e -> Array D ix e #

(-) :: Array D ix e -> Array D ix e -> Array D ix e #

(*) :: Array D ix e -> Array D ix e -> Array D ix e #

negate :: Array D ix e -> Array D ix e #

abs :: Array D ix e -> Array D ix e #

signum :: Array D ix e -> Array D ix e #

fromInteger :: Integer -> Array D ix e #

(Ord e, Index ix) => Ord (Array D ix e) # 
Instance details

Defined in Data.Massiv.Array.Delayed.Internal

Methods

compare :: Array D ix e -> Array D ix e -> Ordering #

(<) :: Array D ix e -> Array D ix e -> Bool #

(<=) :: Array D ix e -> Array D ix e -> Bool #

(>) :: Array D ix e -> Array D ix e -> Bool #

(>=) :: Array D ix e -> Array D ix e -> Bool #

max :: Array D ix e -> Array D ix e -> Array D ix e #

min :: Array D ix e -> Array D ix e -> Array D ix e #

(Ord e, Index ix) => Ord (Array M ix e) # 
Instance details

Defined in Data.Massiv.Array.Manifest.Internal

Methods

compare :: Array M ix e -> Array M ix e -> Ordering #

(<) :: Array M ix e -> Array M ix e -> Bool #

(<=) :: Array M ix e -> Array M ix e -> Bool #

(>) :: Array M ix e -> Array M ix e -> Bool #

(>=) :: Array M ix e -> Array M ix e -> Bool #

max :: Array M ix e -> Array M ix e -> Array M ix e #

min :: Array M ix e -> Array M ix e -> Array M ix e #

(Unbox e, Ord e, Index ix) => Ord (Array U ix e) # 
Instance details

Defined in Data.Massiv.Array.Manifest.Unboxed

Methods

compare :: Array U ix e -> Array U ix e -> Ordering #

(<) :: Array U ix e -> Array U ix e -> Bool #

(<=) :: Array U ix e -> Array U ix e -> Bool #

(>) :: Array U ix e -> Array U ix e -> Bool #

(>=) :: Array U ix e -> Array U ix e -> Bool #

max :: Array U ix e -> Array U ix e -> Array U ix e #

min :: Array U ix e -> Array U ix e -> Array U ix e #

(Storable e, Ord e, Index ix) => Ord (Array S ix e) # 
Instance details

Defined in Data.Massiv.Array.Manifest.Storable

Methods

compare :: Array S ix e -> Array S ix e -> Ordering #

(<) :: Array S ix e -> Array S ix e -> Bool #

(<=) :: Array S ix e -> Array S ix e -> Bool #

(>) :: Array S ix e -> Array S ix e -> Bool #

(>=) :: Array S ix e -> Array S ix e -> Bool #

max :: Array S ix e -> Array S ix e -> Array S ix e #

min :: Array S ix e -> Array S ix e -> Array S ix e #

(Prim e, Ord e, Index ix) => Ord (Array P ix e) # 
Instance details

Defined in Data.Massiv.Array.Manifest.Primitive

Methods

compare :: Array P ix e -> Array P ix e -> Ordering #

(<) :: Array P ix e -> Array P ix e -> Bool #

(<=) :: Array P ix e -> Array P ix e -> Bool #

(>) :: Array P ix e -> Array P ix e -> Bool #

(>=) :: Array P ix e -> Array P ix e -> Bool #

max :: Array P ix e -> Array P ix e -> Array P ix e #

min :: Array P ix e -> Array P ix e -> Array P ix e #

(Index ix, NFData e, Ord e) => Ord (Array N ix e) # 
Instance details

Defined in Data.Massiv.Array.Manifest.Boxed

Methods

compare :: Array N ix e -> Array N ix e -> Ordering #

(<) :: Array N ix e -> Array N ix e -> Bool #

(<=) :: Array N ix e -> Array N ix e -> Bool #

(>) :: Array N ix e -> Array N ix e -> Bool #

(>=) :: Array N ix e -> Array N ix e -> Bool #

max :: Array N ix e -> Array N ix e -> Array N ix e #

min :: Array N ix e -> Array N ix e -> Array N ix e #

(Index ix, Ord e) => Ord (Array B ix e) # 
Instance details

Defined in Data.Massiv.Array.Manifest.Boxed

Methods

compare :: Array B ix e -> Array B ix e -> Ordering #

(<) :: Array B ix e -> Array B ix e -> Bool #

(<=) :: Array B ix e -> Array B ix e -> Bool #

(>) :: Array B ix e -> Array B ix e -> Bool #

(>=) :: Array B ix e -> Array B ix e -> Bool #

max :: Array B ix e -> Array B ix e -> Array B ix e #

min :: Array B ix e -> Array B ix e -> Array B ix e #

(Ragged L ix e, Source r ix e, Show e) => Show (Array r ix e) # 
Instance details

Defined in Data.Massiv.Core.List

Methods

showsPrec :: Int -> Array r ix e -> ShowS #

show :: Array r ix e -> String #

showList :: [Array r ix e] -> ShowS #

(Ragged L ix e, Show e) => Show (Array L ix e) # 
Instance details

Defined in Data.Massiv.Core.List

Methods

showsPrec :: Int -> Array L ix e -> ShowS #

show :: Array L ix e -> String #

showList :: [Array L ix e] -> ShowS #

(Ragged L ix e, Show e) => Show (Array LN ix e) # 
Instance details

Defined in Data.Massiv.Core.List

Methods

showsPrec :: Int -> Array LN ix e -> ShowS #

show :: Array LN ix e -> String #

showList :: [Array LN ix e] -> ShowS #

(Show e, Ragged L ix e, Load DW ix e) => Show (Array DW ix e) # 
Instance details

Defined in Data.Massiv.Array.Delayed.Windowed

Methods

showsPrec :: Int -> Array DW ix e -> ShowS #

show :: Array DW ix e -> String #

showList :: [Array DW ix e] -> ShowS #

(Index ix, NFData e) => NFData (Array U ix e) # 
Instance details

Defined in Data.Massiv.Array.Manifest.Unboxed

Methods

rnf :: Array U ix e -> () #

Index ix => NFData (Array S ix e) # 
Instance details

Defined in Data.Massiv.Array.Manifest.Storable

Methods

rnf :: Array S ix e -> () #

Index ix => NFData (Array P ix e) # 
Instance details

Defined in Data.Massiv.Array.Manifest.Primitive

Methods

rnf :: Array P ix e -> () #

(Index ix, NFData e) => NFData (Array N ix e) # 
Instance details

Defined in Data.Massiv.Array.Manifest.Boxed

Methods

rnf :: Array N ix e -> () #

(Index ix, NFData e) => NFData (Array B ix e) # 
Instance details

Defined in Data.Massiv.Array.Manifest.Boxed

Methods

rnf :: Array B ix e -> () #

data Array L ix e Source # 
Instance details

Defined in Data.Massiv.Core.List

data Array L ix e = LArray {}
data Array LN ix e Source # 
Instance details

Defined in Data.Massiv.Core.List

data Array LN ix e = List {}
data Array D ix e Source # 
Instance details

Defined in Data.Massiv.Array.Delayed.Internal

data Array D ix e = DArray {}
data Array M ix e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Internal

data Array M ix e = MArray {}
data Array U ix e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Unboxed

data Array U ix e = UArray {}
data Array S ix e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Storable

data Array S ix e = SArray {}
data Array P ix e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Primitive

data Array P ix e = PArray {}
data Array N ix e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Boxed

data Array N ix e = NArray {}
data Array B ix e Source # 
Instance details

Defined in Data.Massiv.Array.Manifest.Boxed

data Array B ix e = BArray {}
data Array DW ix e Source # 
Instance details

Defined in Data.Massiv.Array.Delayed.Windowed

data Array DW ix e = DWArray {}
data Array DI ix e Source # 
Instance details

Defined in Data.Massiv.Array.Delayed.Interleaved

data Array DI ix e = DIArray {}
type Item (Array L ix e) # 
Instance details

Defined in Data.Massiv.Core.List

type Item (Array L ix e) = ListItem ix e
type Item (Array LN ix e) # 
Instance details

Defined in Data.Massiv.Core.List

type Item (Array LN ix e) = ListItem ix e
type Item (Array U ix e) # 
Instance details

Defined in Data.Massiv.Array.Manifest.Unboxed

type Item (Array U ix e) = Item (Array L ix e)
type Item (Array S ix e) # 
Instance details

Defined in Data.Massiv.Array.Manifest.Storable

type Item (Array S ix e) = Item (Array L ix e)
type Item (Array P ix e) # 
Instance details

Defined in Data.Massiv.Array.Manifest.Primitive

type Item (Array P ix e) = Item (Array L ix e)
type Item (Array N ix e) # 
Instance details

Defined in Data.Massiv.Array.Manifest.Boxed

type Item (Array N ix e) = Item (Array L ix e)
type Item (Array B ix e) # 
Instance details

Defined in Data.Massiv.Array.Manifest.Boxed

type Item (Array B ix e) = Item (Array L ix e)

data L Source #

Constructors

L 
Instances
(Index ix, Index (Lower ix), Ragged L (Lower ix) e, Elt L ix e ~ Array L (Lower ix) e, Elt LN ix e ~ Array LN (Lower ix) e, Coercible (Elt LN ix e) [Elt LN (Lower ix) e]) => Ragged L ix e Source # 
Instance details

Defined in Data.Massiv.Core.List

Methods

empty :: Comp -> Array L ix e Source #

isNull :: Array L ix e -> Bool Source #

cons :: Elt L ix e -> Array L ix e -> Array L ix e Source #

uncons :: Array L ix e -> Maybe (Elt L ix e, Array L ix e) Source #

unsafeGenerateM :: Monad m => Comp -> ix -> (ix -> m e) -> m (Array L ix e) Source #

edgeSize :: Array L ix e -> ix Source #

flatten :: Array L ix e -> Array L Ix1 e Source #

loadRagged :: (IO () -> IO ()) -> (Int -> e -> IO a) -> Int -> Int -> Lower ix -> Array L ix e -> IO () Source #

raggedFormat :: (e -> String) -> String -> Array L ix e -> String Source #

Ragged L Ix1 e Source # 
Instance details

Defined in Data.Massiv.Core.List

Methods

empty :: Comp -> Array L Ix1 e Source #

isNull :: Array L Ix1 e -> Bool Source #

cons :: Elt L Ix1 e -> Array L Ix1 e -> Array L Ix1 e Source #

uncons :: Array L Ix1 e -> Maybe (Elt L Ix1 e, Array L Ix1 e) Source #

unsafeGenerateM :: Monad m => Comp -> Ix1 -> (Ix1 -> m e) -> m (Array L Ix1 e) Source #

edgeSize :: Array L Ix1 e -> Ix1 Source #

flatten :: Array L Ix1 e -> Array L Ix1 e Source #

loadRagged :: (IO () -> IO ()) -> (Int -> e -> IO a) -> Int -> Int -> Lower Ix1 -> Array L Ix1 e -> IO () Source #

raggedFormat :: (e -> String) -> String -> Array L Ix1 e -> String Source #

Nested L ix e Source # 
Instance details

Defined in Data.Massiv.Core.List

Methods

fromNested :: NestedStruct L ix e -> Array L ix e Source #

toNested :: Array L ix e -> NestedStruct L ix e Source #

Ragged L ix e => OuterSlice L ix e Source # 
Instance details

Defined in Data.Massiv.Core.List

Methods

unsafeOuterSlice :: Array L ix e -> Int -> Elt L ix e Source #

outerLength :: Array L ix e -> Int Source #

OuterSlice L Ix1 e Source # 
Instance details

Defined in Data.Massiv.Core.List

(Index ix, Ragged L ix e, Ragged L (Lower ix) e, Elt L ix e ~ Array L (Lower ix) e) => Construct L ix e Source # 
Instance details

Defined in Data.Massiv.Core.List

Methods

getComp :: Array L ix e -> Comp Source #

setComp :: Comp -> Array L ix e -> Array L ix e Source #

unsafeMakeArray :: Comp -> ix -> (ix -> e) -> Array L ix e Source #

Construct L Ix1 e Source # 
Instance details

Defined in Data.Massiv.Core.List

Methods

getComp :: Array L Ix1 e -> Comp Source #

setComp :: Comp -> Array L Ix1 e -> Array L Ix1 e Source #

unsafeMakeArray :: Comp -> Ix1 -> (Ix1 -> e) -> Array L Ix1 e Source #

Nested LN ix e => IsList (Array L ix e) Source # 
Instance details

Defined in Data.Massiv.Core.List

Associated Types

type Item (Array L ix e) :: * #

Methods

fromList :: [Item (Array L ix e)] -> Array L ix e #

fromListN :: Int -> [Item (Array L ix e)] -> Array L ix e #

toList :: Array L ix e -> [Item (Array L ix e)] #

(Ragged L ix e, Show e) => Show (Array L ix e) Source # 
Instance details

Defined in Data.Massiv.Core.List

Methods

showsPrec :: Int -> Array L ix e -> ShowS #

show :: Array L ix e -> String #

showList :: [Array L ix e] -> ShowS #

data Array L ix e Source # 
Instance details

Defined in Data.Massiv.Core.List

data Array L ix e = LArray {}
type EltRepr L ix Source # 
Instance details

Defined in Data.Massiv.Core.List

type EltRepr L ix = L
type NestedStruct L ix e Source # 
Instance details

Defined in Data.Massiv.Core.List

type NestedStruct L ix e = Array LN ix e
type Item (Array L ix e) Source # 
Instance details

Defined in Data.Massiv.Core.List

type Item (Array L ix e) = ListItem ix e

type family ListItem ix e :: * where ... Source #

Equations

ListItem Ix1 e = e 
ListItem ix e = [ListItem (Lower ix) e] 

data LN Source #

Instances
(Elt LN ix e ~ Array LN (Lower ix) e, ListItem ix e ~ [ListItem (Lower ix) e], Coercible (Elt LN ix e) (ListItem ix e)) => Nested LN ix e Source # 
Instance details

Defined in Data.Massiv.Core.List

Methods

fromNested :: NestedStruct LN ix e -> Array LN ix e Source #

toNested :: Array LN ix e -> NestedStruct LN ix e Source #

Nested LN Ix1 e Source # 
Instance details

Defined in Data.Massiv.Core.List

Nested LN ix e => IsList (Array LN ix e) Source # 
Instance details

Defined in Data.Massiv.Core.List

Associated Types

type Item (Array LN ix e) :: * #

Methods

fromList :: [Item (Array LN ix e)] -> Array LN ix e #

fromListN :: Int -> [Item (Array LN ix e)] -> Array LN ix e #

toList :: Array LN ix e -> [Item (Array LN ix e)] #

(Ragged L ix e, Show e) => Show (Array LN ix e) Source # 
Instance details

Defined in Data.Massiv.Core.List

Methods

showsPrec :: Int -> Array LN ix e -> ShowS #

show :: Array LN ix e -> String #

showList :: [Array LN ix e] -> ShowS #

data Array LN ix e Source # 
Instance details

Defined in Data.Massiv.Core.List

data Array LN ix e = List {}
type EltRepr LN ix Source # 
Instance details

Defined in Data.Massiv.Core.List

type EltRepr LN ix = LN
type NestedStruct LN ix e Source # 
Instance details

Defined in Data.Massiv.Core.List

type NestedStruct LN ix e = [ListItem ix e]
type Item (Array LN ix e) Source # 
Instance details

Defined in Data.Massiv.Core.List

type Item (Array LN ix e) = ListItem ix e

Representations

Stencil