Free cookie consent management tool by TermsFeed Policy Generator

Changeset 17770


Ignore:
Timestamp:
10/02/20 12:50:35 (4 years ago)
Author:
bburlacu
Message:

#3073: Add arithmetic operator overloads for the Interval class

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3073_IA_constraint_splitting/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Interval/Interval.cs

    r17631 r17770  
    6969    }
    7070
     71    private Interval(double v) : this(v, v) { }
     72
    7173    public bool Contains(double value) {
    7274      return LowerBound <= value && value <= UpperBound;
     
    295297    }
    296298    #endregion
     299
     300    #region arithmetic overloads
     301    public static Interval operator +(Interval a, Interval b) => Add(a, b);
     302    public static Interval operator +(Interval a, double b) => Add(a, new Interval(b));
     303    public static Interval operator +(double a, Interval b) => Add(new Interval(a), b);
     304    public static Interval operator -(Interval a, Interval b) => Subtract(a, b);
     305    public static Interval operator -(Interval a, double b) => Subtract(a, new Interval(b));
     306    public static Interval operator -(double a, Interval b) => Subtract(new Interval(a), b);
     307    public static Interval operator -(Interval a) => Subtract(new Interval(0), a);
     308    public static Interval operator *(Interval a, Interval b) => Multiply(a, b);
     309    public static Interval operator *(Interval a, double b) => Multiply(a, new Interval(b));
     310    public static Interval operator *(double a, Interval b) => Multiply(new Interval(a), b);
     311    public static Interval operator /(Interval a, Interval b) => Divide(a, b);
     312    public static Interval operator /(Interval a, double b) => Divide(a, new Interval(b));
     313    public static Interval operator /(double a, Interval b) => Divide(new Interval(a), b);
     314    public static Interval Exponential(double a) { return Exponential(new Interval(a)); }
     315    public static Interval Logarithm(double a) { return Logarithm(new Interval(a)); }
     316    public static Interval Sine(double a) { return Sine(new Interval(a)); }
     317    public static Interval Cosine(double a) { return Cosine(new Interval(a)); }
     318    public static Interval Tangens(double a) { return Tangens(new Interval(a)); }
     319    public static Interval HyperbolicTangent(double a) { return HyperbolicTangent(new Interval(a)); }
     320    public static Interval Square(double a) { return Square(new Interval(a)); }
     321    public static Interval Cube(double a) { return Cube(new Interval(a)); }
     322    public static Interval SquareRoot(double a) { return SquareRoot(new Interval(a)); }
     323    public static Interval CubicRoot(double a) { return CubicRoot(new Interval(a)); }
     324    public static Interval Absolute(double a) { return Absolute(new Interval(a)); }
     325    public static Interval AnalyticQuotient(Interval a, double b) { return AnalyticalQuotient(a, new Interval(b)); }
     326    public static Interval AnalyticQuotient(double a, Interval b) { return AnalyticalQuotient(new Interval(a), b); }
     327    public static Interval AnalyticQuotient(double a, double b) { return AnalyticalQuotient(new Interval(a), new Interval(b)); }
     328    #endregion
    297329  }
    298330}
Note: See TracChangeset for help on using the changeset viewer.