{-# LANGUAGE OverloadedStrings #-}

module Funcons.Core.Values.Primitive.FloatsBuiltin where

import Funcons.EDSL
import Funcons.Operations (Values(..), ComputationTypes(..), Types(..), isIEEEFormat, doubleFromIEEEFormat, tobool)
import Funcons.Core.Values.Primitive.BoolBuiltin
import Funcons.Core.Values.Primitive.IntegersBuiltin

import Data.Fixed (mod')

library :: FunconLibrary
library = [(Name, EvalFunction)] -> FunconLibrary
libFromList [
        (Name
"ieee-float-float-power", ValueOp -> EvalFunction
ValueOp ValueOp
stepIEEE_Float_Power)
    ,   (Name
"ieee-float-add", ValueOp -> EvalFunction
ValueOp ValueOp
stepIEEE_Float_Add)
    ,   (Name
"ieee-float-truncate", ValueOp -> EvalFunction
ValueOp ValueOp
stepIEEE_Float_Truncate)
    ,   (Name
"ieee-float-multiply", ValueOp -> EvalFunction
ValueOp ValueOp
stepIEEE_Float_Multiply)
    ,   (Name
"ieee-float-subtract", ValueOp -> EvalFunction
ValueOp ValueOp
stepIEEE_Float_Subtract)
    ,   (Name
"ieee-float-negate", ValueOp -> EvalFunction
ValueOp ValueOp
stepIEEE_Float_Negate)
    ,   (Name
"ieee-float-divide", ValueOp -> EvalFunction
ValueOp ValueOp
stepIEEE_Float_Divide)
--    ,   ("signed-bits-maximum", ValueOp stepSigned_Bits_Maximum)
--    ,   ("signed-bits-minimum", ValueOp stepSigned_Bits_Minimum)
    ,   (Name
"ieee-float-acos", ValueOp -> EvalFunction
ValueOp ValueOp
stepIEEE_Float_Acos)
    ,   (Name
"ieee-float-asin", ValueOp -> EvalFunction
ValueOp ValueOp
stepIEEE_Float_Asin)
    ,   (Name
"ieee-float-atan", ValueOp -> EvalFunction
ValueOp ValueOp
stepIEEE_Float_Atan)
    ,   (Name
"ieee-float-atan2", ValueOp -> EvalFunction
ValueOp ValueOp
stepIEEE_Float_Atan2)
    ,   (Name
"ieee-float-cos", ValueOp -> EvalFunction
ValueOp ValueOp
stepIEEE_Float_Cos)
    ,   (Name
"ieee-float-cosh", ValueOp -> EvalFunction
ValueOp ValueOp
stepIEEE_Float_Cosh)
    ,   (Name
"ieee-float-exp", ValueOp -> EvalFunction
ValueOp ValueOp
stepIEEE_Float_Exp)
    ,   (Name
"ieee-float-log", ValueOp -> EvalFunction
ValueOp ValueOp
stepIEEE_Float_Log)
    ,   (Name
"ieee-float-log10", ValueOp -> EvalFunction
ValueOp ValueOp
stepIEEE_Float_Log10)
    ,   (Name
"ieee-float-sin", ValueOp -> EvalFunction
ValueOp ValueOp
stepIEEE_Float_Sin)
    ,   (Name
"ieee-float-sinh", ValueOp -> EvalFunction
ValueOp ValueOp
stepIEEE_Float_Sinh)
    ,   (Name
"ieee-float-sqrt", ValueOp -> EvalFunction
ValueOp ValueOp
stepIEEE_Float_Sqrt)
    ,   (Name
"ieee-float-tan", ValueOp -> EvalFunction
ValueOp ValueOp
stepIEEE_Float_Tan)
    ,   (Name
"ieee-float-tanh", ValueOp -> EvalFunction
ValueOp ValueOp
stepIEEE_Float_Tanh)
    ,   (Name
"ieee-float-ceiling", ValueOp -> EvalFunction
ValueOp ValueOp
stepIEEE_Float_Ceiling)
    ,   (Name
"ieee-float-floor", ValueOp -> EvalFunction
ValueOp ValueOp
stepIEEE_Float_Floor)
    ,   (Name
"ieee-float-absolute-value", ValueOp -> EvalFunction
ValueOp ValueOp
stepIEEE_Float_Absolute_Value)
    ,   (Name
"ieee-float-remainder", ValueOp -> EvalFunction
ValueOp ValueOp
stepIEEE_Float_Remainder)
    ,   (Name
"ieee-float-is-less", ValueOp -> EvalFunction
ValueOp ValueOp
stepIEEE_Float_Is_Less)
    ,   (Name
"ieee-float-is-less-or-equal", ValueOp -> EvalFunction
ValueOp ValueOp
stepIEEE_Float_Is_Less_Or_Equal)
    ,   (Name
"ieee-float-is-greater-or-equal", ValueOp -> EvalFunction
ValueOp ValueOp
stepIEEE_Float_Is_Greater_Or_Equal)
    ,   (Name
"ieee-float-is-greater", ValueOp -> EvalFunction
ValueOp ValueOp
stepIEEE_Float_Is_Greater) 
    ]

ieee_float_truncate :: [Funcons] -> Funcons
ieee_float_truncate = Name -> [Funcons] -> Funcons
applyFuncon Name
"ieee-float-truncate"
stepIEEE_Float_Truncate :: ValueOp
stepIEEE_Float_Truncate [IEEE_Float_64 Double
f, ADTVal Name
"binary64" [Funcons]
_] = Funcons -> Rewrite Rewritten
rewriteTo (Funcons -> Rewrite Rewritten) -> Funcons -> Rewrite Rewritten
forall a b. (a -> b) -> a -> b
$ Int -> Funcons
int_ (Double -> Int
forall a b. (RealFrac a, Integral b) => a -> b
truncate Double
f)
stepIEEE_Float_Truncate [Values Funcons]
vn = Funcons -> String -> Rewrite Rewritten
forall a. Funcons -> String -> Rewrite a
sortErr ([Funcons] -> Funcons
ieee_float_truncate ([Values Funcons] -> [Funcons]
fvalues [Values Funcons]
vn)) String
"ieee-float-truncate not applied to a float of the right format"
stepIEEE_Float_Add :: ValueOp
stepIEEE_Float_Add [Values Funcons]
vs       = ValueOp
ieee_float_add_op [Values Funcons]
vs
stepIEEE_Float_Multiply :: ValueOp
stepIEEE_Float_Multiply [Values Funcons]
vs  = ValueOp
ieee_float_multiply_op [Values Funcons]
vs
stepIEEE_Float_Subtract :: ValueOp
stepIEEE_Float_Subtract [Values Funcons
f,Values Funcons
f1,Values Funcons
f2] = Values Funcons
-> Values Funcons -> Values Funcons -> Rewrite Rewritten
ieee_float_subtract_op Values Funcons
f Values Funcons
f1 Values Funcons
f2
stepIEEE_Float_Subtract [Values Funcons]
vn = Funcons -> String -> Rewrite Rewritten
forall a. Funcons -> String -> Rewrite a
sortErr ([Funcons] -> Funcons
ieee_float_subtract ([Values Funcons] -> [Funcons]
fvalues [Values Funcons]
vn)) String
"sort check"
stepIEEE_Float_Negate :: ValueOp
stepIEEE_Float_Negate [Values Funcons
f,Values Funcons
f1] = Values Funcons -> Values Funcons -> Rewrite Rewritten
ieee_float_negate_op Values Funcons
f Values Funcons
f1
stepIEEE_Float_Negate [Values Funcons]
vn = Funcons -> String -> Rewrite Rewritten
forall a. Funcons -> String -> Rewrite a
sortErr ([Funcons] -> Funcons
ieee_float_negate ([Values Funcons] -> [Funcons]
fvalues [Values Funcons]
vn)) String
"sort check"
stepIEEE_Float_Divide :: ValueOp
stepIEEE_Float_Divide [Values Funcons
f,Values Funcons
f1,Values Funcons
f2] = Values Funcons
-> Values Funcons -> Values Funcons -> Rewrite Rewritten
ieee_float_divide_op Values Funcons
f Values Funcons
f1 Values Funcons
f2
stepIEEE_Float_Divide [Values Funcons]
vn = Funcons -> String -> Rewrite Rewritten
forall a. Funcons -> String -> Rewrite a
sortErr ([Funcons] -> Funcons
ieee_float_divide ([Values Funcons] -> [Funcons]
fvalues [Values Funcons]
vn)) String
"sort check"
stepIEEE_Float_Power :: ValueOp
stepIEEE_Float_Power [Values Funcons
f,Values Funcons
f1,Values Funcons
f2] = Values Funcons
-> Values Funcons -> Values Funcons -> Rewrite Rewritten
ieee_float_power_op Values Funcons
f Values Funcons
f1 Values Funcons
f2
stepIEEE_Float_Power [Values Funcons]
vn = Funcons -> String -> Rewrite Rewritten
forall a. Funcons -> String -> Rewrite a
sortErr ([Funcons] -> Funcons
ieee_float_float_power ([Values Funcons] -> [Funcons]
fvalues [Values Funcons]
vn)) String
"sort check"

signed_bits_maximum :: [Funcons] -> Funcons
signed_bits_maximum = Name -> [Funcons] -> Funcons
applyFuncon Name
"signed-bits-maximum"
stepSigned_Bits_Maximum :: ValueOp
stepSigned_Bits_Maximum [Values Funcons
vn] | Nat Integer
n <- Values Funcons -> Values Funcons
forall t. Values t -> Values t
upcastNaturals Values Funcons
vn
        = Funcons -> Rewrite Rewritten
rewriteTo (Funcons -> Rewrite Rewritten) -> Funcons -> Rewrite Rewritten
forall a b. (a -> b) -> a -> b
$ [Funcons] -> Funcons
integer_subtract_ [[Funcons] -> Funcons
integer_power_ [Int -> Funcons
int_ Int
2, [Funcons] -> Funcons
integer_subtract_ [Int -> Funcons
int_ (Int -> Funcons) -> Int -> Funcons
forall a b. (a -> b) -> a -> b
$ Integer -> Int
forall a. Num a => Integer -> a
fromInteger Integer
n, Int -> Funcons
int_ Int
1]],Int -> Funcons
int_ Int
1]
stepSigned_Bits_Maximum [Values Funcons]
vs = Funcons -> String -> Rewrite Rewritten
forall a. Funcons -> String -> Rewrite a
sortErr ([Funcons] -> Funcons
signed_bits_maximum ([Values Funcons] -> [Funcons]
fvalues [Values Funcons]
vs)) String
"sort check"

signed_bits_minimum :: [Funcons] -> Funcons
signed_bits_minimum = Name -> [Funcons] -> Funcons
applyFuncon Name
"signed-bits-minimum"
stepSigned_Bits_Minimum :: ValueOp
stepSigned_Bits_Minimum [Values Funcons
vn] | Nat Integer
n <- Values Funcons -> Values Funcons
forall t. Values t -> Values t
upcastNaturals Values Funcons
vn
        = Funcons -> Rewrite Rewritten
rewriteTo (Funcons -> Rewrite Rewritten) -> Funcons -> Rewrite Rewritten
forall a b. (a -> b) -> a -> b
$ Name -> [Funcons] -> Funcons
applyFuncon Name
"integer-negate" [[Funcons] -> Funcons
signed_bits_maximum [Values Funcons -> Funcons
FValue Values Funcons
vn]]
stepSigned_Bits_Minimum [Values Funcons]
vs = Funcons -> String -> Rewrite Rewritten
forall a. Funcons -> String -> Rewrite a
sortErr ([Funcons] -> Funcons
signed_bits_maximum ([Values Funcons] -> [Funcons]
fvalues [Values Funcons]
vs)) String
"sort check"

    -- TODO binary64 assumption (perhaps use config files)
ieee_float_acos :: [Funcons] -> Funcons
ieee_float_acos = Name -> [Funcons] -> Funcons
applyFuncon Name
"ieee-float-acos"
stepIEEE_Float_Acos :: ValueOp
stepIEEE_Float_Acos [Values Funcons
f,Values Funcons
vx] = let f1 :: Double
f1 = Values Funcons -> Values Funcons -> Double
forall t. Values t -> Values t -> Double
doubleFromIEEEFormat Values Funcons
f Values Funcons
vx
                                     in Funcons -> Rewrite Rewritten
rewriteTo (Funcons -> Rewrite Rewritten) -> Funcons -> Rewrite Rewritten
forall a b. (a -> b) -> a -> b
$ Values Funcons -> Funcons
FValue (Values Funcons -> Funcons) -> Values Funcons -> Funcons
forall a b. (a -> b) -> a -> b
$ Double -> Values Funcons
forall t. Double -> Values t
IEEE_Float_64 (Double -> Double
forall a. Floating a => a -> a
acos Double
f1)
stepIEEE_Float_Acos [Values Funcons]
vn = Funcons -> String -> Rewrite Rewritten
forall a. Funcons -> String -> Rewrite a
sortErr ([Funcons] -> Funcons
ieee_float_acos ([Values Funcons] -> [Funcons]
fvalues [Values Funcons]
vn)) String
"sort check"

ieee_float_asin :: [Funcons] -> Funcons
ieee_float_asin = Name -> [Funcons] -> Funcons
applyFuncon Name
"ieee-float-asin"
stepIEEE_Float_Asin :: ValueOp
stepIEEE_Float_Asin [Values Funcons
f,Values Funcons
vx] = let f1 :: Double
f1 = Values Funcons -> Values Funcons -> Double
forall t. Values t -> Values t -> Double
doubleFromIEEEFormat Values Funcons
f Values Funcons
vx
                                     in Funcons -> Rewrite Rewritten
rewriteTo (Funcons -> Rewrite Rewritten) -> Funcons -> Rewrite Rewritten
forall a b. (a -> b) -> a -> b
$ Values Funcons -> Funcons
FValue (Values Funcons -> Funcons) -> Values Funcons -> Funcons
forall a b. (a -> b) -> a -> b
$ Double -> Values Funcons
forall t. Double -> Values t
IEEE_Float_64 (Double -> Double
forall a. Floating a => a -> a
asin Double
f1)
stepIEEE_Float_Asin [Values Funcons]
vn = Funcons -> String -> Rewrite Rewritten
forall a. Funcons -> String -> Rewrite a
sortErr ([Funcons] -> Funcons
ieee_float_asin ([Values Funcons] -> [Funcons]
fvalues [Values Funcons]
vn)) String
"sort check"

ieee_float_atan :: [Funcons] -> Funcons
ieee_float_atan = Name -> [Funcons] -> Funcons
applyFuncon Name
"ieee-float-atan"
stepIEEE_Float_Atan :: ValueOp
stepIEEE_Float_Atan [Values Funcons
f,Values Funcons
vx] = let f1 :: Double
f1 = Values Funcons -> Values Funcons -> Double
forall t. Values t -> Values t -> Double
doubleFromIEEEFormat Values Funcons
f Values Funcons
vx
                                     in Funcons -> Rewrite Rewritten
rewriteTo (Funcons -> Rewrite Rewritten) -> Funcons -> Rewrite Rewritten
forall a b. (a -> b) -> a -> b
$ Values Funcons -> Funcons
FValue (Values Funcons -> Funcons) -> Values Funcons -> Funcons
forall a b. (a -> b) -> a -> b
$ Double -> Values Funcons
forall t. Double -> Values t
IEEE_Float_64 (Double -> Double
forall a. Floating a => a -> a
atan Double
f1)
stepIEEE_Float_Atan [Values Funcons]
vn = Funcons -> String -> Rewrite Rewritten
forall a. Funcons -> String -> Rewrite a
sortErr ([Funcons] -> Funcons
ieee_float_atan ([Values Funcons] -> [Funcons]
fvalues [Values Funcons]
vn)) String
"sort check"

ieee_float_atan2 :: [Funcons] -> Funcons
ieee_float_atan2 = Name -> [Funcons] -> Funcons
applyFuncon Name
"ieee-float-atan2"
stepIEEE_Float_Atan2 :: ValueOp
stepIEEE_Float_Atan2 [Values Funcons
f,Values Funcons
vx,Values Funcons
vy] = let f1 :: Double
f1 = Values Funcons -> Values Funcons -> Double
forall t. Values t -> Values t -> Double
doubleFromIEEEFormat Values Funcons
f Values Funcons
vx
                                     f2 :: Double
f2 = Values Funcons -> Values Funcons -> Double
forall t. Values t -> Values t -> Double
doubleFromIEEEFormat Values Funcons
f Values Funcons
vy
                                 in Funcons -> Rewrite Rewritten
rewriteTo (Funcons -> Rewrite Rewritten) -> Funcons -> Rewrite Rewritten
forall a b. (a -> b) -> a -> b
$ Values Funcons -> Funcons
FValue (Values Funcons -> Funcons) -> Values Funcons -> Funcons
forall a b. (a -> b) -> a -> b
$ Double -> Values Funcons
forall t. Double -> Values t
IEEE_Float_64 (Double -> Double -> Double
forall a. RealFloat a => a -> a -> a
atan2 Double
f1 Double
f2)
stepIEEE_Float_Atan2 [Values Funcons]
vn = Funcons -> String -> Rewrite Rewritten
forall a. Funcons -> String -> Rewrite a
sortErr ([Funcons] -> Funcons
ieee_float_atan2 ([Values Funcons] -> [Funcons]
fvalues [Values Funcons]
vn)) String
"sort check"

ieee_float_cos :: [Funcons] -> Funcons
ieee_float_cos = Name -> [Funcons] -> Funcons
applyFuncon Name
"ieee-float-cos"
stepIEEE_Float_Cos :: ValueOp
stepIEEE_Float_Cos [Values Funcons
f,Values Funcons
vx] = let f1 :: Double
f1 = Values Funcons -> Values Funcons -> Double
forall t. Values t -> Values t -> Double
doubleFromIEEEFormat Values Funcons
f Values Funcons
vx
                                     in Funcons -> Rewrite Rewritten
rewriteTo (Funcons -> Rewrite Rewritten) -> Funcons -> Rewrite Rewritten
forall a b. (a -> b) -> a -> b
$ Values Funcons -> Funcons
FValue (Values Funcons -> Funcons) -> Values Funcons -> Funcons
forall a b. (a -> b) -> a -> b
$ Double -> Values Funcons
forall t. Double -> Values t
IEEE_Float_64 (Double -> Double
forall a. Floating a => a -> a
cos Double
f1)
stepIEEE_Float_Cos [Values Funcons]
vn = Funcons -> String -> Rewrite Rewritten
forall a. Funcons -> String -> Rewrite a
sortErr ([Funcons] -> Funcons
ieee_float_cos ([Values Funcons] -> [Funcons]
fvalues [Values Funcons]
vn)) String
"sort check"

ieee_float_cosh :: [Funcons] -> Funcons
ieee_float_cosh = Name -> [Funcons] -> Funcons
applyFuncon Name
"ieee-float-cosh"
stepIEEE_Float_Cosh :: ValueOp
stepIEEE_Float_Cosh [Values Funcons
f,Values Funcons
vx] = let f1 :: Double
f1 = Values Funcons -> Values Funcons -> Double
forall t. Values t -> Values t -> Double
doubleFromIEEEFormat Values Funcons
f Values Funcons
vx
                                     in Funcons -> Rewrite Rewritten
rewriteTo (Funcons -> Rewrite Rewritten) -> Funcons -> Rewrite Rewritten
forall a b. (a -> b) -> a -> b
$ Values Funcons -> Funcons
FValue (Values Funcons -> Funcons) -> Values Funcons -> Funcons
forall a b. (a -> b) -> a -> b
$ Double -> Values Funcons
forall t. Double -> Values t
IEEE_Float_64 (Double -> Double
forall a. Floating a => a -> a
cosh Double
f1)
stepIEEE_Float_Cosh [Values Funcons]
vn = Funcons -> String -> Rewrite Rewritten
forall a. Funcons -> String -> Rewrite a
sortErr ([Funcons] -> Funcons
ieee_float_cosh ([Values Funcons] -> [Funcons]
fvalues [Values Funcons]
vn)) String
"sort check"

ieee_float_exp :: [Funcons] -> Funcons
ieee_float_exp = Name -> [Funcons] -> Funcons
applyFuncon Name
"ieee-float-exp"
stepIEEE_Float_Exp :: ValueOp
stepIEEE_Float_Exp [Values Funcons
f,Values Funcons
vx] = let f1 :: Double
f1 = Values Funcons -> Values Funcons -> Double
forall t. Values t -> Values t -> Double
doubleFromIEEEFormat Values Funcons
f Values Funcons
vx
                                     in Funcons -> Rewrite Rewritten
rewriteTo (Funcons -> Rewrite Rewritten) -> Funcons -> Rewrite Rewritten
forall a b. (a -> b) -> a -> b
$ Values Funcons -> Funcons
FValue (Values Funcons -> Funcons) -> Values Funcons -> Funcons
forall a b. (a -> b) -> a -> b
$ Double -> Values Funcons
forall t. Double -> Values t
IEEE_Float_64 (Double -> Double
forall a. Floating a => a -> a
exp Double
f1)
stepIEEE_Float_Exp [Values Funcons]
vn = Funcons -> String -> Rewrite Rewritten
forall a. Funcons -> String -> Rewrite a
sortErr ([Funcons] -> Funcons
ieee_float_exp ([Values Funcons] -> [Funcons]
fvalues [Values Funcons]
vn)) String
"sort check"

ieee_float_log :: [Funcons] -> Funcons
ieee_float_log = Name -> [Funcons] -> Funcons
applyFuncon Name
"ieee-float-log"
stepIEEE_Float_Log :: ValueOp
stepIEEE_Float_Log [Values Funcons
f,Values Funcons
vx] = let f1 :: Double
f1 = Values Funcons -> Values Funcons -> Double
forall t. Values t -> Values t -> Double
doubleFromIEEEFormat Values Funcons
f Values Funcons
vx
                                     in Funcons -> Rewrite Rewritten
rewriteTo (Funcons -> Rewrite Rewritten) -> Funcons -> Rewrite Rewritten
forall a b. (a -> b) -> a -> b
$ Values Funcons -> Funcons
FValue (Values Funcons -> Funcons) -> Values Funcons -> Funcons
forall a b. (a -> b) -> a -> b
$ Double -> Values Funcons
forall t. Double -> Values t
IEEE_Float_64 (Double -> Double
forall a. Floating a => a -> a
log Double
f1)
stepIEEE_Float_Log [Values Funcons]
vn = Funcons -> String -> Rewrite Rewritten
forall a. Funcons -> String -> Rewrite a
sortErr ([Funcons] -> Funcons
ieee_float_log ([Values Funcons] -> [Funcons]
fvalues [Values Funcons]
vn)) String
"sort check"

ieee_float_log10 :: [Funcons] -> Funcons
ieee_float_log10 = Name -> [Funcons] -> Funcons
applyFuncon Name
"ieee-float-log10"
stepIEEE_Float_Log10 :: ValueOp
stepIEEE_Float_Log10 [Values Funcons
f,Values Funcons
vx] = let f1 :: Double
f1 = Values Funcons -> Values Funcons -> Double
forall t. Values t -> Values t -> Double
doubleFromIEEEFormat Values Funcons
f Values Funcons
vx
                                     in Funcons -> Rewrite Rewritten
rewriteTo (Funcons -> Rewrite Rewritten) -> Funcons -> Rewrite Rewritten
forall a b. (a -> b) -> a -> b
$ Values Funcons -> Funcons
FValue (Values Funcons -> Funcons) -> Values Funcons -> Funcons
forall a b. (a -> b) -> a -> b
$ Double -> Values Funcons
forall t. Double -> Values t
IEEE_Float_64 (Double -> Double -> Double
forall a. Floating a => a -> a -> a
logBase Double
10 Double
f1)
stepIEEE_Float_Log10 [Values Funcons]
vn = Funcons -> String -> Rewrite Rewritten
forall a. Funcons -> String -> Rewrite a
sortErr ([Funcons] -> Funcons
ieee_float_log10 ([Values Funcons] -> [Funcons]
fvalues [Values Funcons]
vn)) String
"sort check"

ieee_float_sin :: [Funcons] -> Funcons
ieee_float_sin = Name -> [Funcons] -> Funcons
applyFuncon Name
"ieee-float-sin"
stepIEEE_Float_Sin :: ValueOp
stepIEEE_Float_Sin [Values Funcons
f,Values Funcons
vx] = let f1 :: Double
f1 = Values Funcons -> Values Funcons -> Double
forall t. Values t -> Values t -> Double
doubleFromIEEEFormat Values Funcons
f Values Funcons
vx
                                     in Funcons -> Rewrite Rewritten
rewriteTo (Funcons -> Rewrite Rewritten) -> Funcons -> Rewrite Rewritten
forall a b. (a -> b) -> a -> b
$ Values Funcons -> Funcons
FValue (Values Funcons -> Funcons) -> Values Funcons -> Funcons
forall a b. (a -> b) -> a -> b
$ Double -> Values Funcons
forall t. Double -> Values t
IEEE_Float_64 (Double -> Double
forall a. Floating a => a -> a
sin Double
f1)
stepIEEE_Float_Sin [Values Funcons]
vn = Funcons -> String -> Rewrite Rewritten
forall a. Funcons -> String -> Rewrite a
sortErr ([Funcons] -> Funcons
ieee_float_sin ([Values Funcons] -> [Funcons]
fvalues [Values Funcons]
vn)) String
"sort check"

ieee_float_sinh :: [Funcons] -> Funcons
ieee_float_sinh = Name -> [Funcons] -> Funcons
applyFuncon Name
"ieee-float-sinh"
stepIEEE_Float_Sinh :: ValueOp
stepIEEE_Float_Sinh [Values Funcons
f,Values Funcons
vx] = let f1 :: Double
f1 = Values Funcons -> Values Funcons -> Double
forall t. Values t -> Values t -> Double
doubleFromIEEEFormat Values Funcons
f Values Funcons
vx
                                     in Funcons -> Rewrite Rewritten
rewriteTo (Funcons -> Rewrite Rewritten) -> Funcons -> Rewrite Rewritten
forall a b. (a -> b) -> a -> b
$ Values Funcons -> Funcons
FValue (Values Funcons -> Funcons) -> Values Funcons -> Funcons
forall a b. (a -> b) -> a -> b
$ Double -> Values Funcons
forall t. Double -> Values t
IEEE_Float_64 (Double -> Double
forall a. Floating a => a -> a
sinh Double
f1)
stepIEEE_Float_Sinh [Values Funcons]
vn = Funcons -> String -> Rewrite Rewritten
forall a. Funcons -> String -> Rewrite a
sortErr ([Funcons] -> Funcons
ieee_float_sinh ([Values Funcons] -> [Funcons]
fvalues [Values Funcons]
vn)) String
"sort check"

ieee_float_sqrt :: [Funcons] -> Funcons
ieee_float_sqrt = Name -> [Funcons] -> Funcons
applyFuncon Name
"ieee-float-sqrt"
stepIEEE_Float_Sqrt :: ValueOp
stepIEEE_Float_Sqrt [Values Funcons
f,Values Funcons
vx] = let f1 :: Double
f1 = Values Funcons -> Values Funcons -> Double
forall t. Values t -> Values t -> Double
doubleFromIEEEFormat Values Funcons
f Values Funcons
vx
                                     in Funcons -> Rewrite Rewritten
rewriteTo (Funcons -> Rewrite Rewritten) -> Funcons -> Rewrite Rewritten
forall a b. (a -> b) -> a -> b
$ Values Funcons -> Funcons
FValue (Values Funcons -> Funcons) -> Values Funcons -> Funcons
forall a b. (a -> b) -> a -> b
$ Double -> Values Funcons
forall t. Double -> Values t
IEEE_Float_64 (Double -> Double
forall a. Floating a => a -> a
sqrt Double
f1)
stepIEEE_Float_Sqrt [Values Funcons]
vn = Funcons -> String -> Rewrite Rewritten
forall a. Funcons -> String -> Rewrite a
sortErr ([Funcons] -> Funcons
ieee_float_sqrt ([Values Funcons] -> [Funcons]
fvalues [Values Funcons]
vn)) String
"sort check"

ieee_float_tan :: [Funcons] -> Funcons
ieee_float_tan = Name -> [Funcons] -> Funcons
applyFuncon Name
"ieee-float-tan"
stepIEEE_Float_Tan :: ValueOp
stepIEEE_Float_Tan [Values Funcons
f,Values Funcons
vx] = let f1 :: Double
f1 = Values Funcons -> Values Funcons -> Double
forall t. Values t -> Values t -> Double
doubleFromIEEEFormat Values Funcons
f Values Funcons
vx
                                     in Funcons -> Rewrite Rewritten
rewriteTo (Funcons -> Rewrite Rewritten) -> Funcons -> Rewrite Rewritten
forall a b. (a -> b) -> a -> b
$ Values Funcons -> Funcons
FValue (Values Funcons -> Funcons) -> Values Funcons -> Funcons
forall a b. (a -> b) -> a -> b
$ Double -> Values Funcons
forall t. Double -> Values t
IEEE_Float_64 (Double -> Double
forall a. Floating a => a -> a
tan Double
f1)
stepIEEE_Float_Tan [Values Funcons]
vn = Funcons -> String -> Rewrite Rewritten
forall a. Funcons -> String -> Rewrite a
sortErr ([Funcons] -> Funcons
ieee_float_tan ([Values Funcons] -> [Funcons]
fvalues [Values Funcons]
vn)) String
"sort check"

ieee_float_tanh :: [Funcons] -> Funcons
ieee_float_tanh = Name -> [Funcons] -> Funcons
applyFuncon Name
"ieee-float-tanh"
stepIEEE_Float_Tanh :: ValueOp
stepIEEE_Float_Tanh [Values Funcons
f,Values Funcons
vx] = let f1 :: Double
f1 = Values Funcons -> Values Funcons -> Double
forall t. Values t -> Values t -> Double
doubleFromIEEEFormat Values Funcons
f Values Funcons
vx
                                     in Funcons -> Rewrite Rewritten
rewriteTo (Funcons -> Rewrite Rewritten) -> Funcons -> Rewrite Rewritten
forall a b. (a -> b) -> a -> b
$ Values Funcons -> Funcons
FValue (Values Funcons -> Funcons) -> Values Funcons -> Funcons
forall a b. (a -> b) -> a -> b
$ Double -> Values Funcons
forall t. Double -> Values t
IEEE_Float_64 (Double -> Double
forall a. Floating a => a -> a
tanh Double
f1)
stepIEEE_Float_Tanh [Values Funcons]
vn = Funcons -> String -> Rewrite Rewritten
forall a. Funcons -> String -> Rewrite a
sortErr ([Funcons] -> Funcons
ieee_float_tanh ([Values Funcons] -> [Funcons]
fvalues [Values Funcons]
vn)) String
"sort check"

ieee_float_ceiling :: [Funcons] -> Funcons
ieee_float_ceiling = Name -> [Funcons] -> Funcons
applyFuncon Name
"ieee-float-ceiling"
stepIEEE_Float_Ceiling :: ValueOp
stepIEEE_Float_Ceiling [Values Funcons
f,Values Funcons
vx] = let f1 :: Double
f1 = Values Funcons -> Values Funcons -> Double
forall t. Values t -> Values t -> Double
doubleFromIEEEFormat Values Funcons
f Values Funcons
vx
                                     in Funcons -> Rewrite Rewritten
rewriteTo (Funcons -> Rewrite Rewritten) -> Funcons -> Rewrite Rewritten
forall a b. (a -> b) -> a -> b
$ Int -> Funcons
int_ (Double -> Int
forall a b. (RealFrac a, Integral b) => a -> b
ceiling Double
f1)
stepIEEE_Float_Ceiling [Values Funcons]
vn = Funcons -> String -> Rewrite Rewritten
forall a. Funcons -> String -> Rewrite a
sortErr ([Funcons] -> Funcons
ieee_float_ceiling ([Values Funcons] -> [Funcons]
fvalues [Values Funcons]
vn)) String
"sort check"

ieee_float_floor :: [Funcons] -> Funcons
ieee_float_floor = Name -> [Funcons] -> Funcons
applyFuncon Name
"ieee-float-floor"
stepIEEE_Float_Floor :: ValueOp
stepIEEE_Float_Floor [Values Funcons
f,Values Funcons
vx] = let f1 :: Double
f1 = Values Funcons -> Values Funcons -> Double
forall t. Values t -> Values t -> Double
doubleFromIEEEFormat Values Funcons
f Values Funcons
vx
                                     in Funcons -> Rewrite Rewritten
rewriteTo (Funcons -> Rewrite Rewritten) -> Funcons -> Rewrite Rewritten
forall a b. (a -> b) -> a -> b
$ Int -> Funcons
int_ (Double -> Int
forall a b. (RealFrac a, Integral b) => a -> b
floor Double
f1)
stepIEEE_Float_Floor [Values Funcons]
vn = Funcons -> String -> Rewrite Rewritten
forall a. Funcons -> String -> Rewrite a
sortErr ([Funcons] -> Funcons
ieee_float_floor ([Values Funcons] -> [Funcons]
fvalues [Values Funcons]
vn)) String
"sort check"

ieee_float_absolute_value :: [Funcons] -> Funcons
ieee_float_absolute_value = Name -> [Funcons] -> Funcons
applyFuncon Name
"ieee-float-absolute-value"
stepIEEE_Float_Absolute_Value :: ValueOp
stepIEEE_Float_Absolute_Value [Values Funcons
f,Values Funcons
vx] = let f1 :: Double
f1 = Values Funcons -> Values Funcons -> Double
forall t. Values t -> Values t -> Double
doubleFromIEEEFormat Values Funcons
f Values Funcons
vx
                                     in Funcons -> Rewrite Rewritten
rewriteTo (Funcons -> Rewrite Rewritten) -> Funcons -> Rewrite Rewritten
forall a b. (a -> b) -> a -> b
$ Values Funcons -> Funcons
FValue (Values Funcons -> Funcons) -> Values Funcons -> Funcons
forall a b. (a -> b) -> a -> b
$ Double -> Values Funcons
forall t. Double -> Values t
IEEE_Float_64 (Double -> Double
forall a. Num a => a -> a
Prelude.abs Double
f1)
stepIEEE_Float_Absolute_Value [Values Funcons]
vn = Funcons -> String -> Rewrite Rewritten
forall a. Funcons -> String -> Rewrite a
sortErr ([Funcons] -> Funcons
ieee_float_absolute_value ([Values Funcons] -> [Funcons]
fvalues [Values Funcons]
vn)) String
"sort check"

stepIEEE_Float_Remainder :: ValueOp
stepIEEE_Float_Remainder [Values Funcons
f,Values Funcons
f1,Values Funcons
f2] = Values Funcons
-> Values Funcons -> Values Funcons -> Rewrite Rewritten
ieee_float_remainder_op Values Funcons
f Values Funcons
f1 Values Funcons
f2
stepIEEE_Float_Remainder [Values Funcons]
vn = Funcons -> String -> Rewrite Rewritten
forall a. Funcons -> String -> Rewrite a
sortErr ([Funcons] -> Funcons
ieee_float_remainder ([Values Funcons] -> [Funcons]
fvalues [Values Funcons]
vn)) String
"sort check"

stepIEEE_Float_Is_Less :: ValueOp
stepIEEE_Float_Is_Less [Values Funcons
f,Values Funcons
f1,Values Funcons
f2] = Values Funcons
-> Values Funcons -> Values Funcons -> Rewrite Rewritten
ieee_float_is_less_op Values Funcons
f Values Funcons
f1 Values Funcons
f2
stepIEEE_Float_Is_Less [Values Funcons]
vn = Funcons -> String -> Rewrite Rewritten
forall a. Funcons -> String -> Rewrite a
sortErr ([Funcons] -> Funcons
ieee_float_is_less ([Values Funcons] -> [Funcons]
fvalues [Values Funcons]
vn)) String
"sort check"
stepIEEE_Float_Is_Greater :: ValueOp
stepIEEE_Float_Is_Greater [Values Funcons
f,Values Funcons
f1,Values Funcons
f2] = Values Funcons
-> Values Funcons -> Values Funcons -> Rewrite Rewritten
ieee_float_is_greater_op Values Funcons
f Values Funcons
f1 Values Funcons
f2
stepIEEE_Float_Is_Greater [Values Funcons]
vn = Funcons -> String -> Rewrite Rewritten
forall a. Funcons -> String -> Rewrite a
sortErr ([Funcons] -> Funcons
ieee_float_is_greater ([Values Funcons] -> [Funcons]
fvalues [Values Funcons]
vn)) String
"sort check"
stepIEEE_Float_Is_Less_Or_Equal :: ValueOp
stepIEEE_Float_Is_Less_Or_Equal [Values Funcons
f,Values Funcons
f1,Values Funcons
f2] = Values Funcons
-> Values Funcons -> Values Funcons -> Rewrite Rewritten
ieee_float_is_less_or_equal_op Values Funcons
f Values Funcons
f1 Values Funcons
f2
stepIEEE_Float_Is_Less_Or_Equal [Values Funcons]
vn = Funcons -> String -> Rewrite Rewritten
forall a. Funcons -> String -> Rewrite a
sortErr ([Funcons] -> Funcons
ieee_float_is_less_or_equal ([Values Funcons] -> [Funcons]
fvalues [Values Funcons]
vn)) String
"sort check"
stepIEEE_Float_Is_Greater_Or_Equal :: ValueOp
stepIEEE_Float_Is_Greater_Or_Equal [Values Funcons
f,Values Funcons
f1,Values Funcons
f2] = Values Funcons
-> Values Funcons -> Values Funcons -> Rewrite Rewritten
ieee_float_is_greater_or_equal_op Values Funcons
f Values Funcons
f1 Values Funcons
f2
stepIEEE_Float_Is_Greater_Or_Equal [Values Funcons]
vn = Funcons -> String -> Rewrite Rewritten
forall a. Funcons -> String -> Rewrite a
sortErr ([Funcons] -> Funcons
ieee_float_is_greater_or_equal ([Values Funcons] -> [Funcons]
fvalues [Values Funcons]
vn)) String
"sort check"


ieee_float_op :: String -> ([Funcons] -> Funcons)
               -> (Double -> Double -> Double) 
                -> Double -> Funcons.EDSL.Values -> [Funcons.EDSL.Values] -> Rewrite Rewritten
ieee_float_op :: String
-> ([Funcons] -> Funcons)
-> (Double -> Double -> Double)
-> Double
-> Values Funcons
-> ValueOp
ieee_float_op String
str [Funcons] -> Funcons
cons Double -> Double -> Double
f Double
b Values Funcons
format [Values Funcons]
vs
    | (Values Funcons -> Bool) -> [Values Funcons] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all (Values Funcons -> Values Funcons -> Bool
forall t. Values t -> Values t -> Bool
isIEEEFormat Values Funcons
format) [Values Funcons]
vs = Funcons -> Rewrite Rewritten
rewriteTo (Funcons -> Rewrite Rewritten) -> Funcons -> Rewrite Rewritten
forall a b. (a -> b) -> a -> b
$ Values Funcons -> Funcons
FValue (Values Funcons -> Funcons) -> Values Funcons -> Funcons
forall a b. (a -> b) -> a -> b
$ Double -> Values Funcons
forall t. Double -> Values t
IEEE_Float_64
        (Double -> Values Funcons) -> Double -> Values Funcons
forall a b. (a -> b) -> a -> b
$ (Double -> Double -> Double) -> Double -> [Double] -> Double
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr Double -> Double -> Double
f Double
b ([Double] -> Double) -> [Double] -> Double
forall a b. (a -> b) -> a -> b
$ (Values Funcons -> Double) -> [Values Funcons] -> [Double]
forall a b. (a -> b) -> [a] -> [b]
map (Values Funcons -> Values Funcons -> Double
forall t. Values t -> Values t -> Double
doubleFromIEEEFormat Values Funcons
format) [Values Funcons]
vs
    | Bool
otherwise = Funcons -> String -> Rewrite Rewritten
forall a. Funcons -> String -> Rewrite a
sortErr ([Funcons] -> Funcons
cons ((Values Funcons -> Funcons) -> [Values Funcons] -> [Funcons]
forall a b. (a -> b) -> [a] -> [b]
map Values Funcons -> Funcons
FValue [Values Funcons]
vs)) String
err
    where   err :: String
err     = String
str String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" not applied to ieee_floats"

ieee_float_add :: [Funcons] -> Funcons
ieee_float_add = Name -> [Funcons] -> Funcons
applyFuncon Name
"ieee-float-add"
ieee_float_add_op :: ValueOp
ieee_float_add_op (Values Funcons
format:[Values Funcons]
vs) = String
-> ([Funcons] -> Funcons)
-> (Double -> Double -> Double)
-> Double
-> Values Funcons
-> ValueOp
ieee_float_op String
"ieee_float-add" [Funcons] -> Funcons
ieee_float_add Double -> Double -> Double
forall a. Num a => a -> a -> a
(+) Double
0 Values Funcons
format [Values Funcons]
vs
ieee_float_add_op [] = Funcons -> String -> Rewrite Rewritten
forall a. Funcons -> String -> Rewrite a
sortErr ([Funcons] -> Funcons
ieee_float_add [Values Funcons -> Funcons
FValue (Name -> [Funcons] -> Values Funcons
forall t. Name -> [t] -> Values t
ADTVal Name
"list" [])]) String
"ieee-float-add not applied to a format and a list of floats"

ieee_float_multiply_ :: [Funcons] -> Funcons
ieee_float_multiply_ = [Funcons] -> Funcons
ieee_float_multiply 
ieee_float_multiply :: [Funcons] -> Funcons
ieee_float_multiply = Name -> [Funcons] -> Funcons
applyFuncon Name
"ieee-float-multiply"
ieee_float_multiply_op :: ValueOp
ieee_float_multiply_op (Values Funcons
format:[Values Funcons]
vs) = String
-> ([Funcons] -> Funcons)
-> (Double -> Double -> Double)
-> Double
-> Values Funcons
-> ValueOp
ieee_float_op String
"ieee_float-multiply" [Funcons] -> Funcons
ieee_float_multiply Double -> Double -> Double
forall a. Num a => a -> a -> a
(*) Double
1 Values Funcons
format [Values Funcons]
vs
ieee_float_multiply_op [] = Funcons -> String -> Rewrite Rewritten
forall a. Funcons -> String -> Rewrite a
sortErr ([Funcons] -> Funcons
ieee_float_multiply [Values Funcons -> Funcons
FValue (Name -> [Funcons] -> Values Funcons
forall t. Name -> [t] -> Values t
ADTVal Name
"list" [])]) String
"ieee-float-multiply not applied to a format and a list of floats"

ieee_float_divide :: [Funcons] -> Funcons
ieee_float_divide = Name -> [Funcons] -> Funcons
applyFuncon Name
"ieee-float-divide"
ieee_float_divide_op :: Values Funcons
-> Values Funcons -> Values Funcons -> Rewrite Rewritten
ieee_float_divide_op Values Funcons
format Values Funcons
vx Values Funcons
vy
    | Values Funcons -> Values Funcons -> Bool
forall t. Values t -> Values t -> Bool
isIEEEFormat Values Funcons
format Values Funcons
vx Bool -> Bool -> Bool
&& Values Funcons -> Values Funcons -> Bool
forall t. Values t -> Values t -> Bool
isIEEEFormat Values Funcons
format Values Funcons
vy =
        let f1 :: Double
f1 = Values Funcons -> Values Funcons -> Double
forall t. Values t -> Values t -> Double
doubleFromIEEEFormat Values Funcons
format Values Funcons
vx
            f2 :: Double
f2 = Values Funcons -> Values Funcons -> Double
forall t. Values t -> Values t -> Double
doubleFromIEEEFormat Values Funcons
format Values Funcons
vy
        in Funcons -> Rewrite Rewritten
rewriteTo (Funcons -> Rewrite Rewritten) -> Funcons -> Rewrite Rewritten
forall a b. (a -> b) -> a -> b
$ Values Funcons -> Funcons
FValue (Values Funcons -> Funcons) -> Values Funcons -> Funcons
forall a b. (a -> b) -> a -> b
$ Double -> Values Funcons
forall t. Double -> Values t
IEEE_Float_64 (Double -> Values Funcons) -> Double -> Values Funcons
forall a b. (a -> b) -> a -> b
$ (Double
f1 Double -> Double -> Double
forall a. Fractional a => a -> a -> a
/ Double
f2)
ieee_float_divide_op Values Funcons
ft Values Funcons
vx Values Funcons
vy = Funcons -> String -> Rewrite Rewritten
forall a. Funcons -> String -> Rewrite a
sortErr ([Funcons] -> Funcons
ieee_float_divide [Values Funcons -> Funcons
FValue Values Funcons
ft,Values Funcons -> Funcons
FValue Values Funcons
vx, Values Funcons -> Funcons
FValue Values Funcons
vy])
                         String
"ieee-float-divide not applied to a format and ieee-floats"

ieee_float_remainder :: [Funcons] -> Funcons
ieee_float_remainder = Name -> [Funcons] -> Funcons
applyFuncon Name
"ieee-float-remainder"
ieee_float_remainder_op :: Values Funcons
-> Values Funcons -> Values Funcons -> Rewrite Rewritten
ieee_float_remainder_op Values Funcons
format Values Funcons
vx Values Funcons
vy
    | Values Funcons -> Values Funcons -> Bool
forall t. Values t -> Values t -> Bool
isIEEEFormat Values Funcons
format Values Funcons
vx =
        let f1 :: Double
f1 = Values Funcons -> Values Funcons -> Double
forall t. Values t -> Values t -> Double
doubleFromIEEEFormat Values Funcons
format Values Funcons
vx
            f2 :: Double
f2 = Values Funcons -> Values Funcons -> Double
forall t. Values t -> Values t -> Double
doubleFromIEEEFormat Values Funcons
format Values Funcons
vy
        in Funcons -> Rewrite Rewritten
rewriteTo (Funcons -> Rewrite Rewritten) -> Funcons -> Rewrite Rewritten
forall a b. (a -> b) -> a -> b
$ Values Funcons -> Funcons
FValue (Values Funcons -> Funcons) -> Values Funcons -> Funcons
forall a b. (a -> b) -> a -> b
$ Double -> Values Funcons
forall t. Double -> Values t
IEEE_Float_64 (Double -> Values Funcons) -> Double -> Values Funcons
forall a b. (a -> b) -> a -> b
$ (Double
f1 Double -> Double -> Double
forall a. Real a => a -> a -> a
`mod'` Double
f2)
ieee_float_remainder_op Values Funcons
ft Values Funcons
vx Values Funcons
vy = Funcons -> String -> Rewrite Rewritten
forall a. Funcons -> String -> Rewrite a
sortErr ([Funcons] -> Funcons
ieee_float_remainder [Values Funcons -> Funcons
FValue Values Funcons
ft,Values Funcons -> Funcons
FValue Values Funcons
vx, Values Funcons -> Funcons
FValue Values Funcons
vy])
                         String
"ieee-float-remainder not applied to a format and ieee-floats"

ieee_float_negate :: [Funcons] -> Funcons
ieee_float_negate = Name -> [Funcons] -> Funcons
applyFuncon Name
"ieee-float-negate"
ieee_float_negate_op :: Values Funcons -> Values Funcons -> Rewrite Rewritten
ieee_float_negate_op Values Funcons
format Values Funcons
vx
    | Values Funcons -> Values Funcons -> Bool
forall t. Values t -> Values t -> Bool
isIEEEFormat Values Funcons
format Values Funcons
vx = let f1 :: Double
f1 = Values Funcons -> Values Funcons -> Double
forall t. Values t -> Values t -> Double
doubleFromIEEEFormat Values Funcons
format Values Funcons
vx
                               in Funcons -> Rewrite Rewritten
rewriteTo (Funcons -> Rewrite Rewritten) -> Funcons -> Rewrite Rewritten
forall a b. (a -> b) -> a -> b
$ Values Funcons -> Funcons
FValue (Values Funcons -> Funcons) -> Values Funcons -> Funcons
forall a b. (a -> b) -> a -> b
$ Double -> Values Funcons
forall t. Double -> Values t
IEEE_Float_64 (-Double
f1)
    | Bool
otherwise = Funcons -> String -> Rewrite Rewritten
forall a. Funcons -> String -> Rewrite a
sortErr ([Funcons] -> Funcons
ieee_float_negate [Values Funcons -> Funcons
FValue Values Funcons
format,Values Funcons -> Funcons
FValue Values Funcons
vx]) String
"ieee-float-negate not applied to ieee-float"

ieee_float_subtract :: [Funcons] -> Funcons
ieee_float_subtract = Name -> [Funcons] -> Funcons
applyFuncon Name
"ieee-float-subtract"
ieee_float_subtract_op :: Values Funcons
-> Values Funcons -> Values Funcons -> Rewrite Rewritten
ieee_float_subtract_op Values Funcons
format Values Funcons
vx Values Funcons
vy
    | Values Funcons -> Values Funcons -> Bool
forall t. Values t -> Values t -> Bool
isIEEEFormat Values Funcons
format Values Funcons
vx Bool -> Bool -> Bool
&& Values Funcons -> Values Funcons -> Bool
forall t. Values t -> Values t -> Bool
isIEEEFormat Values Funcons
format Values Funcons
vy =
        let f1 :: Double
f1 = Values Funcons -> Values Funcons -> Double
forall t. Values t -> Values t -> Double
doubleFromIEEEFormat Values Funcons
format Values Funcons
vx
            f2 :: Double
f2 = Values Funcons -> Values Funcons -> Double
forall t. Values t -> Values t -> Double
doubleFromIEEEFormat Values Funcons
format Values Funcons
vy
        in Funcons -> Rewrite Rewritten
rewriteTo (Funcons -> Rewrite Rewritten) -> Funcons -> Rewrite Rewritten
forall a b. (a -> b) -> a -> b
$ Values Funcons -> Funcons
FValue (Values Funcons -> Funcons) -> Values Funcons -> Funcons
forall a b. (a -> b) -> a -> b
$ Double -> Values Funcons
forall t. Double -> Values t
IEEE_Float_64 (Double -> Values Funcons) -> Double -> Values Funcons
forall a b. (a -> b) -> a -> b
$ (Double
f1 Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
f2)
ieee_float_subtract_op Values Funcons
ft Values Funcons
vx Values Funcons
vy = Funcons -> String -> Rewrite Rewritten
forall a. Funcons -> String -> Rewrite a
sortErr ([Funcons] -> Funcons
ieee_float_subtract [Values Funcons -> Funcons
FValue Values Funcons
ft, Values Funcons -> Funcons
FValue Values Funcons
vx, Values Funcons -> Funcons
FValue Values Funcons
vy])
                         String
"ieee-float-subtract not applied to a format and ieee-floats"

ieee_float_float_power :: [Funcons] -> Funcons
ieee_float_float_power = Name -> [Funcons] -> Funcons
applyFuncon Name
"ieee-float-float-power"
ieee_float_power_op :: Values Funcons
-> Values Funcons -> Values Funcons -> Rewrite Rewritten
ieee_float_power_op Values Funcons
format Values Funcons
vx Values Funcons
vy
    | Values Funcons -> Values Funcons -> Bool
forall t. Values t -> Values t -> Bool
isIEEEFormat Values Funcons
format Values Funcons
vx Bool -> Bool -> Bool
&& Values Funcons -> Values Funcons -> Bool
forall t. Values t -> Values t -> Bool
isIEEEFormat Values Funcons
format Values Funcons
vy =
        let f1 :: Double
f1 = Values Funcons -> Values Funcons -> Double
forall t. Values t -> Values t -> Double
doubleFromIEEEFormat Values Funcons
format Values Funcons
vx
            f2 :: Double
f2 = Values Funcons -> Values Funcons -> Double
forall t. Values t -> Values t -> Double
doubleFromIEEEFormat Values Funcons
format Values Funcons
vy
        in Funcons -> Rewrite Rewritten
rewriteTo (Funcons -> Rewrite Rewritten) -> Funcons -> Rewrite Rewritten
forall a b. (a -> b) -> a -> b
$ Values Funcons -> Funcons
FValue (Values Funcons -> Funcons) -> Values Funcons -> Funcons
forall a b. (a -> b) -> a -> b
$ Double -> Values Funcons
forall t. Double -> Values t
IEEE_Float_64 (Double -> Values Funcons) -> Double -> Values Funcons
forall a b. (a -> b) -> a -> b
$ (Double
f1 Double -> Double -> Double
forall a. Floating a => a -> a -> a
** Double
f2)
ieee_float_power_op Values Funcons
ft Values Funcons
vx Values Funcons
vy = Funcons -> String -> Rewrite Rewritten
forall a. Funcons -> String -> Rewrite a
sortErr ([Funcons] -> Funcons
ieee_float_float_power [Values Funcons -> Funcons
FValue Values Funcons
ft, Values Funcons -> Funcons
FValue Values Funcons
vx, Values Funcons -> Funcons
FValue Values Funcons
vy])
                         String
"ieee-float-power not applied to a format and ieee-floats"

ieee_float_is_less :: [Funcons] -> Funcons
ieee_float_is_less = Name -> [Funcons] -> Funcons
applyFuncon Name
"ieee-float-is-less"
ieee_float_is_less_op :: Values Funcons
-> Values Funcons -> Values Funcons -> Rewrite Rewritten
ieee_float_is_less_op Values Funcons
format Values Funcons
vx Values Funcons
vy
    | Values Funcons -> Values Funcons -> Bool
forall t. Values t -> Values t -> Bool
isIEEEFormat Values Funcons
format Values Funcons
vx Bool -> Bool -> Bool
&& Values Funcons -> Values Funcons -> Bool
forall t. Values t -> Values t -> Bool
isIEEEFormat Values Funcons
format Values Funcons
vy =
        let f1 :: Double
f1 = Values Funcons -> Values Funcons -> Double
forall t. Values t -> Values t -> Double
doubleFromIEEEFormat Values Funcons
format Values Funcons
vx
            f2 :: Double
f2 = Values Funcons -> Values Funcons -> Double
forall t. Values t -> Values t -> Double
doubleFromIEEEFormat Values Funcons
format Values Funcons
vy
        in Funcons -> Rewrite Rewritten
rewriteTo (Funcons -> Rewrite Rewritten) -> Funcons -> Rewrite Rewritten
forall a b. (a -> b) -> a -> b
$ Values Funcons -> Funcons
FValue (Values Funcons -> Funcons) -> Values Funcons -> Funcons
forall a b. (a -> b) -> a -> b
$ Bool -> Values Funcons
forall t. Bool -> Values t
tobool (Double
f1 Double -> Double -> Bool
forall a. Ord a => a -> a -> Bool
< Double
f2)
ieee_float_is_less_op Values Funcons
ft Values Funcons
vx Values Funcons
vy = Funcons -> String -> Rewrite Rewritten
forall a. Funcons -> String -> Rewrite a
sortErr ([Funcons] -> Funcons
ieee_float_is_less [Values Funcons -> Funcons
FValue Values Funcons
ft, Values Funcons -> Funcons
FValue Values Funcons
vx, Values Funcons -> Funcons
FValue Values Funcons
vy])
                         String
"ieee-float-is-less not applied to a format and ieee-floats"

ieee_float_is_greater :: [Funcons] -> Funcons
ieee_float_is_greater = Name -> [Funcons] -> Funcons
applyFuncon Name
"ieee-float-is-greater"
ieee_float_is_greater_op :: Values Funcons
-> Values Funcons -> Values Funcons -> Rewrite Rewritten
ieee_float_is_greater_op Values Funcons
format Values Funcons
vx Values Funcons
vy
    | Values Funcons -> Values Funcons -> Bool
forall t. Values t -> Values t -> Bool
isIEEEFormat Values Funcons
format Values Funcons
vx Bool -> Bool -> Bool
&& Values Funcons -> Values Funcons -> Bool
forall t. Values t -> Values t -> Bool
isIEEEFormat Values Funcons
format Values Funcons
vy =
        let f1 :: Double
f1 = Values Funcons -> Values Funcons -> Double
forall t. Values t -> Values t -> Double
doubleFromIEEEFormat Values Funcons
format Values Funcons
vx
            f2 :: Double
f2 = Values Funcons -> Values Funcons -> Double
forall t. Values t -> Values t -> Double
doubleFromIEEEFormat Values Funcons
format Values Funcons
vy
        in Funcons -> Rewrite Rewritten
rewriteTo (Funcons -> Rewrite Rewritten) -> Funcons -> Rewrite Rewritten
forall a b. (a -> b) -> a -> b
$ Values Funcons -> Funcons
FValue (Values Funcons -> Funcons) -> Values Funcons -> Funcons
forall a b. (a -> b) -> a -> b
$ Bool -> Values Funcons
forall t. Bool -> Values t
tobool (Double
f1 Double -> Double -> Bool
forall a. Ord a => a -> a -> Bool
> Double
f2)
ieee_float_is_greater_op Values Funcons
ft Values Funcons
vx Values Funcons
vy = Funcons -> String -> Rewrite Rewritten
forall a. Funcons -> String -> Rewrite a
sortErr ([Funcons] -> Funcons
ieee_float_is_greater [Values Funcons -> Funcons
FValue Values Funcons
ft, Values Funcons -> Funcons
FValue Values Funcons
vx, Values Funcons -> Funcons
FValue Values Funcons
vy])
                         String
"ieee-float-is-greater not applied to a format and ieee-floats"

ieee_float_is_less_or_equal :: [Funcons] -> Funcons
ieee_float_is_less_or_equal = Name -> [Funcons] -> Funcons
applyFuncon Name
"ieee-float-is-less-or-equal"
ieee_float_is_less_or_equal_op :: Values Funcons
-> Values Funcons -> Values Funcons -> Rewrite Rewritten
ieee_float_is_less_or_equal_op Values Funcons
format Values Funcons
vx Values Funcons
vy
    | Values Funcons -> Values Funcons -> Bool
forall t. Values t -> Values t -> Bool
isIEEEFormat Values Funcons
format Values Funcons
vx Bool -> Bool -> Bool
&& Values Funcons -> Values Funcons -> Bool
forall t. Values t -> Values t -> Bool
isIEEEFormat Values Funcons
format Values Funcons
vy =
        let f1 :: Double
f1 = Values Funcons -> Values Funcons -> Double
forall t. Values t -> Values t -> Double
doubleFromIEEEFormat Values Funcons
format Values Funcons
vx
            f2 :: Double
f2 = Values Funcons -> Values Funcons -> Double
forall t. Values t -> Values t -> Double
doubleFromIEEEFormat Values Funcons
format Values Funcons
vy
        in Funcons -> Rewrite Rewritten
rewriteTo (Funcons -> Rewrite Rewritten) -> Funcons -> Rewrite Rewritten
forall a b. (a -> b) -> a -> b
$ Values Funcons -> Funcons
FValue (Values Funcons -> Funcons) -> Values Funcons -> Funcons
forall a b. (a -> b) -> a -> b
$ Bool -> Values Funcons
forall t. Bool -> Values t
tobool (Double
f1 Double -> Double -> Bool
forall a. Ord a => a -> a -> Bool
<= Double
f2)
ieee_float_is_less_or_equal_op Values Funcons
ft Values Funcons
vx Values Funcons
vy = Funcons -> String -> Rewrite Rewritten
forall a. Funcons -> String -> Rewrite a
sortErr ([Funcons] -> Funcons
ieee_float_is_less_or_equal [Values Funcons -> Funcons
FValue Values Funcons
ft,Values Funcons -> Funcons
FValue Values Funcons
vx, Values Funcons -> Funcons
FValue Values Funcons
vy])
                         String
"ieee-float-is-less-or-equal not applied to a format and ieee-floats"

ieee_float_is_greater_or_equal :: [Funcons] -> Funcons
ieee_float_is_greater_or_equal = Name -> [Funcons] -> Funcons
applyFuncon Name
"ieee-float-is-greater-or-equal"
ieee_float_is_greater_or_equal_op :: Values Funcons
-> Values Funcons -> Values Funcons -> Rewrite Rewritten
ieee_float_is_greater_or_equal_op Values Funcons
format Values Funcons
vx Values Funcons
vy
    | Values Funcons -> Values Funcons -> Bool
forall t. Values t -> Values t -> Bool
isIEEEFormat Values Funcons
format Values Funcons
vx Bool -> Bool -> Bool
&& Values Funcons -> Values Funcons -> Bool
forall t. Values t -> Values t -> Bool
isIEEEFormat Values Funcons
format Values Funcons
vy =
        let f1 :: Double
f1 = Values Funcons -> Values Funcons -> Double
forall t. Values t -> Values t -> Double
doubleFromIEEEFormat Values Funcons
format Values Funcons
vx
            f2 :: Double
f2 = Values Funcons -> Values Funcons -> Double
forall t. Values t -> Values t -> Double
doubleFromIEEEFormat Values Funcons
format Values Funcons
vy
        in Funcons -> Rewrite Rewritten
rewriteTo (Funcons -> Rewrite Rewritten) -> Funcons -> Rewrite Rewritten
forall a b. (a -> b) -> a -> b
$ Values Funcons -> Funcons
FValue (Values Funcons -> Funcons) -> Values Funcons -> Funcons
forall a b. (a -> b) -> a -> b
$ Bool -> Values Funcons
forall t. Bool -> Values t
tobool (Double
f1 Double -> Double -> Bool
forall a. Ord a => a -> a -> Bool
>= Double
f2)
ieee_float_is_greater_or_equal_op Values Funcons
ft Values Funcons
vx Values Funcons
vy = Funcons -> String -> Rewrite Rewritten
forall a. Funcons -> String -> Rewrite a
sortErr ([Funcons] -> Funcons
ieee_float_is_greater_or_equal [Values Funcons -> Funcons
FValue Values Funcons
ft,Values Funcons -> Funcons
FValue Values Funcons
vx, Values Funcons -> Funcons
FValue Values Funcons
vy])
                         String
"ieee-float-is-greater-or-equal not applied to a format and ieee-floats"