module Factory.Math.Implementations.Pi.Spigot.Algorithm(
Algorithm(..)
) where
import Data.Ratio((%))
import qualified Factory.Math.Implementations.Pi.Spigot.Gosper as Math.Implementations.Pi.Spigot.Gosper
import qualified Factory.Math.Implementations.Pi.Spigot.RabinowitzWagon as Math.Implementations.Pi.Spigot.RabinowitzWagon
import qualified Factory.Math.Implementations.Pi.Spigot.Spigot as Math.Implementations.Pi.Spigot.Spigot
import qualified Factory.Math.Pi as Math.Pi
import qualified ToolShed.Defaultable
data Algorithm =
Gosper
| RabinowitzWagon
deriving (Eq, Read, Show)
instance ToolShed.Defaultable.Defaultable Algorithm where
defaultValue = Gosper
instance Math.Pi.Algorithmic Algorithm where
openI Gosper = Math.Implementations.Pi.Spigot.Spigot.openI Math.Implementations.Pi.Spigot.Gosper.series
openI RabinowitzWagon = Math.Implementations.Pi.Spigot.Spigot.openI Math.Implementations.Pi.Spigot.RabinowitzWagon.series
openR algorithm decimalDigits = Math.Pi.openI algorithm decimalDigits % (10 ^ pred decimalDigits)