Numeric.Half

half-0.3.2: Half-precision floating-point

Copyright | (C) 2014 Edward Kmett
License | BSD-style (see the file LICENSE)
Maintainer | Edward Kmett <ekmett@gmail.com>
Stability | experimental
Portability | PatternSynonyms
Safe Haskell | Safe
Language | Haskell2010

Numeric.Half

Contents

- Patterns

Description

Half-precision floating-point values. These arise commonly in GPU work and it is useful to be able to compute them and compute with them on the CPU as well.

Synopsis

- newtype Half = Half {
  - getHalf :: CUShort
  }
- isZero :: Half -> Bool
- fromHalf :: Half -> Float
- toHalf :: Float -> Half
- pattern POS_INF :: Half
- pattern NEG_INF :: Half
- pattern QNaN :: Half
- pattern SNaN :: Half
- pattern HALF_MIN :: Half
- pattern HALF_NRM_MIN :: Half
- pattern HALF_MAX :: Half
- pattern HALF_EPSILON :: Half
- pattern HALF_DIG :: (Eq a, Num a) => a
- pattern HALF_MIN_10_EXP :: (Eq a, Num a) => a
- pattern HALF_MAX_10_EXP :: (Eq a, Num a) => a

# Documentation

newtype Half #

A half-precision floating point value

Constructors

Half |
Fields getHalf :: CUShort

#### Instances

Instances details

Binary Half # |
Instance details Defined in Numeric.Half.Internal Methods put :: Half -> Put # get :: Get Half # putList :: [Half] -> Put #
NFData Half # |
Instance details Defined in Numeric.Half.Internal Methods rnf :: Half -> () #
Floating Half # |
Instance details Defined in Numeric.Half.Internal Methods pi :: Half # exp :: Half -> Half # log :: Half -> Half # sqrt :: Half -> Half # (**) :: Half -> Half -> Half # logBase :: Half -> Half -> Half # sin :: Half -> Half # cos :: Half -> Half # tan :: Half -> Half # asin :: Half -> Half # acos :: Half -> Half # atan :: Half -> Half # sinh :: Half -> Half # cosh :: Half -> Half # tanh :: Half -> Half # asinh :: Half -> Half # acosh :: Half -> Half # atanh :: Half -> Half # log1p :: Half -> Half # expm1 :: Half -> Half # log1pexp :: Half -> Half # log1mexp :: Half -> Half #
RealFloat Half # |
Instance details Defined in Numeric.Half.Internal Methods floatRadix :: Half -> Integer # floatDigits :: Half -> Int # floatRange :: Half -> (Int, Int) # decodeFloat :: Half -> (Integer, Int) # encodeFloat :: Integer -> Int -> Half # exponent :: Half -> Int # significand :: Half -> Half # scaleFloat :: Int -> Half -> Half # isNaN :: Half -> Bool # isInfinite :: Half -> Bool # isDenormalized :: Half -> Bool # isNegativeZero :: Half -> Bool # isIEEE :: Half -> Bool # atan2 :: Half -> Half -> Half #
Storable Half # |
Instance details Defined in Numeric.Half.Internal Methods sizeOf :: Half -> Int # alignment :: Half -> Int # peekElemOff :: Ptr Half -> Int -> IO Half # pokeElemOff :: Ptr Half -> Int -> Half -> IO () # peekByteOff :: Ptr b -> Int -> IO Half # pokeByteOff :: Ptr b -> Int -> Half -> IO () # peek :: Ptr Half -> IO Half # poke :: Ptr Half -> Half -> IO () #
Generic Half # |
Instance details Defined in Numeric.Half.Internal Associated Types
type Rep Half |
Instance details Defined in Numeric.Half.Internal type Rep Half = D1 ('MetaData "Half" "Numeric.Half.Internal" "half-0.3.2-GFH8XiHPzd68b9ETUBFF4k" 'True) (C1 ('MetaCons "Half" 'PrefixI 'True) (S1 ('MetaSel ('Just "getHalf") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 CUShort)))
Methods from :: Half -> Rep Half x # to :: Rep Half x -> Half #
Num Half # |
Instance details Defined in Numeric.Half.Internal Methods (+) :: Half -> Half -> Half # (-) :: Half -> Half -> Half # (*) :: Half -> Half -> Half # negate :: Half -> Half # abs :: Half -> Half # signum :: Half -> Half # fromInteger :: Integer -> Half #
Read Half # |
Instance details Defined in Numeric.Half.Internal Methods readsPrec :: Int -> ReadS Half # readList :: ReadS [Half] # readPrec :: ReadPrec Half # readListPrec :: ReadPrec [Half] #
Fractional Half # |
Instance details Defined in Numeric.Half.Internal Methods (/) :: Half -> Half -> Half # recip :: Half -> Half # fromRational :: Rational -> Half #
Real Half # |
Instance details Defined in Numeric.Half.Internal Methods toRational :: Half -> Rational #
RealFrac Half # |
Instance details Defined in Numeric.Half.Internal Methods properFraction :: Integral b => Half -> (b, Half) # truncate :: Integral b => Half -> b # round :: Integral b => Half -> b # ceiling :: Integral b => Half -> b # floor :: Integral b => Half -> b #
Show Half # |
Instance details Defined in Numeric.Half.Internal Methods showsPrec :: Int -> Half -> ShowS # show :: Half -> String # showList :: [Half] -> ShowS #
Eq Half # |
Instance details Defined in Numeric.Half.Internal Methods (==) :: Half -> Half -> Bool # (/=) :: Half -> Half -> Bool #
Ord Half # |
Instance details Defined in Numeric.Half.Internal Methods compare :: Half -> Half -> Ordering # (<) :: Half -> Half -> Bool # (<=) :: Half -> Half -> Bool # (>) :: Half -> Half -> Bool # (>=) :: Half -> Half -> Bool # max :: Half -> Half -> Half # min :: Half -> Half -> Half #
Lift Half # |
Instance details Defined in Numeric.Half.Internal Methods lift :: Quote m => Half -> m Exp # liftTyped :: forall (m :: Type -> Type). Quote m => Half -> Code m Half #
type Rep Half # |
Instance details Defined in Numeric.Half.Internal type Rep Half = D1 ('MetaData "Half" "Numeric.Half.Internal" "half-0.3.2-GFH8XiHPzd68b9ETUBFF4k" 'True) (C1 ('MetaCons "Half" 'PrefixI 'True) (S1 ('MetaSel ('Just "getHalf") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 CUShort)))

isZero :: Half -> Bool #

Is this `Half` equal to 0?

fromHalf :: Half -> Float #

Convert a `Half` to a `Float` while preserving NaN

toHalf :: Float -> Half #

Convert a `Float` to a `Half` with proper rounding, while preserving NaN and dealing appropriately with infinity

# Patterns

pattern POS_INF :: Half #

Positive infinity

pattern NEG_INF :: Half #

Negative infinity

pattern QNaN :: Half #

Quiet NaN

pattern SNaN :: Half #

Signalling NaN

pattern HALF_MIN :: Half #

Smallest positive half

pattern HALF_NRM_MIN :: Half #

Smallest positive normalized half

pattern HALF_MAX :: Half #

Largest positive half

pattern HALF_EPSILON :: Half #

Smallest positive e for which half (1.0 + e) != half (1.0)

pattern HALF_DIG :: (Eq a, Num a) => a #

Number of base 10 digits that can be represented without change

pattern HALF_MIN_10_EXP :: (Eq a, Num a) => a #

Minimum positive integer such that 10 raised to that power is a normalized half

pattern HALF_MAX_10_EXP :: (Eq a, Num a) => a #

Maximum positive integer such that 10 raised to that power is a normalized half