Changeset 16631 for trunk/HeuristicLab.Problems.DataAnalysis
- Timestamp:
- 02/28/19 14:34:17 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Interval.cs
r16571 r16631 201 201 202 202 public static Interval Square(Interval a) { 203 return Power(a, new Interval(2, 2)); 204 } 205 206 public static Interval Cubic(Interval a) { 207 return Power(a, new Interval(3, 3)); 203 if (a.UpperBound <= 0) return new Interval(a.UpperBound * a.UpperBound, a.LowerBound * a.LowerBound); // interval is negative 204 else if (a.LowerBound >= 0) return new Interval(a.LowerBound * a.LowerBound, a.UpperBound * a.UpperBound); // interval is positive 205 else return new Interval(0, Math.Max(a.LowerBound*a.LowerBound, a.UpperBound*a.UpperBound)); // interval goes over zero 206 } 207 208 public static Interval Cube(Interval a) { 209 return new Interval(Math.Pow(a.LowerBound, 3), Math.Pow(a.UpperBound, 3)); 208 210 } 209 211 … … 216 218 217 219 public static Interval SquareRoot(Interval a) { 218 return Root(a, new Interval(2, 2)); 220 if (a.LowerBound < 0) return new Interval(double.NaN, double.NaN); 221 return new Interval(Math.Sqrt(a.LowerBound), Math.Sqrt(a.UpperBound)); 219 222 } 220 223 221 224 public static Interval CubicRoot(Interval a) { 222 return Root(a, new Interval(3, 3)); 225 if (a.LowerBound < 0) return new Interval(double.NaN, double.NaN); 226 return new Interval(Math.Pow(a.LowerBound, 1.0/3), Math.Pow(a.UpperBound, 1.0/3)); 223 227 } 224 228 #endregion
Note: See TracChangeset
for help on using the changeset viewer.