arrayfire-0.5.1.0: exe/Main.hs
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE DataKinds #-}
module Main where
import ArrayFire
import Control.Monad (unless)
import Prelude hiding (sum, product, mod, abs, cos, sin)
main :: IO ()
main = do
print $ constant @Double [10] 3.33
window <- createWindow 800 600 "hey"
let x = iota [200,1] [1,200] / 1000
y = iota [1,200] [200,1] / 1000
go window (1 :: Array Float) x y
where
go window t x y = do
let z = 10*x*(-abs(y)) * cos(x*x*(y+t))+sin(y*(x+t))-1.5
drawSurface window x y z (Cell (-1) (-1) "there" ColorMapDefault)
closed <- isWindowClosed window
unless closed $ go window (t + 0.07) x y
foreign import ccall safe "test_bool"
testBool :: IO ()
foreign import ccall safe "test_window"
testWindow :: IO ()
-- main' :: IO ()
-- main' = print newArray `catch` (\(e :: AFException) -> print e)
-- where
-- newArray = matrix @Double (2,2) [ [1..], [1..] ] * matrix @Double (2,2) [ [2..], [2..] ]
main2 :: IO ()
main2 = do
window <- createWindow 800 600 "hey"
go window
where
go window = do
let x = iota [1,60] [60,1] / (30 :: Array Float)
cell = Cell (-1) (-1) mempty ColorMapDefault
drawImage window x cell
closed <- isWindowClosed window
unless closed $ go window
-- -- print =<< getActiveBackend
-- -- print =<< getDeviceCount
-- -- print =<< getDevice
-- -- putStrLn "info"
-- -- getInfo
-- -- putStrLn "info string"
-- -- putStrLn =<< getInfoString
-- -- print =<< getVersion
secs :: Int -> Int
secs = (*1000000)