我有一个由函数Float
创建的元素向量。getVectorFloat
为了进行一些测量,我需要使用deepSeqArray
. 但是,我无法做到。
这是我的例子:
import Data.Array.Repa as R
import Data.Array.Repa.Algorithms.Randomish
len :: Int
len = 3000000
main = do
ws <- getVectorFloat len
ws `deepSeqArray` return()
getVectorFloat :: Int -> Array DIM1 Float
getVectorFloat len = R.map (toFloat) (getVectorDouble len)
toFloat :: Double -> Float
toFloat a = realToFrac a
getVectorDouble :: Int -> Array DIM1 Double
getVectorDouble len = randomishDoubleArray (Z :. len) (-100) 100 1
我得到的错误是:
haskell.hs:9:9:
Couldn't match expected type `Array sh0 a0'
with actual type `Float'
In the first argument of `deepSeqArray', namely `ws'
In the expression: ws `deepSeqArray` return ()
In the expression:
do { ws <- getVectorFloat len;
ws `deepSeqArray` return () }
我不明白为什么Array sh0 a0
不能匹配到Array Dim1 Float
.
谢谢您的帮助