diff --git a/src/Numerics/Combinatorics.cs b/src/Numerics/Combinatorics.cs index 5ceb8476..fe62cf47 100644 --- a/src/Numerics/Combinatorics.cs +++ b/src/Numerics/Combinatorics.cs @@ -135,7 +135,7 @@ namespace MathNet.Numerics /// The random number generator to use. Optional; the default random source will be used if null. public static int[] GeneratePermutation(int n, System.Random randomSource = null) { - if (n < 0) throw new ArgumentOutOfRangeException("n", n, Resources.ArgumentNotNegative); + if (n < 0) throw new ArgumentOutOfRangeException("n", Resources.ArgumentNotNegative); int[] indices = new int[n]; for (int i = 0; i < indices.Length; i++) @@ -195,7 +195,7 @@ namespace MathNet.Numerics /// Boolean mask array of length N, for each item true if it is selected. public static bool[] GenerateCombination(int n, System.Random randomSource = null) { - if (n < 0) throw new ArgumentOutOfRangeException("n", n, Resources.ArgumentNotNegative); + if (n < 0) throw new ArgumentOutOfRangeException("n", Resources.ArgumentNotNegative); var random = randomSource ?? SystemRandomSource.Default; @@ -217,9 +217,9 @@ namespace MathNet.Numerics /// Boolean mask array of length N, for each item true if it is selected. public static bool[] GenerateCombination(int n, int k, System.Random randomSource = null) { - if (n < 0) throw new ArgumentOutOfRangeException("n", n, Resources.ArgumentNotNegative); - if (k < 0) throw new ArgumentOutOfRangeException("k", k, Resources.ArgumentNotNegative); - if (k > n) throw new ArgumentOutOfRangeException("k", k, string.Format(Resources.ArgumentOutOfRangeSmallerEqual, "k", "n")); + if (n < 0) throw new ArgumentOutOfRangeException("n", Resources.ArgumentNotNegative); + if (k < 0) throw new ArgumentOutOfRangeException("k", Resources.ArgumentNotNegative); + if (k > n) throw new ArgumentOutOfRangeException("k", string.Format(Resources.ArgumentOutOfRangeSmallerEqual, "k", "n")); var random = randomSource ?? SystemRandomSource.Default; @@ -262,8 +262,8 @@ namespace MathNet.Numerics { T[] array = data as T[] ?? data.ToArray(); - if (elementsToChoose < 0) throw new ArgumentOutOfRangeException("elementsToChoose", elementsToChoose, Resources.ArgumentNotNegative); - if (elementsToChoose > array.Length) throw new ArgumentOutOfRangeException("elementsToChoose", elementsToChoose, string.Format(Resources.ArgumentOutOfRangeSmallerEqual, "elementsToChoose", "data.Count")); + if (elementsToChoose < 0) throw new ArgumentOutOfRangeException("elementsToChoose", Resources.ArgumentNotNegative); + if (elementsToChoose > array.Length) throw new ArgumentOutOfRangeException("elementsToChoose", string.Format(Resources.ArgumentOutOfRangeSmallerEqual, "elementsToChoose", "data.Count")); bool[] mask = GenerateCombination(array.Length, elementsToChoose, randomSource); @@ -285,8 +285,8 @@ namespace MathNet.Numerics /// Integer mask array of length N, for each item the number of times it was selected. public static int[] GenerateCombinationWithRepetition(int n, int k, System.Random randomSource = null) { - if (n < 0) throw new ArgumentOutOfRangeException("n", n, Resources.ArgumentNotNegative); - if (k < 0) throw new ArgumentOutOfRangeException("k", k, Resources.ArgumentNotNegative); + if (n < 0) throw new ArgumentOutOfRangeException("n", Resources.ArgumentNotNegative); + if (k < 0) throw new ArgumentOutOfRangeException("k", Resources.ArgumentNotNegative); var random = randomSource ?? SystemRandomSource.Default; @@ -308,7 +308,7 @@ namespace MathNet.Numerics /// The chosen combination with repetition, in the original order. public static IEnumerable SelectCombinationWithRepetition(this IEnumerable data, int elementsToChoose, System.Random randomSource = null) { - if (elementsToChoose < 0) throw new ArgumentOutOfRangeException("elementsToChoose", elementsToChoose, Resources.ArgumentNotNegative); + if (elementsToChoose < 0) throw new ArgumentOutOfRangeException("elementsToChoose", Resources.ArgumentNotNegative); T[] array = data as T[] ?? data.ToArray(); int[] mask = GenerateCombinationWithRepetition(array.Length, elementsToChoose, randomSource); @@ -332,9 +332,9 @@ namespace MathNet.Numerics /// An array of length K that contains the indices of the selections as integers of the interval [0, N). public static int[] GenerateVariation(int n, int k, System.Random randomSource = null) { - if (n < 0) throw new ArgumentOutOfRangeException("n", n, Resources.ArgumentNotNegative); - if (k < 0) throw new ArgumentOutOfRangeException("k", k, Resources.ArgumentNotNegative); - if (k > n) throw new ArgumentOutOfRangeException("k", k, string.Format(Resources.ArgumentOutOfRangeSmallerEqual, "k", "n")); + if (n < 0) throw new ArgumentOutOfRangeException("n", Resources.ArgumentNotNegative); + if (k < 0) throw new ArgumentOutOfRangeException("k", Resources.ArgumentNotNegative); + if (k > n) throw new ArgumentOutOfRangeException("k", string.Format(Resources.ArgumentOutOfRangeSmallerEqual, "k", "n")); var random = randomSource ?? SystemRandomSource.Default; @@ -369,8 +369,8 @@ namespace MathNet.Numerics var random = randomSource ?? SystemRandomSource.Default; T[] array = data.ToArray(); - if (elementsToChoose < 0) throw new ArgumentOutOfRangeException("elementsToChoose", elementsToChoose, Resources.ArgumentNotNegative); - if (elementsToChoose > array.Length) throw new ArgumentOutOfRangeException("elementsToChoose", elementsToChoose, string.Format(Resources.ArgumentOutOfRangeSmallerEqual, "elementsToChoose", "data.Count")); + if (elementsToChoose < 0) throw new ArgumentOutOfRangeException("elementsToChoose", Resources.ArgumentNotNegative); + if (elementsToChoose > array.Length) throw new ArgumentOutOfRangeException("elementsToChoose", string.Format(Resources.ArgumentOutOfRangeSmallerEqual, "elementsToChoose", "data.Count")); // Partial Fisher-Yates Shuffling for (int i = array.Length - 1; i >= array.Length - elementsToChoose; i--) @@ -390,8 +390,8 @@ namespace MathNet.Numerics /// An array of length K that contains the indices of the selections as integers of the interval [0, N). public static int[] GenerateVariationWithRepetition(int n, int k, System.Random randomSource = null) { - if (n < 0) throw new ArgumentOutOfRangeException("n", n, Resources.ArgumentNotNegative); - if (k < 0) throw new ArgumentOutOfRangeException("k", k, Resources.ArgumentNotNegative); + if (n < 0) throw new ArgumentOutOfRangeException("n", Resources.ArgumentNotNegative); + if (k < 0) throw new ArgumentOutOfRangeException("k", Resources.ArgumentNotNegative); var random = randomSource ?? SystemRandomSource.Default; @@ -409,7 +409,7 @@ namespace MathNet.Numerics /// The chosen variation with repetition, in random order. public static IEnumerable SelectVariationWithRepetition(this IEnumerable data, int elementsToChoose, System.Random randomSource = null) { - if (elementsToChoose < 0) throw new ArgumentOutOfRangeException("elementsToChoose", elementsToChoose, Resources.ArgumentNotNegative); + if (elementsToChoose < 0) throw new ArgumentOutOfRangeException("elementsToChoose", Resources.ArgumentNotNegative); T[] array = data as T[] ?? data.ToArray(); int[] indices = GenerateVariationWithRepetition(array.Length, elementsToChoose, randomSource);