packages feed

diagrams-solve 0.1.1 → 0.1.2

raw patch · 4 files changed

+28/−12 lines, 4 filesdep ~basePVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base

API changes (from Hackage documentation)

Files

CHANGES.markdown view
@@ -1,3 +1,9 @@+* 0.1.2 (5 May 2020)++  Improvements to stability/accuraty of `cubForm` and+  `quartForm`, contributed by Jasper Van der Jeugt+  ([#7](https://github.com/diagrams/diagrams-solve/pull/7), [#8](https://github.com/diagrams/diagrams-solve/pull/8))+ * 0.1.1 (3 July 2017)    allow base-4.10 for GHC-8.2
diagrams-solve.cabal view
@@ -1,5 +1,5 @@ name:                diagrams-solve-version:             0.1.1+version:             0.1.2 synopsis:            Pure Haskell solver routines used by diagrams description:         Pure Haskell solver routines used by the diagrams                      project.  Currently includes finding real roots@@ -15,7 +15,7 @@ build-type:          Simple extra-source-files:  README.markdown, CHANGES.markdown cabal-version:       >=1.10-Tested-with:         GHC == 7.6.3, GHC == 7.8.4, GHC == 7.10.3, GHC == 8.0.1, GHC == 8.2.1+Tested-with:         GHC == 7.6.3, GHC == 7.8.4, GHC == 7.10.3, GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.3, GHC == 8.6.1, GHC == 8.8.1 Source-repository head   type:     git   location: http://github.com/diagrams/diagrams-solve.git@@ -23,7 +23,7 @@ library   exposed-modules:     Diagrams.Solve.Polynomial,                        Diagrams.Solve.Tridiagonal-  build-depends:       base >=4.5 && < 4.11+  build-depends:       base >=4.5 && < 5.0   hs-source-dirs:      src   default-language:    Haskell2010 @@ -33,10 +33,9 @@   -- other-modules: Instances   hs-source-dirs: tests   default-language:    Haskell2010-  build-depends:       base >= 4.2 && < 4.11,-                       tasty >= 0.10 && < 0.12,-                       tasty-hunit >= 0.9.2 && < 0.10,-                       tasty-quickcheck >= 0.8 && < 0.9,+  build-depends:       base >= 4.2 && < 5.0,                        deepseq >= 1.3 && < 1.5,-                       diagrams-solve-+                       diagrams-solve,+                       tasty >= 0.10 && < 1.3,+                       tasty-hunit >= 0.9.2 && < 0.11,+                       tasty-quickcheck >= 0.8 && < 0.11
src/Diagrams/Solve/Polynomial.hs view
@@ -107,8 +107,7 @@  where delta  = 18*a*b*c*d - 4*b^3*d + b^2*c^2 - 4*a*c^3 - 27*a^2*d^2        disc   = 3*a*c - b^2        qq     = sqrt(-27*(a^2)*delta)-       qq'    | aboutZero' toler disc = maximumBy (comparing (abs . (+xx))) [qq, -qq]-              | otherwise = qq+       qq'    = if abs (xx + qq) > abs (xx - qq) then qq else -qq        cc     = cubert (1/2*(qq' + xx))        xx     = 2*b^3 - 9*a*b*c + 27*a^2*d        p      = disc/(3*a^2)@@ -169,7 +168,7 @@       -- | roots of the reduced quartic       roots | aboutZero' toler r =                 0 : cubForm 1 0 p q   -- no constant term: y(y^3 + py + q) = 0-            | u < 0 || v < 0 = []     -- no real solutions due to square root+            | u < -toler || v < -toler = []     -- no real solutions due to square root             | otherwise      = s1++s2 -- solutions of the quadratics        -- solve the resolvent cubic - only one solution is needed
tests/Test.hs view
@@ -1,5 +1,6 @@ module Main where +import Data.List (sort) import Diagrams.Solve.Polynomial  import Test.Tasty (defaultMain, testGroup, TestTree)@@ -12,6 +13,17 @@ -- could verify number of solutions, but we would just duplicate the function definition         , testProperty "solutions found satisfy cubic equation" $          \a b c d -> let sat x =  a * x * x * x + b * x * x + c * x + d =~ (0 :: Double) in all sat (cubForm a b c d)++-- some specific examples and regression tests+        , testGroup "Solve specific examples" [+            testProperty "1 * x^3 + -886.7970773009183 * x^2 + 262148.4783430062 * x + -264000817.775054 = 0" $+                let [r] = cubForm 1 (-886.7970773009183) 262148.4783430062 (-264000817.775054) in+                r =~ 915.4538593912++          , testProperty "1 * u^4 + -240 * u^3 + 25449 * u^2 + -1325880 * u + 26471900.25 = 0" $+                let [r1, r2] = sort $ quartForm 1 (-240) 25449 (-1325880) 26471900.25 in+                r1 =~ 50.6451 && r2 =~ 69.3549+            ]         ]  (=~) :: Double -> Double -> Bool