1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
use super::def::IntervalSet; use fp::Float; use std::ops::{Add, Div, Mul, Neg, Sub}; impl<BOUND: Float> Neg for IntervalSet<BOUND> { type Output = Self; #[inline] fn neg(mut self) -> Self::Output { Self { intervals: self.intervals.drain(..).rev().map(|i| -i).collect() } } } impl<BOUND: Float> Add<Self> for IntervalSet<BOUND> { type Output = Self; #[inline] fn add(self, other: Self) -> Self::Output { self.binary_op(other, |i, j| { vec![i + j] }) } } impl<BOUND: Float> Sub<Self> for IntervalSet<BOUND> { type Output = Self; #[inline] fn sub(self, other: Self) -> Self::Output { self.binary_op(other, |i, j| { vec![i - j] }) } } impl<BOUND: Float> Mul<Self> for IntervalSet<BOUND> { type Output = Self; #[inline] fn mul(self, other: Self) -> Self::Output { self.binary_op(other, |i, j| { vec![i * j] }) } } impl<BOUND: Float> Div<Self> for IntervalSet<BOUND> { type Output = Self; #[inline] fn div(self, other: Self) -> Self::Output { self.binary_op(other, |i, j| { i.div_multi(j) }) } }