two_sum

Function two_sum 

Source
fn two_sum(a: f64, b: f64) -> (f64, f64)
Examples found in repository?
crates/competitive/src/num/double_double.rs (line 63)
62fn three_two_sum(a: f64, b: f64, c: f64) -> (f64, f64) {
63    let (u, v) = two_sum(a, b);
64    let (r0, w) = two_sum(u, c);
65    let r1 = v + w;
66    (r0, r1)
67}
68
69impl Add<f64> for DoubleDouble {
70    type Output = Self;
71    fn add(self, rhs: f64) -> Self::Output {
72        let (t0, e) = two_sum(self.0, rhs);
73        let (t1, t2) = two_sum(self.1, e);
74        Self::renormalize(t0, t1, t2)
75    }
76}
77
78impl Add<DoubleDouble> for DoubleDouble {
79    type Output = Self;
80    fn add(self, rhs: Self) -> Self::Output {
81        let (t0, e) = two_sum(self.0, rhs.0);
82        let (t1, t2) = three_two_sum(self.1, rhs.1, e);
83        Self::renormalize(t0, t1, t2)
84    }
85}
86
87impl Sub for DoubleDouble {
88    type Output = Self;
89    fn sub(self, rhs: Self) -> Self::Output {
90        self + -rhs
91    }
92}
93
94impl Neg for DoubleDouble {
95    type Output = Self;
96    fn neg(self) -> Self::Output {
97        Self(-self.0, -self.1)
98    }
99}
100
101impl Mul<f64> for DoubleDouble {
102    type Output = Self;
103    fn mul(self, rhs: f64) -> Self::Output {
104        let (t0, e0) = two_prod(self.0, rhs);
105        let p1 = self.1 * rhs;
106        let (t1, t2) = two_sum(p1, e0);
107        Self::renormalize(t0, t1, t2)
108    }