Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
This module provides helper functions for computing fast enclosures
using double
arithmetic.
Synopsis
- data Di = Di !(ForeignPtr CDi)
- data CDi = CDi CDouble CDouble
- di_interval :: CDouble -> CDouble -> CDi
- arb_get_di :: Ptr CArb -> IO CDi
- arb_set_di :: Ptr CArb -> CDi -> CLong -> IO ()
- di_print :: CDi -> IO ()
- di_randtest2 :: Ptr CFRandState -> IO CDouble
- di_randtest :: Ptr CFRandState -> IO CDi
- di_neg :: CDi -> CDi
- di_fast_add :: CDi -> CDi -> CDi
- di_fast_sub :: CDi -> CDi -> CDi
- di_fast_mul :: CDi -> CDi -> CDi
- di_fast_div :: CDi -> CDi -> CDi
- di_fast_sqr :: CDi -> CDi
- di_fast_add_d :: CDi -> CDouble -> CDi
- di_fast_sub_d :: CDi -> CDouble -> CDi
- di_fast_mul_d :: CDi -> CDouble -> CDi
- di_fast_div_d :: CDi -> CDouble -> CDi
- di_fast_log_nonnegative :: CDi -> CDi
- di_fast_mid :: CDi -> CDi
- di_fast_ubound_radius :: CDi -> CDouble
Double-precision interval arithmetic and helpers
Basic manipulation
di_interval :: CDouble -> CDouble -> CDi Source #
di_interval a b
Returns the interval \([a, b]\). We require that the endpoints are ordered and not NaN.
arb_get_di :: Ptr CArb -> IO CDi Source #
arb_get_di x
Returns the ball x converted to a double-precision interval.
arb_set_di :: Ptr CArb -> CDi -> CLong -> IO () Source #
arb_set_di res x prec
Sets the ball res to the double-precision interval x, rounded to prec bits.
di_print :: CDi -> IO () Source #
di_print x
Prints x to standard output. This simply prints decimal representations of the floating-point endpoints; the decimals are not guaranteed to be rounded outward.
di_randtest2 :: Ptr CFRandState -> IO CDouble Source #
d_randtest2 state
Returns a random non-NaN double
with any exponent. The value can be
infinite or subnormal.
di_randtest :: Ptr CFRandState -> IO CDi Source #
di_randtest state
Returns an interval with random endpoints.
Arithmetic
Fast arithmetic
di_fast_div :: CDi -> CDi -> CDi Source #
di_fast_div x y
Returns the sum, difference, product or quotient of x and y. Division by zero is currently defined to return \([-\infty, +\infty]\).
di_fast_sqr :: CDi -> CDi Source #
di_fast_sqr x
Returns the square of x. The output is clamped to be nonnegative.
di_fast_div_d :: CDi -> CDouble -> CDi Source #
di_fast_div_d x y
Arithmetic with an exact double
operand.
di_fast_log_nonnegative :: CDi -> CDi Source #
di_fast_log_nonnegative x
Returns an enclosure of \(\log(x)\). The lower endpoint of x is rounded up to 0 if it is negative.
di_fast_mid :: CDi -> CDi Source #
di_fast_mid x
Returns an enclosure of the midpoint of x.
di_fast_ubound_radius :: CDi -> CDouble Source #
di_fast_ubound_radius x
Returns an upper bound for the radius of x.