// Division public static IntervalElement /*!*/ operator %(IntervalElement /*!*/ a, IntervalElement /*!*/ b) { Contract.Requires(b != null); Contract.Requires(a != null); Contract.Ensures(Contract.Result <IntervalElement>() != null); if (b.inf.IsZero && b.sup.IsZero) // Check division by zero { return(IntervalElement.Top); } ExtendedInt /*!*/ infinf = a.inf % b.inf; Contract.Assert(infinf != null); ExtendedInt /*!*/ infsup = a.inf % b.sup; Contract.Assert(infsup != null); ExtendedInt /*!*/ supinf = a.sup % b.inf; Contract.Assert(supinf != null); ExtendedInt /*!*/ supsup = a.sup % b.sup; Contract.Assert(supsup != null); ExtendedInt inf = ExtendedInt.Inf(infinf, infsup, supinf, supsup); ExtendedInt sup = ExtendedInt.Sup(infinf, infsup, supinf, supsup); return(Factory(inf, sup)); }
// Multiplication public static IntervalElement /*!*/ operator *(IntervalElement /*!*/ a, IntervalElement /*!*/ b) { Contract.Requires(b != null); Contract.Requires(a != null); Contract.Ensures(Contract.Result <IntervalElement>() != null); ExtendedInt /*!*/ infinf = a.inf * b.inf; Contract.Assert(infinf != null); ExtendedInt /*!*/ infsup = a.inf * b.sup; Contract.Assert(infsup != null); ExtendedInt /*!*/ supinf = a.sup * b.inf; Contract.Assert(supinf != null); ExtendedInt /*!*/ supsup = a.sup * b.sup; Contract.Assert(supsup != null); ExtendedInt /*!*/ inf = ExtendedInt.Inf(infinf, infsup, supinf, supsup); Contract.Assert(inf != null); ExtendedInt /*!*/ sup = ExtendedInt.Sup(infinf, infsup, supinf, supsup); Contract.Assert(sup != null); return(Factory(inf, sup)); }
/// <summary> /// The classic, pointwise, meet of intervals /// </summary> public override Element /*!*/ NontrivialMeet(Element /*!*/ left, Element /*!*/ right) { //Contract.Requires(right != null); //Contract.Requires(left != null); Contract.Ensures(Contract.Result <Element>() != null); IntervalElement /*!*/ leftInterval = (IntervalElement /*!*/)cce.NonNull(left); IntervalElement /*!*/ rightInterval = (IntervalElement /*!*/)cce.NonNull(right); ExtendedInt inf = ExtendedInt.Sup(leftInterval.Inf, rightInterval.Inf); ExtendedInt sup = ExtendedInt.Inf(leftInterval.Sup, rightInterval.Sup); return(IntervalElement.Factory(inf, sup)); }