{-# LANGUAGE MagicHash #-}
{-# LANGUAGE UnliftedFFITypes #-}
module FFIWrapper.Double
( roundedAdd
, roundedSub
, roundedMul
, roundedDiv
, roundedSqrt
, roundedFMA
, roundedFMAIfFast
, roundedFromInt64
, roundedFromWord64
, intervalMul_down
, intervalMul_up
, intervalDiv_down
, intervalDiv_up
, intervalMulAdd_down
, intervalMulAdd_up
, intervalDivAdd_down
, intervalDivAdd_up
, vectorSumPtr
, vectorSumByteArray
, vectorAddPtr
, vectorAddByteArray
, vectorSubPtr
, vectorSubByteArray
, vectorMulPtr
, vectorMulByteArray
, vectorFMAPtr
, vectorFMAByteArray
, vectorDivPtr
, vectorDivByteArray
, vectorSqrtPtr
, vectorSqrtByteArray
) where
import Data.Int (Int64)
import Data.Word (Word64)
import Foreign.Ptr (Ptr)
import GHC.Exts (ByteArray#, MutableByteArray#, RealWorld)
import Numeric.Rounded.Hardware.Internal.Rounding (RoundingMode(..))
foreign import ccall unsafe "rounded_hw_add_double"
c_rounded_add :: Int -> Double -> Double -> Double
foreign import ccall unsafe "rounded_hw_add_double_up"
c_rounded_add_up :: Double -> Double -> Double
foreign import ccall unsafe "rounded_hw_add_double_down"
c_rounded_add_down :: Double -> Double -> Double
foreign import ccall unsafe "rounded_hw_add_double_zero"
c_rounded_add_zero :: Double -> Double -> Double
roundedAdd :: RoundingMode -> Double -> Double -> Double
roundedAdd r = c_rounded_add (fromEnum r)
{-# INLINE [1] roundedAdd #-}
{-# RULES
"roundedAdd/TowardNegInf" [~1] roundedAdd TowardNegInf = c_rounded_add_down
"roundedAdd/TowardInf" [~1] roundedAdd TowardInf = c_rounded_add_up
"roundedAdd/TowardZero" [~1] roundedAdd TowardZero = c_rounded_add_zero
#-}
foreign import ccall unsafe "rounded_hw_sub_double"
c_rounded_sub :: Int -> Double -> Double -> Double
foreign import ccall unsafe "rounded_hw_sub_double_up"
c_rounded_sub_up :: Double -> Double -> Double
foreign import ccall unsafe "rounded_hw_sub_double_down"
c_rounded_sub_down :: Double -> Double -> Double
foreign import ccall unsafe "rounded_hw_sub_double_zero"
c_rounded_sub_zero :: Double -> Double -> Double
roundedSub :: RoundingMode -> Double -> Double -> Double
roundedSub r = c_rounded_sub (fromEnum r)
{-# INLINE [1] roundedSub #-}
{-# RULES
"roundedSub/TowardNegInf" [~1] roundedSub TowardNegInf = c_rounded_sub_down
"roundedSub/TowardInf" [~1] roundedSub TowardInf = c_rounded_sub_up
"roundedSub/TowardZero" [~1] roundedSub TowardZero = c_rounded_sub_zero
#-}
foreign import ccall unsafe "rounded_hw_mul_double"
c_rounded_mul :: Int -> Double -> Double -> Double
foreign import ccall unsafe "rounded_hw_mul_double_up"
c_rounded_mul_up :: Double -> Double -> Double
foreign import ccall unsafe "rounded_hw_mul_double_down"
c_rounded_mul_down :: Double -> Double -> Double
foreign import ccall unsafe "rounded_hw_mul_double_zero"
c_rounded_mul_zero :: Double -> Double -> Double
roundedMul :: RoundingMode -> Double -> Double -> Double
roundedMul r = c_rounded_mul (fromEnum r)
{-# INLINE [1] roundedMul #-}
{-# RULES
"roundedMul/TowardNegInf" [~1] roundedMul TowardNegInf = c_rounded_mul_down
"roundedMul/TowardInf" [~1] roundedMul TowardInf = c_rounded_mul_up
"roundedMul/TowardZero" [~1] roundedMul TowardZero = c_rounded_mul_zero
#-}
foreign import ccall unsafe "rounded_hw_div_double"
c_rounded_div :: Int -> Double -> Double -> Double
foreign import ccall unsafe "rounded_hw_div_double_up"
c_rounded_div_up :: Double -> Double -> Double
foreign import ccall unsafe "rounded_hw_div_double_down"
c_rounded_div_down :: Double -> Double -> Double
foreign import ccall unsafe "rounded_hw_div_double_zero"
c_rounded_div_zero :: Double -> Double -> Double
roundedDiv :: RoundingMode -> Double -> Double -> Double
roundedDiv r = c_rounded_div (fromEnum r)
{-# INLINE [1] roundedDiv #-}
{-# RULES
"roundedDiv/TowardNegInf" [~1] roundedDiv TowardNegInf = c_rounded_div_down
"roundedDiv/TowardInf" [~1] roundedDiv TowardInf = c_rounded_div_up
"roundedDiv/TowardZero" [~1] roundedDiv TowardZero = c_rounded_div_zero
#-}
foreign import ccall unsafe "rounded_hw_sqrt_double"
c_rounded_sqrt :: Int -> Double -> Double
foreign import ccall unsafe "rounded_hw_sqrt_double_up"
c_rounded_sqrt_up :: Double -> Double
foreign import ccall unsafe "rounded_hw_sqrt_double_down"
c_rounded_sqrt_down :: Double -> Double
foreign import ccall unsafe "rounded_hw_sqrt_double_zero"
c_rounded_sqrt_zero :: Double -> Double
roundedSqrt :: RoundingMode -> Double -> Double
roundedSqrt r = c_rounded_sqrt (fromEnum r)
{-# INLINE [1] roundedSqrt #-}
{-# RULES
"roundedSqrt/TowardNegInf" [~1] roundedSqrt TowardNegInf = c_rounded_sqrt_down
"roundedSqrt/TowardInf" [~1] roundedSqrt TowardInf = c_rounded_sqrt_up
"roundedSqrt/TowardZero" [~1] roundedSqrt TowardZero = c_rounded_sqrt_zero
#-}
foreign import ccall unsafe "rounded_hw_fma_double"
c_rounded_fma :: Int -> Double -> Double -> Double -> Double
foreign import ccall unsafe "rounded_hw_fma_double_up"
c_rounded_fma_up :: Double -> Double -> Double -> Double
foreign import ccall unsafe "rounded_hw_fma_double_down"
c_rounded_fma_down :: Double -> Double -> Double -> Double
foreign import ccall unsafe "rounded_hw_fma_double_zero"
c_rounded_fma_zero :: Double -> Double -> Double -> Double
roundedFMA :: RoundingMode -> Double -> Double -> Double -> Double
roundedFMA r = c_rounded_fma (fromEnum r)
{-# INLINE [1] roundedFMA #-}
{-# RULES
"roundedFMA/TowardNegInf" [~1] roundedFMA TowardNegInf = c_rounded_fma_down
"roundedFMA/TowardInf" [~1] roundedFMA TowardInf = c_rounded_fma_up
"roundedFMA/TowardZero" [~1] roundedFMA TowardZero = c_rounded_fma_zero
#-}
foreign import ccall unsafe "rounded_hw_fma_if_fast_double"
c_rounded_fma_if_fast :: Int -> Double -> Double -> Double -> Double
foreign import ccall unsafe "rounded_hw_fma_if_fast_double_up"
c_rounded_fma_if_fast_up :: Double -> Double -> Double -> Double
foreign import ccall unsafe "rounded_hw_fma_if_fast_double_down"
c_rounded_fma_if_fast_down :: Double -> Double -> Double -> Double
foreign import ccall unsafe "rounded_hw_fma_if_fast_double_zero"
c_rounded_fma_if_fast_zero :: Double -> Double -> Double -> Double
roundedFMAIfFast :: RoundingMode -> Double -> Double -> Double -> Double
roundedFMAIfFast r = c_rounded_fma_if_fast (fromEnum r)
{-# INLINE [1] roundedFMAIfFast #-}
{-# RULES
"roundedFMAIfFast/TowardNegInf" [~1] roundedFMAIfFast TowardNegInf = c_rounded_fma_if_fast_down
"roundedFMAIfFast/TowardInf" [~1] roundedFMAIfFast TowardInf = c_rounded_fma_if_fast_up
"roundedFMAIfFast/TowardZero" [~1] roundedFMAIfFast TowardZero = c_rounded_fma_if_fast_zero
#-}
foreign import ccall unsafe "rounded_hw_int64_to_double"
c_rounded_from_int64 :: Int -> Int64 -> Double
foreign import ccall unsafe "rounded_hw_int64_to_double_up"
c_rounded_from_int64_up :: Int64 -> Double
foreign import ccall unsafe "rounded_hw_int64_to_double_down"
c_rounded_from_int64_down :: Int64 -> Double
foreign import ccall unsafe "rounded_hw_int64_to_double_zero"
c_rounded_from_int64_zero :: Int64 -> Double
roundedFromInt64 :: RoundingMode -> Int64 -> Double
roundedFromInt64 r = c_rounded_from_int64 (fromEnum r)
{-# INLINE [1] roundedFromInt64 #-}
{-# RULES
"roundedFromInt64/TowardNegInf" [~1] roundedFromInt64 TowardNegInf = c_rounded_from_int64_down
"roundedFromInt64/TowardInf" [~1] roundedFromInt64 TowardInf = c_rounded_from_int64_up
"roundedFromInt64/TowardZero" [~1] roundedFromInt64 TowardZero = c_rounded_from_int64_zero
#-}
foreign import ccall unsafe "rounded_hw_word64_to_double"
c_rounded_from_word64 :: Int -> Word64 -> Double
foreign import ccall unsafe "rounded_hw_word64_to_double_up"
c_rounded_from_word64_up :: Word64 -> Double
foreign import ccall unsafe "rounded_hw_word64_to_double_down"
c_rounded_from_word64_down :: Word64 -> Double
foreign import ccall unsafe "rounded_hw_word64_to_double_zero"
c_rounded_from_word64_zero :: Word64 -> Double
roundedFromWord64 :: RoundingMode -> Word64 -> Double
roundedFromWord64 r = c_rounded_from_word64 (fromEnum r)
{-# INLINE [1] roundedFromWord64 #-}
{-# RULES
"roundedFromWord64/TowardNegInf" [~1] roundedFromWord64 TowardNegInf = c_rounded_from_word64_down
"roundedFromWord64/TowardInf" [~1] roundedFromWord64 TowardInf = c_rounded_from_word64_up
"roundedFromWord64/TowardZero" [~1] roundedFromWord64 TowardZero = c_rounded_from_word64_zero
#-}
foreign import ccall unsafe "rounded_hw_interval_mul_double_down"
intervalMul_down :: Double -> Double -> Double -> Double -> Double
foreign import ccall unsafe "rounded_hw_interval_mul_double_up"
intervalMul_up :: Double -> Double -> Double -> Double -> Double
foreign import ccall unsafe "rounded_hw_interval_div_double_down"
intervalDiv_down :: Double -> Double -> Double -> Double -> Double
foreign import ccall unsafe "rounded_hw_interval_div_double_up"
intervalDiv_up :: Double -> Double -> Double -> Double -> Double
foreign import ccall unsafe "rounded_hw_interval_mul_add_double_down"
intervalMulAdd_down :: Double -> Double -> Double -> Double -> Double -> Double
foreign import ccall unsafe "rounded_hw_interval_mul_add_double_up"
intervalMulAdd_up :: Double -> Double -> Double -> Double -> Double -> Double
foreign import ccall unsafe "rounded_hw_interval_div_add_double_down"
intervalDivAdd_down :: Double -> Double -> Double -> Double -> Double -> Double
foreign import ccall unsafe "rounded_hw_interval_div_add_double_up"
intervalDivAdd_up :: Double -> Double -> Double -> Double -> Double -> Double
foreign import ccall unsafe "rounded_hw_vector_sum_double"
c_vectorSumPtr :: Int -> Int -> Int -> Ptr Double -> IO Double
vectorSumPtr :: RoundingMode -> Int -> Int -> Ptr Double -> IO Double
vectorSumPtr r = c_vectorSumPtr (fromEnum r)
{-# INLINE vectorSumPtr #-}
foreign import ccall unsafe "rounded_hw_vector_sum_double"
c_vectorSumByteArray :: Int -> Int -> Int -> ByteArray# -> Double
vectorSumByteArray :: RoundingMode -> Int -> Int -> ByteArray# -> Double
vectorSumByteArray r = c_vectorSumByteArray (fromEnum r)
{-# INLINE vectorSumByteArray #-}
foreign import ccall unsafe "rounded_hw_vector_add_double"
c_vectorAddPtr :: Int -> Int -> Int -> Ptr Double -> Int -> Ptr Double -> Int -> Ptr Double -> IO ()
vectorAddPtr :: RoundingMode -> Int -> Int -> Ptr Double -> Int -> Ptr Double -> Int -> Ptr Double -> IO ()
vectorAddPtr r = c_vectorAddPtr (fromEnum r)
{-# INLINE vectorAddPtr #-}
foreign import ccall unsafe "rounded_hw_vector_add_double"
c_vectorAddByteArray :: Int -> Int -> Int -> MutableByteArray# RealWorld -> Int -> ByteArray# -> Int -> ByteArray# -> IO ()
vectorAddByteArray :: RoundingMode -> Int -> Int -> MutableByteArray# RealWorld -> Int -> ByteArray# -> Int -> ByteArray# -> IO ()
vectorAddByteArray r = c_vectorAddByteArray (fromEnum r)
{-# INLINE vectorAddByteArray #-}
foreign import ccall unsafe "rounded_hw_vector_sub_double"
c_vectorSubPtr :: Int -> Int -> Int -> Ptr Double -> Int -> Ptr Double -> Int -> Ptr Double -> IO ()
vectorSubPtr :: RoundingMode -> Int -> Int -> Ptr Double -> Int -> Ptr Double -> Int -> Ptr Double -> IO ()
vectorSubPtr r = c_vectorSubPtr (fromEnum r)
{-# INLINE vectorSubPtr #-}
foreign import ccall unsafe "rounded_hw_vector_sub_double"
c_vectorSubByteArray :: Int -> Int -> Int -> MutableByteArray# RealWorld -> Int -> ByteArray# -> Int -> ByteArray# -> IO ()
vectorSubByteArray :: RoundingMode -> Int -> Int -> MutableByteArray# RealWorld -> Int -> ByteArray# -> Int -> ByteArray# -> IO ()
vectorSubByteArray r = c_vectorSubByteArray (fromEnum r)
{-# INLINE vectorSubByteArray #-}
foreign import ccall unsafe "rounded_hw_vector_mul_double"
c_vectorMulPtr :: Int -> Int -> Int -> Ptr Double -> Int -> Ptr Double -> Int -> Ptr Double -> IO ()
vectorMulPtr :: RoundingMode -> Int -> Int -> Ptr Double -> Int -> Ptr Double -> Int -> Ptr Double -> IO ()
vectorMulPtr r = c_vectorMulPtr (fromEnum r)
{-# INLINE vectorMulPtr #-}
foreign import ccall unsafe "rounded_hw_vector_mul_double"
c_vectorMulByteArray :: Int -> Int -> Int -> MutableByteArray# RealWorld -> Int -> ByteArray# -> Int -> ByteArray# -> IO ()
vectorMulByteArray :: RoundingMode -> Int -> Int -> MutableByteArray# RealWorld -> Int -> ByteArray# -> Int -> ByteArray# -> IO ()
vectorMulByteArray r = c_vectorMulByteArray (fromEnum r)
{-# INLINE vectorMulByteArray #-}
foreign import ccall unsafe "rounded_hw_vector_fma_double"
c_vectorFMAPtr :: Int -> Int -> Int -> Ptr Double -> Int -> Ptr Double -> Int -> Ptr Double -> Int -> Ptr Double -> IO ()
vectorFMAPtr :: RoundingMode -> Int -> Int -> Ptr Double -> Int -> Ptr Double -> Int -> Ptr Double -> Int -> Ptr Double -> IO ()
vectorFMAPtr r = c_vectorFMAPtr (fromEnum r)
{-# INLINE vectorFMAPtr #-}
foreign import ccall unsafe "rounded_hw_vector_fma_double"
c_vectorFMAByteArray :: Int -> Int -> Int -> MutableByteArray# RealWorld -> Int -> ByteArray# -> Int -> ByteArray# -> Int -> ByteArray# -> IO ()
vectorFMAByteArray :: RoundingMode -> Int -> Int -> MutableByteArray# RealWorld -> Int -> ByteArray# -> Int -> ByteArray# -> Int -> ByteArray# -> IO ()
vectorFMAByteArray r = c_vectorFMAByteArray (fromEnum r)
{-# INLINE vectorFMAByteArray #-}
foreign import ccall unsafe "rounded_hw_vector_div_double"
c_vectorDivPtr :: Int -> Int -> Int -> Ptr Double -> Int -> Ptr Double -> Int -> Ptr Double -> IO ()
vectorDivPtr :: RoundingMode -> Int -> Int -> Ptr Double -> Int -> Ptr Double -> Int -> Ptr Double -> IO ()
vectorDivPtr r = c_vectorDivPtr (fromEnum r)
{-# INLINE vectorDivPtr #-}
foreign import ccall unsafe "rounded_hw_vector_div_double"
c_vectorDivByteArray :: Int -> Int -> Int -> MutableByteArray# RealWorld -> Int -> ByteArray# -> Int -> ByteArray# -> IO ()
vectorDivByteArray :: RoundingMode -> Int -> Int -> MutableByteArray# RealWorld -> Int -> ByteArray# -> Int -> ByteArray# -> IO ()
vectorDivByteArray r = c_vectorDivByteArray (fromEnum r)
{-# INLINE vectorDivByteArray #-}
foreign import ccall unsafe "rounded_hw_vector_sqrt_double"
c_vectorSqrtPtr :: Int -> Int -> Int -> Ptr Double -> Int -> Ptr Double -> IO ()
vectorSqrtPtr :: RoundingMode -> Int -> Int -> Ptr Double -> Int -> Ptr Double -> IO ()
vectorSqrtPtr r = c_vectorSqrtPtr (fromEnum r)
{-# INLINE vectorSqrtPtr #-}
foreign import ccall unsafe "rounded_hw_vector_sqrt_double"
c_vectorSqrtByteArray :: Int -> Int -> Int -> MutableByteArray# RealWorld -> Int -> ByteArray# -> IO ()
vectorSqrtByteArray :: RoundingMode -> Int -> Int -> MutableByteArray# RealWorld -> Int -> ByteArray# -> IO ()
vectorSqrtByteArray r = c_vectorSqrtByteArray (fromEnum r)
{-# INLINE vectorSqrtByteArray #-}