| Copyright | David Johnson (c) 2019-2026 |
|---|---|
| License | BSD 3 |
| Maintainer | David Johnson <code@dmj.io> |
| Stability | Experimental |
| Portability | GHC |
| Safe Haskell | None |
| Language | Haskell2010 |
ArrayFire.Data
Description
Functions for populating Array with Data.
>>> constant @Double [2,2] 2.0 ArrayFire Array [2 2 1 1] 2.0000 2.0000 2.0000 2.0000
Synopsis
- bitNot :: (AFType a, Bits a, Integral a) => Array a -> Array a
- constant :: AFType a => [Int] -> Double -> Array a
- constantComplex :: (Real r, AFType (Complex r)) => [Int] -> Complex r -> Array (Complex r)
- constantLong :: [Int] -> Int -> Array Int
- constantULong :: [Int] -> Word64 -> Array Word64
- arange :: AFType a => [Int] -> Int -> Array a
- iota :: AFType a => [Int] -> [Int] -> Array a
- identity :: AFType a => [Int] -> Array a
- diagCreate :: AFType a => Array a -> Int -> Array a
- diagExtract :: AFType a => Array a -> Int -> Array a
- join :: Int -> Array a -> Array a -> Array a
- joinMany :: Int -> [Array a] -> Array a
- withManyForeignPtr :: [ForeignPtr a] -> (Int -> Ptr (Ptr a) -> IO b) -> IO b
- tile :: Array a -> [Int] -> Array a
- reorder :: Array a -> [Int] -> Array a
- shift :: Array a -> Int -> Int -> Int -> Int -> Array a
- moddims :: Array a -> [Int] -> Array a
- flat :: Array a -> Array a
- flip :: Array a -> Int -> Array a
- lower :: Array a -> Bool -> Array a
- upper :: Array a -> Bool -> Array a
- select :: Array CBool -> Array a -> Array a -> Array a
- selectScalarR :: Array CBool -> Array a -> Double -> Array a
- selectScalarL :: Array CBool -> Double -> Array a -> Array a
Documentation
bitNot :: (AFType a, Bits a, Integral a) => Array a -> Array a Source #
Bitwise complement of every element in an Array
>>>A.bitNot (A.scalar @Int32 0)ArrayFire Array [1 1 1 1] -1
Creates a constant Array filled with a Double scalar.
ArrayFire converts the value to the element type internally.
Use constantComplex for complex arrays, constantLong / constantULong
for 64-bit integer arrays where the value exceeds 2^53.
arange :: AFType a => [Int] -> Int -> Array a Source #
Creates a range of values in an Array
>>>arange @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
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 5.0000 10.0000 1.0000 6.0000 11.0000 2.0000 7.0000 12.0000 3.0000 8.0000 13.0000 4.0000 9.0000 14.0000
>>>iota @Double [5,3] [1,2]ArrayFire Array [5 6 1 1] 0.0000 5.0000 10.0000 0.0000 5.0000 10.0000 1.0000 6.0000 11.0000 1.0000 6.0000 11.0000 2.0000 7.0000 12.0000 2.0000 7.0000 12.0000 3.0000 8.0000 13.0000 3.0000 8.0000 13.0000 4.0000 9.0000 14.0000 4.0000 9.0000 14.0000
Creates the identity Array from given dimensions
>>>identity [2,2]ArrayFire Array [2 2 1 1] 1.0000 0.0000 0.0000 1.0000
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..]) 0ArrayFire 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]]) 0ArrayFire 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 3.0000 2.0000 4.0000 5.0000 7.0000 6.0000 8.0000
joinMany :: Int -> [Array a] -> Array a Source #
Join many Arrays together along a specified dimension
>>>joinMany 0 [vector @Int 3 [1..], vector @Int 3 [1..]]ArrayFire Array [6 1 1 1] 1 2 3 1 2 3
withManyForeignPtr :: [ForeignPtr a] -> (Int -> Ptr (Ptr a) -> IO b) -> IO b Source #
Marshals a list of ForeignPtr into a temporary, contiguous C array of
raw pointers, keeping every ForeignPtr alive for the duration of the
action. The continuation receives the number of pointers and a pointer to
the array.
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 0ArrayFire Array [4 1 1 1] 3.0000 4.0000 1.0000 2.0000
moddims :: 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 3.0000 2.0000 3.0000
>>>A.flip (matrix @Double (2,2) [[2,2],[3,3]]) 1ArrayFire Array [2 2 1 1] 3.0000 2.0000 3.0000 2.0000
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) TrueArrayFire Array [2 2 1 1] 1.0000 0.0000 10.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) TrueArrayFire Array [2 2 1 1] 1.0000 10.0000 0.0000 1.0000
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 arr2ArrayFire Array [5 1 1 1] 1.0000 2.0000 1.0000 2.0000 1.0000
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 arr1 xArrayFire Array [5 1 1 1] 1.0000 99.0000 1.0000 99.0000 1.0000
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.
>>>cond = vector @CBool 5 [1,0,1,0,1]>>>arr1 = vector @Double 5 (repeat 1)>>>x = 99>>>selectScalarL cond x arr1ArrayFire Array [5 1 1 1] 99.0000 1.0000 99.0000 1.0000 99.0000