module Factory.Math.Implementations.Pi.Borwein.Algorithm(
Algorithm(..)
) where
import qualified Data.Default
import qualified Factory.Math.Factorial as Math.Factorial
import qualified Factory.Math.Implementations.Pi.Borwein.Borwein1993 as Math.Implementations.Pi.Borwein.Borwein1993
import qualified Factory.Math.Implementations.Pi.Borwein.Implementation as Math.Implementations.Pi.Borwein.Implementation
import qualified Factory.Math.Pi as Math.Pi
import qualified Factory.Math.SquareRoot as Math.SquareRoot
data Algorithm squareRootAlgorithm factorialAlgorithm =
Borwein1993 squareRootAlgorithm factorialAlgorithm
deriving (Algorithm squareRootAlgorithm factorialAlgorithm
-> Algorithm squareRootAlgorithm factorialAlgorithm -> Bool
(Algorithm squareRootAlgorithm factorialAlgorithm
-> Algorithm squareRootAlgorithm factorialAlgorithm -> Bool)
-> (Algorithm squareRootAlgorithm factorialAlgorithm
-> Algorithm squareRootAlgorithm factorialAlgorithm -> Bool)
-> Eq (Algorithm squareRootAlgorithm factorialAlgorithm)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall squareRootAlgorithm factorialAlgorithm.
(Eq squareRootAlgorithm, Eq factorialAlgorithm) =>
Algorithm squareRootAlgorithm factorialAlgorithm
-> Algorithm squareRootAlgorithm factorialAlgorithm -> Bool
/= :: Algorithm squareRootAlgorithm factorialAlgorithm
-> Algorithm squareRootAlgorithm factorialAlgorithm -> Bool
$c/= :: forall squareRootAlgorithm factorialAlgorithm.
(Eq squareRootAlgorithm, Eq factorialAlgorithm) =>
Algorithm squareRootAlgorithm factorialAlgorithm
-> Algorithm squareRootAlgorithm factorialAlgorithm -> Bool
== :: Algorithm squareRootAlgorithm factorialAlgorithm
-> Algorithm squareRootAlgorithm factorialAlgorithm -> Bool
$c== :: forall squareRootAlgorithm factorialAlgorithm.
(Eq squareRootAlgorithm, Eq factorialAlgorithm) =>
Algorithm squareRootAlgorithm factorialAlgorithm
-> Algorithm squareRootAlgorithm factorialAlgorithm -> Bool
Eq, ReadPrec [Algorithm squareRootAlgorithm factorialAlgorithm]
ReadPrec (Algorithm squareRootAlgorithm factorialAlgorithm)
Int -> ReadS (Algorithm squareRootAlgorithm factorialAlgorithm)
ReadS [Algorithm squareRootAlgorithm factorialAlgorithm]
(Int -> ReadS (Algorithm squareRootAlgorithm factorialAlgorithm))
-> ReadS [Algorithm squareRootAlgorithm factorialAlgorithm]
-> ReadPrec (Algorithm squareRootAlgorithm factorialAlgorithm)
-> ReadPrec [Algorithm squareRootAlgorithm factorialAlgorithm]
-> Read (Algorithm squareRootAlgorithm factorialAlgorithm)
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
forall squareRootAlgorithm factorialAlgorithm.
(Read squareRootAlgorithm, Read factorialAlgorithm) =>
ReadPrec [Algorithm squareRootAlgorithm factorialAlgorithm]
forall squareRootAlgorithm factorialAlgorithm.
(Read squareRootAlgorithm, Read factorialAlgorithm) =>
ReadPrec (Algorithm squareRootAlgorithm factorialAlgorithm)
forall squareRootAlgorithm factorialAlgorithm.
(Read squareRootAlgorithm, Read factorialAlgorithm) =>
Int -> ReadS (Algorithm squareRootAlgorithm factorialAlgorithm)
forall squareRootAlgorithm factorialAlgorithm.
(Read squareRootAlgorithm, Read factorialAlgorithm) =>
ReadS [Algorithm squareRootAlgorithm factorialAlgorithm]
readListPrec :: ReadPrec [Algorithm squareRootAlgorithm factorialAlgorithm]
$creadListPrec :: forall squareRootAlgorithm factorialAlgorithm.
(Read squareRootAlgorithm, Read factorialAlgorithm) =>
ReadPrec [Algorithm squareRootAlgorithm factorialAlgorithm]
readPrec :: ReadPrec (Algorithm squareRootAlgorithm factorialAlgorithm)
$creadPrec :: forall squareRootAlgorithm factorialAlgorithm.
(Read squareRootAlgorithm, Read factorialAlgorithm) =>
ReadPrec (Algorithm squareRootAlgorithm factorialAlgorithm)
readList :: ReadS [Algorithm squareRootAlgorithm factorialAlgorithm]
$creadList :: forall squareRootAlgorithm factorialAlgorithm.
(Read squareRootAlgorithm, Read factorialAlgorithm) =>
ReadS [Algorithm squareRootAlgorithm factorialAlgorithm]
readsPrec :: Int -> ReadS (Algorithm squareRootAlgorithm factorialAlgorithm)
$creadsPrec :: forall squareRootAlgorithm factorialAlgorithm.
(Read squareRootAlgorithm, Read factorialAlgorithm) =>
Int -> ReadS (Algorithm squareRootAlgorithm factorialAlgorithm)
Read, Int -> Algorithm squareRootAlgorithm factorialAlgorithm -> ShowS
[Algorithm squareRootAlgorithm factorialAlgorithm] -> ShowS
Algorithm squareRootAlgorithm factorialAlgorithm -> String
(Int -> Algorithm squareRootAlgorithm factorialAlgorithm -> ShowS)
-> (Algorithm squareRootAlgorithm factorialAlgorithm -> String)
-> ([Algorithm squareRootAlgorithm factorialAlgorithm] -> ShowS)
-> Show (Algorithm squareRootAlgorithm factorialAlgorithm)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall squareRootAlgorithm factorialAlgorithm.
(Show squareRootAlgorithm, Show factorialAlgorithm) =>
Int -> Algorithm squareRootAlgorithm factorialAlgorithm -> ShowS
forall squareRootAlgorithm factorialAlgorithm.
(Show squareRootAlgorithm, Show factorialAlgorithm) =>
[Algorithm squareRootAlgorithm factorialAlgorithm] -> ShowS
forall squareRootAlgorithm factorialAlgorithm.
(Show squareRootAlgorithm, Show factorialAlgorithm) =>
Algorithm squareRootAlgorithm factorialAlgorithm -> String
showList :: [Algorithm squareRootAlgorithm factorialAlgorithm] -> ShowS
$cshowList :: forall squareRootAlgorithm factorialAlgorithm.
(Show squareRootAlgorithm, Show factorialAlgorithm) =>
[Algorithm squareRootAlgorithm factorialAlgorithm] -> ShowS
show :: Algorithm squareRootAlgorithm factorialAlgorithm -> String
$cshow :: forall squareRootAlgorithm factorialAlgorithm.
(Show squareRootAlgorithm, Show factorialAlgorithm) =>
Algorithm squareRootAlgorithm factorialAlgorithm -> String
showsPrec :: Int -> Algorithm squareRootAlgorithm factorialAlgorithm -> ShowS
$cshowsPrec :: forall squareRootAlgorithm factorialAlgorithm.
(Show squareRootAlgorithm, Show factorialAlgorithm) =>
Int -> Algorithm squareRootAlgorithm factorialAlgorithm -> ShowS
Show)
instance (
Data.Default.Default squareRootAlgorithm,
Data.Default.Default factorialAlgorithm
) => Data.Default.Default (Algorithm squareRootAlgorithm factorialAlgorithm) where
def :: Algorithm squareRootAlgorithm factorialAlgorithm
def = squareRootAlgorithm
-> factorialAlgorithm
-> Algorithm squareRootAlgorithm factorialAlgorithm
forall squareRootAlgorithm factorialAlgorithm.
squareRootAlgorithm
-> factorialAlgorithm
-> Algorithm squareRootAlgorithm factorialAlgorithm
Borwein1993 squareRootAlgorithm
forall a. Default a => a
Data.Default.def factorialAlgorithm
forall a. Default a => a
Data.Default.def
instance (
Math.SquareRoot.Algorithmic squareRootAlgorithm,
Math.Factorial.Algorithmic factorialAlgorithm
) => Math.Pi.Algorithmic (Algorithm squareRootAlgorithm factorialAlgorithm) where
openR :: Algorithm squareRootAlgorithm factorialAlgorithm -> Int -> Rational
openR (Borwein1993 squareRootAlgorithm
squareRootAlgorithm factorialAlgorithm
factorialAlgorithm) = Series squareRootAlgorithm factorialAlgorithm
-> squareRootAlgorithm -> factorialAlgorithm -> Int -> Rational
forall squareRootAlgorithm factorialAlgorithm.
Series squareRootAlgorithm factorialAlgorithm
-> squareRootAlgorithm -> factorialAlgorithm -> Int -> Rational
Math.Implementations.Pi.Borwein.Implementation.openR Series squareRootAlgorithm factorialAlgorithm
forall squareRootAlgorithm factorialAlgorithm.
(Algorithmic squareRootAlgorithm,
Algorithmic factorialAlgorithm) =>
Series squareRootAlgorithm factorialAlgorithm
Math.Implementations.Pi.Borwein.Borwein1993.series squareRootAlgorithm
squareRootAlgorithm factorialAlgorithm
factorialAlgorithm