arrayfire-0.2.0.0: Haskell bindings to the ArrayFire general-purpose GPU library

CopyrightDavid Johnson (c) 2019-2020
LicenseBSD 3
MaintainerDavid Johnson <djohnson.m@gmail.com>
StabilityExperimental
PortabilityGHC
Safe HaskellNone
LanguageHaskell2010

ArrayFire.Data

Description

 
Synopsis

Documentation

constant Source #

Arguments

:: AFType a 
=> [Int]

Dimensions

-> a

Scalar value

-> Array a 

Creates an Array from a scalar value from given dimensions

>>> constant @Double [2,2] 2.0
 ArrayFire Array
[2 2 1 1]
   2.0000     2.0000
   2.0000     2.0000

range :: forall a. AFType a => [Int] -> Int -> Array a Source #

Creates a range of values in an Array

>>> range @Double [10] (-1)
ArrayFire Array
[10 1 1 1]
   0.0000     1.0000     2.0000     3.0000     4.0000     5.0000     6.0000     7.0000     8.0000     9.0000

iota Source #

Arguments

:: AFType a 
=> [Int]

is the array containing sizes of the dimension

-> [Int]

is array containing the number of repetitions of the unit dimensions

-> Array a

is the generated array

Create an sequence [0, dims.elements() - 1] and modify to specified dimensions dims and then tile it according to tile_dims.

http://arrayfire.org/docs/group__data__func__iota.htm

>>> iota @Double [5,3] []
ArrayFire Array
[5 3 1 1]
   0.0000     1.0000     2.0000     3.0000     4.0000
   5.0000     6.0000     7.0000     8.0000     9.0000
  10.0000    11.0000    12.0000    13.0000    14.0000
>>> iota @Double [5,3] [1,2]
ArrayFire Array
[5 6 1 1]
 0.0000     1.0000     2.0000     3.0000     4.0000
 5.0000     6.0000     7.0000     8.0000     9.0000
10.0000    11.0000    12.0000    13.0000    14.0000
 0.0000     1.0000     2.0000     3.0000     4.0000
 5.0000     6.0000     7.0000     8.0000     9.0000
10.0000    11.0000    12.0000    13.0000    14.0000

identity Source #

Arguments

:: AFType a 
=> [Int]

Dimensions

-> Array a 

Creates the identity Array from given dimensions

>>> identity [2,2]
ArrayFire Array
[2 2 1 1]
   1.0000     0.0000
   0.0000     1.0000

diagCreate Source #

Arguments

:: AFType (a :: *) 
=> Array a

is the input array which is the diagonal

-> Int

is the diagonal index

-> Array a 

Create a diagonal matrix from input array when extract is set to false

>>> diagCreate (vector @Double 2 [1..]) 0
ArrayFire Array
[2 2 1 1]
   1.0000     0.0000
   0.0000     2.0000

diagExtract :: AFType (a :: *) => Array a -> Int -> Array a Source #

Create a diagonal matrix from input array when extract is set to false

>>> diagExtract (matrix @Double (2,2) [[1,2],[3,4]]) 0
ArrayFire Array
[2 1 1 1]
   1.0000     4.0000

join :: Int -> Array (a :: *) -> Array a -> Array a Source #

Join two Arrays together along a specified dimension

>>> join 0 (matrix @Double (2,2) [[1,2],[3,4]]) (matrix @Double (2,2) [[5,6],[7,8]])
ArrayFire Array
[4 2 1 1]
   1.0000     2.0000     5.0000     6.0000
   3.0000     4.0000     7.0000     8.0000

joinMany :: Int -> [Array a] -> Array a Source #

Join many Arrays together along a specified dimension

  • FIX ME*
>>> joinMany 0 [1,2,3]
ArrayFire Array
[3 1 1 1]
   1.0000     2.0000     3.0000

tile :: Array (a :: *) -> [Int] -> Array a Source #

Tiles an Array according to specified dimensions

>>> tile @Double (scalar 22.0) [5,5]
ArrayFire Array
[5 5 1 1]
22.0000    22.0000    22.0000    22.0000    22.0000
22.0000    22.0000    22.0000    22.0000    22.0000
22.0000    22.0000    22.0000    22.0000    22.0000
22.0000    22.0000    22.0000    22.0000    22.0000
22.0000    22.0000    22.0000    22.0000    22.0000

reorder :: Array (a :: *) -> [Int] -> Array a Source #

Reorders an Array according to newly specified dimensions

  • FIX ME*
>>> reorder @Double (scalar 22.0) [5,5]
ArrayFire Array
[5 5 1 1]
22.0000    22.0000    22.0000    22.0000    22.0000
22.0000    22.0000    22.0000    22.0000    22.0000
22.0000    22.0000    22.0000    22.0000    22.0000
22.0000    22.0000    22.0000    22.0000    22.0000
22.0000    22.0000    22.0000    22.0000    22.0000

shift :: Array (a :: *) -> Int -> Int -> Int -> Int -> Array a Source #

Shift elements in an Array along a specified dimension (elements will wrap).

>>> shift (vector @Double 4 [1..]) 2 0 0 0
ArrayFire Array
[4 1 1 1]
   3.0000     4.0000     1.0000     2.0000

moddims :: forall a. Array (a :: *) -> [Int] -> Array a Source #

Modify dimensions of array

>>> moddims (vector @Double 3 [1..]) [1,3]
ArrayFire Array
[1 3 1 1]
   1.0000
   2.0000
   3.0000

flat :: Array a -> Array a Source #

Flatten an Array into a single dimension

>>> flat (matrix @Double (2,2) [[1..],[1..]])
ArrayFire Array
[4 1 1 1]
   1.0000     2.0000     1.0000     2.0000
>>> flat $ cube @Int (2,2,2) [[[1,1],[1,1]],[[1,1],[1,1]]]
ArrayFire Array
[8 1 1 1]
    1          1          1          1          1          1          1          1

flip :: Array a -> Int -> Array a Source #

Flip the values of an Array along a specified dimension

>>> matrix @Double (2,2) [[2,2],[3,3]]
ArrayFire Array
[2 2 1 1]
   2.0000     2.0000
   3.0000     3.0000
>>> A.flip (matrix @Double (2,2) [[2,2],[3,3]]) 1
ArrayFire Array
[2 2 1 1]
   3.0000     3.0000
   2.0000     2.0000

lower Source #

Arguments

:: Array a

is the input matrix

-> Bool

boolean parameter specifying if the diagonal elements should be 1

-> Array a 

Create a lower triangular matrix from input array.

>>> lower (constant [2,2] 10 :: Array Double) True
ArrayFire Array
[2 2 1 1]
   1.0000    10.0000
   0.0000     1.0000

upper :: Array a -> Bool -> Array a Source #

Create an upper triangular matrix from input array.

>>> upper (constant [2,2] 10 :: Array Double) True
ArrayFire Array
[2 2 1 1]
   1.0000     0.0000
  10.0000     1.0000

select Source #

Arguments

:: Array CBool

is the conditional array

-> Array a

is the array containing elements from the true part of the condition

-> Array a

is the array containing elements from the false part of the condition

-> Array a

is the output containing elements of a when cond is true else elements from b

Selects elements from two arrays based on the values of a binary conditional array.

>>> cond = vector @CBool 5 [1,0,1,0,1]
>>> arr1 = vector @Double 5 (repeat 1)
>>> arr2 = vector @Double 5 (repeat 2)
>>> select cond arr1 arr2
ArrayFire Array
[5 1 1 1]
   1.0000     2.0000     1.0000     2.0000     1.0000

selectScalarR Source #

Arguments

:: Array CBool

is the conditional array

-> Array a

is the array containing elements from the true part of the condition

-> Double

is a scalar assigned to out when cond is false

-> Array a

the output containing elements of a when cond is true else elements from b

Selects elements from two arrays based on the values of a binary conditional array.

http://arrayfire.org/docs/group__data__func__select.htm#gab6886120d0bac4717276910e468bbe88

>>> cond = vector @CBool 5 [1,0,1,0,1]
>>> arr1 = vector @Double 5 (repeat 1)
>>> x = 99
>>> selectScalarR cond x arr1
ArrayFire Array
[5 1 1 1]
   1.0000    99.0000     1.0000    99.0000     1.0000

selectScalarL Source #

Arguments

:: Array CBool

the conditional array

-> Double

a scalar assigned to out when cond is true

-> Array a

the array containing elements from the false part of the condition

-> Array a

is the output containing elements of a when cond is true else elements from b

Selects elements from two arrays based on the values of a binary conditional array.

ArrayFire Docs

>>> cond = vector @CBool 5 [1,0,1,0,1]
>>> arr1 = vector @Double 5 (repeat 1)
>>> x = 99
>>> selectScalarL cond x arr1
ArrayFire Array
[5 1 1 1]
  99.0000     1.0000    99.0000     1.0000    99.0000