项目作者: JeffreySarnoff

项目描述 :
A more robust kind of Float32.
高级语言: Julia
项目地址: git://github.com/JeffreySarnoff/Robust32s.jl.git
创建时间: 2020-07-19T15:03:42Z
项目社区:https://github.com/JeffreySarnoff/Robust32s.jl

开源协议:MIT License

下载


Robust32s

A more robust Float32 that preserves float performance.

Docs


An old Rule-of-Thumb offers the simplest way to evade numerical embarrassment.
Perform your compututations carrying somewhat more than twice the precision
of your data and somewhat more than twice the precision of you seek in your results.
This rule has long served statistics, optimization, root-finding, geometry,
and differential equations. Rare exceptions exist, of course.
(adapted from W. Kahan)


This package implements that Rule-of-Thumb in a highly performant manner.
To offer the desired performance, this package works with Float32 data
and provides Float32 results. This is handled automatically. While
you are working with Float32 data and obtaining Float32 results, all is well.

exports

  • Robust32 a robust 32bit floating point type
  • ComplexR32 a robust 32bit complex floating point type (named like ComplexF32)

    installation

    1. julia> using Pkg
    2. julia> Pkg.add("Robust32s")

Basic Examples

  1. using FloatR32s
  2. julia> a, b = sqrt.(Float32.((2.0, 0.5)))
  3. (1.4142135f0, 0.70710677f0)
  4. julia> c = a * b # product of Float32s
  5. 0.99999994f0
  6. julia> a, b = sqrt.(Robust32.((2.0, 0.5)))
  7. (1.4142135f0, 0.70710677f0)
  8. julia> c = a * b # product of FloatR32s
  9. 1.0f0


“.. the simplest way to evade numerical embarrassment is to perform computation carrying extravagantly
more precision throughout than you think necessary, and pray that it is enough. Usually somewhat
more than twice the precision you trust in the data and seek in the results is enough.”

  • W. Kahan, “How Futile are Mindless Assessments of Roundoff in Floating Point Computation”, 2006