Browse Source

LinearAlgebra: permutation indices no longer static

la-knuth
Christoph Ruegg 17 years ago
parent
commit
2b3c8d8407
  1. 23
      src/Numerics/Permutation.cs

23
src/Numerics/Permutation.cs

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

Loading…
Cancel
Save