fast-math (empty) → 0.1
raw patch · 5 files changed
+102/−0 lines, 5 filesdep +basesetup-changed
Dependencies added: base
Files
- LICENSE +30/−0
- Numeric/FastMath.hs +25/−0
- Numeric/FastMath/Infinitesimal.hs +11/−0
- Setup.hs +2/−0
- fast-math.cabal +34/−0
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright © 2011, Liyang HU <fast-math@liyang.hu>++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++ * Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer.++ * Redistributions in binary form must reproduce the above+ copyright notice, this list of conditions and the following+ disclaimer in the documentation and/or other materials provided+ with the distribution.++ * Neither the name of Liyang HU nor the names of other contributors+ may be used to endorse or promote products derived from this+ software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ Numeric/FastMath.hs view
@@ -0,0 +1,25 @@+-- | Compile-time optimisations for 'Float' and 'Double' that break IEEE-754+-- compatibility.+--+-- Namely, this otherwise empty module contains RULES that rewrite @x-x@,+-- @x*0@ and @0*x@ to @0@, which is incorrect (according to IEEE-754) when+-- @x@ is @NaN@.+--+-- At the time of writing, @base-4.3.1.0:GHC/Base.lhs@ erroneously includes+-- these rules for 'Float's, but not for 'Double's. This has been reported+-- as GHC bug #5178: <http://hackage.haskell.org/trac/ghc/ticket/5178>.++module Numeric.FastMath () where++import GHC.Exts++{-# RULES+"minusFloat x x" forall x#. minusFloat# x# x# = 0.0#+"timesFloat x 0.0" forall x#. timesFloat# x# 0.0# = 0.0#+"timesFloat 0.0 x" forall x#. timesFloat# 0.0# x# = 0.0#++"minusDouble x x" forall x#. (-##) x# x# = 0.0##+"timesDouble 0.0 x" forall x#. (*##) 0.0## x# = 0.0##+"timesDouble x 0.0" forall x#. (*##) x# 0.0## = 0.0##+ #-}+
+ Numeric/FastMath/Infinitesimal.hs view
@@ -0,0 +1,11 @@+-- | Also rewrite @0/x@ to @+0@, which should really be @-0@ for negative @x@.++module Numeric.FastMath.Infinitesimal () where++import GHC.Exts++{-# RULES+"divideFloat 0.0 x" forall x#. divideFloat# 0.0# x# = 0.0#+"divideDouble 0.0 x" forall x#. (/##) 0.0## x# = 0.0##+ #-}+
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ fast-math.cabal view
@@ -0,0 +1,34 @@+name: fast-math+version: 0.1+synopsis: Non IEEE-754 compliant compile-time floating-point optimisations+description:+ The "Numeric.FastMath" module brings into scope RULES for 'Float's and+ 'Double's that rewrite @x-x@, @0*x@ and @x*0@ to @0@. This disagrees+ with IEEE-754 when @x@ is @NaN@, but is acceptable for most+ applications.+ .+ Importing "Numeric.FastMath.Infinitesimal" also rewrites @0/x@ to @0@.+ .+ Optimisation (at least @-O1@) must be enabled for any RULES to take effect.+license: BSD3+license-file: LICENSE+author: Liyang HU+maintainer: fast-math@liyang.hu+copyright: © 2011, Liyang HU+category: Math, Numeric+build-type: Simple+cabal-version: >= 1.2.3++library+ build-depends:+ base >= 3 && < 5+ exposed-modules:+ Numeric.FastMath+ Numeric.FastMath.Infinitesimal+ extensions:+ NoImplicitPrelude+ MagicHash+ ghc-options: -Wall -fno-warn-orphans++-- vim: et ts=4 sw=4:+