diff --git a/src/Numerics/Permutation.cs b/src/Numerics/Permutation.cs index 976f2f8e..c6305ee1 100644 --- a/src/Numerics/Permutation.cs +++ b/src/Numerics/Permutation.cs @@ -31,11 +31,6 @@ namespace MathNet.Numerics { using System; - using System.Collections.Generic; - using System.Numerics; - using System.Runtime; - using System.Runtime.InteropServices; - using System.Text; using Properties; /// @@ -47,9 +42,9 @@ namespace MathNet.Numerics #region fields /// - /// Entry mIndices[i] represents the location to which i is permuted to. + /// Entry _indices[i] represents the location to which i is permuted to. /// - private static int[] mIndices; + private readonly int[] _indices; #endregion fields @@ -67,7 +62,7 @@ namespace MathNet.Numerics throw new ArgumentException(Resources.PermutationAsIntArrayInvalid, "indices"); } - mIndices = (int[]) indices.Clone(); + _indices = (int[]) indices.Clone(); } #endregion @@ -77,7 +72,7 @@ namespace MathNet.Numerics /// public int Dimension { - get { return mIndices.Length; } + get { return _indices.Length; } } /// @@ -89,7 +84,7 @@ namespace MathNet.Numerics { get { - return mIndices[idx]; + return _indices[idx]; } } @@ -100,9 +95,9 @@ namespace MathNet.Numerics public Permutation Inverse() { var invIdx = new int[Dimension]; - for (int i = 0; i < Dimension; i++) + for (int i = 0; i < invIdx.Length; i++) { - invIdx[this[i]] = i; + invIdx[_indices[i]] = i; } return new Permutation(invIdx); @@ -147,9 +142,9 @@ namespace MathNet.Numerics /// A sequence of inversions. public int[] ToInversions() { - var idx = (int[])mIndices.Clone(); + var idx = (int[])_indices.Clone(); - for (int i = 0; i < Dimension; i++) + for (int i = 0; i < idx.Length; i++) { if (idx[i] != i) {