module Data.Array.Accelerate.Classes.RealFloat (
RealFloat(..),
) where
import Data.Array.Accelerate.Error
import Data.Array.Accelerate.Smart
import Data.Array.Accelerate.Type
import Data.Array.Accelerate.Classes.Floating
import Data.Array.Accelerate.Classes.RealFrac
import Text.Printf
import Prelude ( String, error, undefined )
import qualified Prelude as P
class (RealFrac a, Floating a) => RealFloat a where
floatRadix :: Exp a -> Exp Int64
default floatRadix :: P.RealFloat a => Exp a -> Exp Int64
floatRadix _ = P.fromInteger (P.floatRadix (undefined::a))
floatDigits :: Exp a -> Exp Int
default floatDigits :: P.RealFloat a => Exp a -> Exp Int
floatDigits _ = constant (P.floatDigits (undefined::a))
floatRange :: Exp a -> (Exp Int, Exp Int)
default floatRange :: P.RealFloat a => Exp a -> (Exp Int, Exp Int)
floatRange _ = let (m,n) = P.floatRange (undefined::a)
in (constant m, constant n)
decodeFloat :: Exp a -> (Exp Int64, Exp Int)
encodeFloat :: Exp Int64 -> Exp Int -> Exp a
exponent :: Exp a -> Exp Int
significand :: Exp a -> Exp a
scaleFloat :: Exp Int -> Exp a -> Exp a
isNaN :: Exp a -> Exp Bool
isInfinite :: Exp a -> Exp Bool
isDenormalized :: Exp a -> Exp Bool
isNegativeZero :: Exp a -> Exp Bool
isIEEE :: Exp a -> Exp Bool
default isIEEE :: P.RealFloat a => Exp a -> Exp Bool
isIEEE _ = constant (P.isIEEE (undefined::Float))
atan2 :: Exp a -> Exp a -> Exp a
decodeFloat = $internalError "RealFloat.decodeFloat" "Not implemented yet"
encodeFloat = $internalError "RealFloat.encodeFloat" "Not implemented yet"
exponent = $internalError "RealFloat.exponent" "Not implemented yet"
significand = $internalError "RealFloat.significand" "Not implemented yet"
scaleFloat = $internalError "RealFloat.scaleFloat" "Not implemented yet"
isInfinite = $internalError "RealFloat.isInfinite" "Not implemented yet"
isDenormalized = $internalError "RealFloat.isDenormalized" "Not implemented yet"
isNegativeZero = $internalError "RealFloat.isNegativeZero" "Not implemented yet"
instance RealFloat Float where
isNaN = mkIsNaN
atan2 = mkAtan2
instance RealFloat Double where
isNaN = mkIsNaN
atan2 = mkAtan2
instance RealFloat CFloat where
isNaN = mkIsNaN
atan2 = mkAtan2
instance RealFloat CDouble where
isNaN = mkIsNaN
atan2 = mkAtan2
instance RealFloat a => P.RealFloat (Exp a) where
floatRadix = preludeError "floatRadix"
floatDigits = preludeError "floatDigits"
floatRange = preludeError "floatRange"
decodeFloat = preludeError "decodeFloat"
encodeFloat = preludeError "encodeFloat"
isNaN = preludeError "isNaN"
isInfinite = preludeError "isInfinite"
isDenormalized = preludeError "isDenormalized"
isNegativeZero = preludeError "isNegativeZero"
isIEEE = preludeError "isIEEE"
preludeError :: String -> a
preludeError x = error (printf "Prelude.%s applied to EDSL types: use Data.Array.Accelerate.%s instead" x)