public void partition_success()
{
int[] a = { 2, 7, 3, 5, 4 };
int pivot = Matrix.Partition(a, 0, a.Length);
Assert.IsTrue(a.IsEqual(new[] { 2, 3, 4, 5, 7 }));
// Assert.IsTrue(a.IsEqual(new[] { 2, 3, 7, 5, 4 }));
a = new int[] { 7, 6, 5, 4, 3, 2, 1, 0 };
pivot = Matrix.Partition(a, 0, a.Length);
Assert.IsTrue(a.IsEqual(new[] { 0, 3, 2, 1, 4, 5, 7, 6 }));
// Assert.IsTrue(a.IsEqual(new[] { 0, 2, 3, 1, 4, 6, 5, 7 }));
a = new int[] { 0, 1, 2, 3, 4, 5, 6, 7 };
Matrix.Partition(a, 0, a.Length);
Assert.IsTrue(a.IsEqual(new[] { 0, 1, 2, 3, 4, 5, 6, 7 }));
a = new int[] { 2, 7, 3, 4, 5, 6, 1, 8 };
double expected = (int)Statistics.Measures.Median(a.Submatrix(4, 7));
int actual = Matrix.Partition(a, 4, 7);
Assert.AreEqual(actual, expected);
//Assert.IsTrue(a.IsEqual(new[] { 2, 7, 3, 4, 5, 1, 6, 8 }));
Assert.IsTrue(a.IsEqual(new[] { 2, 7, 3, 4, 1, 5, 6, 8 }));
}