From db046f8e99482a398469e36ba5ef606575ac0c7c Mon Sep 17 00:00:00 2001 From: Christoph Ruegg Date: Tue, 10 Sep 2013 00:06:19 +0200 Subject: [PATCH] LA: simplify IPreConditioner, misc iterative solver cleanup --- .../IterativeSolvers/BiCgStabSolver.cs | 1 - .../CompositeSolverExample.cs | 1 - .../IterativeSolvers/GpBiCgSolver.cs | 1 - .../IterativeSolvers/MlkBiCgStabSolver.cs | 1 - .../IterativeSolvers/TFQMRSolver.cs | 1 - .../LinearAlgebra/Complex/Solvers/Iterator.cs | 1 - .../Solvers/Preconditioners/Diagonal.cs | 51 +------ .../Complex/Solvers/Preconditioners/Ilutp.cs | 132 ++++++------------ .../Solvers/Preconditioners/IncompleteLU.cs | 54 ++----- .../Complex32/Solvers/Iterator.cs | 1 - .../Solvers/Preconditioners/Diagonal.cs | 50 +------ .../Solvers/Preconditioners/Ilutp.cs | 131 ++++++----------- .../Solvers/Preconditioners/IncompleteLU.cs | 53 ++----- .../LinearAlgebra/Double/Solvers/Iterator.cs | 1 - .../Solvers/Preconditioners/Diagonal.cs | 50 +------ .../Double/Solvers/Preconditioners/Ilutp.cs | 131 ++++++----------- .../Solvers/Preconditioners/IncompleteLU.cs | 53 ++----- .../LinearAlgebra/Single/Solvers/Iterator.cs | 1 - .../Solvers/Preconditioners/Diagonal.cs | 50 +------ .../Single/Solvers/Preconditioners/Ilutp.cs | 131 ++++++----------- .../Solvers/Preconditioners/IncompleteLU.cs | 53 ++----- .../{Status => }/ICalculationStatus.cs | 2 +- .../Solvers/IIterationStopCriterium.cs | 1 - .../LinearAlgebra/Solvers/IIterativeSolver.cs | 3 +- .../Solvers/IIterativeSolverSetup.cs | 4 +- .../LinearAlgebra/Solvers/IIterator.cs | 26 ---- .../LinearAlgebra/Solvers/IPreConditioner.cs | 7 - .../Solvers/IterationCountStopCriterium.cs | 29 ++-- .../LinearAlgebra/Solvers/Iterator.cs | 76 ++-------- .../Solvers/UnitPreconditioner.cs | 48 +------ src/Numerics/Numerics.csproj | 2 +- .../Complex/Solvers/Iterative/BiCgStabTest.cs | 1 - .../Complex/Solvers/Iterative/GpBiCgTest.cs | 1 - .../Solvers/Iterative/MlkBiCgStabTest.cs | 1 - .../Complex/Solvers/Iterative/TFQMRTest.cs | 1 - .../Complex/Solvers/IteratorTest.cs | 56 -------- .../Preconditioners/PreConditionerTest.cs | 56 +------- .../IterationCountStopCriteriumTest.cs | 2 +- .../Solvers/Iterative/BiCgStabTest.cs | 1 - .../Complex32/Solvers/Iterative/GpBiCgTest.cs | 1 - .../Solvers/Iterative/MlkBiCgStabTest.cs | 1 - .../Complex32/Solvers/Iterative/TFQMRTest.cs | 1 - .../Complex32/Solvers/IteratorTest.cs | 56 -------- .../Preconditioners/PreConditionerTest.cs | 56 +------- .../IterationCountStopCriteriumTest.cs | 2 +- .../Double/Solvers/Iterative/BiCgStabTest.cs | 1 - .../Double/Solvers/Iterative/GpBiCgTest.cs | 1 - .../Solvers/Iterative/MlkBiCgStabTest.cs | 1 - .../Double/Solvers/Iterative/TFQMRTest.cs | 1 - .../Double/Solvers/IteratorTest.cs | 56 -------- .../Preconditioners/PreConditionerTest.cs | 56 +------- .../IterationCountStopCriteriumTest.cs | 2 +- .../Single/Solvers/Iterative/BiCgStabTest.cs | 1 - .../Single/Solvers/Iterative/GpBiCgTest.cs | 1 - .../Solvers/Iterative/MlkBiCgStabTest.cs | 1 - .../Single/Solvers/Iterative/TFQMRTest.cs | 1 - .../Single/Solvers/IteratorTest.cs | 56 -------- .../Preconditioners/PreConditionerTest.cs | 56 +------- .../IterationCountStopCriteriumTest.cs | 2 +- 59 files changed, 256 insertions(+), 1362 deletions(-) rename src/Numerics/LinearAlgebra/Solvers/{Status => }/ICalculationStatus.cs (96%) diff --git a/src/Examples/LinearAlgebra/IterativeSolvers/BiCgStabSolver.cs b/src/Examples/LinearAlgebra/IterativeSolvers/BiCgStabSolver.cs index d240535a..b3923cd9 100644 --- a/src/Examples/LinearAlgebra/IterativeSolvers/BiCgStabSolver.cs +++ b/src/Examples/LinearAlgebra/IterativeSolvers/BiCgStabSolver.cs @@ -34,7 +34,6 @@ using MathNet.Numerics.LinearAlgebra.Double; using MathNet.Numerics.LinearAlgebra.Double.Solvers; using MathNet.Numerics.LinearAlgebra.Double.Solvers.StopCriterium; using MathNet.Numerics.LinearAlgebra.Solvers; -using MathNet.Numerics.LinearAlgebra.Solvers.StopCriterium; namespace Examples.LinearAlgebra.IterativeSolversExamples { diff --git a/src/Examples/LinearAlgebra/IterativeSolvers/CompositeSolverExample.cs b/src/Examples/LinearAlgebra/IterativeSolvers/CompositeSolverExample.cs index ae512d5c..70467456 100644 --- a/src/Examples/LinearAlgebra/IterativeSolvers/CompositeSolverExample.cs +++ b/src/Examples/LinearAlgebra/IterativeSolvers/CompositeSolverExample.cs @@ -35,7 +35,6 @@ using MathNet.Numerics.LinearAlgebra.Double; using MathNet.Numerics.LinearAlgebra.Double.Solvers; using MathNet.Numerics.LinearAlgebra.Double.Solvers.StopCriterium; using MathNet.Numerics.LinearAlgebra.Solvers; -using MathNet.Numerics.LinearAlgebra.Solvers.StopCriterium; namespace Examples.LinearAlgebra.IterativeSolversExamples { diff --git a/src/Examples/LinearAlgebra/IterativeSolvers/GpBiCgSolver.cs b/src/Examples/LinearAlgebra/IterativeSolvers/GpBiCgSolver.cs index d3cb3aa3..c2ecd8b3 100644 --- a/src/Examples/LinearAlgebra/IterativeSolvers/GpBiCgSolver.cs +++ b/src/Examples/LinearAlgebra/IterativeSolvers/GpBiCgSolver.cs @@ -34,7 +34,6 @@ using MathNet.Numerics.LinearAlgebra.Double; using MathNet.Numerics.LinearAlgebra.Double.Solvers; using MathNet.Numerics.LinearAlgebra.Double.Solvers.StopCriterium; using MathNet.Numerics.LinearAlgebra.Solvers; -using MathNet.Numerics.LinearAlgebra.Solvers.StopCriterium; namespace Examples.LinearAlgebra.IterativeSolversExamples { diff --git a/src/Examples/LinearAlgebra/IterativeSolvers/MlkBiCgStabSolver.cs b/src/Examples/LinearAlgebra/IterativeSolvers/MlkBiCgStabSolver.cs index 90d108bb..96547e12 100644 --- a/src/Examples/LinearAlgebra/IterativeSolvers/MlkBiCgStabSolver.cs +++ b/src/Examples/LinearAlgebra/IterativeSolvers/MlkBiCgStabSolver.cs @@ -34,7 +34,6 @@ using MathNet.Numerics.LinearAlgebra.Double; using MathNet.Numerics.LinearAlgebra.Double.Solvers; using MathNet.Numerics.LinearAlgebra.Double.Solvers.StopCriterium; using MathNet.Numerics.LinearAlgebra.Solvers; -using MathNet.Numerics.LinearAlgebra.Solvers.StopCriterium; namespace Examples.LinearAlgebra.IterativeSolversExamples { diff --git a/src/Examples/LinearAlgebra/IterativeSolvers/TFQMRSolver.cs b/src/Examples/LinearAlgebra/IterativeSolvers/TFQMRSolver.cs index db25cbf2..08b1d1d2 100644 --- a/src/Examples/LinearAlgebra/IterativeSolvers/TFQMRSolver.cs +++ b/src/Examples/LinearAlgebra/IterativeSolvers/TFQMRSolver.cs @@ -34,7 +34,6 @@ using MathNet.Numerics.LinearAlgebra.Double; using MathNet.Numerics.LinearAlgebra.Double.Solvers; using MathNet.Numerics.LinearAlgebra.Double.Solvers.StopCriterium; using MathNet.Numerics.LinearAlgebra.Solvers; -using MathNet.Numerics.LinearAlgebra.Solvers.StopCriterium; namespace Examples.LinearAlgebra.IterativeSolversExamples { diff --git a/src/Numerics/LinearAlgebra/Complex/Solvers/Iterator.cs b/src/Numerics/LinearAlgebra/Complex/Solvers/Iterator.cs index 3468ecf0..ca2dff4f 100644 --- a/src/Numerics/LinearAlgebra/Complex/Solvers/Iterator.cs +++ b/src/Numerics/LinearAlgebra/Complex/Solvers/Iterator.cs @@ -30,7 +30,6 @@ using MathNet.Numerics.LinearAlgebra.Complex.Solvers.StopCriterium; using MathNet.Numerics.LinearAlgebra.Solvers; -using MathNet.Numerics.LinearAlgebra.Solvers.StopCriterium; namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers { diff --git a/src/Numerics/LinearAlgebra/Complex/Solvers/Preconditioners/Diagonal.cs b/src/Numerics/LinearAlgebra/Complex/Solvers/Preconditioners/Diagonal.cs index 7dd47ce2..316cd888 100644 --- a/src/Numerics/LinearAlgebra/Complex/Solvers/Preconditioners/Diagonal.cs +++ b/src/Numerics/LinearAlgebra/Complex/Solvers/Preconditioners/Diagonal.cs @@ -39,6 +39,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Preconditioners using Complex = Numerics.Complex; #else using Complex = System.Numerics.Complex; + #endif /// @@ -50,7 +51,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Preconditioners /// /// The inverse of the matrix diagonal. /// - private Complex[] _inverseDiagonals; + Complex[] _inverseDiagonals; /// /// Returns the decomposed matrix diagonal. @@ -61,7 +62,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Preconditioners var result = new DiagonalMatrix(_inverseDiagonals.Length); for (var i = 0; i < _inverseDiagonals.Length; i++) { - result.At(i, i, 1 / _inverseDiagonals[i]); + result.At(i, i, 1/_inverseDiagonals[i]); } return result; @@ -76,11 +77,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Preconditioners /// If is not a square matrix. public void Initialize(Matrix matrix) { - if (matrix == null) - { - throw new ArgumentNullException("matrix"); - } - if (matrix.RowCount != matrix.ColumnCount) { throw new ArgumentException(Resources.ArgumentMatrixSquare, "matrix"); @@ -89,35 +85,8 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Preconditioners _inverseDiagonals = new Complex[matrix.RowCount]; for (var i = 0; i < matrix.RowCount; i++) { - _inverseDiagonals[i] = 1 / matrix.At(i, i); - } - } - - /// - /// Approximates the solution to the matrix equation Ax = b. - /// - /// The right hand side vector. - /// The left hand side vector. - public Vector Approximate(Vector rhs) - { - if (rhs == null) - { - throw new ArgumentNullException("rhs"); - } - - if (_inverseDiagonals == null) - { - throw new ArgumentException(Resources.ArgumentMatrixDoesNotExist); - } - - if (rhs.Count != _inverseDiagonals.Length) - { - throw new ArgumentException(Resources.ArgumentVectorsSameLength, "rhs"); + _inverseDiagonals[i] = 1/matrix.At(i, i); } - - var result = new DenseVector(rhs.Count); - Approximate(rhs, result); - return result; } /// @@ -127,16 +96,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Preconditioners /// The left hand side vector. Also known as the result vector. public void Approximate(Vector rhs, Vector lhs) { - if (rhs == null) - { - throw new ArgumentNullException("rhs"); - } - - if (lhs == null) - { - throw new ArgumentNullException("lhs"); - } - if (_inverseDiagonals == null) { throw new ArgumentException(Resources.ArgumentMatrixDoesNotExist); @@ -149,7 +108,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Preconditioners for (var i = 0; i < _inverseDiagonals.Length; i++) { - lhs[i] = rhs[i] * _inverseDiagonals[i]; + lhs[i] = rhs[i]*_inverseDiagonals[i]; } } } diff --git a/src/Numerics/LinearAlgebra/Complex/Solvers/Preconditioners/Ilutp.cs b/src/Numerics/LinearAlgebra/Complex/Solvers/Preconditioners/Ilutp.cs index e9c9194a..e60d5185 100644 --- a/src/Numerics/LinearAlgebra/Complex/Solvers/Preconditioners/Ilutp.cs +++ b/src/Numerics/LinearAlgebra/Complex/Solvers/Preconditioners/Ilutp.cs @@ -40,6 +40,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Preconditioners using Complex = Numerics.Complex; #else using Complex = System.Numerics.Complex; + #endif /// @@ -70,36 +71,36 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Preconditioners /// The default drop tolerance. /// public const double DefaultDropTolerance = 0.0001; - + /// /// The decomposed upper triangular matrix. /// - private SparseMatrix _upper; + SparseMatrix _upper; /// /// The decomposed lower triangular matrix. /// - private SparseMatrix _lower; - + SparseMatrix _lower; + /// /// The array containing the pivot values. /// - private int[] _pivots; + int[] _pivots; /// /// The fill level. /// - private double _fillLevel = DefaultFillLevel; - + double _fillLevel = DefaultFillLevel; + /// /// The drop tolerance. /// - private double _dropTolerance = DefaultDropTolerance; - + double _dropTolerance = DefaultDropTolerance; + /// /// The pivot tolerance. /// - private double _pivotTolerance; + double _pivotTolerance; /// /// Initializes a new instance of the class with the default settings. @@ -145,7 +146,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Preconditioners _dropTolerance = dropTolerance; _pivotTolerance = pivotTolerance; } - + /// /// Gets or sets the amount of fill that is allowed in the matrix. The /// value is a fraction of the number of non-zero entries in the original @@ -168,11 +169,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Preconditioners /// Thrown if a negative value is provided. public double FillLevel { - get - { - return _fillLevel; - } - + get { return _fillLevel; } set { if (value < 0) @@ -203,11 +200,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Preconditioners /// Thrown if a negative value is provided. public double DropTolerance { - get - { - return _dropTolerance; - } - + get { return _dropTolerance; } set { if (value < 0) @@ -240,11 +233,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Preconditioners /// Thrown if a negative value is provided. public double PivotTolerance { - get - { - return _pivotTolerance; - } - + get { return _pivotTolerance; } set { if (value < 0) @@ -255,7 +244,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Preconditioners _pivotTolerance = value; } } - + /// /// Returns the upper triagonal matrix that was created during the LU decomposition. /// @@ -373,7 +362,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Preconditioners // Create the upper triangular matrix and copy the values _upper = new SparseMatrix(sparseMatrix.RowCount); - + // Create the pivot array _pivots = new int[sparseMatrix.RowCount]; for (var i = 0; i < _pivots.Length; i++) @@ -384,20 +373,20 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Preconditioners var workVector = new DenseVector(sparseMatrix.RowCount); var rowVector = new DenseVector(sparseMatrix.ColumnCount); var indexSorting = new int[sparseMatrix.RowCount]; - + // spaceLeft = lfilNnz * nnz(A) - var spaceLeft = (int)_fillLevel * sparseMatrix.NonZerosCount; - + var spaceLeft = (int) _fillLevel*sparseMatrix.NonZerosCount; + // for i = 1, .. , n for (var i = 0; i < sparseMatrix.RowCount; i++) { // w = a(i,*) sparseMatrix.Row(i, workVector); - + // pivot the row PivotRow(workVector); var vectorNorm = workVector.InfinityNorm(); - + // for j = 1, .. , i - 1) for (var j = 0; j < i; j++) { @@ -415,7 +404,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Preconditioners if (workVector[j] != 0.0) { // Calculate the multiplication factors that go into the L matrix - workVector[j] = workVector[j] / _upper[j, j]; + workVector[j] = workVector[j]/_upper[j, j]; if (workVector[j].Magnitude < _dropTolerance) { workVector[j] = 0.0; @@ -447,19 +436,19 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Preconditioners // { // w(j) = 0 // } - if (workVector[j].Magnitude <= _dropTolerance * vectorNorm.Real) + if (workVector[j].Magnitude <= _dropTolerance*vectorNorm.Real) { workVector[j] = 0.0; } } // spaceRow = spaceLeft / (n - i + 1) // Determine the space for this row - var spaceRow = spaceLeft / (sparseMatrix.RowCount - i + 1); + var spaceRow = spaceLeft/(sparseMatrix.RowCount - i + 1); // lfil = spaceRow / 2 // space for this row of L - var fillLevel = spaceRow / 2; + var fillLevel = spaceRow/2; FindLargestItems(0, i - 1, indexSorting, workVector); - + // l(i,j) = w(j) for j = 1, .. , i -1 // only the largest lfil elements var lowerNonZeroCount = 0; var count = 0; @@ -476,10 +465,10 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Preconditioners } FindLargestItems(i + 1, sparseMatrix.RowCount - 1, indexSorting, workVector); - + // lfil = spaceRow - nnz(L(i,:)) // space for this row of U fillLevel = spaceRow - lowerNonZeroCount; - + // u(i,j) = w(j) for j = i + 1, .. , n // only the largest lfil - 1 elements var upperNonZeroCount = 0; count = 0; @@ -511,12 +500,12 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Preconditioners // -1 values. if ((i + 1) < (sparseMatrix.RowCount - 1)) { - if (workVector[i].Magnitude < _pivotTolerance * workVector[indexSorting[0]].Magnitude) + if (workVector[i].Magnitude < _pivotTolerance*workVector[indexSorting[0]].Magnitude) { // swap columns of u (which holds the values of A in the // sections that haven't been partitioned yet. SwapColumns(_upper, i, indexSorting[0]); - + // Update P var temp = _pivots[i]; _pivots[i] = _pivots[indexSorting[0]]; @@ -538,10 +527,10 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Preconditioners /// Pivot elements in the according to internal pivot array /// /// Row to pivot in - private void PivotRow(Vector row) + void PivotRow(Vector row) { var knownPivots = new Dictionary(); - + // pivot the row for (var i = 0; i < row.Count; i++) { @@ -563,7 +552,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Preconditioners /// Pivots already done /// Current item to pivot /// true if performed, otherwise false - private bool PivotMapFound(Dictionary knownPivots, int currentItem) + bool PivotMapFound(Dictionary knownPivots, int currentItem) { if (knownPivots.ContainsKey(_pivots[currentItem])) { @@ -590,7 +579,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Preconditioners /// Source . /// First column index to swap /// Second column index to swap - private static void SwapColumns(Matrix matrix, int firstColumn, int secondColumn) + static void SwapColumns(Matrix matrix, int firstColumn, int secondColumn) { for (var i = 0; i < matrix.RowCount; i++) { @@ -607,7 +596,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Preconditioners /// Sort till upper bound /// Array with sorted vector indicies /// Source - private static void FindLargestItems(int lowerBound, int upperBound, int[] sortedIndices, Vector values) + static void FindLargestItems(int lowerBound, int upperBound, int[] sortedIndices, Vector values) { // Copy the indices for the values into the array for (var i = 0; i < upperBound + 1 - lowerBound; i++) @@ -627,33 +616,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Preconditioners IlutpElementSorter.SortDoubleIndicesDecreasing(0, upperBound - lowerBound, sortedIndices, values); } - /// - /// Approximates the solution to the matrix equation Ax = b. - /// - /// The right hand side vector. - /// The left hand side vector. - public Vector Approximate(Vector rhs) - { - if (rhs == null) - { - throw new ArgumentNullException("rhs"); - } - - if (_upper == null) - { - throw new ArgumentException(Resources.ArgumentMatrixDoesNotExist); - } - - if (rhs.Count != _upper.ColumnCount) - { - throw new ArgumentException(Resources.ArgumentVectorsSameLength, "rhs"); - } - - var result = new DenseVector(rhs.Count); - Approximate(rhs, result); - return result; - } - /// /// Approximates the solution to the matrix equation Ax = b. /// @@ -661,16 +623,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Preconditioners /// The left hand side vector. Also known as the result vector. public void Approximate(Vector rhs, Vector lhs) { - if (rhs == null) - { - throw new ArgumentNullException("rhs"); - } - - if (lhs == null) - { - throw new ArgumentNullException("lhs"); - } - if (_upper == null) { throw new ArgumentException(Resources.ArgumentMatrixDoesNotExist); @@ -680,7 +632,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Preconditioners { throw new ArgumentException(Resources.ArgumentVectorsSameLength, "rhs"); } - + // Solve equation here // Pivot(vector, result); // Solve L*Y = B(piv,:) @@ -692,7 +644,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Preconditioners var sum = Complex.Zero; for (var j = 0; j < i; j++) { - sum += rowValues[j] * lhs[j]; + sum += rowValues[j]*lhs[j]; } lhs[i] = rhs[i] - sum; @@ -706,16 +658,16 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Preconditioners var sum = Complex.Zero; for (var j = _upper.RowCount - 1; j > i; j--) { - sum += rowValues[j] * lhs[j]; + sum += rowValues[j]*lhs[j]; } - lhs[i] = 1 / rowValues[i] * (lhs[i] - sum); + lhs[i] = 1/rowValues[i]*(lhs[i] - sum); } // We have a column pivot so we only need to pivot the // end result not the incoming right hand side vector var temp = lhs.Clone(); - + Pivot(temp, lhs); } @@ -724,7 +676,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Preconditioners /// /// Source . /// Result after pivoting. - private void Pivot(Vector vector, Vector result) + void Pivot(Vector vector, Vector result) { for (var i = 0; i < _pivots.Length; i++) { diff --git a/src/Numerics/LinearAlgebra/Complex/Solvers/Preconditioners/IncompleteLU.cs b/src/Numerics/LinearAlgebra/Complex/Solvers/Preconditioners/IncompleteLU.cs index c6c166a4..57632f78 100644 --- a/src/Numerics/LinearAlgebra/Complex/Solvers/Preconditioners/IncompleteLU.cs +++ b/src/Numerics/LinearAlgebra/Complex/Solvers/Preconditioners/IncompleteLU.cs @@ -39,6 +39,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Preconditioners using Complex = Numerics.Complex; #else using Complex = System.Numerics.Complex; + #endif /// @@ -56,7 +57,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Preconditioners /// The matrix holding the lower (L) and upper (U) matrices. The /// decomposition matrices are combined to reduce storage. /// - private SparseMatrix _decompositionLU; + SparseMatrix _decompositionLU; /// /// Returns the upper triagonal matrix that was created during the LU decomposition. @@ -91,7 +92,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Preconditioners { result[i, j] = 1.0; } - else + else { result[i, j] = _decompositionLU[i, j]; } @@ -140,11 +141,11 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Preconditioners { if (_decompositionLU[i, k] != 0.0) { - var t = _decompositionLU[i, k] / _decompositionLU[k, k]; + var t = _decompositionLU[i, k]/_decompositionLU[k, k]; _decompositionLU[i, k] = t; if (_decompositionLU[k, i] != 0.0) { - _decompositionLU[i, i] = _decompositionLU[i, i] - (t * _decompositionLU[k, i]); + _decompositionLU[i, i] = _decompositionLU[i, i] - (t*_decompositionLU[k, i]); } for (var j = k + 1; j < _decompositionLU.RowCount; j++) @@ -156,7 +157,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Preconditioners if (_decompositionLU[i, j] != 0.0) { - _decompositionLU[i, j] = _decompositionLU[i, j] - (t * _decompositionLU[k, j]); + _decompositionLU[i, j] = _decompositionLU[i, j] - (t*_decompositionLU[k, j]); } } } @@ -164,33 +165,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Preconditioners } } - /// - /// Approximates the solution to the matrix equation Ax = b. - /// - /// The right hand side vector. - /// The left hand side vector. - public Vector Approximate(Vector rhs) - { - if (rhs == null) - { - throw new ArgumentNullException("rhs"); - } - - if (_decompositionLU == null) - { - throw new ArgumentException(Resources.ArgumentMatrixDoesNotExist); - } - - if (rhs.Count != _decompositionLU.ColumnCount) - { - throw new ArgumentException(Resources.ArgumentVectorsSameLength, "rhs"); - } - - var result = new DenseVector(rhs.Count); - Approximate(rhs, result); - return result; - } - /// /// Approximates the solution to the matrix equation Ax = b. /// @@ -198,16 +172,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Preconditioners /// The left hand side vector. Also known as the result vector. public void Approximate(Vector rhs, Vector lhs) { - if (rhs == null) - { - throw new ArgumentNullException("rhs"); - } - - if (lhs == null) - { - throw new ArgumentNullException("lhs"); - } - if (_decompositionLU == null) { throw new ArgumentException(Resources.ArgumentMatrixDoesNotExist); @@ -236,7 +200,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Preconditioners var sum = Complex.Zero; for (var j = 0; j < i; j++) { - sum += rowValues[j] * lhs[j]; + sum += rowValues[j]*lhs[j]; } lhs[i] = rhs[i] - sum; @@ -256,10 +220,10 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Preconditioners var sum = Complex.Zero; for (var j = _decompositionLU.RowCount - 1; j > i; j--) { - sum += rowValues[j] * lhs[j]; + sum += rowValues[j]*lhs[j]; } - lhs[i] = 1 / rowValues[i] * (lhs[i] - sum); + lhs[i] = 1/rowValues[i]*(lhs[i] - sum); } } } diff --git a/src/Numerics/LinearAlgebra/Complex32/Solvers/Iterator.cs b/src/Numerics/LinearAlgebra/Complex32/Solvers/Iterator.cs index 7161e3f0..a1bd9630 100644 --- a/src/Numerics/LinearAlgebra/Complex32/Solvers/Iterator.cs +++ b/src/Numerics/LinearAlgebra/Complex32/Solvers/Iterator.cs @@ -30,7 +30,6 @@ using MathNet.Numerics.LinearAlgebra.Complex32.Solvers.StopCriterium; using MathNet.Numerics.LinearAlgebra.Solvers; -using MathNet.Numerics.LinearAlgebra.Solvers.StopCriterium; namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers { diff --git a/src/Numerics/LinearAlgebra/Complex32/Solvers/Preconditioners/Diagonal.cs b/src/Numerics/LinearAlgebra/Complex32/Solvers/Preconditioners/Diagonal.cs index 1e9c0b5a..2072b0c3 100644 --- a/src/Numerics/LinearAlgebra/Complex32/Solvers/Preconditioners/Diagonal.cs +++ b/src/Numerics/LinearAlgebra/Complex32/Solvers/Preconditioners/Diagonal.cs @@ -45,7 +45,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Preconditioners /// /// The inverse of the matrix diagonal. /// - private Complex32[] _inverseDiagonals; + Complex32[] _inverseDiagonals; /// /// Returns the decomposed matrix diagonal. @@ -56,7 +56,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Preconditioners var result = new DiagonalMatrix(_inverseDiagonals.Length); for (var i = 0; i < _inverseDiagonals.Length; i++) { - result[i, i] = 1 / _inverseDiagonals[i]; + result[i, i] = 1/_inverseDiagonals[i]; } return result; @@ -71,11 +71,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Preconditioners /// If is not a square matrix. public void Initialize(Matrix matrix) { - if (matrix == null) - { - throw new ArgumentNullException("matrix"); - } - if (matrix.RowCount != matrix.ColumnCount) { throw new ArgumentException(Resources.ArgumentMatrixSquare, "matrix"); @@ -84,37 +79,10 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Preconditioners _inverseDiagonals = new Complex32[matrix.RowCount]; for (var i = 0; i < matrix.RowCount; i++) { - _inverseDiagonals[i] = 1 / matrix[i, i]; + _inverseDiagonals[i] = 1/matrix[i, i]; } } - /// - /// Approximates the solution to the matrix equation Ax = b. - /// - /// The right hand side vector. - /// The left hand side vector. - public Vector Approximate(Vector rhs) - { - if (rhs == null) - { - throw new ArgumentNullException("rhs"); - } - - if (_inverseDiagonals == null) - { - throw new ArgumentException(Resources.ArgumentMatrixDoesNotExist); - } - - if (rhs.Count != _inverseDiagonals.Length) - { - throw new ArgumentException(Resources.ArgumentVectorsSameLength, "rhs"); - } - - var result = new DenseVector(rhs.Count); - Approximate(rhs, result); - return result; - } - /// /// Approximates the solution to the matrix equation Ax = b. /// @@ -122,16 +90,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Preconditioners /// The left hand side vector. Also known as the result vector. public void Approximate(Vector rhs, Vector lhs) { - if (rhs == null) - { - throw new ArgumentNullException("rhs"); - } - - if (lhs == null) - { - throw new ArgumentNullException("lhs"); - } - if (_inverseDiagonals == null) { throw new ArgumentException(Resources.ArgumentMatrixDoesNotExist); @@ -144,7 +102,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Preconditioners for (var i = 0; i < _inverseDiagonals.Length; i++) { - lhs[i] = rhs[i] * _inverseDiagonals[i]; + lhs[i] = rhs[i]*_inverseDiagonals[i]; } } } diff --git a/src/Numerics/LinearAlgebra/Complex32/Solvers/Preconditioners/Ilutp.cs b/src/Numerics/LinearAlgebra/Complex32/Solvers/Preconditioners/Ilutp.cs index 1a0d8272..47b13110 100644 --- a/src/Numerics/LinearAlgebra/Complex32/Solvers/Preconditioners/Ilutp.cs +++ b/src/Numerics/LinearAlgebra/Complex32/Solvers/Preconditioners/Ilutp.cs @@ -65,36 +65,36 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Preconditioners /// The default drop tolerance. /// public const double DefaultDropTolerance = 0.0001; - + /// /// The decomposed upper triangular matrix. /// - private SparseMatrix _upper; + SparseMatrix _upper; /// /// The decomposed lower triangular matrix. /// - private SparseMatrix _lower; - + SparseMatrix _lower; + /// /// The array containing the pivot values. /// - private int[] _pivots; + int[] _pivots; /// /// The fill level. /// - private double _fillLevel = DefaultFillLevel; - + double _fillLevel = DefaultFillLevel; + /// /// The drop tolerance. /// - private double _dropTolerance = DefaultDropTolerance; - + double _dropTolerance = DefaultDropTolerance; + /// /// The pivot tolerance. /// - private double _pivotTolerance; + double _pivotTolerance; /// /// Initializes a new instance of the class with the default settings. @@ -140,7 +140,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Preconditioners _dropTolerance = dropTolerance; _pivotTolerance = pivotTolerance; } - + /// /// Gets or sets the amount of fill that is allowed in the matrix. The /// value is a fraction of the number of non-zero entries in the original @@ -163,11 +163,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Preconditioners /// Thrown if a negative value is provided. public double FillLevel { - get - { - return _fillLevel; - } - + get { return _fillLevel; } set { if (value < 0) @@ -198,11 +194,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Preconditioners /// Thrown if a negative value is provided. public double DropTolerance { - get - { - return _dropTolerance; - } - + get { return _dropTolerance; } set { if (value < 0) @@ -235,11 +227,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Preconditioners /// Thrown if a negative value is provided. public double PivotTolerance { - get - { - return _pivotTolerance; - } - + get { return _pivotTolerance; } set { if (value < 0) @@ -250,7 +238,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Preconditioners _pivotTolerance = value; } } - + /// /// Returns the upper triagonal matrix that was created during the LU decomposition. /// @@ -368,7 +356,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Preconditioners // Create the upper triangular matrix and copy the values _upper = new SparseMatrix(sparseMatrix.RowCount); - + // Create the pivot array _pivots = new int[sparseMatrix.RowCount]; for (var i = 0; i < _pivots.Length; i++) @@ -379,20 +367,20 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Preconditioners var workVector = new DenseVector(sparseMatrix.RowCount); var rowVector = new DenseVector(sparseMatrix.ColumnCount); var indexSorting = new int[sparseMatrix.RowCount]; - + // spaceLeft = lfilNnz * nnz(A) - var spaceLeft = (int)_fillLevel * sparseMatrix.NonZerosCount; - + var spaceLeft = (int) _fillLevel*sparseMatrix.NonZerosCount; + // for i = 1, .. , n for (var i = 0; i < sparseMatrix.RowCount; i++) { // w = a(i,*) sparseMatrix.Row(i, workVector); - + // pivot the row PivotRow(workVector); var vectorNorm = workVector.InfinityNorm(); - + // for j = 1, .. , i - 1) for (var j = 0; j < i; j++) { @@ -410,7 +398,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Preconditioners if (workVector[j] != 0.0f) { // Calculate the multiplication factors that go into the L matrix - workVector[j] = workVector[j] / _upper[j, j]; + workVector[j] = workVector[j]/_upper[j, j]; if (workVector[j].Magnitude < _dropTolerance) { workVector[j] = 0.0f; @@ -442,19 +430,19 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Preconditioners // { // w(j) = 0 // } - if (workVector[j].Magnitude <= _dropTolerance * vectorNorm.Real) + if (workVector[j].Magnitude <= _dropTolerance*vectorNorm.Real) { workVector[j] = 0.0f; } } // spaceRow = spaceLeft / (n - i + 1) // Determine the space for this row - var spaceRow = spaceLeft / (sparseMatrix.RowCount - i + 1); + var spaceRow = spaceLeft/(sparseMatrix.RowCount - i + 1); // lfil = spaceRow / 2 // space for this row of L - var fillLevel = spaceRow / 2; + var fillLevel = spaceRow/2; FindLargestItems(0, i - 1, indexSorting, workVector); - + // l(i,j) = w(j) for j = 1, .. , i -1 // only the largest lfil elements var lowerNonZeroCount = 0; var count = 0; @@ -471,10 +459,10 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Preconditioners } FindLargestItems(i + 1, sparseMatrix.RowCount - 1, indexSorting, workVector); - + // lfil = spaceRow - nnz(L(i,:)) // space for this row of U fillLevel = spaceRow - lowerNonZeroCount; - + // u(i,j) = w(j) for j = i + 1, .. , n // only the largest lfil - 1 elements var upperNonZeroCount = 0; count = 0; @@ -506,12 +494,12 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Preconditioners // -1 values. if ((i + 1) < (sparseMatrix.RowCount - 1)) { - if (workVector[i].Magnitude < _pivotTolerance * workVector[indexSorting[0]].Magnitude) + if (workVector[i].Magnitude < _pivotTolerance*workVector[indexSorting[0]].Magnitude) { // swap columns of u (which holds the values of A in the // sections that haven't been partitioned yet. SwapColumns(_upper, i, indexSorting[0]); - + // Update P var temp = _pivots[i]; _pivots[i] = _pivots[indexSorting[0]]; @@ -533,10 +521,10 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Preconditioners /// Pivot elements in the according to internal pivot array /// /// Row to pivot in - private void PivotRow(Vector row) + void PivotRow(Vector row) { var knownPivots = new Dictionary(); - + // pivot the row for (var i = 0; i < row.Count; i++) { @@ -558,7 +546,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Preconditioners /// Pivots already done /// Current item to pivot /// true if performed, otherwise false - private bool PivotMapFound(Dictionary knownPivots, int currentItem) + bool PivotMapFound(Dictionary knownPivots, int currentItem) { if (knownPivots.ContainsKey(_pivots[currentItem])) { @@ -585,7 +573,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Preconditioners /// Source . /// First column index to swap /// Second column index to swap - private static void SwapColumns(Matrix matrix, int firstColumn, int secondColumn) + static void SwapColumns(Matrix matrix, int firstColumn, int secondColumn) { for (var i = 0; i < matrix.RowCount; i++) { @@ -602,7 +590,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Preconditioners /// Sort till upper bound /// Array with sorted vector indicies /// Source - private static void FindLargestItems(int lowerBound, int upperBound, int[] sortedIndices, Vector values) + static void FindLargestItems(int lowerBound, int upperBound, int[] sortedIndices, Vector values) { // Copy the indices for the values into the array for (var i = 0; i < upperBound + 1 - lowerBound; i++) @@ -622,33 +610,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Preconditioners IlutpElementSorter.SortDoubleIndicesDecreasing(0, upperBound - lowerBound, sortedIndices, values); } - /// - /// Approximates the solution to the matrix equation Ax = b. - /// - /// The right hand side vector. - /// The left hand side vector. - public Vector Approximate(Vector rhs) - { - if (rhs == null) - { - throw new ArgumentNullException("rhs"); - } - - if (_upper == null) - { - throw new ArgumentException(Resources.ArgumentMatrixDoesNotExist); - } - - if (rhs.Count != _upper.ColumnCount) - { - throw new ArgumentException(Resources.ArgumentVectorsSameLength, "rhs"); - } - - var result = new DenseVector(rhs.Count); - Approximate(rhs, result); - return result; - } - /// /// Approximates the solution to the matrix equation Ax = b. /// @@ -656,16 +617,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Preconditioners /// The left hand side vector. Also known as the result vector. public void Approximate(Vector rhs, Vector lhs) { - if (rhs == null) - { - throw new ArgumentNullException("rhs"); - } - - if (lhs == null) - { - throw new ArgumentNullException("lhs"); - } - if (_upper == null) { throw new ArgumentException(Resources.ArgumentMatrixDoesNotExist); @@ -675,7 +626,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Preconditioners { throw new ArgumentException(Resources.ArgumentVectorsSameLength, "rhs"); } - + // Solve equation here // Pivot(vector, result); // Solve L*Y = B(piv,:) @@ -687,7 +638,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Preconditioners var sum = Complex32.Zero; for (var j = 0; j < i; j++) { - sum += rowValues[j] * lhs[j]; + sum += rowValues[j]*lhs[j]; } lhs[i] = rhs[i] - sum; @@ -701,16 +652,16 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Preconditioners var sum = Complex32.Zero; for (var j = _upper.RowCount - 1; j > i; j--) { - sum += rowValues[j] * lhs[j]; + sum += rowValues[j]*lhs[j]; } - lhs[i] = 1 / rowValues[i] * (lhs[i] - sum); + lhs[i] = 1/rowValues[i]*(lhs[i] - sum); } // We have a column pivot so we only need to pivot the // end result not the incoming right hand side vector var temp = lhs.Clone(); - + Pivot(temp, lhs); } @@ -719,7 +670,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Preconditioners /// /// Source . /// Result after pivoting. - private void Pivot(Vector vector, Vector result) + void Pivot(Vector vector, Vector result) { for (var i = 0; i < _pivots.Length; i++) { diff --git a/src/Numerics/LinearAlgebra/Complex32/Solvers/Preconditioners/IncompleteLU.cs b/src/Numerics/LinearAlgebra/Complex32/Solvers/Preconditioners/IncompleteLU.cs index 32a5b618..4d440634 100644 --- a/src/Numerics/LinearAlgebra/Complex32/Solvers/Preconditioners/IncompleteLU.cs +++ b/src/Numerics/LinearAlgebra/Complex32/Solvers/Preconditioners/IncompleteLU.cs @@ -51,7 +51,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Preconditioners /// The matrix holding the lower (L) and upper (U) matrices. The /// decomposition matrices are combined to reduce storage. /// - private SparseMatrix _decompositionLU; + SparseMatrix _decompositionLU; /// /// Returns the upper triagonal matrix that was created during the LU decomposition. @@ -86,7 +86,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Preconditioners { result[i, j] = 1.0f; } - else + else { result[i, j] = _decompositionLU[i, j]; } @@ -135,11 +135,11 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Preconditioners { if (_decompositionLU[i, k] != 0.0f) { - var t = _decompositionLU[i, k] / _decompositionLU[k, k]; + var t = _decompositionLU[i, k]/_decompositionLU[k, k]; _decompositionLU[i, k] = t; if (_decompositionLU[k, i] != 0.0f) { - _decompositionLU[i, i] = _decompositionLU[i, i] - (t * _decompositionLU[k, i]); + _decompositionLU[i, i] = _decompositionLU[i, i] - (t*_decompositionLU[k, i]); } for (var j = k + 1; j < _decompositionLU.RowCount; j++) @@ -151,7 +151,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Preconditioners if (_decompositionLU[i, j] != 0.0f) { - _decompositionLU[i, j] = _decompositionLU[i, j] - (t * _decompositionLU[k, j]); + _decompositionLU[i, j] = _decompositionLU[i, j] - (t*_decompositionLU[k, j]); } } } @@ -159,33 +159,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Preconditioners } } - /// - /// Approximates the solution to the matrix equation Ax = b. - /// - /// The right hand side vector. - /// The left hand side vector. - public Vector Approximate(Vector rhs) - { - if (rhs == null) - { - throw new ArgumentNullException("rhs"); - } - - if (_decompositionLU == null) - { - throw new ArgumentException(Resources.ArgumentMatrixDoesNotExist); - } - - if (rhs.Count != _decompositionLU.ColumnCount) - { - throw new ArgumentException(Resources.ArgumentVectorsSameLength, "rhs"); - } - - var result = new DenseVector(rhs.Count); - Approximate(rhs, result); - return result; - } - /// /// Approximates the solution to the matrix equation Ax = b. /// @@ -193,16 +166,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Preconditioners /// The left hand side vector. Also known as the result vector. public void Approximate(Vector rhs, Vector lhs) { - if (rhs == null) - { - throw new ArgumentNullException("rhs"); - } - - if (lhs == null) - { - throw new ArgumentNullException("lhs"); - } - if (_decompositionLU == null) { throw new ArgumentException(Resources.ArgumentMatrixDoesNotExist); @@ -231,7 +194,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Preconditioners var sum = Complex32.Zero; for (var j = 0; j < i; j++) { - sum += rowValues[j] * lhs[j]; + sum += rowValues[j]*lhs[j]; } lhs[i] = rhs[i] - sum; @@ -251,10 +214,10 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Preconditioners var sum = Complex32.Zero; for (var j = _decompositionLU.RowCount - 1; j > i; j--) { - sum += rowValues[j] * lhs[j]; + sum += rowValues[j]*lhs[j]; } - lhs[i] = 1 / rowValues[i] * (lhs[i] - sum); + lhs[i] = 1/rowValues[i]*(lhs[i] - sum); } } } diff --git a/src/Numerics/LinearAlgebra/Double/Solvers/Iterator.cs b/src/Numerics/LinearAlgebra/Double/Solvers/Iterator.cs index 3049ec83..05fc6260 100644 --- a/src/Numerics/LinearAlgebra/Double/Solvers/Iterator.cs +++ b/src/Numerics/LinearAlgebra/Double/Solvers/Iterator.cs @@ -30,7 +30,6 @@ using MathNet.Numerics.LinearAlgebra.Double.Solvers.StopCriterium; using MathNet.Numerics.LinearAlgebra.Solvers; -using MathNet.Numerics.LinearAlgebra.Solvers.StopCriterium; namespace MathNet.Numerics.LinearAlgebra.Double.Solvers { diff --git a/src/Numerics/LinearAlgebra/Double/Solvers/Preconditioners/Diagonal.cs b/src/Numerics/LinearAlgebra/Double/Solvers/Preconditioners/Diagonal.cs index 72c56ed7..97114ce5 100644 --- a/src/Numerics/LinearAlgebra/Double/Solvers/Preconditioners/Diagonal.cs +++ b/src/Numerics/LinearAlgebra/Double/Solvers/Preconditioners/Diagonal.cs @@ -43,7 +43,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Preconditioners /// /// The inverse of the matrix diagonal. /// - private double[] _inverseDiagonals; + double[] _inverseDiagonals; /// /// Returns the decomposed matrix diagonal. @@ -54,7 +54,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Preconditioners var result = new DiagonalMatrix(_inverseDiagonals.Length); for (var i = 0; i < _inverseDiagonals.Length; i++) { - result[i, i] = 1 / _inverseDiagonals[i]; + result[i, i] = 1/_inverseDiagonals[i]; } return result; @@ -69,11 +69,6 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Preconditioners /// If is not a square matrix. public void Initialize(Matrix matrix) { - if (matrix == null) - { - throw new ArgumentNullException("matrix"); - } - if (matrix.RowCount != matrix.ColumnCount) { throw new ArgumentException(Resources.ArgumentMatrixSquare, "matrix"); @@ -82,37 +77,10 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Preconditioners _inverseDiagonals = new double[matrix.RowCount]; for (var i = 0; i < matrix.RowCount; i++) { - _inverseDiagonals[i] = 1 / matrix[i, i]; + _inverseDiagonals[i] = 1/matrix[i, i]; } } - /// - /// Approximates the solution to the matrix equation Ax = b. - /// - /// The right hand side vector. - /// The left hand side vector. - public Vector Approximate(Vector rhs) - { - if (rhs == null) - { - throw new ArgumentNullException("rhs"); - } - - if (_inverseDiagonals == null) - { - throw new ArgumentException(Resources.ArgumentMatrixDoesNotExist); - } - - if (rhs.Count != _inverseDiagonals.Length) - { - throw new ArgumentException(Resources.ArgumentVectorsSameLength, "rhs"); - } - - var result = new DenseVector(rhs.Count); - Approximate(rhs, result); - return result; - } - /// /// Approximates the solution to the matrix equation Ax = b. /// @@ -120,16 +88,6 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Preconditioners /// The left hand side vector. Also known as the result vector. public void Approximate(Vector rhs, Vector lhs) { - if (rhs == null) - { - throw new ArgumentNullException("rhs"); - } - - if (lhs == null) - { - throw new ArgumentNullException("lhs"); - } - if (_inverseDiagonals == null) { throw new ArgumentException(Resources.ArgumentMatrixDoesNotExist); @@ -142,7 +100,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Preconditioners for (var i = 0; i < _inverseDiagonals.Length; i++) { - lhs[i] = rhs[i] * _inverseDiagonals[i]; + lhs[i] = rhs[i]*_inverseDiagonals[i]; } } } diff --git a/src/Numerics/LinearAlgebra/Double/Solvers/Preconditioners/Ilutp.cs b/src/Numerics/LinearAlgebra/Double/Solvers/Preconditioners/Ilutp.cs index b69a706f..e4b50ef9 100644 --- a/src/Numerics/LinearAlgebra/Double/Solvers/Preconditioners/Ilutp.cs +++ b/src/Numerics/LinearAlgebra/Double/Solvers/Preconditioners/Ilutp.cs @@ -63,36 +63,36 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Preconditioners /// The default drop tolerance. /// public const double DefaultDropTolerance = 0.0001; - + /// /// The decomposed upper triangular matrix. /// - private SparseMatrix _upper; + SparseMatrix _upper; /// /// The decomposed lower triangular matrix. /// - private SparseMatrix _lower; - + SparseMatrix _lower; + /// /// The array containing the pivot values. /// - private int[] _pivots; + int[] _pivots; /// /// The fill level. /// - private double _fillLevel = DefaultFillLevel; - + double _fillLevel = DefaultFillLevel; + /// /// The drop tolerance. /// - private double _dropTolerance = DefaultDropTolerance; - + double _dropTolerance = DefaultDropTolerance; + /// /// The pivot tolerance. /// - private double _pivotTolerance; + double _pivotTolerance; /// /// Initializes a new instance of the class with the default settings. @@ -138,7 +138,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Preconditioners _dropTolerance = dropTolerance; _pivotTolerance = pivotTolerance; } - + /// /// Gets or sets the amount of fill that is allowed in the matrix. The /// value is a fraction of the number of non-zero entries in the original @@ -161,11 +161,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Preconditioners /// Thrown if a negative value is provided. public double FillLevel { - get - { - return _fillLevel; - } - + get { return _fillLevel; } set { if (value < 0) @@ -196,11 +192,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Preconditioners /// Thrown if a negative value is provided. public double DropTolerance { - get - { - return _dropTolerance; - } - + get { return _dropTolerance; } set { if (value < 0) @@ -233,11 +225,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Preconditioners /// Thrown if a negative value is provided. public double PivotTolerance { - get - { - return _pivotTolerance; - } - + get { return _pivotTolerance; } set { if (value < 0) @@ -248,7 +236,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Preconditioners _pivotTolerance = value; } } - + /// /// Returns the upper triagonal matrix that was created during the LU decomposition. /// @@ -366,7 +354,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Preconditioners // Create the upper triangular matrix and copy the values _upper = new SparseMatrix(sparseMatrix.RowCount); - + // Create the pivot array _pivots = new int[sparseMatrix.RowCount]; for (var i = 0; i < _pivots.Length; i++) @@ -377,20 +365,20 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Preconditioners var workVector = new DenseVector(sparseMatrix.RowCount); var rowVector = new DenseVector(sparseMatrix.ColumnCount); var indexSorting = new int[sparseMatrix.RowCount]; - + // spaceLeft = lfilNnz * nnz(A) - var spaceLeft = (int)_fillLevel * sparseMatrix.NonZerosCount; - + var spaceLeft = (int) _fillLevel*sparseMatrix.NonZerosCount; + // for i = 1, .. , n for (var i = 0; i < sparseMatrix.RowCount; i++) { // w = a(i,*) sparseMatrix.Row(i, workVector); - + // pivot the row PivotRow(workVector); var vectorNorm = workVector.InfinityNorm(); - + // for j = 1, .. , i - 1) for (var j = 0; j < i; j++) { @@ -408,7 +396,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Preconditioners if (workVector[j] != 0.0) { // Calculate the multiplication factors that go into the L matrix - workVector[j] = workVector[j] / _upper[j, j]; + workVector[j] = workVector[j]/_upper[j, j]; if (Math.Abs(workVector[j]) < _dropTolerance) { workVector[j] = 0.0; @@ -440,19 +428,19 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Preconditioners // { // w(j) = 0 // } - if (Math.Abs(workVector[j]) <= _dropTolerance * vectorNorm) + if (Math.Abs(workVector[j]) <= _dropTolerance*vectorNorm) { workVector[j] = 0.0; } } // spaceRow = spaceLeft / (n - i + 1) // Determine the space for this row - var spaceRow = spaceLeft / (sparseMatrix.RowCount - i + 1); + var spaceRow = spaceLeft/(sparseMatrix.RowCount - i + 1); // lfil = spaceRow / 2 // space for this row of L - var fillLevel = spaceRow / 2; + var fillLevel = spaceRow/2; FindLargestItems(0, i - 1, indexSorting, workVector); - + // l(i,j) = w(j) for j = 1, .. , i -1 // only the largest lfil elements var lowerNonZeroCount = 0; var count = 0; @@ -469,10 +457,10 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Preconditioners } FindLargestItems(i + 1, sparseMatrix.RowCount - 1, indexSorting, workVector); - + // lfil = spaceRow - nnz(L(i,:)) // space for this row of U fillLevel = spaceRow - lowerNonZeroCount; - + // u(i,j) = w(j) for j = i + 1, .. , n // only the largest lfil - 1 elements var upperNonZeroCount = 0; count = 0; @@ -504,12 +492,12 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Preconditioners // -1 values. if ((i + 1) < (sparseMatrix.RowCount - 1)) { - if (Math.Abs(workVector[i]) < _pivotTolerance * Math.Abs(workVector[indexSorting[0]])) + if (Math.Abs(workVector[i]) < _pivotTolerance*Math.Abs(workVector[indexSorting[0]])) { // swap columns of u (which holds the values of A in the // sections that haven't been partitioned yet. SwapColumns(_upper, i, indexSorting[0]); - + // Update P var temp = _pivots[i]; _pivots[i] = _pivots[indexSorting[0]]; @@ -531,10 +519,10 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Preconditioners /// Pivot elements in the according to internal pivot array /// /// Row to pivot in - private void PivotRow(Vector row) + void PivotRow(Vector row) { var knownPivots = new Dictionary(); - + // pivot the row for (var i = 0; i < row.Count; i++) { @@ -556,7 +544,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Preconditioners /// Pivots already done /// Current item to pivot /// true if performed, otherwise false - private bool PivotMapFound(Dictionary knownPivots, int currentItem) + bool PivotMapFound(Dictionary knownPivots, int currentItem) { if (knownPivots.ContainsKey(_pivots[currentItem])) { @@ -583,7 +571,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Preconditioners /// Source . /// First column index to swap /// Second column index to swap - private static void SwapColumns(Matrix matrix, int firstColumn, int secondColumn) + static void SwapColumns(Matrix matrix, int firstColumn, int secondColumn) { for (var i = 0; i < matrix.RowCount; i++) { @@ -600,7 +588,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Preconditioners /// Sort till upper bound /// Array with sorted vector indicies /// Source - private static void FindLargestItems(int lowerBound, int upperBound, int[] sortedIndices, Vector values) + static void FindLargestItems(int lowerBound, int upperBound, int[] sortedIndices, Vector values) { // Copy the indices for the values into the array for (var i = 0; i < upperBound + 1 - lowerBound; i++) @@ -620,33 +608,6 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Preconditioners IlutpElementSorter.SortDoubleIndicesDecreasing(0, upperBound - lowerBound, sortedIndices, values); } - /// - /// Approximates the solution to the matrix equation Ax = b. - /// - /// The right hand side vector. - /// The left hand side vector. - public Vector Approximate(Vector rhs) - { - if (rhs == null) - { - throw new ArgumentNullException("rhs"); - } - - if (_upper == null) - { - throw new ArgumentException(Resources.ArgumentMatrixDoesNotExist); - } - - if (rhs.Count != _upper.ColumnCount) - { - throw new ArgumentException(Resources.ArgumentVectorsSameLength, "rhs"); - } - - var result = new DenseVector(rhs.Count); - Approximate(rhs, result); - return result; - } - /// /// Approximates the solution to the matrix equation Ax = b. /// @@ -654,16 +615,6 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Preconditioners /// The left hand side vector. Also known as the result vector. public void Approximate(Vector rhs, Vector lhs) { - if (rhs == null) - { - throw new ArgumentNullException("rhs"); - } - - if (lhs == null) - { - throw new ArgumentNullException("lhs"); - } - if (_upper == null) { throw new ArgumentException(Resources.ArgumentMatrixDoesNotExist); @@ -673,7 +624,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Preconditioners { throw new ArgumentException(Resources.ArgumentVectorsSameLength, "rhs"); } - + // Solve equation here // Pivot(vector, result); // Solve L*Y = B(piv,:) @@ -685,7 +636,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Preconditioners var sum = 0.0; for (var j = 0; j < i; j++) { - sum += rowValues[j] * lhs[j]; + sum += rowValues[j]*lhs[j]; } lhs[i] = rhs[i] - sum; @@ -699,16 +650,16 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Preconditioners var sum = 0.0; for (var j = _upper.RowCount - 1; j > i; j--) { - sum += rowValues[j] * lhs[j]; + sum += rowValues[j]*lhs[j]; } - lhs[i] = 1 / rowValues[i] * (lhs[i] - sum); + lhs[i] = 1/rowValues[i]*(lhs[i] - sum); } // We have a column pivot so we only need to pivot the // end result not the incoming right hand side vector var temp = lhs.Clone(); - + Pivot(temp, lhs); } @@ -717,7 +668,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Preconditioners /// /// Source . /// Result after pivoting. - private void Pivot(Vector vector, Vector result) + void Pivot(Vector vector, Vector result) { for (var i = 0; i < _pivots.Length; i++) { diff --git a/src/Numerics/LinearAlgebra/Double/Solvers/Preconditioners/IncompleteLU.cs b/src/Numerics/LinearAlgebra/Double/Solvers/Preconditioners/IncompleteLU.cs index be663f34..7f9fbb77 100644 --- a/src/Numerics/LinearAlgebra/Double/Solvers/Preconditioners/IncompleteLU.cs +++ b/src/Numerics/LinearAlgebra/Double/Solvers/Preconditioners/IncompleteLU.cs @@ -49,7 +49,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Preconditioners /// The matrix holding the lower (L) and upper (U) matrices. The /// decomposition matrices are combined to reduce storage. /// - private SparseMatrix _decompositionLU; + SparseMatrix _decompositionLU; /// /// Returns the upper triagonal matrix that was created during the LU decomposition. @@ -84,7 +84,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Preconditioners { result[i, j] = 1.0; } - else + else { result[i, j] = _decompositionLU[i, j]; } @@ -133,11 +133,11 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Preconditioners { if (_decompositionLU[i, k] != 0.0) { - var t = _decompositionLU[i, k] / _decompositionLU[k, k]; + var t = _decompositionLU[i, k]/_decompositionLU[k, k]; _decompositionLU[i, k] = t; if (_decompositionLU[k, i] != 0.0) { - _decompositionLU[i, i] = _decompositionLU[i, i] - (t * _decompositionLU[k, i]); + _decompositionLU[i, i] = _decompositionLU[i, i] - (t*_decompositionLU[k, i]); } for (var j = k + 1; j < _decompositionLU.RowCount; j++) @@ -149,7 +149,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Preconditioners if (_decompositionLU[i, j] != 0.0) { - _decompositionLU[i, j] = _decompositionLU[i, j] - (t * _decompositionLU[k, j]); + _decompositionLU[i, j] = _decompositionLU[i, j] - (t*_decompositionLU[k, j]); } } } @@ -157,33 +157,6 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Preconditioners } } - /// - /// Approximates the solution to the matrix equation Ax = b. - /// - /// The right hand side vector. - /// The left hand side vector. - public Vector Approximate(Vector rhs) - { - if (rhs == null) - { - throw new ArgumentNullException("rhs"); - } - - if (_decompositionLU == null) - { - throw new ArgumentException(Resources.ArgumentMatrixDoesNotExist); - } - - if (rhs.Count != _decompositionLU.ColumnCount) - { - throw new ArgumentException(Resources.ArgumentVectorsSameLength, "rhs"); - } - - var result = new DenseVector(rhs.Count); - Approximate(rhs, result); - return result; - } - /// /// Approximates the solution to the matrix equation Ax = b. /// @@ -191,16 +164,6 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Preconditioners /// The left hand side vector. Also known as the result vector. public void Approximate(Vector rhs, Vector lhs) { - if (rhs == null) - { - throw new ArgumentNullException("rhs"); - } - - if (lhs == null) - { - throw new ArgumentNullException("lhs"); - } - if (_decompositionLU == null) { throw new ArgumentException(Resources.ArgumentMatrixDoesNotExist); @@ -229,7 +192,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Preconditioners var sum = 0.0; for (var j = 0; j < i; j++) { - sum += rowValues[j] * lhs[j]; + sum += rowValues[j]*lhs[j]; } lhs[i] = rhs[i] - sum; @@ -249,10 +212,10 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Preconditioners var sum = 0.0; for (var j = _decompositionLU.RowCount - 1; j > i; j--) { - sum += rowValues[j] * lhs[j]; + sum += rowValues[j]*lhs[j]; } - lhs[i] = 1 / rowValues[i] * (lhs[i] - sum); + lhs[i] = 1/rowValues[i]*(lhs[i] - sum); } } } diff --git a/src/Numerics/LinearAlgebra/Single/Solvers/Iterator.cs b/src/Numerics/LinearAlgebra/Single/Solvers/Iterator.cs index 1ed924a1..e4352a6e 100644 --- a/src/Numerics/LinearAlgebra/Single/Solvers/Iterator.cs +++ b/src/Numerics/LinearAlgebra/Single/Solvers/Iterator.cs @@ -30,7 +30,6 @@ using MathNet.Numerics.LinearAlgebra.Single.Solvers.StopCriterium; using MathNet.Numerics.LinearAlgebra.Solvers; -using MathNet.Numerics.LinearAlgebra.Solvers.StopCriterium; namespace MathNet.Numerics.LinearAlgebra.Single.Solvers { diff --git a/src/Numerics/LinearAlgebra/Single/Solvers/Preconditioners/Diagonal.cs b/src/Numerics/LinearAlgebra/Single/Solvers/Preconditioners/Diagonal.cs index aa79081f..0678607f 100644 --- a/src/Numerics/LinearAlgebra/Single/Solvers/Preconditioners/Diagonal.cs +++ b/src/Numerics/LinearAlgebra/Single/Solvers/Preconditioners/Diagonal.cs @@ -43,7 +43,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Preconditioners /// /// The inverse of the matrix diagonal. /// - private float[] _inverseDiagonals; + float[] _inverseDiagonals; /// /// Returns the decomposed matrix diagonal. @@ -54,7 +54,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Preconditioners var result = new DiagonalMatrix(_inverseDiagonals.Length); for (var i = 0; i < _inverseDiagonals.Length; i++) { - result[i, i] = 1 / _inverseDiagonals[i]; + result[i, i] = 1/_inverseDiagonals[i]; } return result; @@ -69,11 +69,6 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Preconditioners /// If is not a square matrix. public void Initialize(Matrix matrix) { - if (matrix == null) - { - throw new ArgumentNullException("matrix"); - } - if (matrix.RowCount != matrix.ColumnCount) { throw new ArgumentException(Resources.ArgumentMatrixSquare, "matrix"); @@ -82,37 +77,10 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Preconditioners _inverseDiagonals = new float[matrix.RowCount]; for (var i = 0; i < matrix.RowCount; i++) { - _inverseDiagonals[i] = 1 / matrix[i, i]; + _inverseDiagonals[i] = 1/matrix[i, i]; } } - /// - /// Approximates the solution to the matrix equation Ax = b. - /// - /// The right hand side vector. - /// The left hand side vector. - public Vector Approximate(Vector rhs) - { - if (rhs == null) - { - throw new ArgumentNullException("rhs"); - } - - if (_inverseDiagonals == null) - { - throw new ArgumentException(Resources.ArgumentMatrixDoesNotExist); - } - - if (rhs.Count != _inverseDiagonals.Length) - { - throw new ArgumentException(Resources.ArgumentVectorsSameLength, "rhs"); - } - - var result = new DenseVector(rhs.Count); - Approximate(rhs, result); - return result; - } - /// /// Approximates the solution to the matrix equation Ax = b. /// @@ -120,16 +88,6 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Preconditioners /// The left hand side vector. Also known as the result vector. public void Approximate(Vector rhs, Vector lhs) { - if (rhs == null) - { - throw new ArgumentNullException("rhs"); - } - - if (lhs == null) - { - throw new ArgumentNullException("lhs"); - } - if (_inverseDiagonals == null) { throw new ArgumentException(Resources.ArgumentMatrixDoesNotExist); @@ -142,7 +100,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Preconditioners for (var i = 0; i < _inverseDiagonals.Length; i++) { - lhs[i] = rhs[i] * _inverseDiagonals[i]; + lhs[i] = rhs[i]*_inverseDiagonals[i]; } } } diff --git a/src/Numerics/LinearAlgebra/Single/Solvers/Preconditioners/Ilutp.cs b/src/Numerics/LinearAlgebra/Single/Solvers/Preconditioners/Ilutp.cs index b6ed9c56..169cf789 100644 --- a/src/Numerics/LinearAlgebra/Single/Solvers/Preconditioners/Ilutp.cs +++ b/src/Numerics/LinearAlgebra/Single/Solvers/Preconditioners/Ilutp.cs @@ -63,36 +63,36 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Preconditioners /// The default drop tolerance. /// public const double DefaultDropTolerance = 0.0001; - + /// /// The decomposed upper triangular matrix. /// - private SparseMatrix _upper; + SparseMatrix _upper; /// /// The decomposed lower triangular matrix. /// - private SparseMatrix _lower; - + SparseMatrix _lower; + /// /// The array containing the pivot values. /// - private int[] _pivots; + int[] _pivots; /// /// The fill level. /// - private double _fillLevel = DefaultFillLevel; - + double _fillLevel = DefaultFillLevel; + /// /// The drop tolerance. /// - private double _dropTolerance = DefaultDropTolerance; - + double _dropTolerance = DefaultDropTolerance; + /// /// The pivot tolerance. /// - private double _pivotTolerance; + double _pivotTolerance; /// /// Initializes a new instance of the class with the default settings. @@ -138,7 +138,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Preconditioners _dropTolerance = dropTolerance; _pivotTolerance = pivotTolerance; } - + /// /// Gets or sets the amount of fill that is allowed in the matrix. The /// value is a fraction of the number of non-zero entries in the original @@ -161,11 +161,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Preconditioners /// Thrown if a negative value is provided. public double FillLevel { - get - { - return _fillLevel; - } - + get { return _fillLevel; } set { if (value < 0) @@ -196,11 +192,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Preconditioners /// Thrown if a negative value is provided. public double DropTolerance { - get - { - return _dropTolerance; - } - + get { return _dropTolerance; } set { if (value < 0) @@ -233,11 +225,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Preconditioners /// Thrown if a negative value is provided. public double PivotTolerance { - get - { - return _pivotTolerance; - } - + get { return _pivotTolerance; } set { if (value < 0) @@ -248,7 +236,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Preconditioners _pivotTolerance = value; } } - + /// /// Returns the upper triagonal matrix that was created during the LU decomposition. /// @@ -366,7 +354,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Preconditioners // Create the upper triangular matrix and copy the values _upper = new SparseMatrix(sparseMatrix.RowCount); - + // Create the pivot array _pivots = new int[sparseMatrix.RowCount]; for (var i = 0; i < _pivots.Length; i++) @@ -377,20 +365,20 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Preconditioners var workVector = new DenseVector(sparseMatrix.RowCount); var rowVector = new DenseVector(sparseMatrix.ColumnCount); var indexSorting = new int[sparseMatrix.RowCount]; - + // spaceLeft = lfilNnz * nnz(A) - var spaceLeft = (int)_fillLevel * sparseMatrix.NonZerosCount; - + var spaceLeft = (int) _fillLevel*sparseMatrix.NonZerosCount; + // for i = 1, .. , n for (var i = 0; i < sparseMatrix.RowCount; i++) { // w = a(i,*) sparseMatrix.Row(i, workVector); - + // pivot the row PivotRow(workVector); var vectorNorm = workVector.InfinityNorm(); - + // for j = 1, .. , i - 1) for (var j = 0; j < i; j++) { @@ -408,7 +396,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Preconditioners if (workVector[j] != 0.0) { // Calculate the multiplication factors that go into the L matrix - workVector[j] = workVector[j] / _upper[j, j]; + workVector[j] = workVector[j]/_upper[j, j]; if (Math.Abs(workVector[j]) < _dropTolerance) { workVector[j] = 0.0f; @@ -440,19 +428,19 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Preconditioners // { // w(j) = 0 // } - if (Math.Abs(workVector[j]) <= _dropTolerance * vectorNorm) + if (Math.Abs(workVector[j]) <= _dropTolerance*vectorNorm) { workVector[j] = 0.0f; } } // spaceRow = spaceLeft / (n - i + 1) // Determine the space for this row - var spaceRow = spaceLeft / (sparseMatrix.RowCount - i + 1); + var spaceRow = spaceLeft/(sparseMatrix.RowCount - i + 1); // lfil = spaceRow / 2 // space for this row of L - var fillLevel = spaceRow / 2; + var fillLevel = spaceRow/2; FindLargestItems(0, i - 1, indexSorting, workVector); - + // l(i,j) = w(j) for j = 1, .. , i -1 // only the largest lfil elements var lowerNonZeroCount = 0; var count = 0; @@ -469,10 +457,10 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Preconditioners } FindLargestItems(i + 1, sparseMatrix.RowCount - 1, indexSorting, workVector); - + // lfil = spaceRow - nnz(L(i,:)) // space for this row of U fillLevel = spaceRow - lowerNonZeroCount; - + // u(i,j) = w(j) for j = i + 1, .. , n // only the largest lfil - 1 elements var upperNonZeroCount = 0; count = 0; @@ -504,12 +492,12 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Preconditioners // -1 values. if ((i + 1) < (sparseMatrix.RowCount - 1)) { - if (Math.Abs(workVector[i]) < _pivotTolerance * Math.Abs(workVector[indexSorting[0]])) + if (Math.Abs(workVector[i]) < _pivotTolerance*Math.Abs(workVector[indexSorting[0]])) { // swap columns of u (which holds the values of A in the // sections that haven't been partitioned yet. SwapColumns(_upper, i, indexSorting[0]); - + // Update P var temp = _pivots[i]; _pivots[i] = _pivots[indexSorting[0]]; @@ -531,10 +519,10 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Preconditioners /// Pivot elements in the according to internal pivot array /// /// Row to pivot in - private void PivotRow(Vector row) + void PivotRow(Vector row) { var knownPivots = new Dictionary(); - + // pivot the row for (var i = 0; i < row.Count; i++) { @@ -556,7 +544,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Preconditioners /// Pivots already done /// Current item to pivot /// true if performed, otherwise false - private bool PivotMapFound(Dictionary knownPivots, int currentItem) + bool PivotMapFound(Dictionary knownPivots, int currentItem) { if (knownPivots.ContainsKey(_pivots[currentItem])) { @@ -583,7 +571,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Preconditioners /// Source . /// First column index to swap /// Second column index to swap - private static void SwapColumns(Matrix matrix, int firstColumn, int secondColumn) + static void SwapColumns(Matrix matrix, int firstColumn, int secondColumn) { for (var i = 0; i < matrix.RowCount; i++) { @@ -600,7 +588,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Preconditioners /// Sort till upper bound /// Array with sorted vector indicies /// Source - private static void FindLargestItems(int lowerBound, int upperBound, int[] sortedIndices, Vector values) + static void FindLargestItems(int lowerBound, int upperBound, int[] sortedIndices, Vector values) { // Copy the indices for the values into the array for (var i = 0; i < upperBound + 1 - lowerBound; i++) @@ -620,33 +608,6 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Preconditioners IlutpElementSorter.SortDoubleIndicesDecreasing(0, upperBound - lowerBound, sortedIndices, values); } - /// - /// Approximates the solution to the matrix equation Ax = b. - /// - /// The right hand side vector. - /// The left hand side vector. - public Vector Approximate(Vector rhs) - { - if (rhs == null) - { - throw new ArgumentNullException("rhs"); - } - - if (_upper == null) - { - throw new ArgumentException(Resources.ArgumentMatrixDoesNotExist); - } - - if (rhs.Count != _upper.ColumnCount) - { - throw new ArgumentException(Resources.ArgumentVectorsSameLength, "rhs"); - } - - var result = new DenseVector(rhs.Count); - Approximate(rhs, result); - return result; - } - /// /// Approximates the solution to the matrix equation Ax = b. /// @@ -654,16 +615,6 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Preconditioners /// The left hand side vector. Also known as the result vector. public void Approximate(Vector rhs, Vector lhs) { - if (rhs == null) - { - throw new ArgumentNullException("rhs"); - } - - if (lhs == null) - { - throw new ArgumentNullException("lhs"); - } - if (_upper == null) { throw new ArgumentException(Resources.ArgumentMatrixDoesNotExist); @@ -673,7 +624,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Preconditioners { throw new ArgumentException(Resources.ArgumentVectorsSameLength, "rhs"); } - + // Solve equation here // Pivot(vector, result); // Solve L*Y = B(piv,:) @@ -685,7 +636,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Preconditioners var sum = 0.0f; for (var j = 0; j < i; j++) { - sum += rowValues[j] * lhs[j]; + sum += rowValues[j]*lhs[j]; } lhs[i] = rhs[i] - sum; @@ -699,16 +650,16 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Preconditioners var sum = 0.0f; for (var j = _upper.RowCount - 1; j > i; j--) { - sum += rowValues[j] * lhs[j]; + sum += rowValues[j]*lhs[j]; } - lhs[i] = 1 / rowValues[i] * (lhs[i] - sum); + lhs[i] = 1/rowValues[i]*(lhs[i] - sum); } // We have a column pivot so we only need to pivot the // end result not the incoming right hand side vector var temp = lhs.Clone(); - + Pivot(temp, lhs); } @@ -717,7 +668,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Preconditioners /// /// Source . /// Result after pivoting. - private void Pivot(Vector vector, Vector result) + void Pivot(Vector vector, Vector result) { for (var i = 0; i < _pivots.Length; i++) { diff --git a/src/Numerics/LinearAlgebra/Single/Solvers/Preconditioners/IncompleteLU.cs b/src/Numerics/LinearAlgebra/Single/Solvers/Preconditioners/IncompleteLU.cs index 6cf40b6b..56ed5f08 100644 --- a/src/Numerics/LinearAlgebra/Single/Solvers/Preconditioners/IncompleteLU.cs +++ b/src/Numerics/LinearAlgebra/Single/Solvers/Preconditioners/IncompleteLU.cs @@ -49,7 +49,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Preconditioners /// The matrix holding the lower (L) and upper (U) matrices. The /// decomposition matrices are combined to reduce storage. /// - private SparseMatrix _decompositionLU; + SparseMatrix _decompositionLU; /// /// Returns the upper triagonal matrix that was created during the LU decomposition. @@ -84,7 +84,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Preconditioners { result[i, j] = 1.0f; } - else + else { result[i, j] = _decompositionLU[i, j]; } @@ -133,11 +133,11 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Preconditioners { if (_decompositionLU[i, k] != 0.0) { - var t = _decompositionLU[i, k] / _decompositionLU[k, k]; + var t = _decompositionLU[i, k]/_decompositionLU[k, k]; _decompositionLU[i, k] = t; if (_decompositionLU[k, i] != 0.0) { - _decompositionLU[i, i] = _decompositionLU[i, i] - (t * _decompositionLU[k, i]); + _decompositionLU[i, i] = _decompositionLU[i, i] - (t*_decompositionLU[k, i]); } for (var j = k + 1; j < _decompositionLU.RowCount; j++) @@ -149,7 +149,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Preconditioners if (_decompositionLU[i, j] != 0.0) { - _decompositionLU[i, j] = _decompositionLU[i, j] - (t * _decompositionLU[k, j]); + _decompositionLU[i, j] = _decompositionLU[i, j] - (t*_decompositionLU[k, j]); } } } @@ -157,33 +157,6 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Preconditioners } } - /// - /// Approximates the solution to the matrix equation Ax = b. - /// - /// The right hand side vector. - /// The left hand side vector. - public Vector Approximate(Vector rhs) - { - if (rhs == null) - { - throw new ArgumentNullException("rhs"); - } - - if (_decompositionLU == null) - { - throw new ArgumentException(Resources.ArgumentMatrixDoesNotExist); - } - - if (rhs.Count != _decompositionLU.ColumnCount) - { - throw new ArgumentException(Resources.ArgumentVectorsSameLength, "rhs"); - } - - var result = new DenseVector(rhs.Count); - Approximate(rhs, result); - return result; - } - /// /// Approximates the solution to the matrix equation Ax = b. /// @@ -191,16 +164,6 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Preconditioners /// The left hand side vector. Also known as the result vector. public void Approximate(Vector rhs, Vector lhs) { - if (rhs == null) - { - throw new ArgumentNullException("rhs"); - } - - if (lhs == null) - { - throw new ArgumentNullException("lhs"); - } - if (_decompositionLU == null) { throw new ArgumentException(Resources.ArgumentMatrixDoesNotExist); @@ -229,7 +192,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Preconditioners var sum = 0.0f; for (var j = 0; j < i; j++) { - sum += rowValues[j] * lhs[j]; + sum += rowValues[j]*lhs[j]; } lhs[i] = rhs[i] - sum; @@ -249,10 +212,10 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Preconditioners var sum = 0.0f; for (var j = _decompositionLU.RowCount - 1; j > i; j--) { - sum += rowValues[j] * lhs[j]; + sum += rowValues[j]*lhs[j]; } - lhs[i] = 1 / rowValues[i] * (lhs[i] - sum); + lhs[i] = 1/rowValues[i]*(lhs[i] - sum); } } } diff --git a/src/Numerics/LinearAlgebra/Solvers/Status/ICalculationStatus.cs b/src/Numerics/LinearAlgebra/Solvers/ICalculationStatus.cs similarity index 96% rename from src/Numerics/LinearAlgebra/Solvers/Status/ICalculationStatus.cs rename to src/Numerics/LinearAlgebra/Solvers/ICalculationStatus.cs index 7b07f2b5..4b103fb9 100644 --- a/src/Numerics/LinearAlgebra/Solvers/Status/ICalculationStatus.cs +++ b/src/Numerics/LinearAlgebra/Solvers/ICalculationStatus.cs @@ -28,7 +28,7 @@ // OTHER DEALINGS IN THE SOFTWARE. // -namespace MathNet.Numerics.LinearAlgebra.Solvers.Status +namespace MathNet.Numerics.LinearAlgebra.Solvers { /// /// Defines the base interface for calculation status objects. diff --git a/src/Numerics/LinearAlgebra/Solvers/IIterationStopCriterium.cs b/src/Numerics/LinearAlgebra/Solvers/IIterationStopCriterium.cs index 608cfa71..b7366694 100644 --- a/src/Numerics/LinearAlgebra/Solvers/IIterationStopCriterium.cs +++ b/src/Numerics/LinearAlgebra/Solvers/IIterationStopCriterium.cs @@ -29,7 +29,6 @@ // using System; -using MathNet.Numerics.LinearAlgebra.Solvers.Status; namespace MathNet.Numerics.LinearAlgebra.Solvers { diff --git a/src/Numerics/LinearAlgebra/Solvers/IIterativeSolver.cs b/src/Numerics/LinearAlgebra/Solvers/IIterativeSolver.cs index f6240297..379c3007 100644 --- a/src/Numerics/LinearAlgebra/Solvers/IIterativeSolver.cs +++ b/src/Numerics/LinearAlgebra/Solvers/IIterativeSolver.cs @@ -4,7 +4,7 @@ // http://github.com/mathnet/mathnet-numerics // http://mathnetnumerics.codeplex.com // -// Copyright (c) 2009-2010 Math.NET +// Copyright (c) 2009-2013 Math.NET // // Permission is hereby granted, free of charge, to any person // obtaining a copy of this software and associated documentation @@ -29,7 +29,6 @@ // using System; -using MathNet.Numerics.LinearAlgebra.Solvers.Status; namespace MathNet.Numerics.LinearAlgebra.Solvers { diff --git a/src/Numerics/LinearAlgebra/Solvers/IIterativeSolverSetup.cs b/src/Numerics/LinearAlgebra/Solvers/IIterativeSolverSetup.cs index d7f0fff3..ad5124e6 100644 --- a/src/Numerics/LinearAlgebra/Solvers/IIterativeSolverSetup.cs +++ b/src/Numerics/LinearAlgebra/Solvers/IIterativeSolverSetup.cs @@ -4,7 +4,7 @@ // http://github.com/mathnet/mathnet-numerics // http://mathnetnumerics.codeplex.com // -// Copyright (c) 2009-2010 Math.NET +// Copyright (c) 2009-2013 Math.NET // // Permission is hereby granted, free of charge, to any person // obtaining a copy of this software and associated documentation @@ -68,4 +68,4 @@ namespace MathNet.Numerics.LinearAlgebra.Solvers /// Returns a value between 0 and 1 inclusive. double Reliability { get; } } -} \ No newline at end of file +} diff --git a/src/Numerics/LinearAlgebra/Solvers/IIterator.cs b/src/Numerics/LinearAlgebra/Solvers/IIterator.cs index 258c0415..571b66fc 100644 --- a/src/Numerics/LinearAlgebra/Solvers/IIterator.cs +++ b/src/Numerics/LinearAlgebra/Solvers/IIterator.cs @@ -29,8 +29,6 @@ // using System; -using MathNet.Numerics.LinearAlgebra.Solvers.Status; -using MathNet.Numerics.LinearAlgebra.Solvers.StopCriterium; namespace MathNet.Numerics.LinearAlgebra.Solvers { @@ -39,28 +37,6 @@ namespace MathNet.Numerics.LinearAlgebra.Solvers /// public interface IIterator where T : struct, IEquatable, IFormattable { - /// - /// Adds an to the internal collection of stop-criteria. Only a - /// single stop criterium of each type can be stored. - /// - /// The stop criterium to add. - /// Thrown if is . - /// Thrown if is of the same type as an already stored criterium. - void Add(IIterationStopCriterium stopCriterium); - - /// - /// Removes the from the internal collection. - /// - /// The stop criterium that must be removed. - void Remove(IIterationStopCriterium stopCriterium); - - /// - /// Indicates if the specific stop criterium is stored by the . - /// - /// The stop criterium. - /// true if the contains the stop criterium; otherwise false. - bool Contains(IIterationStopCriterium stopCriterium); - /// /// Indicates to the iterator that the iterative process has been cancelled. /// @@ -97,7 +73,5 @@ namespace MathNet.Numerics.LinearAlgebra.Solvers /// calculation. /// void ResetToPrecalculationState(); - - IIterator Clone(); } } diff --git a/src/Numerics/LinearAlgebra/Solvers/IPreConditioner.cs b/src/Numerics/LinearAlgebra/Solvers/IPreConditioner.cs index db4c183f..098c1522 100644 --- a/src/Numerics/LinearAlgebra/Solvers/IPreConditioner.cs +++ b/src/Numerics/LinearAlgebra/Solvers/IPreConditioner.cs @@ -58,13 +58,6 @@ namespace MathNet.Numerics.LinearAlgebra.Solvers /// The matrix on which the preconditioner is based. void Initialize(Matrix matrix); - /// - /// Approximates the solution to the matrix equation Mx = b. - /// - /// The right hand side vector. - /// The left hand side vector. - Vector Approximate(Vector rhs); - /// /// Approximates the solution to the matrix equation Mx = b. /// diff --git a/src/Numerics/LinearAlgebra/Solvers/IterationCountStopCriterium.cs b/src/Numerics/LinearAlgebra/Solvers/IterationCountStopCriterium.cs index f59b93f6..d9667b35 100644 --- a/src/Numerics/LinearAlgebra/Solvers/IterationCountStopCriterium.cs +++ b/src/Numerics/LinearAlgebra/Solvers/IterationCountStopCriterium.cs @@ -4,7 +4,7 @@ // http://github.com/mathnet/mathnet-numerics // http://mathnetnumerics.codeplex.com // -// Copyright (c) 2009-2010 Math.NET +// Copyright (c) 2009-2013 Math.NET // // Permission is hereby granted, free of charge, to any person // obtaining a copy of this software and associated documentation @@ -32,7 +32,7 @@ using System; using System.Diagnostics; using MathNet.Numerics.LinearAlgebra.Solvers.Status; -namespace MathNet.Numerics.LinearAlgebra.Solvers.StopCriterium +namespace MathNet.Numerics.LinearAlgebra.Solvers { /// /// Defines an that monitors the numbers of iteration @@ -49,17 +49,17 @@ namespace MathNet.Numerics.LinearAlgebra.Solvers.StopCriterium /// /// The default status. /// - private static readonly ICalculationStatus DefaultStatus = new CalculationIndetermined(); + static readonly ICalculationStatus DefaultStatus = new CalculationIndetermined(); /// /// The maximum number of iterations the calculation is allowed to perform. /// - private int _maximumNumberOfIterations; + int _maximumNumberOfIterations; /// /// The status of the calculation /// - private ICalculationStatus _status = DefaultStatus; + ICalculationStatus _status = DefaultStatus; /// /// Initializes a new instance of the class with the default maximum @@ -91,10 +91,7 @@ namespace MathNet.Numerics.LinearAlgebra.Solvers.StopCriterium public int MaximumNumberOfIterations { [DebuggerStepThrough] - get - { - return _maximumNumberOfIterations; - } + get { return _maximumNumberOfIterations; } [DebuggerStepThrough] set @@ -149,7 +146,7 @@ namespace MathNet.Numerics.LinearAlgebra.Solvers.StopCriterium /// /// Set status to /// - private void SetStatusToFinished() + void SetStatusToFinished() { if (!(_status is CalculationStoppedWithoutConvergence)) { @@ -160,7 +157,7 @@ namespace MathNet.Numerics.LinearAlgebra.Solvers.StopCriterium /// /// Set status to /// - private void SetStatusToRunning() + void SetStatusToRunning() { if (!(_status is CalculationRunning)) { @@ -174,10 +171,7 @@ namespace MathNet.Numerics.LinearAlgebra.Solvers.StopCriterium public ICalculationStatus Status { [DebuggerStepThrough] - get - { - return _status; - } + get { return _status; } } /// @@ -196,10 +190,7 @@ namespace MathNet.Numerics.LinearAlgebra.Solvers.StopCriterium public StopLevel StopLevel { [DebuggerStepThrough] - get - { - return StopLevel.StoppedWithoutConvergence; - } + get { return StopLevel.StoppedWithoutConvergence; } } /// diff --git a/src/Numerics/LinearAlgebra/Solvers/Iterator.cs b/src/Numerics/LinearAlgebra/Solvers/Iterator.cs index b4a303d7..6e3d2c05 100644 --- a/src/Numerics/LinearAlgebra/Solvers/Iterator.cs +++ b/src/Numerics/LinearAlgebra/Solvers/Iterator.cs @@ -4,7 +4,7 @@ // http://github.com/mathnet/mathnet-numerics // http://mathnetnumerics.codeplex.com // -// Copyright (c) 2009-2010 Math.NET +// Copyright (c) 2009-2013 Math.NET // // Permission is hereby granted, free of charge, to any person // obtaining a copy of this software and associated documentation @@ -32,7 +32,6 @@ using System; using System.Collections.Generic; using System.Linq; using MathNet.Numerics.LinearAlgebra.Solvers.Status; -using MathNet.Numerics.LinearAlgebra.Solvers.StopCriterium; using MathNet.Numerics.Properties; namespace MathNet.Numerics.LinearAlgebra.Solvers @@ -45,23 +44,23 @@ namespace MathNet.Numerics.LinearAlgebra.Solvers /// /// The default status for the iterator. /// - private static readonly ICalculationStatus DefaultStatus = new CalculationIndetermined(); + static readonly ICalculationStatus DefaultStatus = new CalculationIndetermined(); /// /// The collection that holds all the stop criteria and the flag indicating if they should be added /// to the child iterators. /// - private readonly Dictionary> _stopCriterias = new Dictionary>(); + readonly Dictionary> _stopCriterias = new Dictionary>(); /// /// The status of the iterator. /// - private ICalculationStatus _status = DefaultStatus; + ICalculationStatus _status = DefaultStatus; /// /// Indicates if the iteration was canceled. /// - private bool _wasIterationCancelled; + bool _wasIterationCancelled; /// /// Initializes a new instance of the class. @@ -97,25 +96,9 @@ namespace MathNet.Numerics.LinearAlgebra.Solvers /// single stop criterium of each type can be stored. /// /// The stop criterium to add. - /// Thrown if is . - /// - /// Thrown if is of the same type as an already - /// stored criterium. - /// public void Add(IIterationStopCriterium stopCriterium) { - if (stopCriterium == null) - { - throw new ArgumentNullException("stopCriterium"); - } - - if (_stopCriterias.ContainsKey(stopCriterium.GetType())) - { - throw new ArgumentException(Resources.StopCriteriumDuplicate); - } - - // Store the stop criterium. - _stopCriterias.Add(stopCriterium.GetType(), stopCriterium); + _stopCriterias[stopCriterium.GetType()] = stopCriterium; } /// @@ -124,17 +107,6 @@ namespace MathNet.Numerics.LinearAlgebra.Solvers /// The stop criterium that must be removed. public void Remove(IIterationStopCriterium stopCriterium) { - if (stopCriterium == null) - { - throw new ArgumentNullException("stopCriterium"); - } - - if (!_stopCriterias.ContainsKey(stopCriterium.GetType())) - { - return; - } - - // Remove from the collection _stopCriterias.Remove(stopCriterium.GetType()); } @@ -145,7 +117,7 @@ namespace MathNet.Numerics.LinearAlgebra.Solvers /// true if the contains the stop criterium; otherwise false. public bool Contains(IIterationStopCriterium stopCriterium) { - return stopCriterium != null && _stopCriterias.ContainsKey(stopCriterium.GetType()); + return _stopCriterias.ContainsKey(stopCriterium.GetType()); } /// @@ -154,10 +126,7 @@ namespace MathNet.Numerics.LinearAlgebra.Solvers /// Used for testing only. internal int NumberOfCriteria { - get - { - return _stopCriterias.Count; - } + get { return _stopCriterias.Count; } } /// @@ -166,10 +135,7 @@ namespace MathNet.Numerics.LinearAlgebra.Solvers /// Used for testing only. internal IEnumerable> StoredStopCriteria { - get - { - return _stopCriterias.Select(criterium => criterium.Value); - } + get { return _stopCriterias.Select(criterium => criterium.Value); } } /// @@ -209,21 +175,6 @@ namespace MathNet.Numerics.LinearAlgebra.Solvers throw new ArgumentOutOfRangeException("iterationNumber"); } - if (solutionVector == null) - { - throw new ArgumentNullException("solutionVector"); - } - - if (sourceVector == null) - { - throw new ArgumentNullException("sourceVector"); - } - - if (residualVector == null) - { - throw new ArgumentNullException("residualVector"); - } - // While we're cancelled we don't call on the stop-criteria. if (_wasIterationCancelled) { @@ -260,12 +211,9 @@ namespace MathNet.Numerics.LinearAlgebra.Solvers /// /// Gets the current calculation status. /// - public ICalculationStatus Status - { - get - { - return _status; - } + public ICalculationStatus Status + { + get { return _status; } } /// diff --git a/src/Numerics/LinearAlgebra/Solvers/UnitPreconditioner.cs b/src/Numerics/LinearAlgebra/Solvers/UnitPreconditioner.cs index d66c218b..25c6702a 100644 --- a/src/Numerics/LinearAlgebra/Solvers/UnitPreconditioner.cs +++ b/src/Numerics/LinearAlgebra/Solvers/UnitPreconditioner.cs @@ -44,23 +44,17 @@ namespace MathNet.Numerics.LinearAlgebra.Solvers /// The coefficient matrix on which this preconditioner operates. /// Is used to check dimensions on the different vectors that are processed. /// - private int _size; - + int _size; + /// /// Initializes the preconditioner and loads the internal data structures. /// /// /// The matrix upon which the preconditioner is based. /// - /// If is . /// If is not a square matrix. public void Initialize(Matrix matrix) { - if (matrix == null) - { - throw new ArgumentNullException("matrix"); - } - if (matrix.RowCount != matrix.ColumnCount) { throw new ArgumentException(Resources.ArgumentMatrixSquare, "matrix"); @@ -74,8 +68,6 @@ namespace MathNet.Numerics.LinearAlgebra.Solvers /// /// The right hand side vector. /// The left hand side vector. Also known as the result vector. - /// If is . - /// If is . /// /// /// If and do not have the same size. @@ -89,16 +81,6 @@ namespace MathNet.Numerics.LinearAlgebra.Solvers /// public void Approximate(Vector rhs, Vector lhs) { - if (rhs == null) - { - throw new ArgumentNullException("rhs"); - } - - if (lhs == null) - { - throw new ArgumentNullException("lhs"); - } - if ((lhs.Count != rhs.Count) || (lhs.Count != _size)) { throw new ArgumentException(Resources.ArgumentVectorsSameLength); @@ -106,31 +88,5 @@ namespace MathNet.Numerics.LinearAlgebra.Solvers rhs.CopyTo(lhs); } - - /// - /// Approximates the solution to the matrix equation Ax = b. - /// - /// The right hand side vector. - /// The left hand side vector. - /// If is . - /// - /// If the size of is different the number of rows of the coefficient matrix. - /// - public Vector Approximate(Vector rhs) - { - if (rhs == null) - { - throw new ArgumentNullException("rhs"); - } - - if (rhs.Count != _size) - { - throw new ArgumentException(Resources.ArgumentMatrixDimensions); - } - - var result = Vector.Builder.DenseVector(rhs.Count); - Approximate(rhs, result); - return result; - } } } diff --git a/src/Numerics/Numerics.csproj b/src/Numerics/Numerics.csproj index d9049a98..0a9a363b 100644 --- a/src/Numerics/Numerics.csproj +++ b/src/Numerics/Numerics.csproj @@ -353,7 +353,7 @@ - + diff --git a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/BiCgStabTest.cs b/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/BiCgStabTest.cs index 9f903fcf..8bb366ad 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/BiCgStabTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/BiCgStabTest.cs @@ -34,7 +34,6 @@ using MathNet.Numerics.LinearAlgebra.Complex.Solvers; using MathNet.Numerics.LinearAlgebra.Complex.Solvers.StopCriterium; using MathNet.Numerics.LinearAlgebra.Solvers; using MathNet.Numerics.LinearAlgebra.Solvers.Status; -using MathNet.Numerics.LinearAlgebra.Solvers.StopCriterium; using NUnit.Framework; namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterative diff --git a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/GpBiCgTest.cs b/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/GpBiCgTest.cs index 3cace2b4..3fae428e 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/GpBiCgTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/GpBiCgTest.cs @@ -34,7 +34,6 @@ using MathNet.Numerics.LinearAlgebra.Complex.Solvers; using MathNet.Numerics.LinearAlgebra.Complex.Solvers.StopCriterium; using MathNet.Numerics.LinearAlgebra.Solvers; using MathNet.Numerics.LinearAlgebra.Solvers.Status; -using MathNet.Numerics.LinearAlgebra.Solvers.StopCriterium; using NUnit.Framework; namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterative diff --git a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/MlkBiCgStabTest.cs b/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/MlkBiCgStabTest.cs index 88760e0f..c025c9f9 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/MlkBiCgStabTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/MlkBiCgStabTest.cs @@ -34,7 +34,6 @@ using MathNet.Numerics.LinearAlgebra.Complex.Solvers; using MathNet.Numerics.LinearAlgebra.Complex.Solvers.StopCriterium; using MathNet.Numerics.LinearAlgebra.Solvers; using MathNet.Numerics.LinearAlgebra.Solvers.Status; -using MathNet.Numerics.LinearAlgebra.Solvers.StopCriterium; using NUnit.Framework; namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterative diff --git a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/TFQMRTest.cs b/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/TFQMRTest.cs index 0f47e896..fe39f223 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/TFQMRTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/TFQMRTest.cs @@ -34,7 +34,6 @@ using MathNet.Numerics.LinearAlgebra.Complex.Solvers; using MathNet.Numerics.LinearAlgebra.Complex.Solvers.StopCriterium; using MathNet.Numerics.LinearAlgebra.Solvers; using MathNet.Numerics.LinearAlgebra.Solvers.Status; -using MathNet.Numerics.LinearAlgebra.Solvers.StopCriterium; using NUnit.Framework; namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterative diff --git a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/IteratorTest.cs b/src/UnitTests/LinearAlgebraTests/Complex/Solvers/IteratorTest.cs index df72aee0..b0f8ead1 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/IteratorTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/Solvers/IteratorTest.cs @@ -34,7 +34,6 @@ using MathNet.Numerics.LinearAlgebra.Complex; using MathNet.Numerics.LinearAlgebra.Complex.Solvers.StopCriterium; using MathNet.Numerics.LinearAlgebra.Solvers; using MathNet.Numerics.LinearAlgebra.Solvers.Status; -using MathNet.Numerics.LinearAlgebra.Solvers.StopCriterium; using NUnit.Framework; namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers @@ -80,19 +79,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers Assert.AreEqual(0, iterator.NumberOfCriteria, "There shouldn't be any criteria"); } - /// - /// Create with duplicates throws ArgumentException. - /// - [Test] - public void CreateWithDuplicatesThrowsArgumentException() - { - Assert.Throws(() => new Iterator(new IIterationStopCriterium[] - { - new FailureStopCriterium(), - new FailureStopCriterium() - })); - } - /// /// Can create with collection. /// @@ -117,29 +103,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers } } - /// - /// Add with null stop criterium throws ArgumentNullException. - /// - [Test] - public void AddWithNullStopCriteriumThrowsArgumentNullException() - { - var iterator = new Iterator(); - Assert.Throws(() => iterator.Add(null)); - } - - /// - /// Add with existing stop criterium throws ArgumentException. - /// - [Test] - public void AddWithExistingStopCriteriumThrowsArgumentException() - { - var iterator = new Iterator(); - iterator.Add(new FailureStopCriterium()); - Assert.AreEqual(1, iterator.NumberOfCriteria, "Incorrect criterium count"); - - Assert.Throws(() => iterator.Add(new FailureStopCriterium())); - } - /// /// Can add criterium. /// @@ -170,25 +133,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers } } - /// - /// Remove with null stop criterium throws ArgumentNullException. - /// - [Test] - public void RemoveWithNullStopCriteriumThrowsArgumentNullException() - { - var criteria = new List> - { - new FailureStopCriterium(), - new DivergenceStopCriterium(), - new IterationCountStopCriterium(), - new ResidualStopCriterium() - }; - var iterator = new Iterator(criteria); - Assert.AreEqual(criteria.Count, iterator.NumberOfCriteria, "Incorrect criterium count"); - - Assert.Throws(() => iterator.Remove(null)); - } - /// /// Can remove with non-existing stop criterium. /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Preconditioners/PreConditionerTest.cs b/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Preconditioners/PreConditionerTest.cs index de9b5ef0..29a150f2 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Preconditioners/PreConditionerTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Preconditioners/PreConditionerTest.cs @@ -96,25 +96,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi /// Result vector. protected abstract void CheckResult(IPreConditioner preconditioner, SparseMatrix matrix, Vector vector, Vector result); - /// - /// Approximate with a unit matrix returning new vector. - /// - [Test] - public void ApproximateWithUnitMatrixReturningNewVector() - { - const int Size = 10; - - var newMatrix = CreateUnitMatrix(Size); - var vector = CreateStandardBcVector(Size); - - var preconditioner = CreatePreconditioner(); - preconditioner.Initialize(newMatrix); - - var result = preconditioner.Approximate(vector); - - CheckResult(preconditioner, newMatrix, vector, result); - } - /// /// Approximate returning old vector. /// @@ -151,40 +132,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi Assert.Throws(() => preconditioner.Approximate(vector, result)); } - /// - /// Approximate with null vector throws ArgumentNullException. - /// - [Test] - public void ApproximateWithNullVectorThrowsArgumentNullException() - { - const int Size = 10; - var newMatrix = CreateUnitMatrix(Size); - var vector = CreateStandardBcVector(Size); - - var preconditioner = CreatePreconditioner(); - preconditioner.Initialize(newMatrix); - - var result = new DenseVector(vector.Count + 10); - Assert.Throws(() => preconditioner.Approximate(null, result)); - } - - /// - /// Approximate with null result vector throws ArgumentNullException. - /// - [Test] - public void ApproximateWithNullResultVectorThrowsArgumentNullException() - { - const int Size = 10; - var newMatrix = CreateUnitMatrix(Size); - var vector = CreateStandardBcVector(Size); - - var preconditioner = CreatePreconditioner(); - preconditioner.Initialize(newMatrix); - - Vector result = null; - Assert.Throws(() => preconditioner.Approximate(vector, result)); - } - /// /// Approximate with non initialized preconditioner throws ArgumentException. /// @@ -194,7 +141,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi const int Size = 10; var vector = CreateStandardBcVector(Size); var preconditioner = CreatePreconditioner(); - Assert.Throws(() => preconditioner.Approximate(vector)); + var result = new DenseVector(vector.Count); + Assert.Throws(() => preconditioner.Approximate(vector, result)); } } } diff --git a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/StopCriterium/IterationCountStopCriteriumTest.cs b/src/UnitTests/LinearAlgebraTests/Complex/Solvers/StopCriterium/IterationCountStopCriteriumTest.cs index c1850c6a..985b9a1b 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/StopCriterium/IterationCountStopCriteriumTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/Solvers/StopCriterium/IterationCountStopCriteriumTest.cs @@ -30,8 +30,8 @@ using System; using MathNet.Numerics.LinearAlgebra.Complex; +using MathNet.Numerics.LinearAlgebra.Solvers; using MathNet.Numerics.LinearAlgebra.Solvers.Status; -using MathNet.Numerics.LinearAlgebra.Solvers.StopCriterium; using NUnit.Framework; namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.StopCriterium diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/BiCgStabTest.cs b/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/BiCgStabTest.cs index 9847d1a9..9c0a887a 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/BiCgStabTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/BiCgStabTest.cs @@ -34,7 +34,6 @@ using MathNet.Numerics.LinearAlgebra.Complex32.Solvers; using MathNet.Numerics.LinearAlgebra.Complex32.Solvers.StopCriterium; using MathNet.Numerics.LinearAlgebra.Solvers; using MathNet.Numerics.LinearAlgebra.Solvers.Status; -using MathNet.Numerics.LinearAlgebra.Solvers.StopCriterium; using NUnit.Framework; namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterative diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/GpBiCgTest.cs b/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/GpBiCgTest.cs index b000a92a..3046f243 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/GpBiCgTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/GpBiCgTest.cs @@ -34,7 +34,6 @@ using MathNet.Numerics.LinearAlgebra.Complex32.Solvers; using MathNet.Numerics.LinearAlgebra.Complex32.Solvers.StopCriterium; using MathNet.Numerics.LinearAlgebra.Solvers; using MathNet.Numerics.LinearAlgebra.Solvers.Status; -using MathNet.Numerics.LinearAlgebra.Solvers.StopCriterium; using NUnit.Framework; namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterative diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/MlkBiCgStabTest.cs b/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/MlkBiCgStabTest.cs index d5403ef1..2327c755 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/MlkBiCgStabTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/MlkBiCgStabTest.cs @@ -34,7 +34,6 @@ using MathNet.Numerics.LinearAlgebra.Complex32.Solvers; using MathNet.Numerics.LinearAlgebra.Complex32.Solvers.StopCriterium; using MathNet.Numerics.LinearAlgebra.Solvers; using MathNet.Numerics.LinearAlgebra.Solvers.Status; -using MathNet.Numerics.LinearAlgebra.Solvers.StopCriterium; using NUnit.Framework; namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterative diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/TFQMRTest.cs b/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/TFQMRTest.cs index 2115bf71..abb6a3a1 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/TFQMRTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/TFQMRTest.cs @@ -34,7 +34,6 @@ using MathNet.Numerics.LinearAlgebra.Complex32.Solvers; using MathNet.Numerics.LinearAlgebra.Complex32.Solvers.StopCriterium; using MathNet.Numerics.LinearAlgebra.Solvers; using MathNet.Numerics.LinearAlgebra.Solvers.Status; -using MathNet.Numerics.LinearAlgebra.Solvers.StopCriterium; using NUnit.Framework; namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterative diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/IteratorTest.cs b/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/IteratorTest.cs index 344e7146..27f229a5 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/IteratorTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/IteratorTest.cs @@ -34,7 +34,6 @@ using MathNet.Numerics.LinearAlgebra.Complex32; using MathNet.Numerics.LinearAlgebra.Complex32.Solvers.StopCriterium; using MathNet.Numerics.LinearAlgebra.Solvers; using MathNet.Numerics.LinearAlgebra.Solvers.Status; -using MathNet.Numerics.LinearAlgebra.Solvers.StopCriterium; using NUnit.Framework; namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers @@ -80,19 +79,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers Assert.AreEqual(0, iterator.NumberOfCriteria, "There shouldn't be any criteria"); } - /// - /// Create with duplicates throws ArgumentException. - /// - [Test] - public void CreateWithDuplicatesThrowsArgumentException() - { - Assert.Throws(() => new Iterator(new IIterationStopCriterium[] - { - new FailureStopCriterium(), - new FailureStopCriterium() - })); - } - /// /// Can create with collection. /// @@ -117,29 +103,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers } } - /// - /// Add with null stop criterium throws ArgumentNullException. - /// - [Test] - public void AddWithNullStopCriteriumThrowsArgumentNullException() - { - var iterator = new Iterator(); - Assert.Throws(() => iterator.Add(null)); - } - - /// - /// Add with existing stop criterium throws ArgumentException. - /// - [Test] - public void AddWithExistingStopCriteriumThrowsArgumentException() - { - var iterator = new Iterator(); - iterator.Add(new FailureStopCriterium()); - Assert.AreEqual(1, iterator.NumberOfCriteria, "Incorrect criterium count"); - - Assert.Throws(() => iterator.Add(new FailureStopCriterium())); - } - /// /// Can add criterium. /// @@ -170,25 +133,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers } } - /// - /// Remove with null stop criterium throws ArgumentNullException. - /// - [Test] - public void RemoveWithNullStopCriteriumThrowsArgumentNullException() - { - var criteria = new List> - { - new FailureStopCriterium(), - new DivergenceStopCriterium(), - new IterationCountStopCriterium(), - new ResidualStopCriterium() - }; - var iterator = new Iterator(criteria); - Assert.AreEqual(criteria.Count, iterator.NumberOfCriteria, "Incorrect criterium count"); - - Assert.Throws(() => iterator.Remove(null)); - } - /// /// Can remove with non-existing stop criterium. /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Preconditioners/PreConditionerTest.cs b/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Preconditioners/PreConditionerTest.cs index bb784fe4..1b2c742d 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Preconditioners/PreConditionerTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Preconditioners/PreConditionerTest.cs @@ -89,25 +89,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon /// Result vector. protected abstract void CheckResult(IPreConditioner preconditioner, SparseMatrix matrix, Vector vector, Vector result); - /// - /// Approximate with a unit matrix returning new vector. - /// - [Test] - public void ApproximateWithUnitMatrixReturningNewVector() - { - const int Size = 10; - - var newMatrix = CreateUnitMatrix(Size); - var vector = CreateStandardBcVector(Size); - - var preconditioner = CreatePreconditioner(); - preconditioner.Initialize(newMatrix); - - var result = preconditioner.Approximate(vector); - - CheckResult(preconditioner, newMatrix, vector, result); - } - /// /// Approximate returning old vector. /// @@ -144,40 +125,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon Assert.Throws(() => preconditioner.Approximate(vector, result)); } - /// - /// Approximate with null vector throws ArgumentNullException. - /// - [Test] - public void ApproximateWithNullVectorThrowsArgumentNullException() - { - const int Size = 10; - var newMatrix = CreateUnitMatrix(Size); - var vector = CreateStandardBcVector(Size); - - var preconditioner = CreatePreconditioner(); - preconditioner.Initialize(newMatrix); - - var result = new DenseVector(vector.Count + 10); - Assert.Throws(() => preconditioner.Approximate(null, result)); - } - - /// - /// Approximate with null result vector throws ArgumentNullException. - /// - [Test] - public void ApproximateWithNullResultVectorThrowsArgumentNullException() - { - const int Size = 10; - var newMatrix = CreateUnitMatrix(Size); - var vector = CreateStandardBcVector(Size); - - var preconditioner = CreatePreconditioner(); - preconditioner.Initialize(newMatrix); - - Vector result = null; - Assert.Throws(() => preconditioner.Approximate(vector, result)); - } - /// /// Approximate with non initialized preconditioner throws ArgumentException. /// @@ -187,7 +134,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon const int Size = 10; var vector = CreateStandardBcVector(Size); var preconditioner = CreatePreconditioner(); - Assert.Throws(() => preconditioner.Approximate(vector)); + var result = new DenseVector(vector.Count); + Assert.Throws(() => preconditioner.Approximate(vector, result)); } } } diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/StopCriterium/IterationCountStopCriteriumTest.cs b/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/StopCriterium/IterationCountStopCriteriumTest.cs index 2fa7f967..9e638947 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/StopCriterium/IterationCountStopCriteriumTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/StopCriterium/IterationCountStopCriteriumTest.cs @@ -30,8 +30,8 @@ using System; using MathNet.Numerics.LinearAlgebra.Complex32; +using MathNet.Numerics.LinearAlgebra.Solvers; using MathNet.Numerics.LinearAlgebra.Solvers.Status; -using MathNet.Numerics.LinearAlgebra.Solvers.StopCriterium; using NUnit.Framework; namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.StopCriterium diff --git a/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/BiCgStabTest.cs b/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/BiCgStabTest.cs index 8224451a..5d942ade 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/BiCgStabTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/BiCgStabTest.cs @@ -34,7 +34,6 @@ using MathNet.Numerics.LinearAlgebra.Double.Solvers; using MathNet.Numerics.LinearAlgebra.Double.Solvers.StopCriterium; using MathNet.Numerics.LinearAlgebra.Solvers; using MathNet.Numerics.LinearAlgebra.Solvers.Status; -using MathNet.Numerics.LinearAlgebra.Solvers.StopCriterium; using NUnit.Framework; namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative diff --git a/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/GpBiCgTest.cs b/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/GpBiCgTest.cs index 85b4086c..9aa77417 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/GpBiCgTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/GpBiCgTest.cs @@ -34,7 +34,6 @@ using MathNet.Numerics.LinearAlgebra.Double.Solvers; using MathNet.Numerics.LinearAlgebra.Double.Solvers.StopCriterium; using MathNet.Numerics.LinearAlgebra.Solvers; using MathNet.Numerics.LinearAlgebra.Solvers.Status; -using MathNet.Numerics.LinearAlgebra.Solvers.StopCriterium; using NUnit.Framework; namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative diff --git a/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/MlkBiCgStabTest.cs b/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/MlkBiCgStabTest.cs index 4e66d11b..ae195d8c 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/MlkBiCgStabTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/MlkBiCgStabTest.cs @@ -34,7 +34,6 @@ using MathNet.Numerics.LinearAlgebra.Double.Solvers; using MathNet.Numerics.LinearAlgebra.Double.Solvers.StopCriterium; using MathNet.Numerics.LinearAlgebra.Solvers; using MathNet.Numerics.LinearAlgebra.Solvers.Status; -using MathNet.Numerics.LinearAlgebra.Solvers.StopCriterium; using NUnit.Framework; namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative diff --git a/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/TFQMRTest.cs b/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/TFQMRTest.cs index 212cbb5b..b048425a 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/TFQMRTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/TFQMRTest.cs @@ -34,7 +34,6 @@ using MathNet.Numerics.LinearAlgebra.Double.Solvers; using MathNet.Numerics.LinearAlgebra.Double.Solvers.StopCriterium; using MathNet.Numerics.LinearAlgebra.Solvers; using MathNet.Numerics.LinearAlgebra.Solvers.Status; -using MathNet.Numerics.LinearAlgebra.Solvers.StopCriterium; using NUnit.Framework; namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative diff --git a/src/UnitTests/LinearAlgebraTests/Double/Solvers/IteratorTest.cs b/src/UnitTests/LinearAlgebraTests/Double/Solvers/IteratorTest.cs index 82b6db6c..7bc00517 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/Solvers/IteratorTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/Solvers/IteratorTest.cs @@ -34,7 +34,6 @@ using MathNet.Numerics.LinearAlgebra.Double; using MathNet.Numerics.LinearAlgebra.Double.Solvers.StopCriterium; using MathNet.Numerics.LinearAlgebra.Solvers; using MathNet.Numerics.LinearAlgebra.Solvers.Status; -using MathNet.Numerics.LinearAlgebra.Solvers.StopCriterium; using NUnit.Framework; namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers @@ -78,19 +77,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers Assert.AreEqual(0, iterator.NumberOfCriteria, "There shouldn't be any criteria"); } - /// - /// Create with duplicates throws ArgumentException. - /// - [Test] - public void CreateWithDuplicatesThrowsArgumentException() - { - Assert.Throws(() => new Iterator(new IIterationStopCriterium[] - { - new FailureStopCriterium(), - new FailureStopCriterium() - })); - } - /// /// Can create with collection. /// @@ -115,29 +101,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers } } - /// - /// Add with null stop criterium throws ArgumentNullException. - /// - [Test] - public void AddWithNullStopCriteriumThrowsArgumentNullException() - { - var iterator = new Iterator(); - Assert.Throws(() => iterator.Add(null)); - } - - /// - /// Add with existing stop criterium throws ArgumentException. - /// - [Test] - public void AddWithExistingStopCriteriumThrowsArgumentException() - { - var iterator = new Iterator(); - iterator.Add(new FailureStopCriterium()); - Assert.AreEqual(1, iterator.NumberOfCriteria, "Incorrect criterium count"); - - Assert.Throws(() => iterator.Add(new FailureStopCriterium())); - } - /// /// Can add criterium. /// @@ -168,25 +131,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers } } - /// - /// Remove with null stop criterium throws ArgumentNullException. - /// - [Test] - public void RemoveWithNullStopCriteriumThrowsArgumentNullException() - { - var criteria = new List> - { - new FailureStopCriterium(), - new DivergenceStopCriterium(), - new IterationCountStopCriterium(), - new ResidualStopCriterium() - }; - var iterator = new Iterator(criteria); - Assert.AreEqual(criteria.Count, iterator.NumberOfCriteria, "Incorrect criterium count"); - - Assert.Throws(() => iterator.Remove(null)); - } - /// /// Can remove with non-existing stop criterium. /// diff --git a/src/UnitTests/LinearAlgebraTests/Double/Solvers/Preconditioners/PreConditionerTest.cs b/src/UnitTests/LinearAlgebraTests/Double/Solvers/Preconditioners/PreConditionerTest.cs index d139a4f6..671e62b6 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/Solvers/Preconditioners/PreConditionerTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/Solvers/Preconditioners/PreConditionerTest.cs @@ -87,25 +87,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit /// Result vector. protected abstract void CheckResult(IPreConditioner preconditioner, SparseMatrix matrix, Vector vector, Vector result); - /// - /// Approximate with a unit matrix returning new vector. - /// - [Test] - public void ApproximateWithUnitMatrixReturningNewVector() - { - const int Size = 10; - - var newMatrix = CreateUnitMatrix(Size); - var vector = CreateStandardBcVector(Size); - - var preconditioner = CreatePreconditioner(); - preconditioner.Initialize(newMatrix); - - var result = preconditioner.Approximate(vector); - - CheckResult(preconditioner, newMatrix, vector, result); - } - /// /// Approximate returning old vector. /// @@ -142,40 +123,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit Assert.Throws(() => preconditioner.Approximate(vector, result)); } - /// - /// Approximate with null vector throws ArgumentNullException. - /// - [Test] - public void ApproximateWithNullVectorThrowsArgumentNullException() - { - const int Size = 10; - var newMatrix = CreateUnitMatrix(Size); - var vector = CreateStandardBcVector(Size); - - var preconditioner = CreatePreconditioner(); - preconditioner.Initialize(newMatrix); - - var result = new DenseVector(vector.Count + 10); - Assert.Throws(() => preconditioner.Approximate(null, result)); - } - - /// - /// Approximate with null result vector throws ArgumentNullException. - /// - [Test] - public void ApproximateWithNullResultVectorThrowsArgumentNullException() - { - const int Size = 10; - var newMatrix = CreateUnitMatrix(Size); - var vector = CreateStandardBcVector(Size); - - var preconditioner = CreatePreconditioner(); - preconditioner.Initialize(newMatrix); - - Vector result = null; - Assert.Throws(() => preconditioner.Approximate(vector, result)); - } - /// /// Approximate with non initialized preconditioner throws ArgumentException. /// @@ -185,7 +132,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit const int Size = 10; var vector = CreateStandardBcVector(Size); var preconditioner = CreatePreconditioner(); - Assert.Throws(() => preconditioner.Approximate(vector)); + var result = new DenseVector(vector.Count); + Assert.Throws(() => preconditioner.Approximate(vector, result)); } } } diff --git a/src/UnitTests/LinearAlgebraTests/Double/Solvers/StopCriterium/IterationCountStopCriteriumTest.cs b/src/UnitTests/LinearAlgebraTests/Double/Solvers/StopCriterium/IterationCountStopCriteriumTest.cs index 574cdd8c..566dd755 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/Solvers/StopCriterium/IterationCountStopCriteriumTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/Solvers/StopCriterium/IterationCountStopCriteriumTest.cs @@ -30,8 +30,8 @@ using System; using MathNet.Numerics.LinearAlgebra.Double; +using MathNet.Numerics.LinearAlgebra.Solvers; using MathNet.Numerics.LinearAlgebra.Solvers.Status; -using MathNet.Numerics.LinearAlgebra.Solvers.StopCriterium; using NUnit.Framework; namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.StopCriterium diff --git a/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/BiCgStabTest.cs b/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/BiCgStabTest.cs index 444e57d6..6b2a3ade 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/BiCgStabTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/BiCgStabTest.cs @@ -34,7 +34,6 @@ using MathNet.Numerics.LinearAlgebra.Single.Solvers; using MathNet.Numerics.LinearAlgebra.Single.Solvers.StopCriterium; using MathNet.Numerics.LinearAlgebra.Solvers; using MathNet.Numerics.LinearAlgebra.Solvers.Status; -using MathNet.Numerics.LinearAlgebra.Solvers.StopCriterium; using NUnit.Framework; namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative diff --git a/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/GpBiCgTest.cs b/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/GpBiCgTest.cs index d18f7495..2dbb2e1c 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/GpBiCgTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/GpBiCgTest.cs @@ -34,7 +34,6 @@ using MathNet.Numerics.LinearAlgebra.Single.Solvers; using MathNet.Numerics.LinearAlgebra.Single.Solvers.StopCriterium; using MathNet.Numerics.LinearAlgebra.Solvers; using MathNet.Numerics.LinearAlgebra.Solvers.Status; -using MathNet.Numerics.LinearAlgebra.Solvers.StopCriterium; using NUnit.Framework; namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative diff --git a/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/MlkBiCgStabTest.cs b/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/MlkBiCgStabTest.cs index ecb2a9dc..e980630c 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/MlkBiCgStabTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/MlkBiCgStabTest.cs @@ -35,7 +35,6 @@ using MathNet.Numerics.LinearAlgebra.Single.Solvers; using MathNet.Numerics.LinearAlgebra.Single.Solvers.StopCriterium; using MathNet.Numerics.LinearAlgebra.Solvers; using MathNet.Numerics.LinearAlgebra.Solvers.Status; -using MathNet.Numerics.LinearAlgebra.Solvers.StopCriterium; using NUnit.Framework; namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative diff --git a/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/TFQMRTest.cs b/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/TFQMRTest.cs index d7ec4401..87869135 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/TFQMRTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/TFQMRTest.cs @@ -34,7 +34,6 @@ using MathNet.Numerics.LinearAlgebra.Single.Solvers; using MathNet.Numerics.LinearAlgebra.Single.Solvers.StopCriterium; using MathNet.Numerics.LinearAlgebra.Solvers; using MathNet.Numerics.LinearAlgebra.Solvers.Status; -using MathNet.Numerics.LinearAlgebra.Solvers.StopCriterium; using NUnit.Framework; namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative diff --git a/src/UnitTests/LinearAlgebraTests/Single/Solvers/IteratorTest.cs b/src/UnitTests/LinearAlgebraTests/Single/Solvers/IteratorTest.cs index 6b9163d0..bf3f8e44 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/Solvers/IteratorTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/Solvers/IteratorTest.cs @@ -34,7 +34,6 @@ using MathNet.Numerics.LinearAlgebra.Single; using MathNet.Numerics.LinearAlgebra.Single.Solvers.StopCriterium; using MathNet.Numerics.LinearAlgebra.Solvers; using MathNet.Numerics.LinearAlgebra.Solvers.Status; -using MathNet.Numerics.LinearAlgebra.Solvers.StopCriterium; using NUnit.Framework; namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers @@ -78,19 +77,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers Assert.AreEqual(0, iterator.NumberOfCriteria, "There shouldn't be any criteria"); } - /// - /// Create with duplicates throws ArgumentException. - /// - [Test] - public void CreateWithDuplicatesThrowsArgumentException() - { - Assert.Throws(() => new Iterator(new IIterationStopCriterium[] - { - new FailureStopCriterium(), - new FailureStopCriterium() - })); - } - /// /// Can create with collection. /// @@ -115,29 +101,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers } } - /// - /// Add with null stop criterium throws ArgumentNullException. - /// - [Test] - public void AddWithNullStopCriteriumThrowsArgumentNullException() - { - var iterator = new Iterator(); - Assert.Throws(() => iterator.Add(null)); - } - - /// - /// Add with existing stop criterium throws ArgumentException. - /// - [Test] - public void AddWithExistingStopCriteriumThrowsArgumentException() - { - var iterator = new Iterator(); - iterator.Add(new FailureStopCriterium()); - Assert.AreEqual(1, iterator.NumberOfCriteria, "Incorrect criterium count"); - - Assert.Throws(() => iterator.Add(new FailureStopCriterium())); - } - /// /// Can add criterium. /// @@ -168,25 +131,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers } } - /// - /// Remove with null stop criterium throws ArgumentNullException. - /// - [Test] - public void RemoveWithNullStopCriteriumThrowsArgumentNullException() - { - var criteria = new List> - { - new FailureStopCriterium(), - new DivergenceStopCriterium(), - new IterationCountStopCriterium(), - new ResidualStopCriterium() - }; - var iterator = new Iterator(criteria); - Assert.AreEqual(criteria.Count, iterator.NumberOfCriteria, "Incorrect criterium count"); - - Assert.Throws(() => iterator.Remove(null)); - } - /// /// Can remove with non-existing stop criterium. /// diff --git a/src/UnitTests/LinearAlgebraTests/Single/Solvers/Preconditioners/PreConditionerTest.cs b/src/UnitTests/LinearAlgebraTests/Single/Solvers/Preconditioners/PreConditionerTest.cs index a19019f9..9621e3b3 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/Solvers/Preconditioners/PreConditionerTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/Solvers/Preconditioners/PreConditionerTest.cs @@ -89,25 +89,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit /// Result vector. protected abstract void CheckResult(IPreConditioner preconditioner, SparseMatrix matrix, Vector vector, Vector result); - /// - /// Approximate with a unit matrix returning new vector. - /// - [Test] - public void ApproximateWithUnitMatrixReturningNewVector() - { - const int Size = 10; - - var newMatrix = CreateUnitMatrix(Size); - var vector = CreateStandardBcVector(Size); - - var preconditioner = CreatePreconditioner(); - preconditioner.Initialize(newMatrix); - - var result = preconditioner.Approximate(vector); - - CheckResult(preconditioner, newMatrix, vector, result); - } - /// /// Approximate returning old vector. /// @@ -144,40 +125,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit Assert.Throws(() => preconditioner.Approximate(vector, result)); } - /// - /// Approximate with null vector throws ArgumentNullException. - /// - [Test] - public void ApproximateWithNullVectorThrowsArgumentNullException() - { - const int Size = 10; - var newMatrix = CreateUnitMatrix(Size); - var vector = CreateStandardBcVector(Size); - - var preconditioner = CreatePreconditioner(); - preconditioner.Initialize(newMatrix); - - var result = new DenseVector(vector.Count + 10); - Assert.Throws(() => preconditioner.Approximate(null, result)); - } - - /// - /// Approximate with null result vector throws ArgumentNullException. - /// - [Test] - public void ApproximateWithNullResultVectorThrowsArgumentNullException() - { - const int Size = 10; - var newMatrix = CreateUnitMatrix(Size); - var vector = CreateStandardBcVector(Size); - - var preconditioner = CreatePreconditioner(); - preconditioner.Initialize(newMatrix); - - Vector result = null; - Assert.Throws(() => preconditioner.Approximate(vector, result)); - } - /// /// Approximate with non initialized preconditioner throws ArgumentException. /// @@ -187,7 +134,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit const int Size = 10; var vector = CreateStandardBcVector(Size); var preconditioner = CreatePreconditioner(); - Assert.Throws(() => preconditioner.Approximate(vector)); + var result = new DenseVector(vector.Count); + Assert.Throws(() => preconditioner.Approximate(vector, result)); } } } diff --git a/src/UnitTests/LinearAlgebraTests/Single/Solvers/StopCriterium/IterationCountStopCriteriumTest.cs b/src/UnitTests/LinearAlgebraTests/Single/Solvers/StopCriterium/IterationCountStopCriteriumTest.cs index ddb6bf18..c86d58e2 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/Solvers/StopCriterium/IterationCountStopCriteriumTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/Solvers/StopCriterium/IterationCountStopCriteriumTest.cs @@ -30,8 +30,8 @@ using System; using MathNet.Numerics.LinearAlgebra.Single; +using MathNet.Numerics.LinearAlgebra.Solvers; using MathNet.Numerics.LinearAlgebra.Solvers.Status; -using MathNet.Numerics.LinearAlgebra.Solvers.StopCriterium; using NUnit.Framework; namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.StopCriterium