Skip to content

Commit

Permalink
Even more asthetics (#11)
Browse files Browse the repository at this point in the history
* change maintainer, and clarify comments.

* add another license header, and qualify imports.

* add more qualification and license headers
  • Loading branch information
julialongtin authored Dec 23, 2023
1 parent ca7518e commit 4e75700
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 19 deletions.
9 changes: 5 additions & 4 deletions src/Data/Bits/Floating.hs
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,12 @@ class (Floating f, Integral w) => FloatingBits f w | f -> w where
-- If the argument is 0.0, the maximum value smaller than 0.0 is returned.
-- If the argument is -INF, -INF is returned.
nextDown :: f -> f
-- | Return the size of an ulp of the argument. If the argument is NaN, NaN
-- is returned. If the argument is +INF or -INF, +INF is returned. If
-- the argument is 0.0, the minimum value greater than 0.0 is returned.
-- | Return the size of the Unit of Least Precision of the argument.
-- If the argument is NaN, NaN is returned.
-- If the argument is +INF or -INF, +INF is returned.
-- If the argument is 0.0, the minimum value greater than 0.0 is returned.
--
-- If @x@ is not NaN, @'ulp' x == 'ulp' (-x)@ holds.
-- If @x@ is not NaN or one of the infinities, @'ulp' x == 'ulp' (-x)@ holds.
ulp :: f -> f

class ShowFloat f where
Expand Down
4 changes: 2 additions & 2 deletions src/Data/Bits/Floating/Prim.hs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
-----------------------------------------------------------------------------
-- |
-- Copyright : (C) 2015 Anselm Jonas Scholl
-- Copyright : (C) 2015 Anselm Jonas Scholl, (C) 2023 Julia Longtin
-- License : BSD3
-- Maintainer : Anselm Jonas Scholl <anselm.scholl@tu-harburg.de>
-- Maintainer : Julia Longtin
-- Stability : experimental
-- Portability : GHC-specific
--
Expand Down
20 changes: 16 additions & 4 deletions test/Bench.hs
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
-----------------------------------------------------------------------------
-- |
-- Copyright : (C) 2015 Anselm Jonas Scholl, (C) 2023 Julia Longtin
-- License : BSD3
-- Maintainer : Julia Longtin <Julia.Longtin@gmail.com>
-- Stability : experimental
-- Portability : GHC-specific
--

module Main where

import TestUtils
import Prelude (Double, Float, IO, ($), (++), concatMap, map, shows, unzip)

import TestUtils (refDoubleDown, refDoubleToWord, refDoubleUp, refDoubleUlp, refFloatDown, refFloatToWord, refFloatUp, refFloatUlp, refWordToDouble, refWordToFloat, showW, testD, testF)

import Data.Word (Word32, Word64)

import Data.Word
import Data.Bits.Floating
import Data.Bits.Floating (coerceToFloat, coerceToWord, nextDown, nextUp, ulp)

import Criterion.Main
import Criterion.Main (Benchmark, bench, bgroup, defaultMain, nf)

mkSingleBenchmarks :: ((Float, Word32) -> [Benchmark]) -> ((Double, Word64) -> [Benchmark]) -> [Benchmark]
mkSingleBenchmarks mkFTest mkDTest = concatMap mkFTest testF ++ concatMap mkDTest testD
Expand Down
28 changes: 21 additions & 7 deletions test/Test.hs
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
-----------------------------------------------------------------------------
-- |
-- Copyright : (C) 2015 Anselm Jonas Scholl, (C) 2023 Julia Longtin
-- License : BSD3
-- Maintainer : Julia Longtin <Julia.Longtin@gmail.com>
-- Stability : experimental
-- Portability : GHC-specific
--

{-# LANGUAGE BangPatterns #-}

{-# LANGUAGE ScopedTypeVariables #-}

module Main where

import TestUtils
import Prelude(Bool(False), Double, Float, Integral, IO, MonadFail, RealFloat, Show, String, (.), (<), ($), (+), (-), (&&), (++), (<=), (>=), (/=), (==), (||), (<$>), either, fail, fromIntegral, fst, isInfinite, isNaN, isNegativeZero, mapM_, maxBound, minBound, not, otherwise, putStrLn, realToFrac, rem, return, quot, show, shows, snd)

import TestUtils (refDoubleDown, refDoubleToWord, refDoubleUp, refDoubleUlp, refFloatDown, refFloatToWord, refFloatUlp, refFloatUp, refWordToDouble, refWordToFloat, showW, testD, testF)

import Data.Word (Word32, Word64)

import Data.Word
import Data.Bits
import Data.Bits.Floating
import Data.Bits ((.&.), complement)
import Data.Bits.Floating (FloatingBits, ShowFloat, coerceToFloat, coerceToWord, nextDown, nextUp, showFloat, ulp)

import Control.Concurrent
import Control.Exception
import Control.Monad
import Control.Concurrent (MVar, forkIO, getNumCapabilities, newEmptyMVar, putMVar, takeMVar)
import Control.Exception (SomeException, throwIO, try)
import Control.Monad (forM_, join, replicateM_, unless, void, when)

main :: IO ()
main = do
Expand Down
16 changes: 14 additions & 2 deletions test/TestUtils.hs
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
-----------------------------------------------------------------------------
-- |
-- Copyright : (C) 2015 Anselm Jonas Scholl, (C) 2023 Julia Longtin
-- License : BSD3
-- Maintainer : Julia Longtin <Julia.Longtin@gmail.com>
-- Stability : experimental
-- Portability : GHC-specific
--

{-# LANGUAGE ForeignFunctionInterface #-}

module TestUtils where

import Data.Word
import Prelude (Double, Float, Integral, Show, String, (/), pi, sqrt)

import Data.Word (Word32, Word64)

import Numeric
import Numeric (showHex)

-- we do not test NaNs here because their binary representation can be changed
-- without changing their value and some processors have been observed to do that.
Expand Down

0 comments on commit 4e75700

Please sign in to comment.