posit 2022.0.1.1 → 2022.0.1.2
raw patch · 4 files changed
+46/−47 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- README.md +18/−19
- posit.cabal +1/−1
- stack.yaml +3/−3
- test/TestElementaryFunctions.hs +24/−24
README.md view
@@ -1,4 +1,4 @@-# posit 2022.0.1.1+# posit 2022.0.1.2 The [Posit Standard 2022](https://posithub.org/docs/posit_standard-2.pdf), and [Posit Standard 3.2](https://posithub.org/docs/posit_standard.pdf), @@ -101,48 +101,47 @@ instances. -Well, so...-Iron sharpens Iron, or so they say.-So, the implementations might not be perfect, but... they pretty good!+The Elementary Functions for this posit library are implemented natively+using the next larger posit number. P16 and Posit16 numbers are tested+exhaustively against Double Precision numbers as the orical. The results+are below: Number of Accurate Bits `exp`:-+ Number of Accurate Bits `log`:-+ Number of Accurate Bits `sqrt`:-+ Number of Accurate Bits `sin`:-+ Number of Accurate Bits `cos`:-+ Number of Accurate Bits `asin`:-+ Number of Accurate Bits `acos`:-+ Number of Accurate Bits `atan`:-+ Number of Accurate Bits `sinh`:-+ Number of Accurate Bits `cosh`:-+ Number of Accurate Bits `asinh`:-+ Number of Accurate Bits `acosh`:-+ Number of Accurate Bits `atanh`:---+
posit.cabal view
@@ -1,7 +1,7 @@ cabal-version: 1.12 name: posit-version: 2022.0.1.1+version: 2022.0.1.2 description: The Posit Number format attempting to conform to the Posit Standard Versions 3.2 and 2022. Where Real numbers are approximated by `Maybe Rational` and sampled in a similar way to the projective real line. homepage: https://github.com/waivio/posit#readme bug-reports: https://github.com/waivio/posit/issues
stack.yaml view
@@ -1,7 +1,7 @@ # This file is attempting to maintain the working Liquid Haskell versions # that coorispond to a specific GHC or Stackage version -# resolver: nightly-2023-05-20 # ghc-9.4.5+# resolver: nightly-2023-06-19 # ghc-9.4.5 resolver: lts-20.26 # ghc-9.2.8 # resolver: lts-19.33 # ghc-9.0.2 # resolver: lts-18.28 # ghc-8.10.7@@ -16,8 +16,8 @@ - Chart-cairo-1.9.3 - cairo-0.13.10.0 # For LiquidHaskell:- - hashable-1.3.5.0 # lts-20.16 and below- # - hashable-1.4.2.0 # ghc-9.4.4+ # - hashable-1.3.5.0 # lts-20.16 and below+ - hashable-1.4.2.0 # ghc-9.4.4 - text-format-0.3.2 - Diff-0.3.4 - optparse-applicative-0.16.1.0
test/TestElementaryFunctions.hs view
@@ -16,6 +16,7 @@ main :: IO () main = do expPlotP16Posit16 logPlotP16Posit16+ sqrtPlotsP16Posit16 sinPlotsP16Posit16 cosPlotsP16Posit16 asinPlotsP16Posit16@@ -26,23 +27,8 @@ asinhPlotsP16Posit16 acoshPlotsP16Posit16 atanhPlotsP16Posit16- sqrtPlotsP16Posit16 -- -sinPlotsP16Posit16 = toFile def "./test/Results/Bits Accuracy of sin with P16 and Posit16.png" $ do- let sineP16 = filter (\(_,d) -> not $ nanOrInf d) [(read (displayIntegral p) :: Double, err p (sin p) sin) | p <- enumFrom (NaR :: P16)]- sinePosit16 = filter (\(_,d) -> not $ nanOrInf d) [(read (displayIntegral p) :: Double, err p (sin p) sin) | p <- enumFrom (NaR :: Posit16)]- layout_title .= "Number of Accurate Bits of P16 and Posit16 Sine"- plot (line "sin P16 error" [sineP16])- plot (line "sin Posit16 error" [sinePosit16])--cosPlotsP16Posit16 = toFile def "./test/Results/Bits Accuracy of cos with P16 and Posit16.png" $ do- let cosineP16 = filter (\(_,d) -> not $ nanOrInf d) [(read (displayIntegral p) :: Double, err p (cos p) cos) | p <- enumFrom (NaR :: P16)]- cosinePosit16 = filter (\(_,d) -> not $ nanOrInf d) [(read (displayIntegral p) :: Double, err p (cos p) cos) | p <- enumFrom (NaR :: Posit16)]- layout_title .= "Number of Accurate Bits of P16 and Posit16 Cosine"- plot (line "cos P16 error" [cosineP16])- plot (line "cos Posit16 error" [cosinePosit16])- expPlotP16Posit16 = toFile def "./test/Results/Bits Accuracy of exp with P16 and Posit16.png" $ do let expP16 = filter (\(_,d) -> not $ nanOrInf d) [(read (displayIntegral p) :: Double, err p (exp p) exp) | p <- enumFrom (NaR :: P16)] expPosit16 = filter (\(_,d) -> not $ nanOrInf d) [(read (displayIntegral p) :: Double, err p (exp p) exp) | p <- enumFrom (NaR :: Posit16)]@@ -57,6 +43,27 @@ plot (line "log P16 error" [lnP16]) plot (line "log Posit16 error" [lnPosit16]) +sqrtPlotsP16Posit16 = toFile def "./test/Results/Bits Accuracy of sqrt with P16 and Posit16.png" $ do+ let sqrtP16 = filter (\(_,d) -> not $ nanOrInf d) [(read (displayIntegral p) :: Double, err p (sqrt p) sqrt) | p <- enumFrom (0 :: P16)]+ sqrtPosit16 = filter (\(_,d) -> not $ nanOrInf d) [(read (displayIntegral p) :: Double, err p (sqrt p) sqrt) | p <- enumFrom (0 :: Posit16)]+ layout_title .= "Number of Accurate Bits of P16 and Posit16 Square Root"+ plot (line "sqrt P16 error" [sqrtP16])+ plot (line "sqrt Posit16 error" [sqrtPosit16])++sinPlotsP16Posit16 = toFile def "./test/Results/Bits Accuracy of sin with P16 and Posit16.png" $ do+ let sineP16 = filter (\(_,d) -> not $ nanOrInf d) [(read (displayIntegral p) :: Double, err p (sin p) sin) | p <- enumFrom (NaR :: P16)]+ sinePosit16 = filter (\(_,d) -> not $ nanOrInf d) [(read (displayIntegral p) :: Double, err p (sin p) sin) | p <- enumFrom (NaR :: Posit16)]+ layout_title .= "Number of Accurate Bits of P16 and Posit16 Sine"+ plot (line "sin P16 error" [sineP16])+ plot (line "sin Posit16 error" [sinePosit16])++cosPlotsP16Posit16 = toFile def "./test/Results/Bits Accuracy of cos with P16 and Posit16.png" $ do+ let cosineP16 = filter (\(_,d) -> not $ nanOrInf d) [(read (displayIntegral p) :: Double, err p (cos p) cos) | p <- enumFrom (NaR :: P16)]+ cosinePosit16 = filter (\(_,d) -> not $ nanOrInf d) [(read (displayIntegral p) :: Double, err p (cos p) cos) | p <- enumFrom (NaR :: Posit16)]+ layout_title .= "Number of Accurate Bits of P16 and Posit16 Cosine"+ plot (line "cos P16 error" [cosineP16])+ plot (line "cos Posit16 error" [cosinePosit16])+ asinPlotsP16Posit16 = toFile def "./test/Results/Bits Accuracy of asin with P16 and Posit16.png" $ do let arcsineP16 = filter (\(_,d) -> not $ nanOrInf d) [(read (displayIntegral p) :: Double, err p (asin p) sin) | p <- enumFromTo (-1 :: P16) 1] arcsinePosit16 = filter (\(_,d) -> not $ nanOrInf d) [(read (displayIntegral p) :: Double, err p (asin p) sin) | p <- enumFromTo (-1 :: Posit16) 1]@@ -99,10 +106,10 @@ plot (line "asinh P16 error" [archypsineP16]) plot (line "asinh Posit16 error" [archypsinePosit16]) -acoshPlotsP16Posit16 = toFile def "./test/Results/Bits Accuracy of cosh with P16 and Posit16.png" $ do+acoshPlotsP16Posit16 = toFile def "./test/Results/Bits Accuracy of acosh with P16 and Posit16.png" $ do let archypcosineP16 = filter (\(_,d) -> not $ nanOrInf d) [(read (displayIntegral p) :: Double, err p (acosh p) acosh) | p <- enumFrom (NaR :: P16)] archypcosinePosit16 = filter (\(_,d) -> not $ nanOrInf d) [(read (displayIntegral p) :: Double, err p (acosh p) acosh) | p <- enumFrom (NaR :: Posit16)]- layout_title .= "Number of Accurate Bits of P16 and Posit16 Hyperbolic Cosine"+ layout_title .= "Number of Accurate Bits of P16 and Posit16 Inv Hyperbolic Cosine" plot (line "acosh P16 error" [archypcosineP16]) plot (line "acosh Posit16 error" [archypcosinePosit16]) @@ -112,13 +119,6 @@ layout_title .= "Number of Accurate Bits of P16 and Posit16 Inv Hyperbolic Tangent" plot (line "atanh P16 error" [archyptangentP16]) plot (line "atanh Posit16 error" [archyptangentPosit16])--sqrtPlotsP16Posit16 = toFile def "./test/Results/Bits Accuracy of sqrt with P16 and Posit16.png" $ do- let sqrtP16 = filter (\(_,d) -> not $ nanOrInf d) [(read (displayIntegral p) :: Double, err p (sqrt p) sqrt) | p <- enumFrom (0 :: P16)]- sqrtPosit16 = filter (\(_,d) -> not $ nanOrInf d) [(read (displayIntegral p) :: Double, err p (sqrt p) sqrt) | p <- enumFrom (0 :: Posit16)]- layout_title .= "Number of Accurate Bits of P16 and Posit16 Square Root"- plot (line "sqrt P16 error" [sqrtP16])- plot (line "sqrt Posit16 error" [sqrtPosit16])