{-|
    Module      :  AERN2.MP.Float.Operators
    Description :  Infix operators for up/down-rounded floating-point numbers
    Copyright   :  (c) Michal Konecny
    License     :  BSD3

    Maintainer  :  mikkonecny@gmail.com
    Stability   :  experimental
    Portability :  portable

    Infix operators for up/down-rounded floating-point numbers
-}

module AERN2.MP.Float.Operators 
(
    -- upwards and downwards rounded operations
    (+^), (+.)
    , (-^), (-.)
    , (*^), (*.)
    , (/^), (/.)
    -- upwards and downwards rounded conversions
    , fromIntegerUp, fromIntegerDown
    , fromRationalUp, fromRationalDown
    -- upwards and downwards rounded selected elementary functions
    , cosUp, cosDown, sinUp, sinDown
    , sqrtUp, sqrtDown, expUp, expDown, logUp, logDown
)
where

import MixedTypesNumPrelude

import AERN2.MP.Precision
import AERN2.MP.Float.Auxi

import AERN2.MP.Float.Type
import AERN2.MP.Float.Arithmetic
import AERN2.MP.Float.Conversions

infixl 6  +^, -^, +., -.
infixl 7  *^, *., /^, /.

(+^) :: MPFloat -> MPFloat -> MPFloat
+^ :: MPFloat -> MPFloat -> MPFloat
(+^) = (MPFloat -> MPFloat -> BoundsCEDU MPFloat)
-> MPFloat -> MPFloat -> MPFloat
forall t1 t2.
(t1 -> t2 -> BoundsCEDU MPFloat) -> t1 -> t2 -> MPFloat
up2 MPFloat -> MPFloat -> BoundsCEDU MPFloat
addCEDU
(-^) :: MPFloat -> MPFloat -> MPFloat
-^ :: MPFloat -> MPFloat -> MPFloat
(-^) = (MPFloat -> MPFloat -> BoundsCEDU MPFloat)
-> MPFloat -> MPFloat -> MPFloat
forall t1 t2.
(t1 -> t2 -> BoundsCEDU MPFloat) -> t1 -> t2 -> MPFloat
up2 MPFloat -> MPFloat -> BoundsCEDU MPFloat
subCEDU
(*^) :: MPFloat -> MPFloat -> MPFloat
*^ :: MPFloat -> MPFloat -> MPFloat
(*^) = (MPFloat -> MPFloat -> BoundsCEDU MPFloat)
-> MPFloat -> MPFloat -> MPFloat
forall t1 t2.
(t1 -> t2 -> BoundsCEDU MPFloat) -> t1 -> t2 -> MPFloat
up2 MPFloat -> MPFloat -> BoundsCEDU MPFloat
mulCEDU
(/^) :: MPFloat -> MPFloat -> MPFloat
/^ :: MPFloat -> MPFloat -> MPFloat
(/^) = (MPFloat -> MPFloat -> BoundsCEDU MPFloat)
-> MPFloat -> MPFloat -> MPFloat
forall t1 t2.
(t1 -> t2 -> BoundsCEDU MPFloat) -> t1 -> t2 -> MPFloat
up2 MPFloat -> MPFloat -> BoundsCEDU MPFloat
divCEDU

fromIntegerUp :: Precision -> Integer -> MPFloat
fromIntegerUp :: Precision -> Integer -> MPFloat
fromIntegerUp Precision
p = (Integer -> BoundsCEDU MPFloat) -> Integer -> MPFloat
forall t. (t -> BoundsCEDU MPFloat) -> t -> MPFloat
up1 (Precision -> Integer -> BoundsCEDU MPFloat
fromIntegerCEDU Precision
p)
fromRationalUp :: Precision -> Rational -> MPFloat
fromRationalUp :: Precision -> Rational -> MPFloat
fromRationalUp Precision
p = (Rational -> BoundsCEDU MPFloat) -> Rational -> MPFloat
forall t. (t -> BoundsCEDU MPFloat) -> t -> MPFloat
up1 (Precision -> Rational -> BoundsCEDU MPFloat
fromRationalCEDU Precision
p)

cosUp :: MPFloat -> MPFloat
cosUp :: MPFloat -> MPFloat
cosUp = (MPFloat -> BoundsCEDU MPFloat) -> MPFloat -> MPFloat
forall t. (t -> BoundsCEDU MPFloat) -> t -> MPFloat
up1 MPFloat -> BoundsCEDU MPFloat
cosCEDU
sinUp :: MPFloat -> MPFloat
sinUp :: MPFloat -> MPFloat
sinUp = (MPFloat -> BoundsCEDU MPFloat) -> MPFloat -> MPFloat
forall t. (t -> BoundsCEDU MPFloat) -> t -> MPFloat
up1 MPFloat -> BoundsCEDU MPFloat
sinCEDU
sqrtUp :: MPFloat -> MPFloat
sqrtUp :: MPFloat -> MPFloat
sqrtUp = (MPFloat -> BoundsCEDU MPFloat) -> MPFloat -> MPFloat
forall t. (t -> BoundsCEDU MPFloat) -> t -> MPFloat
up1 MPFloat -> BoundsCEDU MPFloat
sqrtCEDU
expUp :: MPFloat -> MPFloat
expUp :: MPFloat -> MPFloat
expUp = (MPFloat -> BoundsCEDU MPFloat) -> MPFloat -> MPFloat
forall t. (t -> BoundsCEDU MPFloat) -> t -> MPFloat
up1 MPFloat -> BoundsCEDU MPFloat
expCEDU
logUp :: MPFloat -> MPFloat
logUp :: MPFloat -> MPFloat
logUp = (MPFloat -> BoundsCEDU MPFloat) -> MPFloat -> MPFloat
forall t. (t -> BoundsCEDU MPFloat) -> t -> MPFloat
up1 MPFloat -> BoundsCEDU MPFloat
logCEDU


(+.) :: MPFloat -> MPFloat -> MPFloat
+. :: MPFloat -> MPFloat -> MPFloat
(+.) = (MPFloat -> MPFloat -> BoundsCEDU MPFloat)
-> MPFloat -> MPFloat -> MPFloat
forall t1 t2.
(t1 -> t2 -> BoundsCEDU MPFloat) -> t1 -> t2 -> MPFloat
down2 MPFloat -> MPFloat -> BoundsCEDU MPFloat
addCEDU
(-.) :: MPFloat -> MPFloat -> MPFloat
-. :: MPFloat -> MPFloat -> MPFloat
(-.) = (MPFloat -> MPFloat -> BoundsCEDU MPFloat)
-> MPFloat -> MPFloat -> MPFloat
forall t1 t2.
(t1 -> t2 -> BoundsCEDU MPFloat) -> t1 -> t2 -> MPFloat
down2 MPFloat -> MPFloat -> BoundsCEDU MPFloat
subCEDU
(*.) :: MPFloat -> MPFloat -> MPFloat
*. :: MPFloat -> MPFloat -> MPFloat
(*.) = (MPFloat -> MPFloat -> BoundsCEDU MPFloat)
-> MPFloat -> MPFloat -> MPFloat
forall t1 t2.
(t1 -> t2 -> BoundsCEDU MPFloat) -> t1 -> t2 -> MPFloat
down2 MPFloat -> MPFloat -> BoundsCEDU MPFloat
mulCEDU
(/.) :: MPFloat -> MPFloat -> MPFloat
/. :: MPFloat -> MPFloat -> MPFloat
(/.) = (MPFloat -> MPFloat -> BoundsCEDU MPFloat)
-> MPFloat -> MPFloat -> MPFloat
forall t1 t2.
(t1 -> t2 -> BoundsCEDU MPFloat) -> t1 -> t2 -> MPFloat
down2 MPFloat -> MPFloat -> BoundsCEDU MPFloat
divCEDU

fromIntegerDown :: Precision -> Integer -> MPFloat
fromIntegerDown :: Precision -> Integer -> MPFloat
fromIntegerDown Precision
p = (Integer -> BoundsCEDU MPFloat) -> Integer -> MPFloat
forall t. (t -> BoundsCEDU MPFloat) -> t -> MPFloat
down1 (Precision -> Integer -> BoundsCEDU MPFloat
fromIntegerCEDU Precision
p)
fromRationalDown :: Precision -> Rational -> MPFloat
fromRationalDown :: Precision -> Rational -> MPFloat
fromRationalDown Precision
p = (Rational -> BoundsCEDU MPFloat) -> Rational -> MPFloat
forall t. (t -> BoundsCEDU MPFloat) -> t -> MPFloat
down1 (Precision -> Rational -> BoundsCEDU MPFloat
fromRationalCEDU Precision
p)

cosDown :: MPFloat -> MPFloat
cosDown :: MPFloat -> MPFloat
cosDown = (MPFloat -> BoundsCEDU MPFloat) -> MPFloat -> MPFloat
forall t. (t -> BoundsCEDU MPFloat) -> t -> MPFloat
down1 MPFloat -> BoundsCEDU MPFloat
cosCEDU
sinDown :: MPFloat -> MPFloat
sinDown :: MPFloat -> MPFloat
sinDown = (MPFloat -> BoundsCEDU MPFloat) -> MPFloat -> MPFloat
forall t. (t -> BoundsCEDU MPFloat) -> t -> MPFloat
down1 MPFloat -> BoundsCEDU MPFloat
sinCEDU
sqrtDown :: MPFloat -> MPFloat
sqrtDown :: MPFloat -> MPFloat
sqrtDown = (MPFloat -> BoundsCEDU MPFloat) -> MPFloat -> MPFloat
forall t. (t -> BoundsCEDU MPFloat) -> t -> MPFloat
down1 MPFloat -> BoundsCEDU MPFloat
sqrtCEDU
expDown :: MPFloat -> MPFloat
expDown :: MPFloat -> MPFloat
expDown = (MPFloat -> BoundsCEDU MPFloat) -> MPFloat -> MPFloat
forall t. (t -> BoundsCEDU MPFloat) -> t -> MPFloat
down1 MPFloat -> BoundsCEDU MPFloat
expCEDU
logDown :: MPFloat -> MPFloat
logDown :: MPFloat -> MPFloat
logDown = (MPFloat -> BoundsCEDU MPFloat) -> MPFloat -> MPFloat
forall t. (t -> BoundsCEDU MPFloat) -> t -> MPFloat
down1 MPFloat -> BoundsCEDU MPFloat
logCEDU


up1, down1 :: 
    (t -> BoundsCEDU MPFloat) -> 
    (t -> MPFloat)
up1 :: (t -> BoundsCEDU MPFloat) -> t -> MPFloat
up1 t -> BoundsCEDU MPFloat
op t
x = BoundsCEDU MPFloat -> MPFloat
forall a. BoundsCEDU a -> a
ceduUp (BoundsCEDU MPFloat -> MPFloat) -> BoundsCEDU MPFloat -> MPFloat
forall a b. (a -> b) -> a -> b
$ t -> BoundsCEDU MPFloat
op t
x
down1 :: (t -> BoundsCEDU MPFloat) -> t -> MPFloat
down1 t -> BoundsCEDU MPFloat
op t
x = BoundsCEDU MPFloat -> MPFloat
forall a. BoundsCEDU a -> a
ceduDown (BoundsCEDU MPFloat -> MPFloat) -> BoundsCEDU MPFloat -> MPFloat
forall a b. (a -> b) -> a -> b
$ t -> BoundsCEDU MPFloat
op t
x

up2, down2 :: 
    (t1 -> t2 -> BoundsCEDU MPFloat) -> 
    (t1 -> t2 -> MPFloat)
up2 :: (t1 -> t2 -> BoundsCEDU MPFloat) -> t1 -> t2 -> MPFloat
up2 t1 -> t2 -> BoundsCEDU MPFloat
op t1
x t2
y = BoundsCEDU MPFloat -> MPFloat
forall a. BoundsCEDU a -> a
ceduUp (BoundsCEDU MPFloat -> MPFloat) -> BoundsCEDU MPFloat -> MPFloat
forall a b. (a -> b) -> a -> b
$ t1 -> t2 -> BoundsCEDU MPFloat
op t1
x t2
y
down2 :: (t1 -> t2 -> BoundsCEDU MPFloat) -> t1 -> t2 -> MPFloat
down2 t1 -> t2 -> BoundsCEDU MPFloat
op t1
x t2
y = BoundsCEDU MPFloat -> MPFloat
forall a. BoundsCEDU a -> a
ceduDown (BoundsCEDU MPFloat -> MPFloat) -> BoundsCEDU MPFloat -> MPFloat
forall a b. (a -> b) -> a -> b
$ t1 -> t2 -> BoundsCEDU MPFloat
op t1
x t2
y