continued-fractions 0.10.0.0 → 0.10.0.1
raw patch · 5 files changed
+73/−35 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGES.md +11/−0
- README.md +23/−0
- continued-fractions.cabal +7/−5
- src/Math/ContinuedFraction.hs +19/−19
- test/Math/CFTests.hs +13/−11
+ CHANGES.md view
@@ -0,0 +1,11 @@+0.10.0.0+=====++* Temporarily move project's repository from [mokus0](https://github.com/mokus0/continued-fractions) to+ [rockbmb](https://github.com/rockbmb/continued-fractions). This was a duplication, not a fork, so+ users can create issues in the latter repository as well.+* Enable Travis CI to run tests for each build for the project's new repository.+* Increase lower bound for the Cabal version to be used when compiling this+ project from `>=1.6` to `>=1.10`.+* Change the supported GHC versions from the interval [7.0.4 .. 7.11] to+ [8.0.2 .. 8.6.1].
+ README.md view
@@ -0,0 +1,23 @@+Continued Fractions+=========++[](https://travis-ci.org/rockbmb/continued-fractions)++`continued-fractions` is a Haskell library for manipulating and evaluating continued+fractions.++To use this library, the following information is relevant:++* The `CF` datatype is defined thusly:+```haskell+data CF a = CF a [a]+ | GCF a [(a,a)]+```+ where the `CF` constructor is used to represent continued fractions whose numerators+ are all `1`, and `GCF` represents generalized continued fractions. These constructors+ are not exported.++* The `cf :: a -> [a] -> CF a` function is used to create continued fractions.++* The `gcf :: a -> [(a,a)] -> CF a` function is used to create generalized continued+ fractions.
continued-fractions.cabal view
@@ -1,22 +1,24 @@ name: continued-fractions-version: 0.10.0.0+version: 0.10.0.1 stability: provisional cabal-version: >= 1.10 build-type: Simple -author: James Cook <mokus@deepbondi.net>-maintainer: James Cook <mokus@deepbondi.net>- Alexandre Rodrigues Baldé <alexandrer_b@outlook.com>+author: James Cook <mokus ΑT deepbondi dot net>+maintainer: James Cook <mokus ΑT deepbondi dot net>,+ Alexandre Rodrigues Baldé <alexandrer_b ΑT outlook dot com> license: PublicDomain homepage: https://github.com/rockbmb/continued-fractions-+bug-reports: https://github.com/rockbmb/continued-fractions/issues category: Math, Numerical synopsis: Continued fractions. description: A type and some functions for manipulating and evaluating continued fractions. tested-with: GHC==8.0.2, GHC==8.2.2, GHC==8.4.3, GHC==8.6.1+extra-source-files: CHANGES.md,+ README.md source-repository head type: git
src/Math/ContinuedFraction.hs view
@@ -199,15 +199,15 @@ -- |Evaluate the convergents of a continued fraction using the fundamental -- recurrence formula: -- --- A0 = b0, B0 = 1+-- @A0 = b0, B0 = 1@ ----- A1 = b1b0 + a1, B1 = b1+-- @A1 = b1b0 + a1, B1 = b1@ -- --- A{n+1} = b{n+1}An + a{n+1}A{n-1}+-- @A{n+1} = b{n+1}An + a{n+1}A{n-1}@ ----- B{n+1} = b{n+1}Bn + a{n+1}B{n-1}+-- @B{n+1} = b{n+1}Bn + a{n+1}B{n-1}@ ----- The convergents are then Xn = An/Bn+-- The convergents are then @Xn = An/Bn@ convergents :: (Fractional a, Eq a) => CF a -> [a] convergents orig = drop 1 (zipWith (/) nums denoms) where@@ -219,17 +219,17 @@ -- Only valid if the denominator in the following recurrence for D_i never -- goes to zero. If this method blows up, try 'modifiedLentz'. ----- D1 = 1/b1+-- @D1 = 1/b1@ -- --- D{i} = 1 / (b{i} + a{i} * D{i-1})+-- @D{i} = 1 / (b{i} + a{i} * D{i-1})@ -- --- dx1 = a1 / b1+-- @dx1 = a1 / b1@ -- --- dx{i} = (b{i} * D{i} - 1) * dx{i-1}+-- @dx{i} = (b{i} * D{i} - 1) * dx{i-1}@ -- --- x0 = b0+-- @x0 = b0@ -- --- x{i} = x{i-1} + dx{i}+-- @x{i} = x{i-1} + dx{i}@ -- -- The convergents are given by @scanl (+) b0 dxs@ steed :: (Fractional a, Eq a) => CF a -> [a]@@ -249,13 +249,13 @@ -- Only valid if the denominators in the following recurrence never go to -- zero. If this method blows up, try 'modifiedLentz'. ----- C1 = b1 + a1 / b0+-- @C1 = b1 + a1 / b0@ ----- D1 = 1/b1+-- @D1 = 1/b1@ -- --- C{n} = b{n} + a{n} / C{n-1}+-- @C{n} = b{n} + a{n} / C{n-1}@ -- --- D{n} = 1 / (b{n} + a{n} * D{n-1})+-- @D{n} = 1 / (b{n} + a{n} * D{n-1})@ -- -- The convergents are given by @scanl (*) b0 (zipWith (*) cs ds)@ lentz :: (Fractional a, Eq a) => CF a -> [a]@@ -313,11 +313,11 @@ -- |Evaluate the convergents of a continued fraction using Lentz's method, -- (see 'lentz') with the additional rule that if a denominator ever goes -- to zero, it will be replaced by a (very small) number of your choosing,--- typically 1e-30 or so (this modification was proposed by Thompson and --- Barnett). +-- typically 1e-30 or so (this modification was proposed by Thompson and+-- Barnett). -- --- Additionally splits the resulting list of convergents into sublists, --- starting a new list every time the \'modification\' is invoked. +-- Additionally splits the resulting list of convergents into sublists,+-- starting a new list every time the \'modification\' is invoked. modifiedLentz :: (Fractional a, Eq a) => a -> CF a -> [[a]] modifiedLentz = modifiedLentzWith id (*) recip
test/Math/CFTests.hs view
@@ -6,13 +6,16 @@ module Math.CFTests ( cfTests+ , prop_modifiedLentzWith_log_sane ) where -import Control.Applicative-import Data.List-import qualified Data.Set as S import Math.ContinuedFraction-import Test.QuickCheck++import Control.Applicative (liftA2)+import Data.List (isPrefixOf, genericLength)+import qualified Data.Set as S+import Test.QuickCheck (Arbitrary (..), CoArbitrary (..),+ NonNegative (..), Property, (==>)) import Test.Framework (Test, testGroup) import Test.Framework.Providers.QuickCheck2 (testProperty) @@ -188,8 +191,8 @@ (sX, x) ~= (sY, y) = sX == sY - && (absErr <= eps * max 1 n- || relErr <= eps * max 1 n+ && (absErr <= eps * max 1 n * 16+ || relErr <= eps * max 1 n * 16 || any isNaN [absErr, relErr]) where absErr = abs (x-y)@@ -229,11 +232,10 @@ addSignLog (xS,xL) (yS,yL) = (xS*yS, xL+yL) negateSignLog (s,l) = (negate s, l) - (sX, x) ~= (sY, y) - = sX == sY - && (absErr <= eps * max 1 n * max 1 m- || relErr <= eps * max 1 n * max 1 m- || any isNaN [absErr, relErr])+ (sX, x) ~= (sY, y) = (sX == sY)+ && (absErr <= eps * max 1 n * max 1 m+ || relErr <= eps * max 1 n * max 1 m+ || any isNaN [absErr, relErr]) where absErr = abs (x-y) relErr = absErr / max (abs x) (abs y)