{-# OPTIONS_GHC -Wno-orphans #-}
module AERN2.AD.MPBallOperations where
import MixedTypesNumPrelude
import AERN2.AD.Type
import AERN2.AD.GenericOperations ()
import AERN2.MP.Ball
import Numeric.CollectErrors.Type (noValueNumErrorCertain, NumError (NumError))
instance
CanAddAsymmetric MPBall (Differential (CN MPBall))
where
type AddType MPBall (Differential (CN MPBall)) = Differential (CN MPBall)
add :: MPBall
-> Differential (CN MPBall)
-> AddType MPBall (Differential (CN MPBall))
add MPBall
a Differential (CN MPBall)
b = Differential (CN MPBall)
-> Differential (CN MPBall)
-> AddType (Differential (CN MPBall)) (Differential (CN MPBall))
forall t1 t2. CanAddAsymmetric t1 t2 => t1 -> t2 -> AddType t1 t2
add (Integer -> CN MPBall -> Differential (CN MPBall)
forall a. CanBeDifferential a => Integer -> a -> Differential a
differential (Differential (CN MPBall) -> Integer
forall a. Differential a -> Integer
order Differential (CN MPBall)
b) (MPBall -> CN MPBall
forall v. v -> CN v
cn MPBall
a)) Differential (CN MPBall)
b
instance
CanAddAsymmetric (Differential (CN MPBall)) MPBall
where
type AddType (Differential (CN MPBall)) MPBall = Differential (CN MPBall)
add :: Differential (CN MPBall)
-> MPBall -> AddType (Differential (CN MPBall)) MPBall
add Differential (CN MPBall)
b MPBall
a = Differential (CN MPBall)
-> Differential (CN MPBall)
-> AddType (Differential (CN MPBall)) (Differential (CN MPBall))
forall t1 t2. CanAddAsymmetric t1 t2 => t1 -> t2 -> AddType t1 t2
add Differential (CN MPBall)
b (Integer -> CN MPBall -> Differential (CN MPBall)
forall a. CanBeDifferential a => Integer -> a -> Differential a
differential (Differential (CN MPBall) -> Integer
forall a. Differential a -> Integer
order Differential (CN MPBall)
b) (MPBall -> CN MPBall
forall v. v -> CN v
cn MPBall
a))
instance
CanAddAsymmetric Integer (Differential (CN MPBall))
where
type AddType Integer (Differential (CN MPBall)) = Differential (CN MPBall)
add :: Integer
-> Differential (CN MPBall)
-> AddType Integer (Differential (CN MPBall))
add Integer
a Differential (CN MPBall)
b = Differential (CN MPBall)
-> Differential (CN MPBall)
-> AddType (Differential (CN MPBall)) (Differential (CN MPBall))
forall t1 t2. CanAddAsymmetric t1 t2 => t1 -> t2 -> AddType t1 t2
add (Integer -> CN MPBall -> Differential (CN MPBall)
forall a. CanBeDifferential a => Integer -> a -> Differential a
differential (Differential (CN MPBall) -> Integer
forall a. Differential a -> Integer
order Differential (CN MPBall)
b) (MPBall -> CN MPBall
forall v. v -> CN v
cn (MPBall -> CN MPBall) -> MPBall -> CN MPBall
forall a b. (a -> b) -> a -> b
$ Integer -> MPBall
forall t. CanBeMPBall t => t -> MPBall
mpBall Integer
a)) Differential (CN MPBall)
b
instance
CanAddAsymmetric (Differential (CN MPBall)) Integer
where
type AddType (Differential (CN MPBall)) Integer = Differential (CN MPBall)
add :: Differential (CN MPBall)
-> Integer -> AddType (Differential (CN MPBall)) Integer
add Differential (CN MPBall)
b Integer
a = Differential (CN MPBall)
-> Differential (CN MPBall)
-> AddType (Differential (CN MPBall)) (Differential (CN MPBall))
forall t1 t2. CanAddAsymmetric t1 t2 => t1 -> t2 -> AddType t1 t2
add Differential (CN MPBall)
b (Integer -> CN MPBall -> Differential (CN MPBall)
forall a. CanBeDifferential a => Integer -> a -> Differential a
differential (Differential (CN MPBall) -> Integer
forall a. Differential a -> Integer
order Differential (CN MPBall)
b) (MPBall -> CN MPBall
forall v. v -> CN v
cn (MPBall -> CN MPBall) -> MPBall -> CN MPBall
forall a b. (a -> b) -> a -> b
$ Integer -> MPBall
forall t. CanBeMPBall t => t -> MPBall
mpBall Integer
a))
instance
(CanBeMPBall a) =>
CanAddAsymmetric (CN a) (Differential (CN MPBall))
where
type AddType (CN a) (Differential (CN MPBall)) = Differential (CN MPBall)
add :: CN a
-> Differential (CN MPBall)
-> AddType (CN a) (Differential (CN MPBall))
add CN a
a Differential (CN MPBall)
b = Differential (CN MPBall)
-> Differential (CN MPBall)
-> AddType (Differential (CN MPBall)) (Differential (CN MPBall))
forall t1 t2. CanAddAsymmetric t1 t2 => t1 -> t2 -> AddType t1 t2
add (Integer -> CN MPBall -> Differential (CN MPBall)
forall a. CanBeDifferential a => Integer -> a -> Differential a
differential (Differential (CN MPBall) -> Integer
forall a. Differential a -> Integer
order Differential (CN MPBall)
b) ((a -> MPBall) -> CN a -> CN MPBall
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> MPBall
forall t. CanBeMPBall t => t -> MPBall
mpBall CN a
a)) Differential (CN MPBall)
b
instance
(CanBeMPBall a) =>
CanAddAsymmetric (Differential (CN MPBall)) (CN a)
where
type AddType (Differential (CN MPBall)) (CN a) = Differential (CN MPBall)
add :: Differential (CN MPBall)
-> CN a -> AddType (Differential (CN MPBall)) (CN a)
add Differential (CN MPBall)
b CN a
a = Differential (CN MPBall)
-> Differential (CN MPBall)
-> AddType (Differential (CN MPBall)) (Differential (CN MPBall))
forall t1 t2. CanAddAsymmetric t1 t2 => t1 -> t2 -> AddType t1 t2
add Differential (CN MPBall)
b (Integer -> CN MPBall -> Differential (CN MPBall)
forall a. CanBeDifferential a => Integer -> a -> Differential a
differential (Differential (CN MPBall) -> Integer
forall a. Differential a -> Integer
order Differential (CN MPBall)
b) ((a -> MPBall) -> CN a -> CN MPBall
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> MPBall
forall t. CanBeMPBall t => t -> MPBall
mpBall CN a
a))
instance
CanSub Integer (Differential (CN MPBall))
where
type SubType Integer (Differential (CN MPBall)) = Differential (CN MPBall)
sub :: Integer
-> Differential (CN MPBall)
-> SubType Integer (Differential (CN MPBall))
sub Integer
a Differential (CN MPBall)
b = Differential (CN MPBall)
-> Differential (CN MPBall)
-> SubType (Differential (CN MPBall)) (Differential (CN MPBall))
forall t1 t2. CanSub t1 t2 => t1 -> t2 -> SubType t1 t2
sub (Integer -> CN MPBall -> Differential (CN MPBall)
forall a. CanBeDifferential a => Integer -> a -> Differential a
differential (Differential (CN MPBall) -> Integer
forall a. Differential a -> Integer
order Differential (CN MPBall)
b) (MPBall -> CN MPBall
forall v. v -> CN v
cn (MPBall -> CN MPBall) -> MPBall -> CN MPBall
forall a b. (a -> b) -> a -> b
$ Integer -> MPBall
forall t. CanBeMPBall t => t -> MPBall
mpBall Integer
a)) Differential (CN MPBall)
b
instance
CanSub (Differential (CN MPBall)) Integer
where
type SubType (Differential (CN MPBall)) Integer = Differential (CN MPBall)
sub :: Differential (CN MPBall)
-> Integer -> SubType (Differential (CN MPBall)) Integer
sub Differential (CN MPBall)
b Integer
a = Differential (CN MPBall)
-> Differential (CN MPBall)
-> SubType (Differential (CN MPBall)) (Differential (CN MPBall))
forall t1 t2. CanSub t1 t2 => t1 -> t2 -> SubType t1 t2
sub Differential (CN MPBall)
b (Integer -> CN MPBall -> Differential (CN MPBall)
forall a. CanBeDifferential a => Integer -> a -> Differential a
differential (Differential (CN MPBall) -> Integer
forall a. Differential a -> Integer
order Differential (CN MPBall)
b) (MPBall -> CN MPBall
forall v. v -> CN v
cn (MPBall -> CN MPBall) -> MPBall -> CN MPBall
forall a b. (a -> b) -> a -> b
$ Integer -> MPBall
forall t. CanBeMPBall t => t -> MPBall
mpBall Integer
a))
instance
CanSub MPBall (Differential (CN MPBall))
where
type SubType MPBall (Differential (CN MPBall)) = Differential (CN MPBall)
sub :: MPBall
-> Differential (CN MPBall)
-> SubType MPBall (Differential (CN MPBall))
sub MPBall
a Differential (CN MPBall)
b = Differential (CN MPBall)
-> Differential (CN MPBall)
-> SubType (Differential (CN MPBall)) (Differential (CN MPBall))
forall t1 t2. CanSub t1 t2 => t1 -> t2 -> SubType t1 t2
sub (Integer -> CN MPBall -> Differential (CN MPBall)
forall a. CanBeDifferential a => Integer -> a -> Differential a
differential (Differential (CN MPBall) -> Integer
forall a. Differential a -> Integer
order Differential (CN MPBall)
b) (MPBall -> CN MPBall
forall v. v -> CN v
cn MPBall
a)) Differential (CN MPBall)
b
instance
CanSub (Differential (CN MPBall)) MPBall
where
type SubType (Differential (CN MPBall)) MPBall = Differential (CN MPBall)
sub :: Differential (CN MPBall)
-> MPBall -> SubType (Differential (CN MPBall)) MPBall
sub Differential (CN MPBall)
b MPBall
a = Differential (CN MPBall)
-> Differential (CN MPBall)
-> SubType (Differential (CN MPBall)) (Differential (CN MPBall))
forall t1 t2. CanSub t1 t2 => t1 -> t2 -> SubType t1 t2
sub Differential (CN MPBall)
b (Integer -> CN MPBall -> Differential (CN MPBall)
forall a. CanBeDifferential a => Integer -> a -> Differential a
differential (Differential (CN MPBall) -> Integer
forall a. Differential a -> Integer
order Differential (CN MPBall)
b) (MPBall -> CN MPBall
forall v. v -> CN v
cn MPBall
a))
instance
(CanBeMPBall a) =>
CanSub (CN a) (Differential (CN MPBall))
where
type SubType (CN a) (Differential (CN MPBall)) = Differential (CN MPBall)
sub :: CN a
-> Differential (CN MPBall)
-> SubType (CN a) (Differential (CN MPBall))
sub CN a
a Differential (CN MPBall)
b = Differential (CN MPBall)
-> Differential (CN MPBall)
-> SubType (Differential (CN MPBall)) (Differential (CN MPBall))
forall t1 t2. CanSub t1 t2 => t1 -> t2 -> SubType t1 t2
sub (Integer -> CN MPBall -> Differential (CN MPBall)
forall a. CanBeDifferential a => Integer -> a -> Differential a
differential (Differential (CN MPBall) -> Integer
forall a. Differential a -> Integer
order Differential (CN MPBall)
b) ((a -> MPBall) -> CN a -> CN MPBall
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> MPBall
forall t. CanBeMPBall t => t -> MPBall
mpBall CN a
a)) Differential (CN MPBall)
b
instance
(CanBeMPBall a) =>
CanSub (Differential (CN MPBall)) (CN a)
where
type SubType (Differential (CN MPBall)) (CN a) = Differential (CN MPBall)
sub :: Differential (CN MPBall)
-> CN a -> SubType (Differential (CN MPBall)) (CN a)
sub Differential (CN MPBall)
b CN a
a = Differential (CN MPBall)
-> Differential (CN MPBall)
-> SubType (Differential (CN MPBall)) (Differential (CN MPBall))
forall t1 t2. CanSub t1 t2 => t1 -> t2 -> SubType t1 t2
sub Differential (CN MPBall)
b (Integer -> CN MPBall -> Differential (CN MPBall)
forall a. CanBeDifferential a => Integer -> a -> Differential a
differential (Differential (CN MPBall) -> Integer
forall a. Differential a -> Integer
order Differential (CN MPBall)
b) ((a -> MPBall) -> CN a -> CN MPBall
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> MPBall
forall t. CanBeMPBall t => t -> MPBall
mpBall CN a
a))
instance
CanMulAsymmetric Integer (Differential (CN MPBall))
where
type MulType Integer (Differential (CN MPBall)) = Differential (CN MPBall)
mul :: Integer
-> Differential (CN MPBall)
-> MulType Integer (Differential (CN MPBall))
mul Integer
a Differential (CN MPBall)
b = Differential (CN MPBall)
-> Differential (CN MPBall)
-> MulType (Differential (CN MPBall)) (Differential (CN MPBall))
forall t1 t2. CanMulAsymmetric t1 t2 => t1 -> t2 -> MulType t1 t2
mul (Integer -> CN MPBall -> Differential (CN MPBall)
forall a. CanBeDifferential a => Integer -> a -> Differential a
differential (Differential (CN MPBall) -> Integer
forall a. Differential a -> Integer
order Differential (CN MPBall)
b) (MPBall -> CN MPBall
forall v. v -> CN v
cn (MPBall -> CN MPBall) -> MPBall -> CN MPBall
forall a b. (a -> b) -> a -> b
$ Integer -> MPBall
forall t. CanBeMPBall t => t -> MPBall
mpBall Integer
a)) Differential (CN MPBall)
b
instance
CanMulAsymmetric (Differential (CN MPBall)) Integer
where
type MulType (Differential (CN MPBall)) Integer = Differential (CN MPBall)
mul :: Differential (CN MPBall)
-> Integer -> MulType (Differential (CN MPBall)) Integer
mul Differential (CN MPBall)
b Integer
a = Differential (CN MPBall)
-> Differential (CN MPBall)
-> MulType (Differential (CN MPBall)) (Differential (CN MPBall))
forall t1 t2. CanMulAsymmetric t1 t2 => t1 -> t2 -> MulType t1 t2
mul Differential (CN MPBall)
b (Integer -> CN MPBall -> Differential (CN MPBall)
forall a. CanBeDifferential a => Integer -> a -> Differential a
differential (Differential (CN MPBall) -> Integer
forall a. Differential a -> Integer
order Differential (CN MPBall)
b) (MPBall -> CN MPBall
forall v. v -> CN v
cn (MPBall -> CN MPBall) -> MPBall -> CN MPBall
forall a b. (a -> b) -> a -> b
$ Integer -> MPBall
forall t. CanBeMPBall t => t -> MPBall
mpBall Integer
a))
instance
CanMulAsymmetric MPBall (Differential (CN MPBall))
where
type MulType MPBall (Differential (CN MPBall)) = Differential (CN MPBall)
mul :: MPBall
-> Differential (CN MPBall)
-> MulType MPBall (Differential (CN MPBall))
mul MPBall
a Differential (CN MPBall)
b = Differential (CN MPBall)
-> Differential (CN MPBall)
-> MulType (Differential (CN MPBall)) (Differential (CN MPBall))
forall t1 t2. CanMulAsymmetric t1 t2 => t1 -> t2 -> MulType t1 t2
mul (Integer -> CN MPBall -> Differential (CN MPBall)
forall a. CanBeDifferential a => Integer -> a -> Differential a
differential (Differential (CN MPBall) -> Integer
forall a. Differential a -> Integer
order Differential (CN MPBall)
b) (MPBall -> CN MPBall
forall v. v -> CN v
cn MPBall
a)) Differential (CN MPBall)
b
instance
CanMulAsymmetric (Differential (CN MPBall)) MPBall
where
type MulType (Differential (CN MPBall)) MPBall = Differential (CN MPBall)
mul :: Differential (CN MPBall)
-> MPBall -> MulType (Differential (CN MPBall)) MPBall
mul Differential (CN MPBall)
b MPBall
a = Differential (CN MPBall)
-> Differential (CN MPBall)
-> MulType (Differential (CN MPBall)) (Differential (CN MPBall))
forall t1 t2. CanMulAsymmetric t1 t2 => t1 -> t2 -> MulType t1 t2
mul Differential (CN MPBall)
b (Integer -> CN MPBall -> Differential (CN MPBall)
forall a. CanBeDifferential a => Integer -> a -> Differential a
differential (Differential (CN MPBall) -> Integer
forall a. Differential a -> Integer
order Differential (CN MPBall)
b) (MPBall -> CN MPBall
forall v. v -> CN v
cn MPBall
a))
instance
CanDiv Integer (Differential (CN MPBall))
where
type DivType Integer (Differential (CN MPBall)) = Differential (CN MPBall)
divide :: Integer
-> Differential (CN MPBall)
-> DivType Integer (Differential (CN MPBall))
divide Integer
a Differential (CN MPBall)
b = Differential (CN MPBall)
-> Differential (CN MPBall)
-> DivType (Differential (CN MPBall)) (Differential (CN MPBall))
forall t1 t2. CanDiv t1 t2 => t1 -> t2 -> DivType t1 t2
divide (Integer -> CN MPBall -> Differential (CN MPBall)
forall a. CanBeDifferential a => Integer -> a -> Differential a
differential (Differential (CN MPBall) -> Integer
forall a. Differential a -> Integer
order Differential (CN MPBall)
b) (MPBall -> CN MPBall
forall v. v -> CN v
cn (MPBall -> CN MPBall) -> MPBall -> CN MPBall
forall a b. (a -> b) -> a -> b
$ Integer -> MPBall
forall t. CanBeMPBall t => t -> MPBall
mpBall Integer
a)) Differential (CN MPBall)
b
instance
CanDiv (Differential (CN MPBall)) Integer
where
type DivType (Differential (CN MPBall)) Integer = Differential (CN MPBall)
divide :: Differential (CN MPBall)
-> Integer -> DivType (Differential (CN MPBall)) Integer
divide Differential (CN MPBall)
b Integer
a = Differential (CN MPBall)
-> Differential (CN MPBall)
-> DivType (Differential (CN MPBall)) (Differential (CN MPBall))
forall t1 t2. CanDiv t1 t2 => t1 -> t2 -> DivType t1 t2
divide Differential (CN MPBall)
b (Integer -> CN MPBall -> Differential (CN MPBall)
forall a. CanBeDifferential a => Integer -> a -> Differential a
differential (Differential (CN MPBall) -> Integer
forall a. Differential a -> Integer
order Differential (CN MPBall)
b) (MPBall -> CN MPBall
forall v. v -> CN v
cn (MPBall -> CN MPBall) -> MPBall -> CN MPBall
forall a b. (a -> b) -> a -> b
$ Integer -> MPBall
forall t. CanBeMPBall t => t -> MPBall
mpBall Integer
a))
instance
CanDiv MPBall (Differential (CN MPBall))
where
type DivType MPBall (Differential (CN MPBall)) = Differential (CN MPBall)
divide :: MPBall
-> Differential (CN MPBall)
-> DivType MPBall (Differential (CN MPBall))
divide MPBall
a Differential (CN MPBall)
b = Differential (CN MPBall)
-> Differential (CN MPBall)
-> DivType (Differential (CN MPBall)) (Differential (CN MPBall))
forall t1 t2. CanDiv t1 t2 => t1 -> t2 -> DivType t1 t2
divide (Integer -> CN MPBall -> Differential (CN MPBall)
forall a. CanBeDifferential a => Integer -> a -> Differential a
differential (Differential (CN MPBall) -> Integer
forall a. Differential a -> Integer
order Differential (CN MPBall)
b) (MPBall -> CN MPBall
forall v. v -> CN v
cn MPBall
a)) Differential (CN MPBall)
b
instance
CanDiv (Differential (CN MPBall)) MPBall
where
type DivType (Differential (CN MPBall)) MPBall = Differential (CN MPBall)
divide :: Differential (CN MPBall)
-> MPBall -> DivType (Differential (CN MPBall)) MPBall
divide Differential (CN MPBall)
b MPBall
a = Differential (CN MPBall)
-> Differential (CN MPBall)
-> DivType (Differential (CN MPBall)) (Differential (CN MPBall))
forall t1 t2. CanDiv t1 t2 => t1 -> t2 -> DivType t1 t2
divide Differential (CN MPBall)
b (Integer -> CN MPBall -> Differential (CN MPBall)
forall a. CanBeDifferential a => Integer -> a -> Differential a
differential (Differential (CN MPBall) -> Integer
forall a. Differential a -> Integer
order Differential (CN MPBall)
b) (MPBall -> CN MPBall
forall v. v -> CN v
cn MPBall
a))
instance
(CanBeMPBall a) =>
CanMulAsymmetric (CN a) (Differential (CN MPBall))
where
type MulType (CN a) (Differential (CN MPBall)) = Differential (CN MPBall)
mul :: CN a
-> Differential (CN MPBall)
-> MulType (CN a) (Differential (CN MPBall))
mul CN a
a Differential (CN MPBall)
b = Differential (CN MPBall)
-> Differential (CN MPBall)
-> MulType (Differential (CN MPBall)) (Differential (CN MPBall))
forall t1 t2. CanMulAsymmetric t1 t2 => t1 -> t2 -> MulType t1 t2
mul (Integer -> CN MPBall -> Differential (CN MPBall)
forall a. CanBeDifferential a => Integer -> a -> Differential a
differential (Differential (CN MPBall) -> Integer
forall a. Differential a -> Integer
order Differential (CN MPBall)
b) ((a -> MPBall) -> CN a -> CN MPBall
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> MPBall
forall t. CanBeMPBall t => t -> MPBall
mpBall CN a
a)) Differential (CN MPBall)
b
instance
(CanBeMPBall a) =>
CanMulAsymmetric (Differential (CN MPBall)) (CN a)
where
type MulType (Differential (CN MPBall)) (CN a) = Differential (CN MPBall)
mul :: Differential (CN MPBall)
-> CN a -> MulType (Differential (CN MPBall)) (CN a)
mul Differential (CN MPBall)
b CN a
a = Differential (CN MPBall)
-> Differential (CN MPBall)
-> MulType (Differential (CN MPBall)) (Differential (CN MPBall))
forall t1 t2. CanMulAsymmetric t1 t2 => t1 -> t2 -> MulType t1 t2
mul Differential (CN MPBall)
b (Integer -> CN MPBall -> Differential (CN MPBall)
forall a. CanBeDifferential a => Integer -> a -> Differential a
differential (Differential (CN MPBall) -> Integer
forall a. Differential a -> Integer
order Differential (CN MPBall)
b) ((a -> MPBall) -> CN a -> CN MPBall
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> MPBall
forall t. CanBeMPBall t => t -> MPBall
mpBall CN a
a))
instance
(CanBeMPBall a) =>
CanDiv (CN a) (Differential (CN MPBall))
where
type DivType (CN a) (Differential (CN MPBall)) = Differential (CN MPBall)
divide :: CN a
-> Differential (CN MPBall)
-> DivType (CN a) (Differential (CN MPBall))
divide CN a
a Differential (CN MPBall)
b = Differential (CN MPBall)
-> Differential (CN MPBall)
-> DivType (Differential (CN MPBall)) (Differential (CN MPBall))
forall t1 t2. CanDiv t1 t2 => t1 -> t2 -> DivType t1 t2
divide (Integer -> CN MPBall -> Differential (CN MPBall)
forall a. CanBeDifferential a => Integer -> a -> Differential a
differential (Differential (CN MPBall) -> Integer
forall a. Differential a -> Integer
order Differential (CN MPBall)
b) ((a -> MPBall) -> CN a -> CN MPBall
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> MPBall
forall t. CanBeMPBall t => t -> MPBall
mpBall CN a
a)) Differential (CN MPBall)
b
instance
(CanBeMPBall a) =>
CanDiv (Differential (CN MPBall)) (CN a)
where
type DivType (Differential (CN MPBall)) (CN a) = Differential (CN MPBall)
divide :: Differential (CN MPBall)
-> CN a -> DivType (Differential (CN MPBall)) (CN a)
divide Differential (CN MPBall)
b CN a
a = Differential (CN MPBall)
-> Differential (CN MPBall)
-> DivType (Differential (CN MPBall)) (Differential (CN MPBall))
forall t1 t2. CanDiv t1 t2 => t1 -> t2 -> DivType t1 t2
divide Differential (CN MPBall)
b (Integer -> CN MPBall -> Differential (CN MPBall)
forall a. CanBeDifferential a => Integer -> a -> Differential a
differential (Differential (CN MPBall) -> Integer
forall a. Differential a -> Integer
order Differential (CN MPBall)
b) ((a -> MPBall) -> CN a -> CN MPBall
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> MPBall
forall t. CanBeMPBall t => t -> MPBall
mpBall CN a
a))
instance
CanPow (Differential (CN MPBall)) Integer
where
type PowType (Differential (CN MPBall)) Integer = (Differential (CN MPBall))
pow :: Differential (CN MPBall)
-> Integer -> PowType (Differential (CN MPBall)) Integer
pow (OrderZero CN MPBall
x) Integer
n =
CN MPBall -> Differential (CN MPBall)
forall a. a -> Differential a
OrderZero CN MPBall
IfThenElseType Bool (CN MPBall)
p
where
rawP :: PowType (CN MPBall) Integer
rawP = CN MPBall -> Integer -> PowType (CN MPBall) Integer
forall b e. CanPow b e => b -> e -> PowType b e
pow CN MPBall
x Integer
n
p :: IfThenElseType Bool (CN MPBall)
p = if Integer -> Bool
forall a. Integral a => a -> Bool
even Integer
n then CN MPBall -> AbsType (CN MPBall)
forall t. CanAbs t => t -> AbsType t
abs CN MPBall
PowType (CN MPBall) Integer
rawP else CN MPBall
PowType (CN MPBall) Integer
rawP
pow (OrderOne CN MPBall
x CN MPBall
dx) Integer
n =
CN MPBall -> CN MPBall -> Differential (CN MPBall)
forall a. a -> a -> Differential a
OrderOne CN MPBall
IfThenElseType Bool (CN MPBall)
p CN MPBall
MulType (CN MPBall) (CN MPBall)
dp
where
nEven :: Bool
nEven = Integer -> Bool
forall a. Integral a => a -> Bool
even Integer
n
rawP' :: PowType (CN MPBall) Integer
rawP' = CN MPBall -> Integer -> PowType (CN MPBall) Integer
forall b e. CanPow b e => b -> e -> PowType b e
pow CN MPBall
x (Integer
n Integer -> Integer -> SubType Integer Integer
forall t1 t2. CanSub t1 t2 => t1 -> t2 -> SubType t1 t2
- Integer
1)
rawP :: MulType (CN MPBall) (CN MPBall)
rawP = CN MPBall
x CN MPBall -> CN MPBall -> MulType (CN MPBall) (CN MPBall)
forall t1 t2. CanMulAsymmetric t1 t2 => t1 -> t2 -> MulType t1 t2
* CN MPBall
PowType (CN MPBall) Integer
rawP'
p :: IfThenElseType Bool (CN MPBall)
p = if Bool
nEven then CN MPBall -> AbsType (CN MPBall)
forall t. CanAbs t => t -> AbsType t
abs CN MPBall
MulType (CN MPBall) (CN MPBall)
rawP else CN MPBall
MulType (CN MPBall) (CN MPBall)
rawP
dp :: MulType (CN MPBall) (CN MPBall)
dp = Integer
n Integer -> CN MPBall -> MulType Integer (CN MPBall)
forall t1 t2. CanMulAsymmetric t1 t2 => t1 -> t2 -> MulType t1 t2
* CN MPBall
dx CN MPBall -> CN MPBall -> MulType (CN MPBall) (CN MPBall)
forall t1 t2. CanMulAsymmetric t1 t2 => t1 -> t2 -> MulType t1 t2
* if Bool
nEven then CN MPBall
PowType (CN MPBall) Integer
rawP' else CN MPBall -> AbsType (CN MPBall)
forall t. CanAbs t => t -> AbsType t
abs CN MPBall
PowType (CN MPBall) Integer
rawP'
pow (OrderTwo CN MPBall
x CN MPBall
dx CN MPBall
dxt CN MPBall
d2x) Integer
n =
CN MPBall
-> CN MPBall -> CN MPBall -> CN MPBall -> Differential (CN MPBall)
forall a. a -> a -> a -> a -> Differential a
OrderTwo CN MPBall
IfThenElseType Bool (CN MPBall)
p CN MPBall
MulType (CN MPBall) (CN MPBall)
dp CN MPBall
MulType (CN MPBall) (CN MPBall)
dpt CN MPBall
MulType Integer (CN MPBall)
d2p
where
nEven :: Bool
nEven = Integer -> Bool
forall a. Integral a => a -> Bool
even Integer
n
rawP'' :: PowType (CN MPBall) Integer
rawP'' = CN MPBall -> Integer -> PowType (CN MPBall) Integer
forall b e. CanPow b e => b -> e -> PowType b e
pow CN MPBall
x (Integer
n Integer -> Integer -> SubType Integer Integer
forall t1 t2. CanSub t1 t2 => t1 -> t2 -> SubType t1 t2
- Integer
2)
rawP' :: MulType (CN MPBall) (CN MPBall)
rawP' = CN MPBall
x CN MPBall -> CN MPBall -> MulType (CN MPBall) (CN MPBall)
forall t1 t2. CanMulAsymmetric t1 t2 => t1 -> t2 -> MulType t1 t2
* CN MPBall
PowType (CN MPBall) Integer
rawP''
rawP :: MulType (CN MPBall) (CN MPBall)
rawP = CN MPBall
x CN MPBall -> CN MPBall -> MulType (CN MPBall) (CN MPBall)
forall t1 t2. CanMulAsymmetric t1 t2 => t1 -> t2 -> MulType t1 t2
* CN MPBall
MulType (CN MPBall) (CN MPBall)
rawP'
p :: IfThenElseType Bool (CN MPBall)
p = if Bool
nEven then CN MPBall -> AbsType (CN MPBall)
forall t. CanAbs t => t -> AbsType t
abs CN MPBall
MulType (CN MPBall) (CN MPBall)
rawP else CN MPBall
MulType (CN MPBall) (CN MPBall)
rawP
xnm1 :: IfThenElseType Bool (CN MPBall)
xnm1 = if Bool
nEven then CN MPBall
MulType (CN MPBall) (CN MPBall)
rawP' else CN MPBall -> AbsType (CN MPBall)
forall t. CanAbs t => t -> AbsType t
abs CN MPBall
MulType (CN MPBall) (CN MPBall)
rawP'
dp :: MulType (CN MPBall) (CN MPBall)
dp = Integer
n Integer -> CN MPBall -> MulType Integer (CN MPBall)
forall t1 t2. CanMulAsymmetric t1 t2 => t1 -> t2 -> MulType t1 t2
* CN MPBall
dx CN MPBall -> CN MPBall -> MulType (CN MPBall) (CN MPBall)
forall t1 t2. CanMulAsymmetric t1 t2 => t1 -> t2 -> MulType t1 t2
* CN MPBall
IfThenElseType Bool (CN MPBall)
xnm1
dpt :: MulType (CN MPBall) (CN MPBall)
dpt = Integer
n Integer -> CN MPBall -> MulType Integer (CN MPBall)
forall t1 t2. CanMulAsymmetric t1 t2 => t1 -> t2 -> MulType t1 t2
* CN MPBall
dxt CN MPBall -> CN MPBall -> MulType (CN MPBall) (CN MPBall)
forall t1 t2. CanMulAsymmetric t1 t2 => t1 -> t2 -> MulType t1 t2
* CN MPBall
IfThenElseType Bool (CN MPBall)
xnm1
xnm2 :: IfThenElseType Bool (CN MPBall)
xnm2 = if Bool
nEven then CN MPBall -> AbsType (CN MPBall)
forall t. CanAbs t => t -> AbsType t
abs CN MPBall
PowType (CN MPBall) Integer
rawP'' else CN MPBall
PowType (CN MPBall) Integer
rawP''
d2p :: MulType Integer (CN MPBall)
d2p = Integer
nInteger -> CN MPBall -> MulType Integer (CN MPBall)
forall t1 t2. CanMulAsymmetric t1 t2 => t1 -> t2 -> MulType t1 t2
*((Integer
n Integer -> Integer -> SubType Integer Integer
forall t1 t2. CanSub t1 t2 => t1 -> t2 -> SubType t1 t2
- Integer
1)Integer -> CN MPBall -> MulType Integer (CN MPBall)
forall t1 t2. CanMulAsymmetric t1 t2 => t1 -> t2 -> MulType t1 t2
*CN MPBall
dxCN MPBall -> CN MPBall -> MulType (CN MPBall) (CN MPBall)
forall t1 t2. CanMulAsymmetric t1 t2 => t1 -> t2 -> MulType t1 t2
*CN MPBall
dxtCN MPBall -> CN MPBall -> MulType (CN MPBall) (CN MPBall)
forall t1 t2. CanMulAsymmetric t1 t2 => t1 -> t2 -> MulType t1 t2
*CN MPBall
IfThenElseType Bool (CN MPBall)
xnm2 CN MPBall -> CN MPBall -> AddType (CN MPBall) (CN MPBall)
forall t1 t2. CanAddAsymmetric t1 t2 => t1 -> t2 -> AddType t1 t2
+ CN MPBall
d2xCN MPBall -> CN MPBall -> MulType (CN MPBall) (CN MPBall)
forall t1 t2. CanMulAsymmetric t1 t2 => t1 -> t2 -> MulType t1 t2
*CN MPBall
IfThenElseType Bool (CN MPBall)
xnm1)
instance
CanAbs (Differential (CN MPBall))
where
type AbsType (Differential (CN MPBall)) = Differential (CN MPBall)
abs :: Differential (CN MPBall) -> AbsType (Differential (CN MPBall))
abs (OrderZero CN MPBall
x) = CN MPBall -> Differential (CN MPBall)
forall a. a -> Differential a
OrderZero (CN MPBall -> Differential (CN MPBall))
-> CN MPBall -> Differential (CN MPBall)
forall a b. (a -> b) -> a -> b
$ CN MPBall -> AbsType (CN MPBall)
forall t. CanAbs t => t -> AbsType t
abs CN MPBall
x
abs (OrderOne CN MPBall
x CN MPBall
dx) = CN MPBall -> CN MPBall -> Differential (CN MPBall)
forall a. a -> a -> Differential a
OrderOne (CN MPBall -> AbsType (CN MPBall)
forall t. CanAbs t => t -> AbsType t
abs CN MPBall
x) CN MPBall
newDx
where
newDx :: CN MPBall
newDx = do
MPBall
dx_ <- CN MPBall
dx
MPBall -> CN MPBall
forall (f :: * -> *) a. Applicative f => a -> f a
pure (MPBall -> CN MPBall) -> MPBall -> CN MPBall
forall a b. (a -> b) -> a -> b
$ (MPBall -> MPBall -> MPBall
hullMPBall MPBall
dx_ (-MPBall
dx_))
abs (OrderTwo CN MPBall
_ CN MPBall
_ CN MPBall
_ CN MPBall
_) = [Char] -> Differential (CN MPBall)
forall a. HasCallStack => [Char] -> a
error [Char]
"Abs for differential order two undefined"
instance
CanDivIMod (Differential (CN MPBall)) (Differential (CN MPBall))
where
type DivIType (Differential (CN MPBall)) (Differential (CN MPBall)) = (Differential (CN MPBall))
divIMod :: Differential (CN MPBall)
-> Differential (CN MPBall)
-> (DivIType (Differential (CN MPBall)) (Differential (CN MPBall)),
ModType (Differential (CN MPBall)) (Differential (CN MPBall)))
divIMod Differential (CN MPBall)
a Differential (CN MPBall)
b = ([Char] -> Differential (CN MPBall)
forall a. HasCallStack => [Char] -> a
error [Char]
"Integer division for Differential (CN MPBall) undefined", CN MPBall
-> CN MPBall -> CN MPBall -> CN MPBall -> Differential (CN MPBall)
forall a. a -> a -> a -> a -> Differential a
OrderTwo (CN MPBall -> CN MPBall -> ModType (CN MPBall) (CN MPBall)
forall t1 t2. CanDivIMod t1 t2 => t1 -> t2 -> ModType t1 t2
mod CN MPBall
ax CN MPBall
bx) CN MPBall
forall v. CN v
err CN MPBall
forall v. CN v
err CN MPBall
forall v. CN v
err)
where
ax :: CN MPBall
ax = Differential (CN MPBall) -> CN MPBall
forall a. Differential a -> a
diff_x Differential (CN MPBall)
a
bx :: CN MPBall
bx = Differential (CN MPBall) -> CN MPBall
forall a. Differential a -> a
diff_x Differential (CN MPBall)
b
err :: CN v
err = NumError -> CN v
forall v. NumError -> CN v
noValueNumErrorCertain (NumError -> CN v) -> NumError -> CN v
forall a b. (a -> b) -> a -> b
$ [Char] -> NumError
NumError [Char]
"No derivatives after modulus"