Copyright | David Johnson (c) 2019-2020 |
---|---|
License | BSD 3 |
Maintainer | David Johnson <djohnson.m@gmail.com> |
Stability | Experimental |
Portability | GHC |
Safe Haskell | None |
Language | Haskell2010 |
Various utilities for working with the ArrayFire C library
import qualified ArrayFire as A import Control.Monad main :: IO () main = do let arr = A.constant [1,1,1,1] 10 idx <- A.saveArray "key" arr "file.array" False foundIndex <- A.readArrayKeyCheck "file.array" "key" when (idx == foundIndex) $ do array <- A.readArrayKey "file.array" "key" print array
ArrayFire Array [ 1 1 1 1 ] 10
Synopsis
- getVersion :: IO (Int, Int, Int)
- printArray :: Array a -> IO ()
- getRevision :: IO String
- printArrayGen :: String -> Array a -> Int -> IO ()
- saveArray :: String -> Array a -> FilePath -> Bool -> IO Int
- readArrayIndex :: FilePath -> Int -> IO (Array a)
- readArrayKey :: FilePath -> String -> IO (Array a)
- readArrayKeyCheck :: FilePath -> String -> IO Int
- arrayString :: Array a -> String
- arrayToString :: String -> Array a -> Int -> Bool -> String
- getSizeOf :: forall a. AFType a => Proxy a -> Int
Documentation
getRevision :: IO String Source #
:: String | An expression used as tag/key for the |
-> Array a | Input |
-> FilePath | Path that |
-> Bool | Used to append to an existing file when |
-> IO Int | The index location of the |
Saves Array
to disk
Save an array to a binary file.
The saveArray
and readArray functions are designed to provide store and read access to arrays using files written to disk.
http://arrayfire.org/docs/group__stream__func__save.htm
>>> saveArray "my array" (constant @Double
[1] 1) "array.file"True
0
Reads Array by index
The saveArray
and readArray functions are designed to provide store and read access to arrays using files written to disk.
http://arrayfire.org/docs/group__stream__func__save.htm
>>> readArrayIndex "array.file" 0
ArrayFire Array [ 1 1 1 1 ] 10.0000
:: FilePath | Path to file |
-> String | Key |
-> IO Int | is the tag/name of the array to be read. The key needs to have an exact match. |
Reads Array, checks if a key exists in the specified file
When reading by key, it may be a good idea to run this function first to check for the key and then call the readArray using the index. http://arrayfire.org/docs/group__stream__func__read.htm#ga31522b71beee2b1c06d49b5aa65a5c6f
>>> readArrayCheck "array.file" "my array"
0