我需要将Accelerate library的Exp
或Acc
类型内的实数值转换为其相应的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中的lift
或unlift
可能会以某种方式解决此问题,但无法找出正确的用法。
对于我的尝试ghc
抱怨
• Couldn't match type ‘Exp Double’ with ‘Double’
Expected type: Exp (Complex Double)
Actual type: Exp (Complex (Exp Double))