#[repr(C)]pub struct DoubleDouble {
hi: f64,
lo: f64,
}Expand description
A double-double number: the exact sum hi + lo of two f64, normalized
(invariant D1). About 106 bits of significand (32 decimal digits), the
exponent range of f64.
#[repr(C)] with hi first: a slice &[DoubleDouble] is an array of
(hi, lo) pairs, the layout the SIMD kernels read.
Fields§
§hi: f64§lo: f64Implementations§
Source§impl DoubleDouble
impl DoubleDouble
Sourcepub const TAU: Self
pub const TAU: Self
2π, the nearest double-double: 6.283185307179586e0 + 2.4492935982947064e-16.
Sourcepub const FRAC_PI_2: Self
pub const FRAC_PI_2: Self
π/2, the nearest double-double: 1.5707963267948966e0 + 6.123233995736766e-17.
Sourcepub const FRAC_PI_3: Self
pub const FRAC_PI_3: Self
π/3, the nearest double-double: 1.0471975511965979e0 + -1.072081766451091e-16.
Sourcepub const FRAC_PI_4: Self
pub const FRAC_PI_4: Self
π/4, the nearest double-double: 7.853981633974483e-1 + 3.061616997868383e-17.
Sourcepub const FRAC_PI_6: Self
pub const FRAC_PI_6: Self
π/6, the nearest double-double: 5.235987755982989e-1 + -5.360408832255455e-17.
Sourcepub const FRAC_PI_8: Self
pub const FRAC_PI_8: Self
π/8, the nearest double-double: 3.9269908169872414e-1 + 1.5308084989341915e-17.
Sourcepub const FRAC_1_PI: Self
pub const FRAC_1_PI: Self
1/π, the nearest double-double: 3.183098861837907e-1 + -1.9678676675182486e-17.
Sourcepub const FRAC_2_PI: Self
pub const FRAC_2_PI: Self
2/π, the nearest double-double: 6.366197723675814e-1 + -3.935735335036497e-17.
Sourcepub const FRAC_2_SQRT_PI: Self
pub const FRAC_2_SQRT_PI: Self
2/√π, the nearest double-double: 1.1283791670955126e0 + 1.533545961316588e-17.
Sourcepub const SQRT_2: Self
pub const SQRT_2: Self
√2, the nearest double-double: 1.4142135623730951e0 + -9.667293313452913e-17.
Sourcepub const FRAC_1_SQRT_2: Self
pub const FRAC_1_SQRT_2: Self
1/√2, the nearest double-double: 7.071067811865476e-1 + -4.833646656726457e-17.
Sourcepub const LOG2_E: Self
pub const LOG2_E: Self
log₂ e, the nearest double-double: 1.4426950408889634e0 + 2.0355273740931033e-17.
Sourcepub const LOG2_10: Self
pub const LOG2_10: Self
log₂ 10, the nearest double-double: 3.321928094887362e0 + 1.661617516973592e-16.
Sourcepub const LOG10_E: Self
pub const LOG10_E: Self
log₁₀ e, the nearest double-double: 4.342944819032518e-1 + 1.098319650216765e-17.
Sourcepub const LOG10_2: Self
pub const LOG10_2: Self
log₁₀ 2, the nearest double-double: 3.010299956639812e-1 + -2.8037281277851704e-18.
Sourcepub const LN_2: Self
pub const LN_2: Self
ln 2, the nearest double-double: 6.931471805599453e-1 + 2.3190468138462996e-17.
Sourcepub const LN_10: Self
pub const LN_10: Self
ln 10, the nearest double-double: 2.302585092994046e0 + -2.1707562233822494e-16.
Sourcepub const ERROR_BOUNDS: &'static [ErrorBound]
pub const ERROR_BOUNDS: &'static [ErrorBound]
The bounds of the chapter’s table, for the tests and for callers
that propagate errors. The subtractions have the bounds of the
additions; 1 / dd is dd / dd. Each units_of_u2 is an f64 at
least the proven expression, with u = 2⁻⁵³:
| operation | proven bound | units_of_u2 |
|---|---|---|
dd + f64 | 2u²/(1 − 2u) | 2 + 2⁻⁵⁰ (the expression rounded up) |
dd + dd | 3u²/(1 − 4u) | 3 + 2⁻⁴⁹ (rounded up) |
dd · f64 | 2u² | 2 (exact) |
dd · dd | 4u² | 4 (exact) |
dd² | 3u² | 3 (exact) |
dd / f64 | 3u² | 3 (exact) |
dd / dd | 15u² + 56u³ | 15 + 2⁻⁴⁷ (rounded up) |
√dd | (25/8) u² | 3.125 (exact) |
The test error_bounds_dominate_the_proven_expressions checks each
row in exact rational arithmetic.
Sourcepub fn from_product(a: f64, b: f64) -> Self
pub fn from_product(a: f64, b: f64) -> Self
a · b exactly, for any two f64 in the range of two_prod
(outside it: within η/2, and still normalized).
Sourcepub fn from_parts(hi: f64, lo: f64) -> Self
pub fn from_parts(hi: f64, lo: f64) -> Self
The pair (hi, lo) as given, requires it normalized (D1); a
debug_assert!. For deserialization and tests.
The requirement is unchecked in release builds, and every bound of
this chapter assumes it: use DoubleDouble::from_sum for an
arbitrary pair.
Source§impl DoubleDouble
impl DoubleDouble
Sourcepub const FUNCTION_BOUNDS: &'static [FunctionBound]
pub const FUNCTION_BOUNDS: &'static [FunctionBound]
The declared error bounds of the elementary functions (Chapter 11.11), one row per function, each proven in the chapter. The tests read them.
Source§impl DoubleDouble
impl DoubleDouble
Sourcepub fn exp(self) -> Self
pub fn exp(self) -> Self
eˣ (Algorithm E). Relative error at most 8u² for results in
[2⁻⁹⁶⁸, Ω] (proven: 4.6u²), plus η below. exp(±0) = 1,
exp(+∞) = +∞, exp(−∞) = +0; +∞ on overflow, +0 for x < −745.2.
Sourcepub fn exp2(self) -> Self
pub fn exp2(self) -> Self
2ˣ (Algorithm E); exact for integer x whose power is
representable. Bound as DoubleDouble::exp.
Source§impl DoubleDouble
impl DoubleDouble
Sourcepub fn ln(self) -> Self
pub fn ln(self) -> Self
Natural logarithm (Algorithm L): relative error at most 8u²
(proven: 6.7u²); ln(1) = +0. NaN for x < 0, −∞ for ±0,
+∞ for +∞.
Sourcepub fn ln_1p(self) -> Self
pub fn ln_1p(self) -> Self
ln(1 + x), with relative accuracy near zero (Algorithm L′):
relative error at most 8u² (proven: 7.7u²). ±0 for ±0, −∞
for −1, NaN for x < −1.
Sourcepub fn log2(self) -> Self
pub fn log2(self) -> Self
Base-2 logarithm; exact for powers of two. Relative error at most
12u² (proven: 11.7u²). Special cases as DoubleDouble::ln.
Sourcepub fn log10(self) -> Self
pub fn log10(self) -> Self
Base-10 logarithm, ln x · LOG10_E: relative error at most 12u²
(proven: 11.7u²). Special cases as DoubleDouble::ln.
Source§impl DoubleDouble
impl DoubleDouble
Sourcepub fn powi(self, n: i32) -> Self
pub fn powi(self, n: i32) -> Self
xⁿ by binary powering with a separate exponent (Algorithm P): no
spurious overflow or underflow. Relative error at most (15 + 4|n|)u² (proven: (11 + 4|n|)u²); exact for n ∈ {0, 1}, one
square (3u²) for n = 2, DoubleDouble::recip for n = −1.
The special cases of IEEE 754 pown: powi(x, 0) = 1 for every x,
NaN included; ±0 and ±∞ by the sign and parity of n.
Sourcepub fn powf(self, y: Self) -> Self
pub fn powf(self, y: Self) -> Self
xʸ as exp(y ln x) (Theorem F): relative error at most (16 + 11|y ln x|)u² (proven: (4.6 + 10.7|y ln x|)u²); x itself for y = 1. The special cases of IEEE 754 pow (C99 Annex F), as f64:
pow(x, ±0) = 1 and pow(1, y) = 1 even for NaN; NaN for x < 0
and y not an integer; ±0, ±∞ and ±1 by the usual limits.
Source§impl DoubleDouble
impl DoubleDouble
Sourcepub fn sin(self) -> Self
pub fn sin(self) -> Self
Sine (Algorithms R and K): error at most 8u²|sin x| + 2⁻²⁰⁰ for
every finite x (proven: 6.9u²|sin x| + 2⁻³¹⁵), so relative when
|sin x| ≥ 2⁻⁹⁴. sin(±0) = ±0; NaN for ±∞; odd bit for bit.
Sourcepub fn cos(self) -> Self
pub fn cos(self) -> Self
Cosine; bound as DoubleDouble::sin. cos(±0) = 1; NaN for ±∞;
even bit for bit.
Sourcepub fn tan(self) -> Self
pub fn tan(self) -> Self
Tangent (Algorithms R and K, then D2): error at most 32u²|tan x| + 2⁻²⁰⁰(1 + tan²x) (proven: 27.4u²|tan x| + 2⁻³¹⁵(1 + tan²x)).
tan(±0) = ±0; NaN for ±∞; odd bit for bit.
Sourcepub fn sin_cos(self) -> (Self, Self)
pub fn sin_cos(self) -> (Self, Self)
(sin x, cos x) from one argument reduction; the same bits as
DoubleDouble::sin and DoubleDouble::cos.
Source§impl DoubleDouble
impl DoubleDouble
Sourcepub fn atan(self) -> Self
pub fn atan(self) -> Self
Arctangent in [−π/2, π/2] (Algorithm T): relative error at most
8u² (proven: 5.8u²). atan(±0) = ±0, atan(±∞) = ±π/2; odd bit
for bit.
Sourcepub fn atan2(self, other: Self) -> Self
pub fn atan2(self, other: Self) -> Self
Four-quadrant arctangent of self / other (self is y), in [−π, π]: relative error at most 32u² (proven: 20u²). The special
cases of f64::atan2: (±0, −0) → ±π, (±0, +0) → ±0, (±0, x < 0) → ±π, (±0, x > 0) → ±0, (y ≠ 0, ±0) → ±π/2 by the sign of y,
(±y, −∞) → ±π and (±y, +∞) → ±0 for finite y, (±∞, x finite) → ±π/2, (±∞, −∞) → ±3π/4, (±∞, +∞) → ±π/4; NaN in either → NaN.
Source§impl DoubleDouble
impl DoubleDouble
Sourcepub fn sinh(self) -> Self
pub fn sinh(self) -> Self
Hyperbolic sine: relative error at most 32u² (proven: 18.7u²).
±0, ±∞ for ±0, ±∞; ±∞ on overflow; odd bit for bit.
Sourcepub fn cosh(self) -> Self
pub fn cosh(self) -> Self
Hyperbolic cosine: relative error at most 32u² (proven: 15.1u²).
cosh(±0) = 1, +∞ for ±∞ and on overflow; even bit for bit.
Sourcepub fn tanh(self) -> Self
pub fn tanh(self) -> Self
Hyperbolic tangent: relative error at most 32u² (proven:
26.4u²). ±0 for ±0, ±1 for ±∞; for large |x| the pair
(±1, ∓2e^(−2|x|)), exactly ±1 once that is below η/2; odd bit
for bit.
Sourcepub fn asinh(self) -> Self
pub fn asinh(self) -> Self
Inverse hyperbolic sine: relative error at most 32u² (proven:
19.7u²). ±0, ±∞ for ±0, ±∞; odd bit for bit.
Trait Implementations§
Source§impl Add for DoubleDouble
impl Add for DoubleDouble
Source§impl Add<f64> for DoubleDouble
Mixed operation with an f64 right operand: the cheaper algorithm of
the chapter’s table, not a promotion.
impl Add<f64> for DoubleDouble
Mixed operation with an f64 right operand: the cheaper algorithm of
the chapter’s table, not a promotion.
Source§impl AddAssign for DoubleDouble
impl AddAssign for DoubleDouble
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
+= operation. Read moreSource§impl Clone for DoubleDouble
impl Clone for DoubleDouble
impl Copy for DoubleDouble
Source§impl Debug for DoubleDouble
impl Debug for DoubleDouble
Source§impl Default for DoubleDouble
impl Default for DoubleDouble
Source§impl DenseKernel<DoubleDouble> for DdDense
impl DenseKernel<DoubleDouble> for DdDense
Source§fn potrf(&self, a: &mut DenseBlock<DoubleDouble>) -> Result<(), DenseError>
fn potrf(&self, a: &mut DenseBlock<DoubleDouble>) -> Result<(), DenseError>
A = L Lᵀ of a square block (Algorithm P).Source§fn sytrf(
&self,
a: &mut DenseBlock<DoubleDouble>,
perm: &mut Perm,
pivot_2x2: &mut Vec<bool>,
) -> Result<Inertia, DenseError>
fn sytrf( &self, a: &mut DenseBlock<DoubleDouble>, perm: &mut Perm, pivot_2x2: &mut Vec<bool>, ) -> Result<Inertia, DenseError>
P A Pᵀ = L B Lᵀ with 1×1/2×2 pivots (Bunch–Kaufman,
Algorithm B); returns the inertia and writes the permutation into
perm and the 2×2 marks into pivot_2x2 (both resized to n).Source§fn trsm_lower(
&self,
l: &DenseBlock<DoubleDouble>,
b: &mut DenseBlock<DoubleDouble>,
transpose: bool,
)
fn trsm_lower( &self, l: &DenseBlock<DoubleDouble>, b: &mut DenseBlock<DoubleDouble>, transpose: bool, )
Source§fn gemm_sub(
&self,
a: &DenseBlock<DoubleDouble>,
b: &DenseBlock<DoubleDouble>,
c: &mut DenseBlock<DoubleDouble>,
)
fn gemm_sub( &self, a: &DenseBlock<DoubleDouble>, b: &DenseBlock<DoubleDouble>, c: &mut DenseBlock<DoubleDouble>, )
C ← C − A Bᵀ. Read moreSource§fn syrk_sub(
&self,
a: &DenseBlock<DoubleDouble>,
c: &mut DenseBlock<DoubleDouble>,
)
fn syrk_sub( &self, a: &DenseBlock<DoubleDouble>, c: &mut DenseBlock<DoubleDouble>, )
Source§fn solve_min_rows(&self) -> usize
fn solve_min_rows(&self) -> usize
n_r of a supernode block for which the
solves of SupernodalLdl go through this kernel (gather, hook,
scatter; step S0′ of Chapter 5.17). usize::MAX — the default —
keeps the loops of the second edition everywhere. A cost switch
only (invariant (D5)).Source§fn solve_unit_lower(
&self,
l: &DenseBlock<DoubleDouble>,
skip: &[bool],
y: &mut [DoubleDouble],
)
fn solve_unit_lower( &self, l: &DenseBlock<DoubleDouble>, skip: &[bool], y: &mut [DoubleDouble], )
y ← L⁻¹ y (Algorithm V).
l is the stored block (rows ≥ cols, unit lower trapezoidal,
diagonal slots ignored); skip is empty or has l.cols marks (the
first column of each 2×2 pivot). Read moreSource§fn solve_unit_lower_t(
&self,
l: &DenseBlock<DoubleDouble>,
skip: &[bool],
y: &mut [DoubleDouble],
)
fn solve_unit_lower_t( &self, l: &DenseBlock<DoubleDouble>, skip: &[bool], y: &mut [DoubleDouble], )
y_{..cols} ← L₁₁⁻ᵀ (y_{..cols} − L₂₁ᵀ y_{cols..})
(Algorithm W); y[cols..] is read only. Read moreSource§impl Display for DoubleDouble
Decimal, scientific notation when the exponent calls for it; {:.N}
gives N digits after the point, the default is the value correctly
rounded to 31 significant digits, trailing zeros dropped (Algorithm O
of Chapter 11.4). A decimal of at most 31 digits that was read by
from_str is written back as the same decimal; the output parses back
to the same bits whenever the value has at most 31 significant
decimal digits — see invariant P3 for why no fixed number of digits can
do so in general ({:.1100e} always does).
impl Display for DoubleDouble
Decimal, scientific notation when the exponent calls for it; {:.N}
gives N digits after the point, the default is the value correctly
rounded to 31 significant digits, trailing zeros dropped (Algorithm O
of Chapter 11.4). A decimal of at most 31 digits that was read by
from_str is written back as the same decimal; the output parses back
to the same bits whenever the value has at most 31 significant
decimal digits — see invariant P3 for why no fixed number of digits can
do so in general ({:.1100e} always does).
Source§impl Div for DoubleDouble
impl Div for DoubleDouble
Source§impl Div<f64> for DoubleDouble
Mixed operation with an f64 right operand: the cheaper algorithm of
the chapter’s table, not a promotion.
impl Div<f64> for DoubleDouble
Mixed operation with an f64 right operand: the cheaper algorithm of
the chapter’s table, not a promotion.
Source§impl DivAssign for DoubleDouble
impl DivAssign for DoubleDouble
Source§fn div_assign(&mut self, rhs: Self)
fn div_assign(&mut self, rhs: Self)
/= operation. Read moreSource§impl From<f64> for DoubleDouble
impl From<f64> for DoubleDouble
Source§impl FromStr for DoubleDouble
Decimal or scientific notation, inf, nan; faithful (question E7) —
in fact correctly rounded: the leading component is the f64 nearest
to the string’s value and the trailing one the f64 nearest to the
rest (Algorithm I of Chapter 11.4).
impl FromStr for DoubleDouble
Decimal or scientific notation, inf, nan; faithful (question E7) —
in fact correctly rounded: the leading component is the f64 nearest
to the string’s value and the trailing one the f64 nearest to the
rest (Algorithm I of Chapter 11.4).
Source§impl LowerExp for DoubleDouble
Scientific notation as for f64: d.ddd then e and the decimal
exponent, without + or leading zeros (1.5e-7, 1e0, 0e0).
{:e} gives the value correctly rounded to the 31 significant digits
of Display, trailing zeros dropped; {:.Ne} gives N digits after
the point, correctly rounded (half to even), zero-padded.
impl LowerExp for DoubleDouble
Scientific notation as for f64: d.ddd then e and the decimal
exponent, without + or leading zeros (1.5e-7, 1e0, 0e0).
{:e} gives the value correctly rounded to the 31 significant digits
of Display, trailing zeros dropped; {:.Ne} gives N digits after
the point, correctly rounded (half to even), zero-padded.
Source§impl Mul for DoubleDouble
impl Mul for DoubleDouble
Source§impl Mul<f64> for DoubleDouble
Mixed operation with an f64 right operand: the cheaper algorithm of
the chapter’s table, not a promotion.
impl Mul<f64> for DoubleDouble
Mixed operation with an f64 right operand: the cheaper algorithm of
the chapter’s table, not a promotion.
Source§impl MulAssign for DoubleDouble
impl MulAssign for DoubleDouble
Source§fn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
*= operation. Read moreSource§impl Neg for DoubleDouble
impl Neg for DoubleDouble
Source§impl PartialEq for DoubleDouble
impl PartialEq for DoubleDouble
Source§impl PartialOrd for DoubleDouble
impl PartialOrd for DoubleDouble
Source§impl Real for DoubleDouble
Available on crate feature sparse only.Real for double-double (requirements R1 as reworded in E2, R2–R4 by
invariants D3–D5): the containers and factorizations of xingo-sparse
instantiate in DoubleDouble unchanged.
impl Real for DoubleDouble
sparse only.Real for double-double (requirements R1 as reworded in E2, R2–R4 by
invariants D3–D5): the containers and factorizations of xingo-sparse
instantiate in DoubleDouble unchanged.
impl StructuralPartialEq for DoubleDouble
Source§impl Sub for DoubleDouble
impl Sub for DoubleDouble
Source§impl Sub<f64> for DoubleDouble
Mixed operation with an f64 right operand: the cheaper algorithm of
the chapter’s table, not a promotion.
impl Sub<f64> for DoubleDouble
Mixed operation with an f64 right operand: the cheaper algorithm of
the chapter’s table, not a promotion.
Source§impl SubAssign for DoubleDouble
impl SubAssign for DoubleDouble
Source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
-= operation. Read moreSource§impl Sum for DoubleDouble
Left to right from DoubleDouble::ZERO (requirement R3 of Real).
impl Sum for DoubleDouble
Left to right from DoubleDouble::ZERO (requirement R3 of Real).