| 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.Array
Description
Synopsis
- scalar :: AFType a => a -> Array a
- vector :: AFType a => Int -> [a] -> Array a
- fromList :: AFType a => [Int] -> [a] -> Array a
- matrix :: AFType a => (Int, Int) -> [[a]] -> Array a
- cube :: AFType a => (Int, Int, Int) -> [[[a]]] -> Array a
- tensor :: AFType a => (Int, Int, Int, Int) -> [[[[a]]]] -> Array a
- mkArray :: AFType array => [Int] -> [array] -> Array array
- fromVector :: AFType a => [Int] -> Vector a -> Array a
- copyArray :: AFType a => Array a -> Array a
- retainArray :: AFType a => Array a -> Array a
- getDataRefCount :: AFType a => Array a -> Int
- eval :: AFType a => Array a -> Array a
- setManualEvalFlag :: Bool -> IO ()
- getManualEvalFlag :: IO Bool
- getElements :: AFType a => Array a -> Int
- getType :: AFType a => Array a -> AFDType
- getDims :: AFType a => Array a -> (Int, Int, Int, Int)
- getNumDims :: AFType a => Array a -> Int
- isEmpty :: AFType a => Array a -> Bool
- isScalar :: AFType a => Array a -> Bool
- isRow :: AFType a => Array a -> Bool
- isColumn :: AFType a => Array a -> Bool
- isVector :: AFType a => Array a -> Bool
- isComplex :: AFType a => Array a -> Bool
- isReal :: AFType a => Array a -> Bool
- isDouble :: AFType a => Array a -> Bool
- isSingle :: AFType a => Array a -> Bool
- isRealFloating :: AFType a => Array a -> Bool
- isFloating :: AFType a => Array a -> Bool
- isInteger :: AFType a => Array a -> Bool
- isBool :: AFType a => Array a -> Bool
- isSparse :: AFType a => Array a -> Bool
- toVector :: AFType a => Array a -> Vector a
- toList :: AFType a => Array a -> [a]
- getScalar :: (Storable a, AFType b) => Array b -> a
Documentation
scalar :: AFType a => a -> Array a Source #
Smart constructor for creating a scalar Array
>>>scalar @Double 2.0ArrayFire Array [1 1 1 1] 2.0000
vector :: AFType a => Int -> [a] -> Array a Source #
Smart constructor for creating a vector Array
>>>vector @Double 10 [1..]ArrayFire Array [10 1 1 1] 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000
fromList :: AFType a => [Int] -> [a] -> Array a Source #
Construct an Array from a flat list with explicit dimensions.
Dimensions are in column-major order (first dim varies fastest).
Prefer fromVector when data is already in a Vector
to avoid the intermediate list allocation.
>>>fromList [2,3] [1..6 :: Double]ArrayFire Array [2 3 1 1] 1.0000 3.0000 5.0000 2.0000 4.0000 6.0000
matrix :: AFType a => (Int, Int) -> [[a]] -> Array a Source #
Smart constructor for creating a matrix Array
>>>A.matrix @Double (3,2) [[1,2,3],[4,5,6]]ArrayFire Array [3 2 1 1] 1.0000 4.0000 2.0000 5.0000 3.0000 6.0000
cube :: AFType a => (Int, Int, Int) -> [[[a]]] -> Array a Source #
Smart constructor for creating a cubic Array
>>>cube @Double (2,2,2) [[[2,2],[2,2]],[[2,2],[2,2]]]
ArrayFire Array [2 2 2 1] 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000
tensor :: AFType a => (Int, Int, Int, Int) -> [[[[a]]]] -> Array a Source #
Smart constructor for creating a tensor Array
>>>tensor @Double (2,2,2,2) [[[[2,2],[2,2]],[[2,2],[2,2]]], [[[2,2],[2,2]],[[2,2],[2,2]]]]
ArrayFire Array
[2 2 2 2]
2.0000 2.0000
2.0000 2.0000
2.0000 2.0000
2.0000 2.0000
2.0000 2.0000
2.0000 2.0000
2.0000 2.0000
2.0000 2.0000
Internal function for Array construction
>>>mkArray @Double [10] [1.0 .. 10.0]ArrayFire Array [10 1 1 1] 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000
Constructs an Array from a Storable Vector, avoiding the intermediate list allocation of mkArray.
The vector's contiguous buffer is handed straight to af_create_array, which
copies it into the Array (and uploads to device memory on GPU backends), so
no intermediate Haskell list is built.
Throws AFException if the vector length does not match the product of the given dimensions.
>>>fromVector @Double [3] (Data.Vector.Storable.fromList [1,2,3])ArrayFire Array [3 1 1 1] 1.0000 2.0000 3.0000
Retains an Array, increases reference count
>>>retainArray (scalar @Double 10)ArrayFire Array [1 1 1 1] 10.0000
Retrieves Array reference count
>>>initialArray = scalar @Double 10>>>retainedArray = retainArray initialArray>>>getDataRefCount retainedArray2
eval :: AFType a => Array a -> Array a Source #
Force evaluation of a lazily-deferred Array, flushing any pending
computation in the JIT queue and returning the same array.
>>>eval (vector @Double 10 [1..])ArrayFire Array ...
Should manual evaluation occur
>>>setManualEvalFlag True()
getManualEvalFlag :: IO Bool Source #
Retrieve manual evaluation status
>>>setManualEvalFlag False>>>getManualEvalFlagFalse
Retrieve element count
>>>getElements (vector @Double 10 [1..])10
getType :: AFType a => Array a -> AFDType Source #
Retrieve type of Array
>>>getType (vector @Double 10 [1..])F64
getDims :: AFType a => Array a -> (Int, Int, Int, Int) Source #
Retrieves dimensions of Array
>>>getDims (vector @Double 10 [1..])(10,1,1,1)
getNumDims :: AFType a => Array a -> Int Source #
Retrieves number of dimensions in Array
>>>getNumDims (matrix @Double (2,2) [[1..],[1..]])2
isEmpty :: AFType a => Array a -> Bool Source #
Checks if an Array is empty
>>>isEmpty (matrix @Double (2,2) [[1..],[1..]])False
isScalar :: AFType a => Array a -> Bool Source #
Checks if an Array is a scalar (contains only one element)
>>>isScalar (matrix @Double (2,2) [[1..],[1..]])False>>>isScalar (1.0 :: Array Double)True
isRow :: AFType a => Array a -> Bool Source #
Checks if an Array is row-oriented
>>>isRow (matrix @Double (2,2) [[1..],[1..]])False
isColumn :: AFType a => Array a -> Bool Source #
Checks if an Array is a column-oriented
>>>isColumn (vector @Double 10 [1..])True
isVector :: AFType a => Array a -> Bool Source #
Checks if an Array is a vector
>>>isVector (vector @Double 10 [1..])True>>>isVector (1.0 :: Array Double)False
isComplex :: AFType a => Array a -> Bool Source #
Checks if an Array is a Complex
>>>isComplex (scalar (1.0 :+ 1.0) :: Array (Complex Double))True
isReal :: AFType a => Array a -> Bool Source #
Checks if an Array is Real
>>>isReal (scalar 1.0 :: Array Double)True
isInteger :: AFType a => Array a -> Bool Source #
Checks if an Array is of type Int16, Int32, or Int64
>>>isInteger (scalar 1 :: Array Int16)True
isBool :: AFType a => Array a -> Bool Source #
Checks if an Array is of type CBool
>>>isBool (scalar 1 :: Array CBool)True
isSparse :: AFType a => Array a -> Bool Source #
Checks if an Array is sparse
>>>isSparse (scalar 1 :: Array Double)False