
On Mon, 16 May 2011 20:33:12 +0400
Grigory Sarnitskiy
Hello!
I'm probing CUDA with Haskell, accelerate package to be exact. Sound stupid, but I couldn't find how to actually construct an array, for example Vector Float.
There is quite a number of examples provided with the package, but they seem not simple enough for me just to start.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Have a fish :-) import Data.Array.Repa as A import Data.Array.Repa.Index import Data.Array.Repa.Shape as AS newArray :: Int -> Array DIM2 Double newArray n = -- A.fromList ((AS.shapeOfList [n, n])::(DIM2)) ((Prelude.map fromIntegral [1..n*n])::[Double]) A.fromList (AS.shapeOfList [n, n]) (Prelude.map fromIntegral [1..n*n]) main = do let x = newArray 5 let y = newArray 5 let z = A.zipWith(+) x y putStrLn $ show x putStrLn $ show y putStrLn $ show z *Main> main [1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0,17.0,18.0,19.0,20.0,21.0,22.0,23.0,24.0,25.0] [1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0,17.0,18.0,19.0,20.0,21.0,22.0,23.0,24.0,25.0] [2.0,4.0,6.0,8.0,10.0,12.0,14.0,16.0,18.0,20.0,22.0,24.0,26.0,28.0,30.0,32.0,34.0,36.0,38.0,40.0,42.0,44.0,46.0,48.0,50.0] *Main> I can't remember what Prelude.map collided with. Brian