- Timestamp:
- 04/16/13 13:13:41 (11 years ago)
- Location:
- branches/OaaS
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OaaS
- Property svn:ignore
-
old new 21 21 protoc.exe 22 22 _ReSharper.HeuristicLab 3.3 Tests 23 Google.ProtocolBuffers-2.4.1.473.dll 23 24 packages
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/OaaS/HeuristicLab.Common/3.3/EnumerableStatisticExtensions.cs
r7259 r9363 45 45 return (valuesArr[(n / 2) - 1] + valuesArr[n / 2]) / 2.0; 46 46 } 47 } 48 49 /// <summary> 50 /// Calculates the range (max - min) of the enumeration. 51 /// </summary> 52 /// <param name="values"></param> 53 /// <returns></returns> 54 public static double Range(this IEnumerable<double> values) { 55 double min = double.PositiveInfinity; 56 double max = double.NegativeInfinity; 57 int i = 0; 58 foreach (var e in values) { 59 if (min > e) min = e; 60 if (max < e) max = e; 61 i++; 62 } 63 if (i < 1) throw new ArgumentException("The enumerable must contain at least two elements", "values"); 64 return max - min; 47 65 } 48 66 … … 105 123 106 124 public static IEnumerable<double> LimitToRange(this IEnumerable<double> values, double min, double max) { 125 if (min > max) throw new ArgumentException(string.Format("Minimum {0} is larger than maximum {1}.", min, max)); 107 126 foreach (var x in values) { 108 127 if (double.IsNaN(x)) yield return (max + min) / 2.0;
Note: See TracChangeset
for help on using the changeset viewer.