Browse Source

Cosmetics

optimization-1
Christoph Ruegg 13 years ago
parent
commit
8c9457cc8a
  1. 25
      src/Numerics/LinearAlgebra/Double/Solvers/MILU0Preconditioner.cs

25
src/Numerics/LinearAlgebra/Double/Solvers/MILU0Preconditioner.cs

@ -36,16 +36,9 @@ using MathNet.Numerics.Properties;
namespace MathNet.Numerics.LinearAlgebra.Double.Solvers namespace MathNet.Numerics.LinearAlgebra.Double.Solvers
{ {
/// <summary> /// <summary>
/// Milu0 is a simple milu(0) preconditioner. /// A simple milu(0) preconditioner.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// It is assumed that the the elements in the input matrix are ordered
/// in such a way that in each row the lower part comes first and then
/// the upper part. To get the correct ILU factorization, it is also
/// necessary to have the elements of L ordered by increasing column
/// number. It may therefore be necessary to sort the elements prior
/// to calling milu0.
///
/// Original Fortran code by Youcef Saad (07 January 2004) /// Original Fortran code by Youcef Saad (07 January 2004)
/// </remarks> /// </remarks>
public sealed class MILU0Preconditioner : IPreconditioner<double> public sealed class MILU0Preconditioner : IPreconditioner<double>
@ -78,11 +71,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers
/// <summary> /// <summary>
/// Gets a value indicating whether the preconditioner is initialized. /// Gets a value indicating whether the preconditioner is initialized.
/// </summary> /// </summary>
public bool IsInitialized public bool IsInitialized { get; private set; }
{
get;
private set;
}
/// <summary> /// <summary>
/// Initializes the preconditioner and loads the internal data structures. /// Initializes the preconditioner and loads the internal data structures.
@ -93,13 +82,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers
/// instance of SparseCompressedRowMatrixStorage.</exception> /// instance of SparseCompressedRowMatrixStorage.</exception>
public void Initialize(Matrix<double> matrix) public void Initialize(Matrix<double> matrix)
{ {
if (matrix == null)
{
throw new ArgumentNullException("matrix");
}
var csr = matrix.Storage as SparseCompressedRowMatrixStorage<double>; var csr = matrix.Storage as SparseCompressedRowMatrixStorage<double>;
if (csr == null) if (csr == null)
{ {
throw new ArgumentException("Matrix must be in sparse storage format", "matrix"); throw new ArgumentException("Matrix must be in sparse storage format", "matrix");
@ -107,15 +90,14 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers
// Dimension of matrix // Dimension of matrix
int n = csr.RowCount; int n = csr.RowCount;
if (n != csr.ColumnCount) if (n != csr.ColumnCount)
{ {
throw new ArgumentException(Resources.ArgumentMatrixSquare, "matrix"); throw new ArgumentException(Resources.ArgumentMatrixSquare, "matrix");
} }
// Original matrix compressed sparse row storage. // Original matrix compressed sparse row storage.
int[] ja = csr.ColumnIndices;
double[] a = csr.Values; double[] a = csr.Values;
int[] ja = csr.ColumnIndices;
int[] ia = csr.RowPointers; int[] ia = csr.RowPointers;
_alu = new double[ia.Length]; _alu = new double[ia.Length];
@ -123,7 +105,6 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers
_diag = new int[n]; _diag = new int[n];
int code = Compute(n, a, ja, ia, _alu, _jlu, _diag, UseModified); int code = Compute(n, a, ja, ia, _alu, _jlu, _diag, UseModified);
if (code > -1) if (code > -1)
{ {
throw new Exception("Zero pivot encountered on row " + code + " during ILU process"); throw new Exception("Zero pivot encountered on row " + code + " during ILU process");

Loading…
Cancel
Save