Create double precision version of `y12mfe`
ivan-pi opened this issue · comments
The routine y12mfe
applies Gaussian elimination with subsequent iterative refinement of the solution. The residuals are calculated in double precision, and then downcast to reals.
Since quadruple precision is not guaranteed to be available on all compilers, to create the double precision version y12mff
preserve the original algorithm in y12mfe
, some other trick is necessary.
The residuals are defined here (note only er,er1,er2
appear to be used)
Line 4 in 2b1e27b
We can use selected_real_kind
to try and select a real kind with higher precision (either extended double precision or quadruple). If none of these are available the return value is negative. In that case we could use double-double arithmetic.
A few implementations are available for reference:
- qd (C++ with Fortran bindings)
- doubledouble (Python)
- DoubleFloats.jl and the older (deprecated) DoubleDouble.jl (Julia)
- double-double (C++)
- dbldbl (C); more information at the NVIDIA developer forum
By the looks of things we only need subtraction and multiplication.
A few more useful resources:
- What Every Computer Scientist Should Know About Floating-Point Arithmetic
- Library for Double-Double and Quad-Double Arithmetic
- High precision numerical accuracy in Physics research
- Handbook of Floating-Point Arithmetic , 2nd edition
- Algorithms for Quad-Double Precision Floating Point Arithmetic
- float128 and double-double arithmetic