在Exp / Acc中进行实数类型转换

时间:2019-04-24 16:17:51

标签: haskell accelerate-haskell

我需要将Accelerate libraryExpAcc类型内的实数值转换为其相应的Complex值,例如:

toComplex :: Exp Double -> Exp (Complex Double)
toComplex' :: Acc (Vector Double) -> Acc (Vector (Complex Double))

我尝试过图案匹配

toComplex :: Exp Double -> Exp (Complex Double)
toComplex a = (\(r, i) -> constant $ r :+ i) $ (a, constant 0)

并怀疑https://www.acceleratehs.org/examples/mandelbrot.html中的liftunlift可能会以某种方式解决此问题,但无法找出正确的用法。

对于我的尝试ghc抱怨

• Couldn't match type ‘Exp Double’ with ‘Double’
      Expected type: Exp (Complex Double)
        Actual type: Exp (Complex (Exp Double))

0 个答案:

没有答案