Changeset 11594 for branches/Breadcrumbs/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/ValueGenerator.cs
- Timestamp:
- 11/27/14 11:23:37 (10 years ago)
- Location:
- branches/Breadcrumbs
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Breadcrumbs
- Property svn:ignore
-
old new 8 8 FxCopResults.txt 9 9 Google.ProtocolBuffers-0.9.1.dll 10 Google.ProtocolBuffers-2.4.1.473.dll 10 11 HeuristicLab 3.3.5.1.ReSharper.user 11 12 HeuristicLab 3.3.6.0.ReSharper.user 12 13 HeuristicLab.4.5.resharper.user 13 14 HeuristicLab.ExtLibs.6.0.ReSharper.user 15 HeuristicLab.Scripting.Development 14 16 HeuristicLab.resharper.user 15 17 ProtoGen.exe … … 17 19 _ReSharper.HeuristicLab 18 20 _ReSharper.HeuristicLab 3.3 21 _ReSharper.HeuristicLab 3.3 Tests 19 22 _ReSharper.HeuristicLab.ExtLibs 20 23 bin 21 24 protoc.exe 22 _ReSharper.HeuristicLab 3.3 Tests23 Google.ProtocolBuffers-2.4.1.473.dll
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/Breadcrumbs/HeuristicLab.Problems.Instances.DataAnalysis
- Property svn:mergeinfo changed
-
branches/Breadcrumbs/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/ValueGenerator.cs
r9456 r11594 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 3Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 31 31 32 32 /// <summary> 33 /// Generates a sequence of evenly spaced points between start and end (inclusive!). 33 /// Generates a sequence of evenly spaced points by returning the start value and adding the stepwidth until the end is reached or surpassed. 34 /// 34 35 /// </summary> 35 36 /// <param name="start">The smallest and first value of the sequence.</param> 36 37 /// <param name="end">The largest and last value of the sequence.</param> 37 38 /// <param name="stepWidth">The step size between subsequent values.</param> 38 /// <returns>An sequence of values from start to end (inclusive)</returns> 39 public static IEnumerable<double> GenerateSteps(double start, double end, double stepWidth) { 40 if (start > end) throw new ArgumentException("start must be less than or equal end."); 41 if (stepWidth <= 0) throw new ArgumentException("stepwith must be larger than zero.", "stepWidth"); 42 double x = start; 43 // x<=end could skip the last value because of numerical problems 44 while (x < end || x.IsAlmost(end)) { 39 /// <param name="includeEnd">Determines if the end should be included in the sequence regardless if the end is divisible by the stepwidth.</param> 40 /// <returns>A sequence of values from start to end (inclusive)</returns> 41 [Obsolete("It is recommended to use the decimal overload to achieve a higher numerical accuracy.")] 42 public static IEnumerable<double> GenerateSteps(double start, double end, double stepWidth, bool includeEnd = false) { 43 //mkommend: IEnumerable.Cast fails due to boxing and unboxing of the involved types 44 // http://referencesource.microsoft.com/#System.Core/System/Linq/Enumerable.cs#27bb217a6d5457ec 45 // http://blogs.msdn.com/b/ericlippert/archive/2009/03/19/representation-and-identity.aspx 46 47 return GenerateSteps((decimal)start, (decimal)end, (decimal)stepWidth, includeEnd).Select(x => (double)x); 48 } 49 50 /// <summary> 51 /// Generates a sequence of evenly spaced points by returning the start value and adding the stepwidth until the end is reached or surpassed. 52 /// </summary> 53 /// <param name="start">The smallest and first value of the sequence.</param> 54 /// <param name="end">The largest and last value of the sequence.</param> 55 /// <param name="stepWidth">The step size between subsequent values.</param> 56 /// /// <param name="includeEnd">Determines if the end should be included in the sequence regardless if the end is divisible by the stepwidth.</param> 57 /// <returns>A sequence of values from start to end</returns> 58 public static IEnumerable<decimal> GenerateSteps(decimal start, decimal end, decimal stepWidth, bool includeEnd = false) { 59 if (stepWidth == 0) 60 throw new ArgumentException("The step width cannot be zero."); 61 if (start < end && stepWidth < 0) 62 throw new ArgumentException("The step width must be larger than zero for increasing sequences (start < end)."); 63 if (start > end && stepWidth > 0) 64 throw new ArgumentException("The step width must be smaller than zero for decreasing sequences (start > end)."); 65 66 decimal x = start; 67 while (x <= end) { 45 68 yield return x; 46 69 x += stepWidth; 47 70 } 71 if (x - stepWidth < end && includeEnd) yield return end; 48 72 } 49 73
Note: See TracChangeset
for help on using the changeset viewer.