Browse Source

LA: preconditioner more consistent naming

pull/163/head
Christoph Ruegg 13 years ago
parent
commit
d18a0b24b3
  1. 3
      MathNet.Numerics.sln.DotSettings
  2. 3
      src/Numerics/LinearAlgebra/Complex/Solvers/Preconditioners/DiagonalPreconditioner.cs
  3. 3
      src/Numerics/LinearAlgebra/Complex/Solvers/Preconditioners/ILU0Preconditioner.cs
  4. 204
      src/Numerics/LinearAlgebra/Complex/Solvers/Preconditioners/ILUTPPreconditioner.cs
  5. 230
      src/Numerics/LinearAlgebra/Complex/Solvers/Preconditioners/IlutpElementSorter.cs
  6. 2
      src/Numerics/LinearAlgebra/Complex32/Solvers/Preconditioners/DiagonalPreconditioner.cs
  7. 2
      src/Numerics/LinearAlgebra/Complex32/Solvers/Preconditioners/ILU0Preconditioner.cs
  8. 203
      src/Numerics/LinearAlgebra/Complex32/Solvers/Preconditioners/ILUTPPreconditioner.cs
  9. 225
      src/Numerics/LinearAlgebra/Complex32/Solvers/Preconditioners/IlutpElementSorter.cs
  10. 2
      src/Numerics/LinearAlgebra/Double/Solvers/Preconditioners/DiagonalPreconditioner.cs
  11. 2
      src/Numerics/LinearAlgebra/Double/Solvers/Preconditioners/ILU0Preconditioner.cs
  12. 203
      src/Numerics/LinearAlgebra/Double/Solvers/Preconditioners/ILUTPPreconditioner.cs
  13. 223
      src/Numerics/LinearAlgebra/Double/Solvers/Preconditioners/IlutpElementSorter.cs
  14. 2
      src/Numerics/LinearAlgebra/Double/Solvers/Preconditioners/MILU0Preconditioner.cs
  15. 2
      src/Numerics/LinearAlgebra/Single/Solvers/Preconditioners/DiagonalPreconditioner.cs
  16. 2
      src/Numerics/LinearAlgebra/Single/Solvers/Preconditioners/ILU0Preconditioner.cs
  17. 203
      src/Numerics/LinearAlgebra/Single/Solvers/Preconditioners/ILUTPPreconditioner.cs
  18. 223
      src/Numerics/LinearAlgebra/Single/Solvers/Preconditioners/IlutpElementSorter.cs
  19. 30
      src/Numerics/Numerics.csproj
  20. 4
      src/UnitTests/LinearAlgebraTests/Complex/Solvers/Preconditioners/DiagonalTest.cs
  21. 38
      src/UnitTests/LinearAlgebraTests/Complex/Solvers/Preconditioners/IluptElementSorterTest.cs
  22. 20
      src/UnitTests/LinearAlgebraTests/Complex/Solvers/Preconditioners/IlutpTest.cs
  23. 12
      src/UnitTests/LinearAlgebraTests/Complex/Solvers/Preconditioners/IncompleteLUTest.cs
  24. 4
      src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Preconditioners/DiagonalTest.cs
  25. 38
      src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Preconditioners/IluptElementSorterTest.cs
  26. 20
      src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Preconditioners/IlutpTest.cs
  27. 12
      src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Preconditioners/IncompleteLUTest.cs
  28. 4
      src/UnitTests/LinearAlgebraTests/Double/Solvers/Preconditioners/DiagonalTest.cs
  29. 38
      src/UnitTests/LinearAlgebraTests/Double/Solvers/Preconditioners/IluptElementSorterTest.cs
  30. 20
      src/UnitTests/LinearAlgebraTests/Double/Solvers/Preconditioners/IlutpTest.cs
  31. 12
      src/UnitTests/LinearAlgebraTests/Double/Solvers/Preconditioners/IncompleteLUTest.cs
  32. 4
      src/UnitTests/LinearAlgebraTests/Single/Solvers/Preconditioners/DiagonalTest.cs
  33. 38
      src/UnitTests/LinearAlgebraTests/Single/Solvers/Preconditioners/IluptElementSorterTest.cs
  34. 20
      src/UnitTests/LinearAlgebraTests/Single/Solvers/Preconditioners/IlutpTest.cs
  35. 12
      src/UnitTests/LinearAlgebraTests/Single/Solvers/Preconditioners/IncompleteLUTest.cs

3
MathNet.Numerics.sln.DotSettings

@ -49,10 +49,13 @@ OTHER DEALINGS IN THE SOFTWARE.
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=CDF/@EntryIndexedValue">CDF</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=DFT/@EntryIndexedValue">DFT</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=FFT/@EntryIndexedValue">FFT</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=ILU/@EntryIndexedValue">ILU</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=ILUTP/@EntryIndexedValue">ILUTP</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=LU/@EntryIndexedValue">LU</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=MAE/@EntryIndexedValue">MAE</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=MC/@EntryIndexedValue">MC</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=MCMC/@EntryIndexedValue">MCMC</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=MILU/@EntryIndexedValue">MILU</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=MSE/@EntryIndexedValue">MSE</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=PDF/@EntryIndexedValue">PDF</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=QR/@EntryIndexedValue">QR</s:String>

3
src/Numerics/LinearAlgebra/Complex/Solvers/Preconditioners/Diagonal.cs → src/Numerics/LinearAlgebra/Complex/Solvers/Preconditioners/DiagonalPreconditioner.cs

@ -39,14 +39,13 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Preconditioners
using Complex = Numerics.Complex;
#else
using Complex = System.Numerics.Complex;
#endif
/// <summary>
/// A diagonal preconditioner. The preconditioner uses the inverse
/// of the matrix diagonal as preconditioning values.
/// </summary>
public sealed class Diagonal : IPreconditioner<Complex>
public sealed class DiagonalPreconditioner : IPreconditioner<Complex>
{
/// <summary>
/// The inverse of the matrix diagonal.

3
src/Numerics/LinearAlgebra/Complex/Solvers/Preconditioners/IncompleteLU.cs → src/Numerics/LinearAlgebra/Complex/Solvers/Preconditioners/ILU0Preconditioner.cs

@ -39,7 +39,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Preconditioners
using Complex = Numerics.Complex;
#else
using Complex = System.Numerics.Complex;
#endif
/// <summary>
@ -51,7 +50,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Preconditioners
/// Yousef Saad <br/>
/// Algorithm is described in Chapter 10, section 10.3.2, page 275 <br/>
/// </remarks>
public sealed class IncompleteLU : IPreconditioner<Complex>
public sealed class ILU0Preconditioner : IPreconditioner<Complex>
{
/// <summary>
/// The matrix holding the lower (L) and upper (U) matrices. The

204
src/Numerics/LinearAlgebra/Complex/Solvers/Preconditioners/Ilutp.cs → src/Numerics/LinearAlgebra/Complex/Solvers/Preconditioners/ILUTPPreconditioner.cs

@ -40,7 +40,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Preconditioners
using Complex = Numerics.Complex;
#else
using Complex = System.Numerics.Complex;
#endif
/// <summary>
@ -60,7 +59,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Preconditioners
/// pp. 20 - 28 <br/>
/// Algorithm is described in Section 2, page 22
/// </remarks>
public sealed class Ilutp : IPreconditioner<Complex>
public sealed class ILUTPPreconditioner : IPreconditioner<Complex>
{
/// <summary>
/// The default fill level.
@ -103,14 +102,14 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Preconditioners
double _pivotTolerance;
/// <summary>
/// Initializes a new instance of the <see cref="Ilutp"/> class with the default settings.
/// Initializes a new instance of the <see cref="ILUTPPreconditioner"/> class with the default settings.
/// </summary>
public Ilutp()
public ILUTPPreconditioner()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="Ilutp"/> class with the specified settings.
/// Initializes a new instance of the <see cref="ILUTPPreconditioner"/> class with the specified settings.
/// </summary>
/// <param name="fillLevel">
/// The amount of fill that is allowed in the matrix. The value is a fraction of
@ -125,7 +124,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Preconditioners
/// The pivot tolerance which indicates at what level pivoting will take place. A
/// value of 0.0 means that no pivoting will take place.
/// </param>
public Ilutp(double fillLevel, double dropTolerance, double pivotTolerance)
public ILUTPPreconditioner(double fillLevel, double dropTolerance, double pivotTolerance)
{
if (fillLevel < 0)
{
@ -613,7 +612,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Preconditioners
// Sorting starts at index 0 because the index array
// starts at zero
// and ends at index upperBound - lowerBound
IlutpElementSorter.SortDoubleIndicesDecreasing(0, upperBound - lowerBound, sortedIndices, values);
ILUTPElementSorter.SortDoubleIndicesDecreasing(0, upperBound - lowerBound, sortedIndices, values);
}
/// <summary>
@ -684,4 +683,195 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Preconditioners
}
}
}
/// <summary>
/// An element sort algorithm for the <see cref="ILUTPPreconditioner"/> class.
/// </summary>
/// <remarks>
/// This sort algorithm is used to sort the columns in a sparse matrix based on
/// the value of the element on the diagonal of the matrix.
/// </remarks>
internal static class ILUTPElementSorter
{
/// <summary>
/// Sorts the elements of the <paramref name="values"/> vector in decreasing
/// fashion. The vector itself is not affected.
/// </summary>
/// <param name="lowerBound">The starting index.</param>
/// <param name="upperBound">The stopping index.</param>
/// <param name="sortedIndices">An array that will contain the sorted indices once the algorithm finishes.</param>
/// <param name="values">The <see cref="Vector{T}"/> that contains the values that need to be sorted.</param>
public static void SortDoubleIndicesDecreasing(int lowerBound, int upperBound, int[] sortedIndices, Vector<Complex> values)
{
// Move all the indices that we're interested in to the beginning of the
// array. Ignore the rest of the indices.
if (lowerBound > 0)
{
for (var i = 0; i < (upperBound - lowerBound + 1); i++)
{
Exchange(sortedIndices, i, i + lowerBound);
}
upperBound -= lowerBound;
lowerBound = 0;
}
HeapSortDoublesIndices(lowerBound, upperBound, sortedIndices, values);
}
/// <summary>
/// Sorts the elements of the <paramref name="values"/> vector in decreasing
/// fashion using heap sort algorithm. The vector itself is not affected.
/// </summary>
/// <param name="lowerBound">The starting index.</param>
/// <param name="upperBound">The stopping index.</param>
/// <param name="sortedIndices">An array that will contain the sorted indices once the algorithm finishes.</param>
/// <param name="values">The <see cref="Vector{T}"/> that contains the values that need to be sorted.</param>
private static void HeapSortDoublesIndices(int lowerBound, int upperBound, int[] sortedIndices, Vector<Complex> values)
{
var start = ((upperBound - lowerBound + 1) / 2) - 1 + lowerBound;
var end = (upperBound - lowerBound + 1) - 1 + lowerBound;
BuildDoubleIndexHeap(start, upperBound - lowerBound + 1, sortedIndices, values);
while (end >= lowerBound)
{
Exchange(sortedIndices, end, lowerBound);
SiftDoubleIndices(sortedIndices, values, lowerBound, end);
end -= 1;
}
}
/// <summary>
/// Build heap for double indicies
/// </summary>
/// <param name="start">Root position</param>
/// <param name="count">Length of <paramref name="values"/></param>
/// <param name="sortedIndices">Indicies of <paramref name="values"/></param>
/// <param name="values">Target <see cref="Vector{T}"/></param>
private static void BuildDoubleIndexHeap(int start, int count, int[] sortedIndices, Vector<Complex> values)
{
while (start >= 0)
{
SiftDoubleIndices(sortedIndices, values, start, count);
start -= 1;
}
}
/// <summary>
/// Sift double indicies
/// </summary>
/// <param name="sortedIndices">Indicies of <paramref name="values"/></param>
/// <param name="values">Target <see cref="Vector{T}"/></param>
/// <param name="begin">Root position</param>
/// <param name="count">Length of <paramref name="values"/></param>
private static void SiftDoubleIndices(int[] sortedIndices, Vector<Complex> values, int begin, int count)
{
var root = begin;
while (root * 2 < count)
{
var child = root * 2;
if ((child < count - 1) && (values[sortedIndices[child]].Magnitude > values[sortedIndices[child + 1]].Magnitude))
{
child += 1;
}
if (values[sortedIndices[root]].Magnitude <= values[sortedIndices[child]].Magnitude)
{
return;
}
Exchange(sortedIndices, root, child);
root = child;
}
}
/// <summary>
/// Sorts the given integers in a decreasing fashion.
/// </summary>
/// <param name="values">The values.</param>
public static void SortIntegersDecreasing(int[] values)
{
HeapSortIntegers(values, values.Length);
}
/// <summary>
/// Sort the given integers in a decreasing fashion using heapsort algorithm
/// </summary>
/// <param name="values">Array of values to sort</param>
/// <param name="count">Length of <paramref name="values"/></param>
private static void HeapSortIntegers(int[] values, int count)
{
var start = (count / 2) - 1;
var end = count - 1;
BuildHeap(values, start, count);
while (end >= 0)
{
Exchange(values, end, 0);
Sift(values, 0, end);
end -= 1;
}
}
/// <summary>
/// Build heap
/// </summary>
/// <param name="values">Target values array</param>
/// <param name="start">Root position</param>
/// <param name="count">Length of <paramref name="values"/></param>
private static void BuildHeap(int[] values, int start, int count)
{
while (start >= 0)
{
Sift(values, start, count);
start -= 1;
}
}
/// <summary>
/// Sift values
/// </summary>
/// <param name="values">Target value array</param>
/// <param name="start">Root position</param>
/// <param name="count">Length of <paramref name="values"/></param>
private static void Sift(int[] values, int start, int count)
{
var root = start;
while (root * 2 < count)
{
var child = root * 2;
if ((child < count - 1) && (values[child] > values[child + 1]))
{
child += 1;
}
if (values[root] > values[child])
{
Exchange(values, root, child);
root = child;
}
else
{
return;
}
}
}
/// <summary>
/// Exchange values in array
/// </summary>
/// <param name="values">Target values array</param>
/// <param name="first">First value to exchange</param>
/// <param name="second">Second value to exchange</param>
private static void Exchange(int[] values, int first, int second)
{
var t = values[first];
values[first] = values[second];
values[second] = t;
}
}
}

230
src/Numerics/LinearAlgebra/Complex/Solvers/Preconditioners/IlutpElementSorter.cs

@ -1,230 +0,0 @@
// <copyright file="IlutpElementSorter.cs" company="Math.NET">
// Math.NET Numerics, part of the Math.NET Project
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
//
// Copyright (c) 2009-2010 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Preconditioners
{
#if NOSYSNUMERICS
using Numerics;
#else
using System.Numerics;
#endif
/// <summary>
/// An element sort algorithm for the <see cref="Ilutp"/> class.
/// </summary>
/// <remarks>
/// This sort algorithm is used to sort the columns in a sparse matrix based on
/// the value of the element on the diagonal of the matrix.
/// </remarks>
internal static class IlutpElementSorter
{
/// <summary>
/// Sorts the elements of the <paramref name="values"/> vector in decreasing
/// fashion. The vector itself is not affected.
/// </summary>
/// <param name="lowerBound">The starting index.</param>
/// <param name="upperBound">The stopping index.</param>
/// <param name="sortedIndices">An array that will contain the sorted indices once the algorithm finishes.</param>
/// <param name="values">The <see cref="Vector{T}"/> that contains the values that need to be sorted.</param>
public static void SortDoubleIndicesDecreasing(int lowerBound, int upperBound, int[] sortedIndices, Vector<Complex> values)
{
// Move all the indices that we're interested in to the beginning of the
// array. Ignore the rest of the indices.
if (lowerBound > 0)
{
for (var i = 0; i < (upperBound - lowerBound + 1); i++)
{
Exchange(sortedIndices, i, i + lowerBound);
}
upperBound -= lowerBound;
lowerBound = 0;
}
HeapSortDoublesIndices(lowerBound, upperBound, sortedIndices, values);
}
/// <summary>
/// Sorts the elements of the <paramref name="values"/> vector in decreasing
/// fashion using heap sort algorithm. The vector itself is not affected.
/// </summary>
/// <param name="lowerBound">The starting index.</param>
/// <param name="upperBound">The stopping index.</param>
/// <param name="sortedIndices">An array that will contain the sorted indices once the algorithm finishes.</param>
/// <param name="values">The <see cref="Vector{T}"/> that contains the values that need to be sorted.</param>
private static void HeapSortDoublesIndices(int lowerBound, int upperBound, int[] sortedIndices, Vector<Complex> values)
{
var start = ((upperBound - lowerBound + 1) / 2) - 1 + lowerBound;
var end = (upperBound - lowerBound + 1) - 1 + lowerBound;
BuildDoubleIndexHeap(start, upperBound - lowerBound + 1, sortedIndices, values);
while (end >= lowerBound)
{
Exchange(sortedIndices, end, lowerBound);
SiftDoubleIndices(sortedIndices, values, lowerBound, end);
end -= 1;
}
}
/// <summary>
/// Build heap for double indicies
/// </summary>
/// <param name="start">Root position</param>
/// <param name="count">Length of <paramref name="values"/></param>
/// <param name="sortedIndices">Indicies of <paramref name="values"/></param>
/// <param name="values">Target <see cref="Vector{T}"/></param>
private static void BuildDoubleIndexHeap(int start, int count, int[] sortedIndices, Vector<Complex> values)
{
while (start >= 0)
{
SiftDoubleIndices(sortedIndices, values, start, count);
start -= 1;
}
}
/// <summary>
/// Sift double indicies
/// </summary>
/// <param name="sortedIndices">Indicies of <paramref name="values"/></param>
/// <param name="values">Target <see cref="Vector{T}"/></param>
/// <param name="begin">Root position</param>
/// <param name="count">Length of <paramref name="values"/></param>
private static void SiftDoubleIndices(int[] sortedIndices, Vector<Complex> values, int begin, int count)
{
var root = begin;
while (root * 2 < count)
{
var child = root * 2;
if ((child < count - 1) && (values[sortedIndices[child]].Magnitude > values[sortedIndices[child + 1]].Magnitude))
{
child += 1;
}
if (values[sortedIndices[root]].Magnitude <= values[sortedIndices[child]].Magnitude)
{
return;
}
Exchange(sortedIndices, root, child);
root = child;
}
}
/// <summary>
/// Sorts the given integers in a decreasing fashion.
/// </summary>
/// <param name="values">The values.</param>
public static void SortIntegersDecreasing(int[] values)
{
HeapSortIntegers(values, values.Length);
}
/// <summary>
/// Sort the given integers in a decreasing fashion using heapsort algorithm
/// </summary>
/// <param name="values">Array of values to sort</param>
/// <param name="count">Length of <paramref name="values"/></param>
private static void HeapSortIntegers(int[] values, int count)
{
var start = (count / 2) - 1;
var end = count - 1;
BuildHeap(values, start, count);
while (end >= 0)
{
Exchange(values, end, 0);
Sift(values, 0, end);
end -= 1;
}
}
/// <summary>
/// Build heap
/// </summary>
/// <param name="values">Target values array</param>
/// <param name="start">Root position</param>
/// <param name="count">Length of <paramref name="values"/></param>
private static void BuildHeap(int[] values, int start, int count)
{
while (start >= 0)
{
Sift(values, start, count);
start -= 1;
}
}
/// <summary>
/// Sift values
/// </summary>
/// <param name="values">Target value array</param>
/// <param name="start">Root position</param>
/// <param name="count">Length of <paramref name="values"/></param>
private static void Sift(int[] values, int start, int count)
{
var root = start;
while (root * 2 < count)
{
var child = root * 2;
if ((child < count - 1) && (values[child] > values[child + 1]))
{
child += 1;
}
if (values[root] > values[child])
{
Exchange(values, root, child);
root = child;
}
else
{
return;
}
}
}
/// <summary>
/// Exchange values in array
/// </summary>
/// <param name="values">Target values array</param>
/// <param name="first">First value to exchange</param>
/// <param name="second">Second value to exchange</param>
private static void Exchange(int[] values, int first, int second)
{
var t = values[first];
values[first] = values[second];
values[second] = t;
}
}
}

2
src/Numerics/LinearAlgebra/Complex32/Solvers/Preconditioners/Diagonal.cs → src/Numerics/LinearAlgebra/Complex32/Solvers/Preconditioners/DiagonalPreconditioner.cs

@ -40,7 +40,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Preconditioners
/// A diagonal preconditioner. The preconditioner uses the inverse
/// of the matrix diagonal as preconditioning values.
/// </summary>
public sealed class Diagonal : IPreconditioner<Complex32>
public sealed class DiagonalPreconditioner : IPreconditioner<Complex32>
{
/// <summary>
/// The inverse of the matrix diagonal.

2
src/Numerics/LinearAlgebra/Complex32/Solvers/Preconditioners/IncompleteLU.cs → src/Numerics/LinearAlgebra/Complex32/Solvers/Preconditioners/ILU0Preconditioner.cs

@ -45,7 +45,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Preconditioners
/// Yousef Saad <br/>
/// Algorithm is described in Chapter 10, section 10.3.2, page 275 <br/>
/// </remarks>
public sealed class IncompleteLU : IPreconditioner<Complex32>
public sealed class ILU0Preconditioner : IPreconditioner<Complex32>
{
/// <summary>
/// The matrix holding the lower (L) and upper (U) matrices. The

203
src/Numerics/LinearAlgebra/Complex32/Solvers/Preconditioners/Ilutp.cs → src/Numerics/LinearAlgebra/Complex32/Solvers/Preconditioners/ILUTPPreconditioner.cs

@ -54,7 +54,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Preconditioners
/// pp. 20 - 28 <br/>
/// Algorithm is described in Section 2, page 22
/// </remarks>
public sealed class Ilutp : IPreconditioner<Complex32>
public sealed class ILUTPPreconditioner : IPreconditioner<Complex32>
{
/// <summary>
/// The default fill level.
@ -97,14 +97,14 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Preconditioners
double _pivotTolerance;
/// <summary>
/// Initializes a new instance of the <see cref="Ilutp"/> class with the default settings.
/// Initializes a new instance of the <see cref="ILUTPPreconditioner"/> class with the default settings.
/// </summary>
public Ilutp()
public ILUTPPreconditioner()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="Ilutp"/> class with the specified settings.
/// Initializes a new instance of the <see cref="ILUTPPreconditioner"/> class with the specified settings.
/// </summary>
/// <param name="fillLevel">
/// The amount of fill that is allowed in the matrix. The value is a fraction of
@ -119,7 +119,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Preconditioners
/// The pivot tolerance which indicates at what level pivoting will take place. A
/// value of 0.0 means that no pivoting will take place.
/// </param>
public Ilutp(double fillLevel, double dropTolerance, double pivotTolerance)
public ILUTPPreconditioner(double fillLevel, double dropTolerance, double pivotTolerance)
{
if (fillLevel < 0)
{
@ -607,7 +607,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Preconditioners
// Sorting starts at index 0 because the index array
// starts at zero
// and ends at index upperBound - lowerBound
IlutpElementSorter.SortDoubleIndicesDecreasing(0, upperBound - lowerBound, sortedIndices, values);
ILUTPElementSorter.SortDoubleIndicesDecreasing(0, upperBound - lowerBound, sortedIndices, values);
}
/// <summary>
@ -678,4 +678,195 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Preconditioners
}
}
}
/// <summary>
/// An element sort algorithm for the <see cref="ILUTPPreconditioner"/> class.
/// </summary>
/// <remarks>
/// This sort algorithm is used to sort the columns in a sparse matrix based on
/// the value of the element on the diagonal of the matrix.
/// </remarks>
internal static class ILUTPElementSorter
{
/// <summary>
/// Sorts the elements of the <paramref name="values"/> vector in decreasing
/// fashion. The vector itself is not affected.
/// </summary>
/// <param name="lowerBound">The starting index.</param>
/// <param name="upperBound">The stopping index.</param>
/// <param name="sortedIndices">An array that will contain the sorted indices once the algorithm finishes.</param>
/// <param name="values">The <see cref="Vector"/> that contains the values that need to be sorted.</param>
public static void SortDoubleIndicesDecreasing(int lowerBound, int upperBound, int[] sortedIndices, Vector<Complex32> values)
{
// Move all the indices that we're interested in to the beginning of the
// array. Ignore the rest of the indices.
if (lowerBound > 0)
{
for (var i = 0; i < (upperBound - lowerBound + 1); i++)
{
Exchange(sortedIndices, i, i + lowerBound);
}
upperBound -= lowerBound;
lowerBound = 0;
}
HeapSortDoublesIndices(lowerBound, upperBound, sortedIndices, values);
}
/// <summary>
/// Sorts the elements of the <paramref name="values"/> vector in decreasing
/// fashion using heap sort algorithm. The vector itself is not affected.
/// </summary>
/// <param name="lowerBound">The starting index.</param>
/// <param name="upperBound">The stopping index.</param>
/// <param name="sortedIndices">An array that will contain the sorted indices once the algorithm finishes.</param>
/// <param name="values">The <see cref="Vector"/> that contains the values that need to be sorted.</param>
private static void HeapSortDoublesIndices(int lowerBound, int upperBound, int[] sortedIndices, Vector<Complex32> values)
{
var start = ((upperBound - lowerBound + 1) / 2) - 1 + lowerBound;
var end = (upperBound - lowerBound + 1) - 1 + lowerBound;
BuildDoubleIndexHeap(start, upperBound - lowerBound + 1, sortedIndices, values);
while (end >= lowerBound)
{
Exchange(sortedIndices, end, lowerBound);
SiftDoubleIndices(sortedIndices, values, lowerBound, end);
end -= 1;
}
}
/// <summary>
/// Build heap for double indicies
/// </summary>
/// <param name="start">Root position</param>
/// <param name="count">Length of <paramref name="values"/></param>
/// <param name="sortedIndices">Indicies of <paramref name="values"/></param>
/// <param name="values">Target <see cref="Vector"/></param>
private static void BuildDoubleIndexHeap(int start, int count, int[] sortedIndices, Vector<Complex32> values)
{
while (start >= 0)
{
SiftDoubleIndices(sortedIndices, values, start, count);
start -= 1;
}
}
/// <summary>
/// Sift double indicies
/// </summary>
/// <param name="sortedIndices">Indicies of <paramref name="values"/></param>
/// <param name="values">Target <see cref="Vector"/></param>
/// <param name="begin">Root position</param>
/// <param name="count">Length of <paramref name="values"/></param>
private static void SiftDoubleIndices(int[] sortedIndices, Vector<Complex32> values, int begin, int count)
{
var root = begin;
while (root * 2 < count)
{
var child = root * 2;
if ((child < count - 1) && (values[sortedIndices[child]].Magnitude > values[sortedIndices[child + 1]].Magnitude))
{
child += 1;
}
if (values[sortedIndices[root]].Magnitude <= values[sortedIndices[child]].Magnitude)
{
return;
}
Exchange(sortedIndices, root, child);
root = child;
}
}
/// <summary>
/// Sorts the given integers in a decreasing fashion.
/// </summary>
/// <param name="values">The values.</param>
public static void SortIntegersDecreasing(int[] values)
{
HeapSortIntegers(values, values.Length);
}
/// <summary>
/// Sort the given integers in a decreasing fashion using heapsort algorithm
/// </summary>
/// <param name="values">Array of values to sort</param>
/// <param name="count">Length of <paramref name="values"/></param>
private static void HeapSortIntegers(int[] values, int count)
{
var start = (count / 2) - 1;
var end = count - 1;
BuildHeap(values, start, count);
while (end >= 0)
{
Exchange(values, end, 0);
Sift(values, 0, end);
end -= 1;
}
}
/// <summary>
/// Build heap
/// </summary>
/// <param name="values">Target values array</param>
/// <param name="start">Root position</param>
/// <param name="count">Length of <paramref name="values"/></param>
private static void BuildHeap(int[] values, int start, int count)
{
while (start >= 0)
{
Sift(values, start, count);
start -= 1;
}
}
/// <summary>
/// Sift values
/// </summary>
/// <param name="values">Target value array</param>
/// <param name="start">Root position</param>
/// <param name="count">Length of <paramref name="values"/></param>
private static void Sift(int[] values, int start, int count)
{
var root = start;
while (root * 2 < count)
{
var child = root * 2;
if ((child < count - 1) && (values[child] > values[child + 1]))
{
child += 1;
}
if (values[root] > values[child])
{
Exchange(values, root, child);
root = child;
}
else
{
return;
}
}
}
/// <summary>
/// Exchange values in array
/// </summary>
/// <param name="values">Target values array</param>
/// <param name="first">First value to exchange</param>
/// <param name="second">Second value to exchange</param>
private static void Exchange(int[] values, int first, int second)
{
var t = values[first];
values[first] = values[second];
values[second] = t;
}
}
}

225
src/Numerics/LinearAlgebra/Complex32/Solvers/Preconditioners/IlutpElementSorter.cs

@ -1,225 +0,0 @@
// <copyright file="IlutpElementSorter.cs" company="Math.NET">
// Math.NET Numerics, part of the Math.NET Project
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
//
// Copyright (c) 2009-2010 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Preconditioners
{
using Numerics;
/// <summary>
/// An element sort algorithm for the <see cref="Ilutp"/> class.
/// </summary>
/// <remarks>
/// This sort algorithm is used to sort the columns in a sparse matrix based on
/// the value of the element on the diagonal of the matrix.
/// </remarks>
internal static class IlutpElementSorter
{
/// <summary>
/// Sorts the elements of the <paramref name="values"/> vector in decreasing
/// fashion. The vector itself is not affected.
/// </summary>
/// <param name="lowerBound">The starting index.</param>
/// <param name="upperBound">The stopping index.</param>
/// <param name="sortedIndices">An array that will contain the sorted indices once the algorithm finishes.</param>
/// <param name="values">The <see cref="Vector"/> that contains the values that need to be sorted.</param>
public static void SortDoubleIndicesDecreasing(int lowerBound, int upperBound, int[] sortedIndices, Vector<Complex32> values)
{
// Move all the indices that we're interested in to the beginning of the
// array. Ignore the rest of the indices.
if (lowerBound > 0)
{
for (var i = 0; i < (upperBound - lowerBound + 1); i++)
{
Exchange(sortedIndices, i, i + lowerBound);
}
upperBound -= lowerBound;
lowerBound = 0;
}
HeapSortDoublesIndices(lowerBound, upperBound, sortedIndices, values);
}
/// <summary>
/// Sorts the elements of the <paramref name="values"/> vector in decreasing
/// fashion using heap sort algorithm. The vector itself is not affected.
/// </summary>
/// <param name="lowerBound">The starting index.</param>
/// <param name="upperBound">The stopping index.</param>
/// <param name="sortedIndices">An array that will contain the sorted indices once the algorithm finishes.</param>
/// <param name="values">The <see cref="Vector"/> that contains the values that need to be sorted.</param>
private static void HeapSortDoublesIndices(int lowerBound, int upperBound, int[] sortedIndices, Vector<Complex32> values)
{
var start = ((upperBound - lowerBound + 1) / 2) - 1 + lowerBound;
var end = (upperBound - lowerBound + 1) - 1 + lowerBound;
BuildDoubleIndexHeap(start, upperBound - lowerBound + 1, sortedIndices, values);
while (end >= lowerBound)
{
Exchange(sortedIndices, end, lowerBound);
SiftDoubleIndices(sortedIndices, values, lowerBound, end);
end -= 1;
}
}
/// <summary>
/// Build heap for double indicies
/// </summary>
/// <param name="start">Root position</param>
/// <param name="count">Length of <paramref name="values"/></param>
/// <param name="sortedIndices">Indicies of <paramref name="values"/></param>
/// <param name="values">Target <see cref="Vector"/></param>
private static void BuildDoubleIndexHeap(int start, int count, int[] sortedIndices, Vector<Complex32> values)
{
while (start >= 0)
{
SiftDoubleIndices(sortedIndices, values, start, count);
start -= 1;
}
}
/// <summary>
/// Sift double indicies
/// </summary>
/// <param name="sortedIndices">Indicies of <paramref name="values"/></param>
/// <param name="values">Target <see cref="Vector"/></param>
/// <param name="begin">Root position</param>
/// <param name="count">Length of <paramref name="values"/></param>
private static void SiftDoubleIndices(int[] sortedIndices, Vector<Complex32> values, int begin, int count)
{
var root = begin;
while (root * 2 < count)
{
var child = root * 2;
if ((child < count - 1) && (values[sortedIndices[child]].Magnitude > values[sortedIndices[child + 1]].Magnitude))
{
child += 1;
}
if (values[sortedIndices[root]].Magnitude <= values[sortedIndices[child]].Magnitude)
{
return;
}
Exchange(sortedIndices, root, child);
root = child;
}
}
/// <summary>
/// Sorts the given integers in a decreasing fashion.
/// </summary>
/// <param name="values">The values.</param>
public static void SortIntegersDecreasing(int[] values)
{
HeapSortIntegers(values, values.Length);
}
/// <summary>
/// Sort the given integers in a decreasing fashion using heapsort algorithm
/// </summary>
/// <param name="values">Array of values to sort</param>
/// <param name="count">Length of <paramref name="values"/></param>
private static void HeapSortIntegers(int[] values, int count)
{
var start = (count / 2) - 1;
var end = count - 1;
BuildHeap(values, start, count);
while (end >= 0)
{
Exchange(values, end, 0);
Sift(values, 0, end);
end -= 1;
}
}
/// <summary>
/// Build heap
/// </summary>
/// <param name="values">Target values array</param>
/// <param name="start">Root position</param>
/// <param name="count">Length of <paramref name="values"/></param>
private static void BuildHeap(int[] values, int start, int count)
{
while (start >= 0)
{
Sift(values, start, count);
start -= 1;
}
}
/// <summary>
/// Sift values
/// </summary>
/// <param name="values">Target value array</param>
/// <param name="start">Root position</param>
/// <param name="count">Length of <paramref name="values"/></param>
private static void Sift(int[] values, int start, int count)
{
var root = start;
while (root * 2 < count)
{
var child = root * 2;
if ((child < count - 1) && (values[child] > values[child + 1]))
{
child += 1;
}
if (values[root] > values[child])
{
Exchange(values, root, child);
root = child;
}
else
{
return;
}
}
}
/// <summary>
/// Exchange values in array
/// </summary>
/// <param name="values">Target values array</param>
/// <param name="first">First value to exchange</param>
/// <param name="second">Second value to exchange</param>
private static void Exchange(int[] values, int first, int second)
{
var t = values[first];
values[first] = values[second];
values[second] = t;
}
}
}

2
src/Numerics/LinearAlgebra/Double/Solvers/Preconditioners/Diagonal.cs → src/Numerics/LinearAlgebra/Double/Solvers/Preconditioners/DiagonalPreconditioner.cs

@ -38,7 +38,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Preconditioners
/// A diagonal preconditioner. The preconditioner uses the inverse
/// of the matrix diagonal as preconditioning values.
/// </summary>
public sealed class Diagonal : IPreconditioner<double>
public sealed class DiagonalPreconditioner : IPreconditioner<double>
{
/// <summary>
/// The inverse of the matrix diagonal.

2
src/Numerics/LinearAlgebra/Double/Solvers/Preconditioners/IncompleteLU.cs → src/Numerics/LinearAlgebra/Double/Solvers/Preconditioners/ILU0Preconditioner.cs

@ -43,7 +43,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Preconditioners
/// Yousef Saad <br/>
/// Algorithm is described in Chapter 10, section 10.3.2, page 275 <br/>
/// </remarks>
public sealed class IncompleteLU : IPreconditioner<double>
public sealed class ILU0Preconditioner : IPreconditioner<double>
{
/// <summary>
/// The matrix holding the lower (L) and upper (U) matrices. The

203
src/Numerics/LinearAlgebra/Double/Solvers/Preconditioners/Ilutp.cs → src/Numerics/LinearAlgebra/Double/Solvers/Preconditioners/ILUTPPreconditioner.cs

@ -52,7 +52,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Preconditioners
/// pp. 20 - 28 <br/>
/// Algorithm is described in Section 2, page 22
/// </remarks>
public sealed class Ilutp : IPreconditioner<double>
public sealed class ILUTPPreconditioner : IPreconditioner<double>
{
/// <summary>
/// The default fill level.
@ -95,14 +95,14 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Preconditioners
double _pivotTolerance;
/// <summary>
/// Initializes a new instance of the <see cref="Ilutp"/> class with the default settings.
/// Initializes a new instance of the <see cref="ILUTPPreconditioner"/> class with the default settings.
/// </summary>
public Ilutp()
public ILUTPPreconditioner()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="Ilutp"/> class with the specified settings.
/// Initializes a new instance of the <see cref="ILUTPPreconditioner"/> class with the specified settings.
/// </summary>
/// <param name="fillLevel">
/// The amount of fill that is allowed in the matrix. The value is a fraction of
@ -117,7 +117,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Preconditioners
/// The pivot tolerance which indicates at what level pivoting will take place. A
/// value of 0.0 means that no pivoting will take place.
/// </param>
public Ilutp(double fillLevel, double dropTolerance, double pivotTolerance)
public ILUTPPreconditioner(double fillLevel, double dropTolerance, double pivotTolerance)
{
if (fillLevel < 0)
{
@ -605,7 +605,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Preconditioners
// Sorting starts at index 0 because the index array
// starts at zero
// and ends at index upperBound - lowerBound
IlutpElementSorter.SortDoubleIndicesDecreasing(0, upperBound - lowerBound, sortedIndices, values);
ILUTPElementSorter.SortDoubleIndicesDecreasing(0, upperBound - lowerBound, sortedIndices, values);
}
/// <summary>
@ -676,4 +676,195 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Preconditioners
}
}
}
/// <summary>
/// An element sort algorithm for the <see cref="ILUTPPreconditioner"/> class.
/// </summary>
/// <remarks>
/// This sort algorithm is used to sort the columns in a sparse matrix based on
/// the value of the element on the diagonal of the matrix.
/// </remarks>
internal static class ILUTPElementSorter
{
/// <summary>
/// Sorts the elements of the <paramref name="values"/> vector in decreasing
/// fashion. The vector itself is not affected.
/// </summary>
/// <param name="lowerBound">The starting index.</param>
/// <param name="upperBound">The stopping index.</param>
/// <param name="sortedIndices">An array that will contain the sorted indices once the algorithm finishes.</param>
/// <param name="values">The <see cref="Vector"/> that contains the values that need to be sorted.</param>
public static void SortDoubleIndicesDecreasing(int lowerBound, int upperBound, int[] sortedIndices, Vector<double> values)
{
// Move all the indices that we're interested in to the beginning of the
// array. Ignore the rest of the indices.
if (lowerBound > 0)
{
for (var i = 0; i < (upperBound - lowerBound + 1); i++)
{
Exchange(sortedIndices, i, i + lowerBound);
}
upperBound -= lowerBound;
lowerBound = 0;
}
HeapSortDoublesIndices(lowerBound, upperBound, sortedIndices, values);
}
/// <summary>
/// Sorts the elements of the <paramref name="values"/> vector in decreasing
/// fashion using heap sort algorithm. The vector itself is not affected.
/// </summary>
/// <param name="lowerBound">The starting index.</param>
/// <param name="upperBound">The stopping index.</param>
/// <param name="sortedIndices">An array that will contain the sorted indices once the algorithm finishes.</param>
/// <param name="values">The <see cref="Vector"/> that contains the values that need to be sorted.</param>
private static void HeapSortDoublesIndices(int lowerBound, int upperBound, int[] sortedIndices, Vector<double> values)
{
var start = ((upperBound - lowerBound + 1) / 2) - 1 + lowerBound;
var end = (upperBound - lowerBound + 1) - 1 + lowerBound;
BuildDoubleIndexHeap(start, upperBound - lowerBound + 1, sortedIndices, values);
while (end >= lowerBound)
{
Exchange(sortedIndices, end, lowerBound);
SiftDoubleIndices(sortedIndices, values, lowerBound, end);
end -= 1;
}
}
/// <summary>
/// Build heap for double indicies
/// </summary>
/// <param name="start">Root position</param>
/// <param name="count">Length of <paramref name="values"/></param>
/// <param name="sortedIndices">Indicies of <paramref name="values"/></param>
/// <param name="values">Target <see cref="Vector"/></param>
private static void BuildDoubleIndexHeap(int start, int count, int[] sortedIndices, Vector<double> values)
{
while (start >= 0)
{
SiftDoubleIndices(sortedIndices, values, start, count);
start -= 1;
}
}
/// <summary>
/// Sift double indicies
/// </summary>
/// <param name="sortedIndices">Indicies of <paramref name="values"/></param>
/// <param name="values">Target <see cref="Vector"/></param>
/// <param name="begin">Root position</param>
/// <param name="count">Length of <paramref name="values"/></param>
private static void SiftDoubleIndices(int[] sortedIndices, Vector<double> values, int begin, int count)
{
var root = begin;
while (root * 2 < count)
{
var child = root * 2;
if ((child < count - 1) && (values[sortedIndices[child]] > values[sortedIndices[child + 1]]))
{
child += 1;
}
if (values[sortedIndices[root]] <= values[sortedIndices[child]])
{
return;
}
Exchange(sortedIndices, root, child);
root = child;
}
}
/// <summary>
/// Sorts the given integers in a decreasing fashion.
/// </summary>
/// <param name="values">The values.</param>
public static void SortIntegersDecreasing(int[] values)
{
HeapSortIntegers(values, values.Length);
}
/// <summary>
/// Sort the given integers in a decreasing fashion using heapsort algorithm
/// </summary>
/// <param name="values">Array of values to sort</param>
/// <param name="count">Length of <paramref name="values"/></param>
private static void HeapSortIntegers(int[] values, int count)
{
var start = (count / 2) - 1;
var end = count - 1;
BuildHeap(values, start, count);
while (end >= 0)
{
Exchange(values, end, 0);
Sift(values, 0, end);
end -= 1;
}
}
/// <summary>
/// Build heap
/// </summary>
/// <param name="values">Target values array</param>
/// <param name="start">Root position</param>
/// <param name="count">Length of <paramref name="values"/></param>
private static void BuildHeap(int[] values, int start, int count)
{
while (start >= 0)
{
Sift(values, start, count);
start -= 1;
}
}
/// <summary>
/// Sift values
/// </summary>
/// <param name="values">Target value array</param>
/// <param name="start">Root position</param>
/// <param name="count">Length of <paramref name="values"/></param>
private static void Sift(int[] values, int start, int count)
{
var root = start;
while (root * 2 < count)
{
var child = root * 2;
if ((child < count - 1) && (values[child] > values[child + 1]))
{
child += 1;
}
if (values[root] > values[child])
{
Exchange(values, root, child);
root = child;
}
else
{
return;
}
}
}
/// <summary>
/// Exchange values in array
/// </summary>
/// <param name="values">Target values array</param>
/// <param name="first">First value to exchange</param>
/// <param name="second">Second value to exchange</param>
private static void Exchange(int[] values, int first, int second)
{
var t = values[first];
values[first] = values[second];
values[second] = t;
}
}
}

223
src/Numerics/LinearAlgebra/Double/Solvers/Preconditioners/IlutpElementSorter.cs

@ -1,223 +0,0 @@
// <copyright file="IlutpElementSorter.cs" company="Math.NET">
// Math.NET Numerics, part of the Math.NET Project
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
//
// Copyright (c) 2009-2010 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Preconditioners
{
/// <summary>
/// An element sort algorithm for the <see cref="Ilutp"/> class.
/// </summary>
/// <remarks>
/// This sort algorithm is used to sort the columns in a sparse matrix based on
/// the value of the element on the diagonal of the matrix.
/// </remarks>
internal static class IlutpElementSorter
{
/// <summary>
/// Sorts the elements of the <paramref name="values"/> vector in decreasing
/// fashion. The vector itself is not affected.
/// </summary>
/// <param name="lowerBound">The starting index.</param>
/// <param name="upperBound">The stopping index.</param>
/// <param name="sortedIndices">An array that will contain the sorted indices once the algorithm finishes.</param>
/// <param name="values">The <see cref="Vector"/> that contains the values that need to be sorted.</param>
public static void SortDoubleIndicesDecreasing(int lowerBound, int upperBound, int[] sortedIndices, Vector<double> values)
{
// Move all the indices that we're interested in to the beginning of the
// array. Ignore the rest of the indices.
if (lowerBound > 0)
{
for (var i = 0; i < (upperBound - lowerBound + 1); i++)
{
Exchange(sortedIndices, i, i + lowerBound);
}
upperBound -= lowerBound;
lowerBound = 0;
}
HeapSortDoublesIndices(lowerBound, upperBound, sortedIndices, values);
}
/// <summary>
/// Sorts the elements of the <paramref name="values"/> vector in decreasing
/// fashion using heap sort algorithm. The vector itself is not affected.
/// </summary>
/// <param name="lowerBound">The starting index.</param>
/// <param name="upperBound">The stopping index.</param>
/// <param name="sortedIndices">An array that will contain the sorted indices once the algorithm finishes.</param>
/// <param name="values">The <see cref="Vector"/> that contains the values that need to be sorted.</param>
private static void HeapSortDoublesIndices(int lowerBound, int upperBound, int[] sortedIndices, Vector<double> values)
{
var start = ((upperBound - lowerBound + 1) / 2) - 1 + lowerBound;
var end = (upperBound - lowerBound + 1) - 1 + lowerBound;
BuildDoubleIndexHeap(start, upperBound - lowerBound + 1, sortedIndices, values);
while (end >= lowerBound)
{
Exchange(sortedIndices, end, lowerBound);
SiftDoubleIndices(sortedIndices, values, lowerBound, end);
end -= 1;
}
}
/// <summary>
/// Build heap for double indicies
/// </summary>
/// <param name="start">Root position</param>
/// <param name="count">Length of <paramref name="values"/></param>
/// <param name="sortedIndices">Indicies of <paramref name="values"/></param>
/// <param name="values">Target <see cref="Vector"/></param>
private static void BuildDoubleIndexHeap(int start, int count, int[] sortedIndices, Vector<double> values)
{
while (start >= 0)
{
SiftDoubleIndices(sortedIndices, values, start, count);
start -= 1;
}
}
/// <summary>
/// Sift double indicies
/// </summary>
/// <param name="sortedIndices">Indicies of <paramref name="values"/></param>
/// <param name="values">Target <see cref="Vector"/></param>
/// <param name="begin">Root position</param>
/// <param name="count">Length of <paramref name="values"/></param>
private static void SiftDoubleIndices(int[] sortedIndices, Vector<double> values, int begin, int count)
{
var root = begin;
while (root * 2 < count)
{
var child = root * 2;
if ((child < count - 1) && (values[sortedIndices[child]] > values[sortedIndices[child + 1]]))
{
child += 1;
}
if (values[sortedIndices[root]] <= values[sortedIndices[child]])
{
return;
}
Exchange(sortedIndices, root, child);
root = child;
}
}
/// <summary>
/// Sorts the given integers in a decreasing fashion.
/// </summary>
/// <param name="values">The values.</param>
public static void SortIntegersDecreasing(int[] values)
{
HeapSortIntegers(values, values.Length);
}
/// <summary>
/// Sort the given integers in a decreasing fashion using heapsort algorithm
/// </summary>
/// <param name="values">Array of values to sort</param>
/// <param name="count">Length of <paramref name="values"/></param>
private static void HeapSortIntegers(int[] values, int count)
{
var start = (count / 2) - 1;
var end = count - 1;
BuildHeap(values, start, count);
while (end >= 0)
{
Exchange(values, end, 0);
Sift(values, 0, end);
end -= 1;
}
}
/// <summary>
/// Build heap
/// </summary>
/// <param name="values">Target values array</param>
/// <param name="start">Root position</param>
/// <param name="count">Length of <paramref name="values"/></param>
private static void BuildHeap(int[] values, int start, int count)
{
while (start >= 0)
{
Sift(values, start, count);
start -= 1;
}
}
/// <summary>
/// Sift values
/// </summary>
/// <param name="values">Target value array</param>
/// <param name="start">Root position</param>
/// <param name="count">Length of <paramref name="values"/></param>
private static void Sift(int[] values, int start, int count)
{
var root = start;
while (root * 2 < count)
{
var child = root * 2;
if ((child < count - 1) && (values[child] > values[child + 1]))
{
child += 1;
}
if (values[root] > values[child])
{
Exchange(values, root, child);
root = child;
}
else
{
return;
}
}
}
/// <summary>
/// Exchange values in array
/// </summary>
/// <param name="values">Target values array</param>
/// <param name="first">First value to exchange</param>
/// <param name="second">Second value to exchange</param>
private static void Exchange(int[] values, int first, int second)
{
var t = values[first];
values[first] = values[second];
values[second] = t;
}
}
}

2
src/Numerics/LinearAlgebra/Double/Solvers/Preconditioners/Milu0.cs → src/Numerics/LinearAlgebra/Double/Solvers/Preconditioners/MILU0Preconditioner.cs

@ -48,7 +48,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Preconditioners
///
/// Original Fortran code by Youcef Saad (07 January 2004)
/// </remarks>
public sealed class Milu0 : IPreconditioner<double>
public sealed class MILU0Preconditioner : IPreconditioner<double>
{
// Matrix stored in Modified Sparse Row (MSR) format containing the L and U
// factors together.

2
src/Numerics/LinearAlgebra/Single/Solvers/Preconditioners/Diagonal.cs → src/Numerics/LinearAlgebra/Single/Solvers/Preconditioners/DiagonalPreconditioner.cs

@ -38,7 +38,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Preconditioners
/// A diagonal preconditioner. The preconditioner uses the inverse
/// of the matrix diagonal as preconditioning values.
/// </summary>
public sealed class Diagonal : IPreconditioner<float>
public sealed class DiagonalPreconditioner : IPreconditioner<float>
{
/// <summary>
/// The inverse of the matrix diagonal.

2
src/Numerics/LinearAlgebra/Single/Solvers/Preconditioners/IncompleteLU.cs → src/Numerics/LinearAlgebra/Single/Solvers/Preconditioners/ILU0Preconditioner.cs

@ -43,7 +43,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Preconditioners
/// Yousef Saad <br/>
/// Algorithm is described in Chapter 10, section 10.3.2, page 275 <br/>
/// </remarks>
public sealed class IncompleteLU : IPreconditioner<float>
public sealed class ILU0Preconditioner : IPreconditioner<float>
{
/// <summary>
/// The matrix holding the lower (L) and upper (U) matrices. The

203
src/Numerics/LinearAlgebra/Single/Solvers/Preconditioners/Ilutp.cs → src/Numerics/LinearAlgebra/Single/Solvers/Preconditioners/ILUTPPreconditioner.cs

@ -52,7 +52,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Preconditioners
/// pp. 20 - 28 <br/>
/// Algorithm is described in Section 2, page 22
/// </remarks>
public sealed class Ilutp : IPreconditioner<float>
public sealed class ILUTPPreconditioner : IPreconditioner<float>
{
/// <summary>
/// The default fill level.
@ -95,14 +95,14 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Preconditioners
double _pivotTolerance;
/// <summary>
/// Initializes a new instance of the <see cref="Ilutp"/> class with the default settings.
/// Initializes a new instance of the <see cref="ILUTPPreconditioner"/> class with the default settings.
/// </summary>
public Ilutp()
public ILUTPPreconditioner()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="Ilutp"/> class with the specified settings.
/// Initializes a new instance of the <see cref="ILUTPPreconditioner"/> class with the specified settings.
/// </summary>
/// <param name="fillLevel">
/// The amount of fill that is allowed in the matrix. The value is a fraction of
@ -117,7 +117,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Preconditioners
/// The pivot tolerance which indicates at what level pivoting will take place. A
/// value of 0.0 means that no pivoting will take place.
/// </param>
public Ilutp(double fillLevel, double dropTolerance, double pivotTolerance)
public ILUTPPreconditioner(double fillLevel, double dropTolerance, double pivotTolerance)
{
if (fillLevel < 0)
{
@ -605,7 +605,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Preconditioners
// Sorting starts at index 0 because the index array
// starts at zero
// and ends at index upperBound - lowerBound
IlutpElementSorter.SortDoubleIndicesDecreasing(0, upperBound - lowerBound, sortedIndices, values);
ILUTPElementSorter.SortDoubleIndicesDecreasing(0, upperBound - lowerBound, sortedIndices, values);
}
/// <summary>
@ -676,4 +676,195 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Preconditioners
}
}
}
/// <summary>
/// An element sort algorithm for the <see cref="ILUTPPreconditioner"/> class.
/// </summary>
/// <remarks>
/// This sort algorithm is used to sort the columns in a sparse matrix based on
/// the value of the element on the diagonal of the matrix.
/// </remarks>
internal static class ILUTPElementSorter
{
/// <summary>
/// Sorts the elements of the <paramref name="values"/> vector in decreasing
/// fashion. The vector itself is not affected.
/// </summary>
/// <param name="lowerBound">The starting index.</param>
/// <param name="upperBound">The stopping index.</param>
/// <param name="sortedIndices">An array that will contain the sorted indices once the algorithm finishes.</param>
/// <param name="values">The <see cref="Vector"/> that contains the values that need to be sorted.</param>
public static void SortDoubleIndicesDecreasing(int lowerBound, int upperBound, int[] sortedIndices, Vector<float> values)
{
// Move all the indices that we're interested in to the beginning of the
// array. Ignore the rest of the indices.
if (lowerBound > 0)
{
for (var i = 0; i < (upperBound - lowerBound + 1); i++)
{
Exchange(sortedIndices, i, i + lowerBound);
}
upperBound -= lowerBound;
lowerBound = 0;
}
HeapSortDoublesIndices(lowerBound, upperBound, sortedIndices, values);
}
/// <summary>
/// Sorts the elements of the <paramref name="values"/> vector in decreasing
/// fashion using heap sort algorithm. The vector itself is not affected.
/// </summary>
/// <param name="lowerBound">The starting index.</param>
/// <param name="upperBound">The stopping index.</param>
/// <param name="sortedIndices">An array that will contain the sorted indices once the algorithm finishes.</param>
/// <param name="values">The <see cref="Vector"/> that contains the values that need to be sorted.</param>
private static void HeapSortDoublesIndices(int lowerBound, int upperBound, int[] sortedIndices, Vector<float> values)
{
var start = ((upperBound - lowerBound + 1) / 2) - 1 + lowerBound;
var end = (upperBound - lowerBound + 1) - 1 + lowerBound;
BuildDoubleIndexHeap(start, upperBound - lowerBound + 1, sortedIndices, values);
while (end >= lowerBound)
{
Exchange(sortedIndices, end, lowerBound);
SiftDoubleIndices(sortedIndices, values, lowerBound, end);
end -= 1;
}
}
/// <summary>
/// Build heap for double indicies
/// </summary>
/// <param name="start">Root position</param>
/// <param name="count">Length of <paramref name="values"/></param>
/// <param name="sortedIndices">Indicies of <paramref name="values"/></param>
/// <param name="values">Target <see cref="Vector"/></param>
private static void BuildDoubleIndexHeap(int start, int count, int[] sortedIndices, Vector<float> values)
{
while (start >= 0)
{
SiftDoubleIndices(sortedIndices, values, start, count);
start -= 1;
}
}
/// <summary>
/// Sift double indicies
/// </summary>
/// <param name="sortedIndices">Indicies of <paramref name="values"/></param>
/// <param name="values">Target <see cref="Vector"/></param>
/// <param name="begin">Root position</param>
/// <param name="count">Length of <paramref name="values"/></param>
private static void SiftDoubleIndices(int[] sortedIndices, Vector<float> values, int begin, int count)
{
var root = begin;
while (root * 2 < count)
{
var child = root * 2;
if ((child < count - 1) && (values[sortedIndices[child]] > values[sortedIndices[child + 1]]))
{
child += 1;
}
if (values[sortedIndices[root]] <= values[sortedIndices[child]])
{
return;
}
Exchange(sortedIndices, root, child);
root = child;
}
}
/// <summary>
/// Sorts the given integers in a decreasing fashion.
/// </summary>
/// <param name="values">The values.</param>
public static void SortIntegersDecreasing(int[] values)
{
HeapSortIntegers(values, values.Length);
}
/// <summary>
/// Sort the given integers in a decreasing fashion using heapsort algorithm
/// </summary>
/// <param name="values">Array of values to sort</param>
/// <param name="count">Length of <paramref name="values"/></param>
private static void HeapSortIntegers(int[] values, int count)
{
var start = (count / 2) - 1;
var end = count - 1;
BuildHeap(values, start, count);
while (end >= 0)
{
Exchange(values, end, 0);
Sift(values, 0, end);
end -= 1;
}
}
/// <summary>
/// Build heap
/// </summary>
/// <param name="values">Target values array</param>
/// <param name="start">Root position</param>
/// <param name="count">Length of <paramref name="values"/></param>
private static void BuildHeap(int[] values, int start, int count)
{
while (start >= 0)
{
Sift(values, start, count);
start -= 1;
}
}
/// <summary>
/// Sift values
/// </summary>
/// <param name="values">Target value array</param>
/// <param name="start">Root position</param>
/// <param name="count">Length of <paramref name="values"/></param>
private static void Sift(int[] values, int start, int count)
{
var root = start;
while (root * 2 < count)
{
var child = root * 2;
if ((child < count - 1) && (values[child] > values[child + 1]))
{
child += 1;
}
if (values[root] > values[child])
{
Exchange(values, root, child);
root = child;
}
else
{
return;
}
}
}
/// <summary>
/// Exchange values in array
/// </summary>
/// <param name="values">Target values array</param>
/// <param name="first">First value to exchange</param>
/// <param name="second">Second value to exchange</param>
private static void Exchange(int[] values, int first, int second)
{
var t = values[first];
values[first] = values[second];
values[second] = t;
}
}
}

223
src/Numerics/LinearAlgebra/Single/Solvers/Preconditioners/IlutpElementSorter.cs

@ -1,223 +0,0 @@
// <copyright file="IlutpElementSorter.cs" company="Math.NET">
// Math.NET Numerics, part of the Math.NET Project
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
//
// Copyright (c) 2009-2010 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Preconditioners
{
/// <summary>
/// An element sort algorithm for the <see cref="Ilutp"/> class.
/// </summary>
/// <remarks>
/// This sort algorithm is used to sort the columns in a sparse matrix based on
/// the value of the element on the diagonal of the matrix.
/// </remarks>
internal static class IlutpElementSorter
{
/// <summary>
/// Sorts the elements of the <paramref name="values"/> vector in decreasing
/// fashion. The vector itself is not affected.
/// </summary>
/// <param name="lowerBound">The starting index.</param>
/// <param name="upperBound">The stopping index.</param>
/// <param name="sortedIndices">An array that will contain the sorted indices once the algorithm finishes.</param>
/// <param name="values">The <see cref="Vector"/> that contains the values that need to be sorted.</param>
public static void SortDoubleIndicesDecreasing(int lowerBound, int upperBound, int[] sortedIndices, Vector<float> values)
{
// Move all the indices that we're interested in to the beginning of the
// array. Ignore the rest of the indices.
if (lowerBound > 0)
{
for (var i = 0; i < (upperBound - lowerBound + 1); i++)
{
Exchange(sortedIndices, i, i + lowerBound);
}
upperBound -= lowerBound;
lowerBound = 0;
}
HeapSortDoublesIndices(lowerBound, upperBound, sortedIndices, values);
}
/// <summary>
/// Sorts the elements of the <paramref name="values"/> vector in decreasing
/// fashion using heap sort algorithm. The vector itself is not affected.
/// </summary>
/// <param name="lowerBound">The starting index.</param>
/// <param name="upperBound">The stopping index.</param>
/// <param name="sortedIndices">An array that will contain the sorted indices once the algorithm finishes.</param>
/// <param name="values">The <see cref="Vector"/> that contains the values that need to be sorted.</param>
private static void HeapSortDoublesIndices(int lowerBound, int upperBound, int[] sortedIndices, Vector<float> values)
{
var start = ((upperBound - lowerBound + 1) / 2) - 1 + lowerBound;
var end = (upperBound - lowerBound + 1) - 1 + lowerBound;
BuildDoubleIndexHeap(start, upperBound - lowerBound + 1, sortedIndices, values);
while (end >= lowerBound)
{
Exchange(sortedIndices, end, lowerBound);
SiftDoubleIndices(sortedIndices, values, lowerBound, end);
end -= 1;
}
}
/// <summary>
/// Build heap for double indicies
/// </summary>
/// <param name="start">Root position</param>
/// <param name="count">Length of <paramref name="values"/></param>
/// <param name="sortedIndices">Indicies of <paramref name="values"/></param>
/// <param name="values">Target <see cref="Vector"/></param>
private static void BuildDoubleIndexHeap(int start, int count, int[] sortedIndices, Vector<float> values)
{
while (start >= 0)
{
SiftDoubleIndices(sortedIndices, values, start, count);
start -= 1;
}
}
/// <summary>
/// Sift double indicies
/// </summary>
/// <param name="sortedIndices">Indicies of <paramref name="values"/></param>
/// <param name="values">Target <see cref="Vector"/></param>
/// <param name="begin">Root position</param>
/// <param name="count">Length of <paramref name="values"/></param>
private static void SiftDoubleIndices(int[] sortedIndices, Vector<float> values, int begin, int count)
{
var root = begin;
while (root * 2 < count)
{
var child = root * 2;
if ((child < count - 1) && (values[sortedIndices[child]] > values[sortedIndices[child + 1]]))
{
child += 1;
}
if (values[sortedIndices[root]] <= values[sortedIndices[child]])
{
return;
}
Exchange(sortedIndices, root, child);
root = child;
}
}
/// <summary>
/// Sorts the given integers in a decreasing fashion.
/// </summary>
/// <param name="values">The values.</param>
public static void SortIntegersDecreasing(int[] values)
{
HeapSortIntegers(values, values.Length);
}
/// <summary>
/// Sort the given integers in a decreasing fashion using heapsort algorithm
/// </summary>
/// <param name="values">Array of values to sort</param>
/// <param name="count">Length of <paramref name="values"/></param>
private static void HeapSortIntegers(int[] values, int count)
{
var start = (count / 2) - 1;
var end = count - 1;
BuildHeap(values, start, count);
while (end >= 0)
{
Exchange(values, end, 0);
Sift(values, 0, end);
end -= 1;
}
}
/// <summary>
/// Build heap
/// </summary>
/// <param name="values">Target values array</param>
/// <param name="start">Root position</param>
/// <param name="count">Length of <paramref name="values"/></param>
private static void BuildHeap(int[] values, int start, int count)
{
while (start >= 0)
{
Sift(values, start, count);
start -= 1;
}
}
/// <summary>
/// Sift values
/// </summary>
/// <param name="values">Target value array</param>
/// <param name="start">Root position</param>
/// <param name="count">Length of <paramref name="values"/></param>
private static void Sift(int[] values, int start, int count)
{
var root = start;
while (root * 2 < count)
{
var child = root * 2;
if ((child < count - 1) && (values[child] > values[child + 1]))
{
child += 1;
}
if (values[root] > values[child])
{
Exchange(values, root, child);
root = child;
}
else
{
return;
}
}
}
/// <summary>
/// Exchange values in array
/// </summary>
/// <param name="values">Target values array</param>
/// <param name="first">First value to exchange</param>
/// <param name="second">Second value to exchange</param>
private static void Exchange(int[] values, int first, int second)
{
var t = values[first];
values[first] = values[second];
values[second] = t;
}
}
}

30
src/Numerics/Numerics.csproj

@ -122,7 +122,7 @@
<Compile Include="Distributions\Wishart.cs" />
<Compile Include="Distributions\Zipf.cs" />
<Compile Include="LinearAlgebra\Builder.cs" />
<Compile Include="LinearAlgebra\Double\Solvers\Preconditioners\Milu0.cs" />
<Compile Include="LinearAlgebra\Double\Solvers\Preconditioners\MILU0Preconditioner.cs" />
<Compile Include="LinearAlgebra\Matrix.Solve.cs" />
<Compile Include="LinearAlgebra\Solvers\CancellationStopCriterium.cs" />
<Compile Include="LinearAlgebra\Solvers\IterationStatus.cs" />
@ -244,10 +244,9 @@
<Compile Include="LinearAlgebra\Complex32\Solvers\GpBiCg.cs" />
<Compile Include="LinearAlgebra\Complex32\Solvers\MlkBiCgStab.cs" />
<Compile Include="LinearAlgebra\Complex32\Solvers\TFQMR.cs" />
<Compile Include="LinearAlgebra\Complex32\Solvers\Preconditioners\Diagonal.cs" />
<Compile Include="LinearAlgebra\Complex32\Solvers\Preconditioners\Ilutp.cs" />
<Compile Include="LinearAlgebra\Complex32\Solvers\Preconditioners\IlutpElementSorter.cs" />
<Compile Include="LinearAlgebra\Complex32\Solvers\Preconditioners\IncompleteLU.cs" />
<Compile Include="LinearAlgebra\Complex32\Solvers\Preconditioners\DiagonalPreconditioner.cs" />
<Compile Include="LinearAlgebra\Complex32\Solvers\Preconditioners\ILUTPPreconditioner.cs" />
<Compile Include="LinearAlgebra\Complex32\Solvers\Preconditioners\ILU0Preconditioner.cs" />
<Compile Include="LinearAlgebra\Complex32\Solvers\StopCriterium\DivergenceStopCriterium.cs" />
<Compile Include="LinearAlgebra\Complex32\Solvers\StopCriterium\FailureStopCriterium.cs" />
<Compile Include="LinearAlgebra\Complex32\Solvers\StopCriterium\ResidualStopCriterium.cs" />
@ -269,10 +268,9 @@
<Compile Include="LinearAlgebra\Complex\Solvers\GpBiCg.cs" />
<Compile Include="LinearAlgebra\Complex\Solvers\MlkBiCgStab.cs" />
<Compile Include="LinearAlgebra\Complex\Solvers\TFQMR.cs" />
<Compile Include="LinearAlgebra\Complex\Solvers\Preconditioners\Diagonal.cs" />
<Compile Include="LinearAlgebra\Complex\Solvers\Preconditioners\Ilutp.cs" />
<Compile Include="LinearAlgebra\Complex\Solvers\Preconditioners\IlutpElementSorter.cs" />
<Compile Include="LinearAlgebra\Complex\Solvers\Preconditioners\IncompleteLU.cs" />
<Compile Include="LinearAlgebra\Complex\Solvers\Preconditioners\DiagonalPreconditioner.cs" />
<Compile Include="LinearAlgebra\Complex\Solvers\Preconditioners\ILUTPPreconditioner.cs" />
<Compile Include="LinearAlgebra\Complex\Solvers\Preconditioners\ILU0Preconditioner.cs" />
<Compile Include="LinearAlgebra\Complex\Solvers\StopCriterium\DivergenceStopCriterium.cs" />
<Compile Include="LinearAlgebra\Complex\Solvers\StopCriterium\FailureStopCriterium.cs" />
<Compile Include="LinearAlgebra\Complex\Solvers\StopCriterium\ResidualStopCriterium.cs" />
@ -310,10 +308,9 @@
<Compile Include="LinearAlgebra\Single\Solvers\GpBiCg.cs" />
<Compile Include="LinearAlgebra\Single\Solvers\MlkBiCgStab.cs" />
<Compile Include="LinearAlgebra\Single\Solvers\TFQMR.cs" />
<Compile Include="LinearAlgebra\Single\Solvers\Preconditioners\Diagonal.cs" />
<Compile Include="LinearAlgebra\Single\Solvers\Preconditioners\Ilutp.cs" />
<Compile Include="LinearAlgebra\Single\Solvers\Preconditioners\IlutpElementSorter.cs" />
<Compile Include="LinearAlgebra\Single\Solvers\Preconditioners\IncompleteLU.cs" />
<Compile Include="LinearAlgebra\Single\Solvers\Preconditioners\DiagonalPreconditioner.cs" />
<Compile Include="LinearAlgebra\Single\Solvers\Preconditioners\ILUTPPreconditioner.cs" />
<Compile Include="LinearAlgebra\Single\Solvers\Preconditioners\ILU0Preconditioner.cs" />
<Compile Include="LinearAlgebra\Single\Solvers\StopCriterium\DivergenceStopCriterium.cs" />
<Compile Include="LinearAlgebra\Single\Solvers\StopCriterium\FailureStopCriterium.cs" />
<Compile Include="LinearAlgebra\Single\Solvers\StopCriterium\ResidualStopCriterium.cs" />
@ -338,10 +335,9 @@
<Compile Include="LinearAlgebra\Double\Solvers\GpBiCg.cs" />
<Compile Include="LinearAlgebra\Double\Solvers\MlkBiCgStab.cs" />
<Compile Include="LinearAlgebra\Double\Solvers\TFQMR.cs" />
<Compile Include="LinearAlgebra\Double\Solvers\Preconditioners\Diagonal.cs" />
<Compile Include="LinearAlgebra\Double\Solvers\Preconditioners\Ilutp.cs" />
<Compile Include="LinearAlgebra\Double\Solvers\Preconditioners\IlutpElementSorter.cs" />
<Compile Include="LinearAlgebra\Double\Solvers\Preconditioners\IncompleteLU.cs">
<Compile Include="LinearAlgebra\Double\Solvers\Preconditioners\DiagonalPreconditioner.cs" />
<Compile Include="LinearAlgebra\Double\Solvers\Preconditioners\ILUTPPreconditioner.cs" />
<Compile Include="LinearAlgebra\Double\Solvers\Preconditioners\ILU0Preconditioner.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="LinearAlgebra\Solvers\UnitPreconditioner.cs" />

4
src/UnitTests/LinearAlgebraTests/Complex/Solvers/Preconditioners/DiagonalTest.cs

@ -51,7 +51,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi
/// <returns>New preconditioner instance.</returns>
internal override IPreconditioner<Complex> CreatePreconditioner()
{
return new Diagonal();
return new DiagonalPreconditioner();
}
/// <summary>
@ -63,7 +63,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi
/// <param name="result">Result vector.</param>
protected override void CheckResult(IPreconditioner<Complex> preconditioner, SparseMatrix matrix, Vector<Complex> vector, Vector<Complex> result)
{
Assert.AreEqual(typeof(Diagonal), preconditioner.GetType(), "#01");
Assert.AreEqual(typeof(DiagonalPreconditioner), preconditioner.GetType(), "#01");
// Compute M * result = product
// compare vector and product. Should be equal

38
src/UnitTests/LinearAlgebraTests/Complex/Solvers/Preconditioners/IluptElementSorterTest.cs

@ -46,7 +46,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi
public void HeapSortWithIncreasingIntegerArray()
{
var sortedIndices = new[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
IlutpElementSorter.SortIntegersDecreasing(sortedIndices);
ILUTPElementSorter.SortIntegersDecreasing(sortedIndices);
for (var i = 0; i < sortedIndices.Length; i++)
{
Assert.AreEqual(sortedIndices.Length - 1 - i, sortedIndices[i], "#01-" + i);
@ -60,7 +60,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi
public void HeapSortWithDecreasingIntegerArray()
{
var sortedIndices = new[] { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
IlutpElementSorter.SortIntegersDecreasing(sortedIndices);
ILUTPElementSorter.SortIntegersDecreasing(sortedIndices);
for (var i = 0; i < sortedIndices.Length; i++)
{
Assert.AreEqual(sortedIndices.Length - 1 - i, sortedIndices[i], "#01-" + i);
@ -74,7 +74,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi
public void HeapSortWithRandomIntegerArray()
{
var sortedIndices = new[] { 5, 2, 8, 6, 0, 4, 1, 7, 3, 9 };
IlutpElementSorter.SortIntegersDecreasing(sortedIndices);
ILUTPElementSorter.SortIntegersDecreasing(sortedIndices);
for (var i = 0; i < sortedIndices.Length; i++)
{
Assert.AreEqual(sortedIndices.Length - 1 - i, sortedIndices[i], "#01-" + i);
@ -88,7 +88,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi
public void HeapSortWithDuplicateEntries()
{
var sortedIndices = new[] { 1, 1, 1, 1, 2, 2, 2, 2, 3, 4 };
IlutpElementSorter.SortIntegersDecreasing(sortedIndices);
ILUTPElementSorter.SortIntegersDecreasing(sortedIndices);
for (var i = 0; i < sortedIndices.Length; i++)
{
if (i == 0)
@ -129,7 +129,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi
public void HeapSortWithSpecialConstructedIntegerArray()
{
var sortedIndices = new[] { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 };
IlutpElementSorter.SortIntegersDecreasing(sortedIndices);
ILUTPElementSorter.SortIntegersDecreasing(sortedIndices);
for (var i = 0; i < sortedIndices.Length; i++)
{
if (i == 0)
@ -140,7 +140,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi
}
sortedIndices = new[] { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
IlutpElementSorter.SortIntegersDecreasing(sortedIndices);
ILUTPElementSorter.SortIntegersDecreasing(sortedIndices);
for (var i = 0; i < sortedIndices.Length; i++)
{
if (i == 0)
@ -151,7 +151,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi
}
sortedIndices = new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 };
IlutpElementSorter.SortIntegersDecreasing(sortedIndices);
ILUTPElementSorter.SortIntegersDecreasing(sortedIndices);
for (var i = 0; i < sortedIndices.Length; i++)
{
if (i == 0)
@ -162,7 +162,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi
}
sortedIndices = new[] { 1, 1, 1, 0, 1, 1, 1, 1, 1, 1 };
IlutpElementSorter.SortIntegersDecreasing(sortedIndices);
ILUTPElementSorter.SortIntegersDecreasing(sortedIndices);
for (var i = 0; i < sortedIndices.Length; i++)
{
if (i == 9)
@ -196,7 +196,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi
sortedIndices[i] = i;
}
IlutpElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
ILUTPElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
for (var i = 0; i < sortedIndices.Length; i++)
{
Assert.AreEqual(sortedIndices.Length - 1 - i, sortedIndices[i], "#01-" + i);
@ -226,7 +226,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi
sortedIndices[i] = i;
}
IlutpElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
ILUTPElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
for (var i = 0; i < sortedIndices.Length; i++)
{
Assert.AreEqual(i, sortedIndices[i], "#01-" + i);
@ -256,7 +256,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi
sortedIndices[i] = i;
}
IlutpElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
ILUTPElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
for (var i = 0; i < sortedIndices.Length; i++)
{
switch (i)
@ -319,7 +319,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi
sortedIndices[i] = i;
}
IlutpElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
ILUTPElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
for (var i = 0; i < sortedIndices.Length; i++)
{
if (i == 0)
@ -382,7 +382,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi
sortedIndices[i] = i;
}
IlutpElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
ILUTPElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
for (var i = 0; i < sortedIndices.Length; i++)
{
if (i == 0)
@ -407,7 +407,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi
sortedIndices[i] = i;
}
IlutpElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
ILUTPElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
for (var i = 0; i < sortedIndices.Length; i++)
{
if (i == 0)
@ -432,7 +432,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi
sortedIndices[i] = i;
}
IlutpElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
ILUTPElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
for (var i = 0; i < sortedIndices.Length; i++)
{
if (i == 0)
@ -457,7 +457,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi
sortedIndices[i] = i;
}
IlutpElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
ILUTPElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
for (var i = 0; i < sortedIndices.Length; i++)
{
if (i == 9)
@ -491,7 +491,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi
sortedIndices[i] = i;
}
IlutpElementSorter.SortDoubleIndicesDecreasing(4, sortedIndices.Length - 1, sortedIndices, values);
ILUTPElementSorter.SortDoubleIndicesDecreasing(4, sortedIndices.Length - 1, sortedIndices, values);
for (var i = 0; i < sortedIndices.Length - 4; i++)
{
Assert.AreEqual(sortedIndices.Length - 1 - i, sortedIndices[i], "#01-" + i);
@ -521,7 +521,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi
sortedIndices[i] = i;
}
IlutpElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 5, sortedIndices, values);
ILUTPElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 5, sortedIndices, values);
for (var i = 0; i < sortedIndices.Length - 5; i++)
{
Assert.AreEqual(sortedIndices.Length - 5 - i, sortedIndices[i], "#01-" + i);
@ -551,7 +551,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi
sortedIndices[i] = i;
}
IlutpElementSorter.SortDoubleIndicesDecreasing(2, sortedIndices.Length - 3, sortedIndices, values);
ILUTPElementSorter.SortDoubleIndicesDecreasing(2, sortedIndices.Length - 3, sortedIndices, values);
for (var i = 0; i < sortedIndices.Length - 4; i++)
{
Assert.AreEqual(sortedIndices.Length - 3 - i, sortedIndices[i], "#01-" + i);

20
src/UnitTests/LinearAlgebraTests/Complex/Solvers/Preconditioners/IlutpTest.cs

@ -80,7 +80,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi
/// <param name="ilutp">Ilutp instance.</param>
/// <param name="methodName">Method name.</param>
/// <returns>Result of the method invocation.</returns>
private static T GetMethod<T>(Ilutp ilutp, string methodName)
private static T GetMethod<T>(ILUTPPreconditioner ilutp, string methodName)
{
var type = ilutp.GetType();
var methodInfo = type.GetMethod(
@ -99,7 +99,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi
/// </summary>
/// <param name="ilutp">Ilutp instance.</param>
/// <returns>Upper triangle.</returns>
private static SparseMatrix GetUpperTriangle(Ilutp ilutp)
private static SparseMatrix GetUpperTriangle(ILUTPPreconditioner ilutp)
{
return GetMethod<SparseMatrix>(ilutp, "UpperTriangle");
}
@ -109,7 +109,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi
/// </summary>
/// <param name="ilutp">Ilutp instance.</param>
/// <returns>Lower triangle.</returns>
private static SparseMatrix GetLowerTriangle(Ilutp ilutp)
private static SparseMatrix GetLowerTriangle(ILUTPPreconditioner ilutp)
{
return GetMethod<SparseMatrix>(ilutp, "LowerTriangle");
}
@ -119,7 +119,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi
/// </summary>
/// <param name="ilutp">Ilutp instance.</param>
/// <returns>Pivots array.</returns>
private static int[] GetPivots(Ilutp ilutp)
private static int[] GetPivots(ILUTPPreconditioner ilutp)
{
return GetMethod<int[]>(ilutp, "Pivots");
}
@ -144,9 +144,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi
/// Create preconditioner (internal)
/// </summary>
/// <returns>Ilutp instance.</returns>
private Ilutp InternalCreatePreconditioner()
private ILUTPPreconditioner InternalCreatePreconditioner()
{
var result = new Ilutp
var result = new ILUTPPreconditioner
{
DropTolerance = _dropTolerance,
FillLevel = _fillLevel,
@ -176,7 +176,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi
/// <param name="result">Result vector.</param>
protected override void CheckResult(IPreconditioner<Complex> preconditioner, SparseMatrix matrix, Vector<Complex> vector, Vector<Complex> result)
{
Assert.AreEqual(typeof(Ilutp), preconditioner.GetType(), "#01");
Assert.AreEqual(typeof(ILUTPPreconditioner), preconditioner.GetType(), "#01");
// Compute M * result = product
// compare vector and product. Should be equal
@ -248,7 +248,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi
sparseMatrix[2, 0] = 6;
sparseMatrix[2, 1] = 8;
sparseMatrix[2, 2] = 9;
var ilu = new Ilutp
var ilu = new ILUTPPreconditioner
{
PivotTolerance = 0.0,
DropTolerance = 0,
@ -304,7 +304,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi
sparseMatrix[2, 0] = 6;
sparseMatrix[2, 1] = 8;
sparseMatrix[2, 2] = 9;
var ilu = new Ilutp
var ilu = new ILUTPPreconditioner
{
PivotTolerance = 1.0,
DropTolerance = 0,
@ -341,7 +341,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi
const int Size = 10;
var newMatrix = CreateReverseUnitMatrix(Size);
var vector = CreateStandardBcVector(Size);
var preconditioner = new Ilutp
var preconditioner = new ILUTPPreconditioner
{
PivotTolerance = 1.0,
DropTolerance = 0,

12
src/UnitTests/LinearAlgebraTests/Complex/Solvers/Preconditioners/IncompleteLUTest.cs

@ -54,7 +54,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi
/// <param name="ilu"><c>IncompleteLU</c> instance.</param>
/// <param name="methodName">Method name.</param>
/// <returns>Result of the method invocation.</returns>
private static T GetMethod<T>(IncompleteLU ilu, string methodName)
private static T GetMethod<T>(ILU0Preconditioner ilu, string methodName)
{
var type = ilu.GetType();
var methodInfo = type.GetMethod(
@ -73,7 +73,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi
/// </summary>
/// <param name="ilu"><c>IncompleteLU</c> instance.</param>
/// <returns>Upper triangle.</returns>
private static Matrix<Complex> GetUpperTriangle(IncompleteLU ilu)
private static Matrix<Complex> GetUpperTriangle(ILU0Preconditioner ilu)
{
return GetMethod<Matrix<Complex>>(ilu, "UpperTriangle");
}
@ -83,7 +83,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi
/// </summary>
/// <param name="ilu"><c>IncompleteLU</c> instance.</param>
/// <returns>Lower triangle.</returns>
private static Matrix<Complex> GetLowerTriangle(IncompleteLU ilu)
private static Matrix<Complex> GetLowerTriangle(ILU0Preconditioner ilu)
{
return GetMethod<Matrix<Complex>>(ilu, "LowerTriangle");
}
@ -94,7 +94,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi
/// <returns>New preconditioner instance.</returns>
internal override IPreconditioner<Complex> CreatePreconditioner()
{
return new IncompleteLU();
return new ILU0Preconditioner();
}
/// <summary>
@ -106,7 +106,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi
/// <param name="result">Result vector.</param>
protected override void CheckResult(IPreconditioner<Complex> preconditioner, SparseMatrix matrix, Vector<Complex> vector, Vector<Complex> result)
{
Assert.AreEqual(typeof(IncompleteLU), preconditioner.GetType(), "#01");
Assert.AreEqual(typeof(ILU0Preconditioner), preconditioner.GetType(), "#01");
// Compute M * result = product
// compare vector and product. Should be equal
@ -136,7 +136,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi
sparseMatrix[2, 0] = 6;
sparseMatrix[2, 1] = 8;
sparseMatrix[2, 2] = 9;
var ilu = new IncompleteLU();
var ilu = new ILU0Preconditioner();
ilu.Initialize(sparseMatrix);
var original = GetLowerTriangle(ilu).Multiply(GetUpperTriangle(ilu));

4
src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Preconditioners/DiagonalTest.cs

@ -46,7 +46,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
/// <returns>New preconditioner instance.</returns>
internal override IPreconditioner<Complex32> CreatePreconditioner()
{
return new Diagonal();
return new DiagonalPreconditioner();
}
/// <summary>
@ -58,7 +58,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
/// <param name="result">Result vector.</param>
protected override void CheckResult(IPreconditioner<Complex32> preconditioner, SparseMatrix matrix, Vector<Complex32> vector, Vector<Complex32> result)
{
Assert.AreEqual(typeof(Diagonal), preconditioner.GetType(), "#01");
Assert.AreEqual(typeof(DiagonalPreconditioner), preconditioner.GetType(), "#01");
// Compute M * result = product
// compare vector and product. Should be equal

38
src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Preconditioners/IluptElementSorterTest.cs

@ -43,7 +43,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
public void HeapSortWithIncreasingIntegerArray()
{
var sortedIndices = new[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
IlutpElementSorter.SortIntegersDecreasing(sortedIndices);
ILUTPElementSorter.SortIntegersDecreasing(sortedIndices);
for (var i = 0; i < sortedIndices.Length; i++)
{
Assert.AreEqual(sortedIndices.Length - 1 - i, sortedIndices[i], "#01-" + i);
@ -57,7 +57,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
public void HeapSortWithDecreasingIntegerArray()
{
var sortedIndices = new[] { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
IlutpElementSorter.SortIntegersDecreasing(sortedIndices);
ILUTPElementSorter.SortIntegersDecreasing(sortedIndices);
for (var i = 0; i < sortedIndices.Length; i++)
{
Assert.AreEqual(sortedIndices.Length - 1 - i, sortedIndices[i], "#01-" + i);
@ -71,7 +71,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
public void HeapSortWithRandomIntegerArray()
{
var sortedIndices = new[] { 5, 2, 8, 6, 0, 4, 1, 7, 3, 9 };
IlutpElementSorter.SortIntegersDecreasing(sortedIndices);
ILUTPElementSorter.SortIntegersDecreasing(sortedIndices);
for (var i = 0; i < sortedIndices.Length; i++)
{
Assert.AreEqual(sortedIndices.Length - 1 - i, sortedIndices[i], "#01-" + i);
@ -85,7 +85,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
public void HeapSortWithDuplicateEntries()
{
var sortedIndices = new[] { 1, 1, 1, 1, 2, 2, 2, 2, 3, 4 };
IlutpElementSorter.SortIntegersDecreasing(sortedIndices);
ILUTPElementSorter.SortIntegersDecreasing(sortedIndices);
for (var i = 0; i < sortedIndices.Length; i++)
{
if (i == 0)
@ -126,7 +126,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
public void HeapSortWithSpecialConstructedIntegerArray()
{
var sortedIndices = new[] { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 };
IlutpElementSorter.SortIntegersDecreasing(sortedIndices);
ILUTPElementSorter.SortIntegersDecreasing(sortedIndices);
for (var i = 0; i < sortedIndices.Length; i++)
{
if (i == 0)
@ -137,7 +137,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
}
sortedIndices = new[] { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
IlutpElementSorter.SortIntegersDecreasing(sortedIndices);
ILUTPElementSorter.SortIntegersDecreasing(sortedIndices);
for (var i = 0; i < sortedIndices.Length; i++)
{
if (i == 0)
@ -148,7 +148,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
}
sortedIndices = new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 };
IlutpElementSorter.SortIntegersDecreasing(sortedIndices);
ILUTPElementSorter.SortIntegersDecreasing(sortedIndices);
for (var i = 0; i < sortedIndices.Length; i++)
{
if (i == 0)
@ -159,7 +159,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
}
sortedIndices = new[] { 1, 1, 1, 0, 1, 1, 1, 1, 1, 1 };
IlutpElementSorter.SortIntegersDecreasing(sortedIndices);
ILUTPElementSorter.SortIntegersDecreasing(sortedIndices);
for (var i = 0; i < sortedIndices.Length; i++)
{
if (i == 9)
@ -193,7 +193,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
sortedIndices[i] = i;
}
IlutpElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
ILUTPElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
for (var i = 0; i < sortedIndices.Length; i++)
{
Assert.AreEqual(sortedIndices.Length - 1 - i, sortedIndices[i], "#01-" + i);
@ -223,7 +223,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
sortedIndices[i] = i;
}
IlutpElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
ILUTPElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
for (var i = 0; i < sortedIndices.Length; i++)
{
Assert.AreEqual(i, sortedIndices[i], "#01-" + i);
@ -253,7 +253,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
sortedIndices[i] = i;
}
IlutpElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
ILUTPElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
for (var i = 0; i < sortedIndices.Length; i++)
{
switch (i)
@ -316,7 +316,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
sortedIndices[i] = i;
}
IlutpElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
ILUTPElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
for (var i = 0; i < sortedIndices.Length; i++)
{
if (i == 0)
@ -379,7 +379,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
sortedIndices[i] = i;
}
IlutpElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
ILUTPElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
for (var i = 0; i < sortedIndices.Length; i++)
{
if (i == 0)
@ -404,7 +404,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
sortedIndices[i] = i;
}
IlutpElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
ILUTPElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
for (var i = 0; i < sortedIndices.Length; i++)
{
if (i == 0)
@ -429,7 +429,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
sortedIndices[i] = i;
}
IlutpElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
ILUTPElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
for (var i = 0; i < sortedIndices.Length; i++)
{
if (i == 0)
@ -454,7 +454,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
sortedIndices[i] = i;
}
IlutpElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
ILUTPElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
for (var i = 0; i < sortedIndices.Length; i++)
{
if (i == 9)
@ -488,7 +488,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
sortedIndices[i] = i;
}
IlutpElementSorter.SortDoubleIndicesDecreasing(4, sortedIndices.Length - 1, sortedIndices, values);
ILUTPElementSorter.SortDoubleIndicesDecreasing(4, sortedIndices.Length - 1, sortedIndices, values);
for (var i = 0; i < sortedIndices.Length - 4; i++)
{
Assert.AreEqual(sortedIndices.Length - 1 - i, sortedIndices[i], "#01-" + i);
@ -518,7 +518,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
sortedIndices[i] = i;
}
IlutpElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 5, sortedIndices, values);
ILUTPElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 5, sortedIndices, values);
for (var i = 0; i < sortedIndices.Length - 5; i++)
{
Assert.AreEqual(sortedIndices.Length - 5 - i, sortedIndices[i], "#01-" + i);
@ -548,7 +548,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
sortedIndices[i] = i;
}
IlutpElementSorter.SortDoubleIndicesDecreasing(2, sortedIndices.Length - 3, sortedIndices, values);
ILUTPElementSorter.SortDoubleIndicesDecreasing(2, sortedIndices.Length - 3, sortedIndices, values);
for (var i = 0; i < sortedIndices.Length - 4; i++)
{
Assert.AreEqual(sortedIndices.Length - 3 - i, sortedIndices[i], "#01-" + i);

20
src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Preconditioners/IlutpTest.cs

@ -75,7 +75,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
/// <param name="ilutp">Ilutp instance.</param>
/// <param name="methodName">Method name.</param>
/// <returns>Result of the method invocation.</returns>
private static T GetMethod<T>(Ilutp ilutp, string methodName)
private static T GetMethod<T>(ILUTPPreconditioner ilutp, string methodName)
{
var type = ilutp.GetType();
var methodInfo = type.GetMethod(
@ -94,7 +94,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
/// </summary>
/// <param name="ilutp">Ilutp instance.</param>
/// <returns>Upper triangle.</returns>
private static SparseMatrix GetUpperTriangle(Ilutp ilutp)
private static SparseMatrix GetUpperTriangle(ILUTPPreconditioner ilutp)
{
return GetMethod<SparseMatrix>(ilutp, "UpperTriangle");
}
@ -104,7 +104,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
/// </summary>
/// <param name="ilutp">Ilutp instance.</param>
/// <returns>Lower triangle.</returns>
private static SparseMatrix GetLowerTriangle(Ilutp ilutp)
private static SparseMatrix GetLowerTriangle(ILUTPPreconditioner ilutp)
{
return GetMethod<SparseMatrix>(ilutp, "LowerTriangle");
}
@ -114,7 +114,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
/// </summary>
/// <param name="ilutp">Ilutp instance.</param>
/// <returns>Pivots array.</returns>
private static int[] GetPivots(Ilutp ilutp)
private static int[] GetPivots(ILUTPPreconditioner ilutp)
{
return GetMethod<int[]>(ilutp, "Pivots");
}
@ -139,9 +139,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
/// Create preconditioner (internal)
/// </summary>
/// <returns>Ilutp instance.</returns>
private Ilutp InternalCreatePreconditioner()
private ILUTPPreconditioner InternalCreatePreconditioner()
{
var result = new Ilutp
var result = new ILUTPPreconditioner
{
DropTolerance = _dropTolerance,
FillLevel = _fillLevel,
@ -171,7 +171,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
/// <param name="result">Result vector.</param>
protected override void CheckResult(IPreconditioner<Complex32> preconditioner, SparseMatrix matrix, Vector<Complex32> vector, Vector<Complex32> result)
{
Assert.AreEqual(typeof(Ilutp), preconditioner.GetType(), "#01");
Assert.AreEqual(typeof(ILUTPPreconditioner), preconditioner.GetType(), "#01");
// Compute M * result = product
// compare vector and product. Should be equal
@ -243,7 +243,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
sparseMatrix[2, 0] = 6;
sparseMatrix[2, 1] = 8;
sparseMatrix[2, 2] = 9;
var ilu = new Ilutp
var ilu = new ILUTPPreconditioner
{
PivotTolerance = 0.0,
DropTolerance = 0,
@ -299,7 +299,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
sparseMatrix[2, 0] = 6;
sparseMatrix[2, 1] = 8;
sparseMatrix[2, 2] = 9;
var ilu = new Ilutp
var ilu = new ILUTPPreconditioner
{
PivotTolerance = 1.0,
DropTolerance = 0,
@ -336,7 +336,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
const int Size = 10;
var newMatrix = CreateReverseUnitMatrix(Size);
var vector = CreateStandardBcVector(Size);
var preconditioner = new Ilutp
var preconditioner = new ILUTPPreconditioner
{
PivotTolerance = 1.0,
DropTolerance = 0,

12
src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Preconditioners/IncompleteLUTest.cs

@ -49,7 +49,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
/// <param name="ilu"><c>IncompleteLU</c> instance.</param>
/// <param name="methodName">Method name.</param>
/// <returns>Result of the method invocation.</returns>
private static T GetMethod<T>(IncompleteLU ilu, string methodName)
private static T GetMethod<T>(ILU0Preconditioner ilu, string methodName)
{
var type = ilu.GetType();
var methodInfo = type.GetMethod(
@ -68,7 +68,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
/// </summary>
/// <param name="ilu"><c>IncompleteLU</c> instance.</param>
/// <returns>Upper triangle.</returns>
private static Matrix<Complex32> GetUpperTriangle(IncompleteLU ilu)
private static Matrix<Complex32> GetUpperTriangle(ILU0Preconditioner ilu)
{
return GetMethod<Matrix<Complex32>>(ilu, "UpperTriangle");
}
@ -78,7 +78,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
/// </summary>
/// <param name="ilu"><c>IncompleteLU</c> instance.</param>
/// <returns>Lower triangle.</returns>
private static Matrix<Complex32> GetLowerTriangle(IncompleteLU ilu)
private static Matrix<Complex32> GetLowerTriangle(ILU0Preconditioner ilu)
{
return GetMethod<Matrix<Complex32>>(ilu, "LowerTriangle");
}
@ -89,7 +89,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
/// <returns>New preconditioner instance.</returns>
internal override IPreconditioner<Complex32> CreatePreconditioner()
{
return new IncompleteLU();
return new ILU0Preconditioner();
}
/// <summary>
@ -101,7 +101,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
/// <param name="result">Result vector.</param>
protected override void CheckResult(IPreconditioner<Complex32> preconditioner, SparseMatrix matrix, Vector<Complex32> vector, Vector<Complex32> result)
{
Assert.AreEqual(typeof(IncompleteLU), preconditioner.GetType(), "#01");
Assert.AreEqual(typeof(ILU0Preconditioner), preconditioner.GetType(), "#01");
// Compute M * result = product
// compare vector and product. Should be equal
@ -131,7 +131,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
sparseMatrix[2, 0] = 6;
sparseMatrix[2, 1] = 8;
sparseMatrix[2, 2] = 9;
var ilu = new IncompleteLU();
var ilu = new ILU0Preconditioner();
ilu.Initialize(sparseMatrix);
var original = GetLowerTriangle(ilu).Multiply(GetUpperTriangle(ilu));
for (var i = 0; i < sparseMatrix.RowCount; i++)

4
src/UnitTests/LinearAlgebraTests/Double/Solvers/Preconditioners/DiagonalTest.cs

@ -44,7 +44,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
/// <returns>New preconditioner instance.</returns>
internal override IPreconditioner<double> CreatePreconditioner()
{
return new Diagonal();
return new DiagonalPreconditioner();
}
/// <summary>
@ -56,7 +56,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
/// <param name="result">Result vector.</param>
protected override void CheckResult(IPreconditioner<double> preconditioner, SparseMatrix matrix, Vector<double> vector, Vector<double> result)
{
Assert.AreEqual(typeof(Diagonal), preconditioner.GetType(), "#01");
Assert.AreEqual(typeof(DiagonalPreconditioner), preconditioner.GetType(), "#01");
// Compute M * result = product
// compare vector and product. Should be equal

38
src/UnitTests/LinearAlgebraTests/Double/Solvers/Preconditioners/IluptElementSorterTest.cs

@ -43,7 +43,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
public void HeapSortWithIncreasingIntegerArray()
{
var sortedIndices = new[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
IlutpElementSorter.SortIntegersDecreasing(sortedIndices);
ILUTPElementSorter.SortIntegersDecreasing(sortedIndices);
for (var i = 0; i < sortedIndices.Length; i++)
{
Assert.AreEqual(sortedIndices.Length - 1 - i, sortedIndices[i], "#01-" + i);
@ -57,7 +57,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
public void HeapSortWithDecreasingIntegerArray()
{
var sortedIndices = new[] { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
IlutpElementSorter.SortIntegersDecreasing(sortedIndices);
ILUTPElementSorter.SortIntegersDecreasing(sortedIndices);
for (var i = 0; i < sortedIndices.Length; i++)
{
Assert.AreEqual(sortedIndices.Length - 1 - i, sortedIndices[i], "#01-" + i);
@ -71,7 +71,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
public void HeapSortWithRandomIntegerArray()
{
var sortedIndices = new[] { 5, 2, 8, 6, 0, 4, 1, 7, 3, 9 };
IlutpElementSorter.SortIntegersDecreasing(sortedIndices);
ILUTPElementSorter.SortIntegersDecreasing(sortedIndices);
for (var i = 0; i < sortedIndices.Length; i++)
{
Assert.AreEqual(sortedIndices.Length - 1 - i, sortedIndices[i], "#01-" + i);
@ -85,7 +85,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
public void HeapSortWithDuplicateEntries()
{
var sortedIndices = new[] { 1, 1, 1, 1, 2, 2, 2, 2, 3, 4 };
IlutpElementSorter.SortIntegersDecreasing(sortedIndices);
ILUTPElementSorter.SortIntegersDecreasing(sortedIndices);
for (var i = 0; i < sortedIndices.Length; i++)
{
if (i == 0)
@ -126,7 +126,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
public void HeapSortWithSpecialConstructedIntegerArray()
{
var sortedIndices = new[] { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 };
IlutpElementSorter.SortIntegersDecreasing(sortedIndices);
ILUTPElementSorter.SortIntegersDecreasing(sortedIndices);
for (var i = 0; i < sortedIndices.Length; i++)
{
if (i == 0)
@ -137,7 +137,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
}
sortedIndices = new[] { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
IlutpElementSorter.SortIntegersDecreasing(sortedIndices);
ILUTPElementSorter.SortIntegersDecreasing(sortedIndices);
for (var i = 0; i < sortedIndices.Length; i++)
{
if (i == 0)
@ -148,7 +148,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
}
sortedIndices = new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 };
IlutpElementSorter.SortIntegersDecreasing(sortedIndices);
ILUTPElementSorter.SortIntegersDecreasing(sortedIndices);
for (var i = 0; i < sortedIndices.Length; i++)
{
if (i == 0)
@ -159,7 +159,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
}
sortedIndices = new[] { 1, 1, 1, 0, 1, 1, 1, 1, 1, 1 };
IlutpElementSorter.SortIntegersDecreasing(sortedIndices);
ILUTPElementSorter.SortIntegersDecreasing(sortedIndices);
for (var i = 0; i < sortedIndices.Length; i++)
{
if (i == 9)
@ -193,7 +193,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
sortedIndices[i] = i;
}
IlutpElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
ILUTPElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
for (var i = 0; i < sortedIndices.Length; i++)
{
Assert.AreEqual(sortedIndices.Length - 1 - i, sortedIndices[i], "#01-" + i);
@ -223,7 +223,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
sortedIndices[i] = i;
}
IlutpElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
ILUTPElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
for (var i = 0; i < sortedIndices.Length; i++)
{
Assert.AreEqual(i, sortedIndices[i], "#01-" + i);
@ -253,7 +253,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
sortedIndices[i] = i;
}
IlutpElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
ILUTPElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
for (var i = 0; i < sortedIndices.Length; i++)
{
switch (i)
@ -316,7 +316,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
sortedIndices[i] = i;
}
IlutpElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
ILUTPElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
for (var i = 0; i < sortedIndices.Length; i++)
{
if (i == 0)
@ -379,7 +379,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
sortedIndices[i] = i;
}
IlutpElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
ILUTPElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
for (var i = 0; i < sortedIndices.Length; i++)
{
if (i == 0)
@ -404,7 +404,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
sortedIndices[i] = i;
}
IlutpElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
ILUTPElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
for (var i = 0; i < sortedIndices.Length; i++)
{
if (i == 0)
@ -429,7 +429,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
sortedIndices[i] = i;
}
IlutpElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
ILUTPElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
for (var i = 0; i < sortedIndices.Length; i++)
{
if (i == 0)
@ -454,7 +454,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
sortedIndices[i] = i;
}
IlutpElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
ILUTPElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
for (var i = 0; i < sortedIndices.Length; i++)
{
if (i == 9)
@ -488,7 +488,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
sortedIndices[i] = i;
}
IlutpElementSorter.SortDoubleIndicesDecreasing(4, sortedIndices.Length - 1, sortedIndices, values);
ILUTPElementSorter.SortDoubleIndicesDecreasing(4, sortedIndices.Length - 1, sortedIndices, values);
for (var i = 0; i < sortedIndices.Length - 4; i++)
{
Assert.AreEqual(sortedIndices.Length - 1 - i, sortedIndices[i], "#01-" + i);
@ -518,7 +518,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
sortedIndices[i] = i;
}
IlutpElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 5, sortedIndices, values);
ILUTPElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 5, sortedIndices, values);
for (var i = 0; i < sortedIndices.Length - 5; i++)
{
Assert.AreEqual(sortedIndices.Length - 5 - i, sortedIndices[i], "#01-" + i);
@ -548,7 +548,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
sortedIndices[i] = i;
}
IlutpElementSorter.SortDoubleIndicesDecreasing(2, sortedIndices.Length - 3, sortedIndices, values);
ILUTPElementSorter.SortDoubleIndicesDecreasing(2, sortedIndices.Length - 3, sortedIndices, values);
for (var i = 0; i < sortedIndices.Length - 4; i++)
{
Assert.AreEqual(sortedIndices.Length - 3 - i, sortedIndices[i], "#01-" + i);

20
src/UnitTests/LinearAlgebraTests/Double/Solvers/Preconditioners/IlutpTest.cs

@ -73,7 +73,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
/// <param name="ilutp">Ilutp instance.</param>
/// <param name="methodName">Method name.</param>
/// <returns>Result of the method invocation.</returns>
private static T GetMethod<T>(Ilutp ilutp, string methodName)
private static T GetMethod<T>(ILUTPPreconditioner ilutp, string methodName)
{
var type = ilutp.GetType();
var methodInfo = type.GetMethod(
@ -92,7 +92,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
/// </summary>
/// <param name="ilutp">Ilutp instance.</param>
/// <returns>Upper triangle.</returns>
private static SparseMatrix GetUpperTriangle(Ilutp ilutp)
private static SparseMatrix GetUpperTriangle(ILUTPPreconditioner ilutp)
{
return GetMethod<SparseMatrix>(ilutp, "UpperTriangle");
}
@ -102,7 +102,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
/// </summary>
/// <param name="ilutp">Ilutp instance.</param>
/// <returns>Lower triangle.</returns>
private static SparseMatrix GetLowerTriangle(Ilutp ilutp)
private static SparseMatrix GetLowerTriangle(ILUTPPreconditioner ilutp)
{
return GetMethod<SparseMatrix>(ilutp, "LowerTriangle");
}
@ -112,7 +112,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
/// </summary>
/// <param name="ilutp">Ilutp instance.</param>
/// <returns>Pivots array.</returns>
private static int[] GetPivots(Ilutp ilutp)
private static int[] GetPivots(ILUTPPreconditioner ilutp)
{
return GetMethod<int[]>(ilutp, "Pivots");
}
@ -137,9 +137,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
/// Create preconditioner (internal)
/// </summary>
/// <returns>Ilutp instance.</returns>
private Ilutp InternalCreatePreconditioner()
private ILUTPPreconditioner InternalCreatePreconditioner()
{
var result = new Ilutp
var result = new ILUTPPreconditioner
{
DropTolerance = _dropTolerance,
FillLevel = _fillLevel,
@ -169,7 +169,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
/// <param name="result">Result vector.</param>
protected override void CheckResult(IPreconditioner<double> preconditioner, SparseMatrix matrix, Vector<double> vector, Vector<double> result)
{
Assert.AreEqual(typeof(Ilutp), preconditioner.GetType(), "#01");
Assert.AreEqual(typeof(ILUTPPreconditioner), preconditioner.GetType(), "#01");
// Compute M * result = product
// compare vector and product. Should be equal
@ -240,7 +240,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
sparseMatrix[2, 0] = 6;
sparseMatrix[2, 1] = 8;
sparseMatrix[2, 2] = 9;
var ilu = new Ilutp
var ilu = new ILUTPPreconditioner
{
PivotTolerance = 0.0,
DropTolerance = 0,
@ -295,7 +295,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
sparseMatrix[2, 0] = 6;
sparseMatrix[2, 1] = 8;
sparseMatrix[2, 2] = 9;
var ilu = new Ilutp
var ilu = new ILUTPPreconditioner
{
PivotTolerance = 1.0,
DropTolerance = 0,
@ -331,7 +331,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
const int Size = 10;
var newMatrix = CreateReverseUnitMatrix(Size);
var vector = CreateStandardBcVector(Size);
var preconditioner = new Ilutp
var preconditioner = new ILUTPPreconditioner
{
PivotTolerance = 1.0,
DropTolerance = 0,

12
src/UnitTests/LinearAlgebraTests/Double/Solvers/Preconditioners/IncompleteLUTest.cs

@ -47,7 +47,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
/// <param name="ilu"><c>IncompleteLU</c> instance.</param>
/// <param name="methodName">Method name.</param>
/// <returns>Result of the method invocation.</returns>
private static T GetMethod<T>(IncompleteLU ilu, string methodName)
private static T GetMethod<T>(ILU0Preconditioner ilu, string methodName)
{
var type = ilu.GetType();
var methodInfo = type.GetMethod(
@ -66,7 +66,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
/// </summary>
/// <param name="ilu"><c>IncompleteLU</c> instance.</param>
/// <returns>Upper triangle.</returns>
private static Matrix<double> GetUpperTriangle(IncompleteLU ilu)
private static Matrix<double> GetUpperTriangle(ILU0Preconditioner ilu)
{
return GetMethod<Matrix<double>>(ilu, "UpperTriangle");
}
@ -76,7 +76,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
/// </summary>
/// <param name="ilu"><c>IncompleteLU</c> instance.</param>
/// <returns>Lower triangle.</returns>
private static Matrix<double> GetLowerTriangle(IncompleteLU ilu)
private static Matrix<double> GetLowerTriangle(ILU0Preconditioner ilu)
{
return GetMethod<Matrix<double>>(ilu, "LowerTriangle");
}
@ -87,7 +87,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
/// <returns>New preconditioner instance.</returns>
internal override IPreconditioner<double> CreatePreconditioner()
{
return new IncompleteLU();
return new ILU0Preconditioner();
}
/// <summary>
@ -99,7 +99,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
/// <param name="result">Result vector.</param>
protected override void CheckResult(IPreconditioner<double> preconditioner, SparseMatrix matrix, Vector<double> vector, Vector<double> result)
{
Assert.AreEqual(typeof(IncompleteLU), preconditioner.GetType(), "#01");
Assert.AreEqual(typeof(ILU0Preconditioner), preconditioner.GetType(), "#01");
// Compute M * result = product
// compare vector and product. Should be equal
@ -128,7 +128,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
sparseMatrix[2, 0] = 6;
sparseMatrix[2, 1] = 8;
sparseMatrix[2, 2] = 9;
var ilu = new IncompleteLU();
var ilu = new ILU0Preconditioner();
ilu.Initialize(sparseMatrix);
var original = GetLowerTriangle(ilu).Multiply(GetUpperTriangle(ilu));
for (var i = 0; i < sparseMatrix.RowCount; i++)

4
src/UnitTests/LinearAlgebraTests/Single/Solvers/Preconditioners/DiagonalTest.cs

@ -44,7 +44,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit
/// <returns>New preconditioner instance.</returns>
internal override IPreconditioner<float> CreatePreconditioner()
{
return new Diagonal();
return new DiagonalPreconditioner();
}
/// <summary>
@ -56,7 +56,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit
/// <param name="result">Result vector.</param>
protected override void CheckResult(IPreconditioner<float> preconditioner, SparseMatrix matrix, Vector<float> vector, Vector<float> result)
{
Assert.AreEqual(typeof(Diagonal), preconditioner.GetType(), "#01");
Assert.AreEqual(typeof(DiagonalPreconditioner), preconditioner.GetType(), "#01");
// Compute M * result = product
// compare vector and product. Should be equal

38
src/UnitTests/LinearAlgebraTests/Single/Solvers/Preconditioners/IluptElementSorterTest.cs

@ -43,7 +43,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit
public void HeapSortWithIncreasingIntegerArray()
{
var sortedIndices = new[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
IlutpElementSorter.SortIntegersDecreasing(sortedIndices);
ILUTPElementSorter.SortIntegersDecreasing(sortedIndices);
for (var i = 0; i < sortedIndices.Length; i++)
{
Assert.AreEqual(sortedIndices.Length - 1 - i, sortedIndices[i], "#01-" + i);
@ -57,7 +57,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit
public void HeapSortWithDecreasingIntegerArray()
{
var sortedIndices = new[] { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
IlutpElementSorter.SortIntegersDecreasing(sortedIndices);
ILUTPElementSorter.SortIntegersDecreasing(sortedIndices);
for (var i = 0; i < sortedIndices.Length; i++)
{
Assert.AreEqual(sortedIndices.Length - 1 - i, sortedIndices[i], "#01-" + i);
@ -71,7 +71,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit
public void HeapSortWithRandomIntegerArray()
{
var sortedIndices = new[] { 5, 2, 8, 6, 0, 4, 1, 7, 3, 9 };
IlutpElementSorter.SortIntegersDecreasing(sortedIndices);
ILUTPElementSorter.SortIntegersDecreasing(sortedIndices);
for (var i = 0; i < sortedIndices.Length; i++)
{
Assert.AreEqual(sortedIndices.Length - 1 - i, sortedIndices[i], "#01-" + i);
@ -85,7 +85,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit
public void HeapSortWithDuplicateEntries()
{
var sortedIndices = new[] { 1, 1, 1, 1, 2, 2, 2, 2, 3, 4 };
IlutpElementSorter.SortIntegersDecreasing(sortedIndices);
ILUTPElementSorter.SortIntegersDecreasing(sortedIndices);
for (var i = 0; i < sortedIndices.Length; i++)
{
if (i == 0)
@ -126,7 +126,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit
public void HeapSortWithSpecialConstructedIntegerArray()
{
var sortedIndices = new[] { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 };
IlutpElementSorter.SortIntegersDecreasing(sortedIndices);
ILUTPElementSorter.SortIntegersDecreasing(sortedIndices);
for (var i = 0; i < sortedIndices.Length; i++)
{
if (i == 0)
@ -137,7 +137,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit
}
sortedIndices = new[] { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
IlutpElementSorter.SortIntegersDecreasing(sortedIndices);
ILUTPElementSorter.SortIntegersDecreasing(sortedIndices);
for (var i = 0; i < sortedIndices.Length; i++)
{
if (i == 0)
@ -148,7 +148,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit
}
sortedIndices = new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 };
IlutpElementSorter.SortIntegersDecreasing(sortedIndices);
ILUTPElementSorter.SortIntegersDecreasing(sortedIndices);
for (var i = 0; i < sortedIndices.Length; i++)
{
if (i == 0)
@ -159,7 +159,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit
}
sortedIndices = new[] { 1, 1, 1, 0, 1, 1, 1, 1, 1, 1 };
IlutpElementSorter.SortIntegersDecreasing(sortedIndices);
ILUTPElementSorter.SortIntegersDecreasing(sortedIndices);
for (var i = 0; i < sortedIndices.Length; i++)
{
if (i == 9)
@ -193,7 +193,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit
sortedIndices[i] = i;
}
IlutpElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
ILUTPElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
for (var i = 0; i < sortedIndices.Length; i++)
{
Assert.AreEqual(sortedIndices.Length - 1 - i, sortedIndices[i], "#01-" + i);
@ -223,7 +223,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit
sortedIndices[i] = i;
}
IlutpElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
ILUTPElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
for (var i = 0; i < sortedIndices.Length; i++)
{
Assert.AreEqual(i, sortedIndices[i], "#01-" + i);
@ -253,7 +253,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit
sortedIndices[i] = i;
}
IlutpElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
ILUTPElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
for (var i = 0; i < sortedIndices.Length; i++)
{
switch (i)
@ -316,7 +316,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit
sortedIndices[i] = i;
}
IlutpElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
ILUTPElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
for (var i = 0; i < sortedIndices.Length; i++)
{
if (i == 0)
@ -379,7 +379,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit
sortedIndices[i] = i;
}
IlutpElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
ILUTPElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
for (var i = 0; i < sortedIndices.Length; i++)
{
if (i == 0)
@ -404,7 +404,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit
sortedIndices[i] = i;
}
IlutpElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
ILUTPElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
for (var i = 0; i < sortedIndices.Length; i++)
{
if (i == 0)
@ -429,7 +429,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit
sortedIndices[i] = i;
}
IlutpElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
ILUTPElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
for (var i = 0; i < sortedIndices.Length; i++)
{
if (i == 0)
@ -454,7 +454,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit
sortedIndices[i] = i;
}
IlutpElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
ILUTPElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 1, sortedIndices, values);
for (var i = 0; i < sortedIndices.Length; i++)
{
if (i == 9)
@ -488,7 +488,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit
sortedIndices[i] = i;
}
IlutpElementSorter.SortDoubleIndicesDecreasing(4, sortedIndices.Length - 1, sortedIndices, values);
ILUTPElementSorter.SortDoubleIndicesDecreasing(4, sortedIndices.Length - 1, sortedIndices, values);
for (var i = 0; i < sortedIndices.Length - 4; i++)
{
Assert.AreEqual(sortedIndices.Length - 1 - i, sortedIndices[i], "#01-" + i);
@ -518,7 +518,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit
sortedIndices[i] = i;
}
IlutpElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 5, sortedIndices, values);
ILUTPElementSorter.SortDoubleIndicesDecreasing(0, sortedIndices.Length - 5, sortedIndices, values);
for (var i = 0; i < sortedIndices.Length - 5; i++)
{
Assert.AreEqual(sortedIndices.Length - 5 - i, sortedIndices[i], "#01-" + i);
@ -548,7 +548,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit
sortedIndices[i] = i;
}
IlutpElementSorter.SortDoubleIndicesDecreasing(2, sortedIndices.Length - 3, sortedIndices, values);
ILUTPElementSorter.SortDoubleIndicesDecreasing(2, sortedIndices.Length - 3, sortedIndices, values);
for (var i = 0; i < sortedIndices.Length - 4; i++)
{
Assert.AreEqual(sortedIndices.Length - 3 - i, sortedIndices[i], "#01-" + i);

20
src/UnitTests/LinearAlgebraTests/Single/Solvers/Preconditioners/IlutpTest.cs

@ -73,7 +73,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit
/// <param name="ilutp">Ilutp instance.</param>
/// <param name="methodName">Method name.</param>
/// <returns>Result of the method invocation.</returns>
private static T GetMethod<T>(Ilutp ilutp, string methodName)
private static T GetMethod<T>(ILUTPPreconditioner ilutp, string methodName)
{
var type = ilutp.GetType();
var methodInfo = type.GetMethod(
@ -92,7 +92,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit
/// </summary>
/// <param name="ilutp">Ilutp instance.</param>
/// <returns>Upper triangle.</returns>
private static SparseMatrix GetUpperTriangle(Ilutp ilutp)
private static SparseMatrix GetUpperTriangle(ILUTPPreconditioner ilutp)
{
return GetMethod<SparseMatrix>(ilutp, "UpperTriangle");
}
@ -102,7 +102,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit
/// </summary>
/// <param name="ilutp">Ilutp instance.</param>
/// <returns>Lower triangle.</returns>
private static SparseMatrix GetLowerTriangle(Ilutp ilutp)
private static SparseMatrix GetLowerTriangle(ILUTPPreconditioner ilutp)
{
return GetMethod<SparseMatrix>(ilutp, "LowerTriangle");
}
@ -112,7 +112,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit
/// </summary>
/// <param name="ilutp">Ilutp instance.</param>
/// <returns>Pivots array.</returns>
private static int[] GetPivots(Ilutp ilutp)
private static int[] GetPivots(ILUTPPreconditioner ilutp)
{
return GetMethod<int[]>(ilutp, "Pivots");
}
@ -137,9 +137,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit
/// Create preconditioner (internal)
/// </summary>
/// <returns>Ilutp instance.</returns>
private Ilutp InternalCreatePreconditioner()
private ILUTPPreconditioner InternalCreatePreconditioner()
{
var result = new Ilutp
var result = new ILUTPPreconditioner
{
DropTolerance = _dropTolerance,
FillLevel = _fillLevel,
@ -169,7 +169,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit
/// <param name="result">Result vector.</param>
protected override void CheckResult(IPreconditioner<float> preconditioner, SparseMatrix matrix, Vector<float> vector, Vector<float> result)
{
Assert.AreEqual(typeof(Ilutp), preconditioner.GetType(), "#01");
Assert.AreEqual(typeof(ILUTPPreconditioner), preconditioner.GetType(), "#01");
// Compute M * result = product
// compare vector and product. Should be equal
@ -240,7 +240,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit
sparseMatrix[2, 0] = 6;
sparseMatrix[2, 1] = 8;
sparseMatrix[2, 2] = 9;
var ilu = new Ilutp
var ilu = new ILUTPPreconditioner
{
PivotTolerance = 0.0,
DropTolerance = 0,
@ -295,7 +295,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit
sparseMatrix[2, 0] = 6;
sparseMatrix[2, 1] = 8;
sparseMatrix[2, 2] = 9;
var ilu = new Ilutp
var ilu = new ILUTPPreconditioner
{
PivotTolerance = 1.0,
DropTolerance = 0,
@ -331,7 +331,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit
const int Size = 10;
var newMatrix = CreateReverseUnitMatrix(Size);
var vector = CreateStandardBcVector(Size);
var preconditioner = new Ilutp
var preconditioner = new ILUTPPreconditioner
{
PivotTolerance = 1.0,
DropTolerance = 0,

12
src/UnitTests/LinearAlgebraTests/Single/Solvers/Preconditioners/IncompleteLUTest.cs

@ -47,7 +47,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit
/// <param name="ilu"><c>IncompleteLU</c> instance.</param>
/// <param name="methodName">Method name.</param>
/// <returns>Result of the method invocation.</returns>
private static T GetMethod<T>(IncompleteLU ilu, string methodName)
private static T GetMethod<T>(ILU0Preconditioner ilu, string methodName)
{
var type = ilu.GetType();
var methodInfo = type.GetMethod(
@ -66,7 +66,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit
/// </summary>
/// <param name="ilu"><c>IncompleteLU</c> instance.</param>
/// <returns>Upper triangle.</returns>
private static Matrix<float> GetUpperTriangle(IncompleteLU ilu)
private static Matrix<float> GetUpperTriangle(ILU0Preconditioner ilu)
{
return GetMethod<Matrix<float>>(ilu, "UpperTriangle");
}
@ -76,7 +76,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit
/// </summary>
/// <param name="ilu"><c>IncompleteLU</c> instance.</param>
/// <returns>Lower triangle.</returns>
private static Matrix<float> GetLowerTriangle(IncompleteLU ilu)
private static Matrix<float> GetLowerTriangle(ILU0Preconditioner ilu)
{
return GetMethod<Matrix<float>>(ilu, "LowerTriangle");
}
@ -87,7 +87,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit
/// <returns>New preconditioner instance.</returns>
internal override IPreconditioner<float> CreatePreconditioner()
{
return new IncompleteLU();
return new ILU0Preconditioner();
}
/// <summary>
@ -99,7 +99,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit
/// <param name="result">Result vector.</param>
protected override void CheckResult(IPreconditioner<float> preconditioner, SparseMatrix matrix, Vector<float> vector, Vector<float> result)
{
Assert.AreEqual(typeof(IncompleteLU), preconditioner.GetType(), "#01");
Assert.AreEqual(typeof(ILU0Preconditioner), preconditioner.GetType(), "#01");
// Compute M * result = product
// compare vector and product. Should be equal
@ -128,7 +128,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit
sparseMatrix[2, 0] = 6;
sparseMatrix[2, 1] = 8;
sparseMatrix[2, 2] = 9;
var ilu = new IncompleteLU();
var ilu = new ILU0Preconditioner();
ilu.Initialize(sparseMatrix);
var original = GetLowerTriangle(ilu).Multiply(GetUpperTriangle(ilu));

Loading…
Cancel
Save