half-0.3.1: 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 | Trustworthy
Language | Haskell2010

Numeric.Half.Internal

Contents

- Patterns
- Pure conversions

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
- pure_floatToHalf :: Float -> Half
- pure_halfToFloat :: Half -> Float

# Documentation

newtype Half Source #

Constructors

Half |

Fields

- getHalf :: CUShort

#### Instances

Instances details

Storable Half Source # |

Instance details

Defined in Numeric.Half.Internal

Methods

sizeOf :: Half -> Int Source #

alignment :: Half -> Int Source #

peekElemOff :: Ptr Half -> Int -> IO Half Source #

pokeElemOff :: Ptr Half -> Int -> Half -> IO () Source #

peekByteOff :: Ptr b -> Int -> IO Half Source #

pokeByteOff :: Ptr b -> Int -> Half -> IO () Source #

peek :: Ptr Half -> IO Half Source #

poke :: Ptr Half -> Half -> IO () Source #

Floating Half Source # |

Instance details

Defined in Numeric.Half.Internal

Methods

pi :: Half Source #

exp :: Half -> Half Source #

log :: Half -> Half Source #

sqrt :: Half -> Half Source #

(**) :: Half -> Half -> Half Source #

logBase :: Half -> Half -> Half Source #

sin :: Half -> Half Source #

cos :: Half -> Half Source #

tan :: Half -> Half Source #

asin :: Half -> Half Source #

acos :: Half -> Half Source #

atan :: Half -> Half Source #

sinh :: Half -> Half Source #

cosh :: Half -> Half Source #

tanh :: Half -> Half Source #

asinh :: Half -> Half Source #

acosh :: Half -> Half Source #

atanh :: Half -> Half Source #

log1p :: Half -> Half Source #

expm1 :: Half -> Half Source #

log1pexp :: Half -> Half Source #

log1mexp :: Half -> Half Source #

RealFloat Half Source # |

Instance details

Defined in Numeric.Half.Internal

Methods

floatRadix :: Half -> Integer Source #

floatDigits :: Half -> Int Source #

floatRange :: Half -> (Int, Int) Source #

decodeFloat :: Half -> (Integer, Int) Source #

encodeFloat :: Integer -> Int -> Half Source #

exponent :: Half -> Int Source #

significand :: Half -> Half Source #

scaleFloat :: Int -> Half -> Half Source #

isNaN :: Half -> Bool Source #

isInfinite :: Half -> Bool Source #

isDenormalized :: Half -> Bool Source #

isNegativeZero :: Half -> Bool Source #

isIEEE :: Half -> Bool Source #

atan2 :: Half -> Half -> Half Source #

Generic Half Source # |
Instance details Defined in Numeric.Half.Internal Associated Types type Rep Half :: Type -> Type Source # Methods from :: Half -> Rep Half x Source # to :: Rep Half x -> Half Source #
Num Half Source # |
Instance details Defined in Numeric.Half.Internal Methods (+) :: Half -> Half -> Half Source # (-) :: Half -> Half -> Half Source # (*) :: Half -> Half -> Half Source # negate :: Half -> Half Source # abs :: Half -> Half Source # signum :: Half -> Half Source # fromInteger :: Integer -> Half Source #
Read Half Source # |
Instance details Defined in Numeric.Half.Internal Methods readsPrec :: Int -> ReadS Half Source # readList :: ReadS [Half] Source # readPrec :: ReadPrec Half Source # readListPrec :: ReadPrec [Half] Source #
Fractional Half Source # |
Instance details Defined in Numeric.Half.Internal Methods (/) :: Half -> Half -> Half Source # recip :: Half -> Half Source # fromRational :: Rational -> Half Source #
Real Half Source # |
Instance details Defined in Numeric.Half.Internal Methods toRational :: Half -> Rational Source #
RealFrac Half Source # |
Instance details Defined in Numeric.Half.Internal Methods properFraction :: Integral b => Half -> (b, Half) Source # truncate :: Integral b => Half -> b Source # round :: Integral b => Half -> b Source # ceiling :: Integral b => Half -> b Source # floor :: Integral b => Half -> b Source #
Show Half Source # |
Instance details Defined in Numeric.Half.Internal Methods showsPrec :: Int -> Half -> ShowS Source # show :: Half -> String Source # showList :: [Half] -> ShowS Source #
Binary Half Source # |
Instance details Defined in Numeric.Half.Internal Methods put :: Half -> Put Source # get :: Get Half Source # putList :: [Half] -> Put Source #
NFData Half Source # |
Instance details Defined in Numeric.Half.Internal Methods rnf :: Half -> () Source #
Eq Half Source # |
Instance details Defined in Numeric.Half.Internal Methods (==) :: Half -> Half -> Bool Source # (/=) :: Half -> Half -> Bool Source #
Ord Half Source # |
Instance details Defined in Numeric.Half.Internal Methods compare :: Half -> Half -> Ordering Source # (<) :: Half -> Half -> Bool Source # (<=) :: Half -> Half -> Bool Source # (>) :: Half -> Half -> Bool Source # (>=) :: Half -> Half -> Bool Source # max :: Half -> Half -> Half Source # min :: Half -> Half -> Half Source #
Lift Half Source # |
Instance details Defined in Numeric.Half.Internal Methods lift :: Quote m => Half -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => Half -> Code m Half Source #
type Rep Half Source # |
Instance details Defined in Numeric.Half.Internal type Rep Half = D1 ('MetaData "Half" "Numeric.Half.Internal" "half-0.3.1-H4tuI2JRlq2ChsYBLMzzDb" 'True) (C1 ('MetaCons "Half" 'PrefixI 'True) (S1 ('MetaSel ('Just "getHalf") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 CUShort)))

isZero :: Half -> Bool Source #

Is this `Half` equal to 0?

fromHalf :: Half -> Float Source #

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

toHalf :: Float -> Half Source #

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

# Patterns

These are available with GHC-7.8 and later.

pattern POS_INF :: Half Source #

Positive infinity

pattern NEG_INF :: Half Source #

Negative infinity

pattern QNaN :: Half Source #

Quiet NaN

pattern SNaN :: Half Source #

Signalling NaN

pattern HALF_MIN :: Half Source #

Smallest positive half

pattern HALF_NRM_MIN :: Half Source #

Smallest positive normalized half

pattern HALF_MAX :: Half Source #

Largest positive half

pattern HALF_EPSILON :: Half Source #

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

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

Number of base 10 digits that can be represented without change

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

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

# Pure conversions

pure_floatToHalf :: Float -> Half Source #

Naive pure-Haskell implementation of `toHalf`.

pure_halfToFloat :: Half -> Float Source #

Naive pure-Haskell implementation of `fromHalf`.