Browse Source

LA: make IIterativeSolver generic & shared

pull/163/head
Christoph Ruegg 13 years ago
parent
commit
d130913232
  1. 3
      src/Examples/LinearAlgebra/IterativeSolvers/CompositeSolverExample.cs
  2. 104
      src/Numerics/LinearAlgebra/Complex/Solvers/IIterativeSolver.cs
  3. 12
      src/Numerics/LinearAlgebra/Complex/Solvers/IIterativeSolverSetup.cs
  4. 2
      src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/BiCgStab.cs
  5. 6
      src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/CompositeSolver.cs
  6. 2
      src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/GpBiCg.cs
  7. 2
      src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/MlkBiCgStab.cs
  8. 2
      src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/TFQMR.cs
  9. 99
      src/Numerics/LinearAlgebra/Complex32/Solvers/IIterativeSolver.cs
  10. 9
      src/Numerics/LinearAlgebra/Complex32/Solvers/IIterativeSolverSetup.cs
  11. 2
      src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/BiCgStab.cs
  12. 6
      src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/CompositeSolver.cs
  13. 2
      src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/GpBiCg.cs
  14. 2
      src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/MlkBiCgStab.cs
  15. 2
      src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/TFQMR.cs
  16. 97
      src/Numerics/LinearAlgebra/Double/Solvers/IIterativeSolver.cs
  17. 4
      src/Numerics/LinearAlgebra/Double/Solvers/IIterativeSolverSetup.cs
  18. 2
      src/Numerics/LinearAlgebra/Double/Solvers/Iterative/BiCgStab.cs
  19. 6
      src/Numerics/LinearAlgebra/Double/Solvers/Iterative/CompositeSolver.cs
  20. 2
      src/Numerics/LinearAlgebra/Double/Solvers/Iterative/GpBiCg.cs
  21. 2
      src/Numerics/LinearAlgebra/Double/Solvers/Iterative/MlkBiCgStab.cs
  22. 2
      src/Numerics/LinearAlgebra/Double/Solvers/Iterative/TFQMR.cs
  23. 4
      src/Numerics/LinearAlgebra/Single/Solvers/IIterativeSolverSetup.cs
  24. 2
      src/Numerics/LinearAlgebra/Single/Solvers/Iterative/BiCgStab.cs
  25. 6
      src/Numerics/LinearAlgebra/Single/Solvers/Iterative/CompositeSolver.cs
  26. 2
      src/Numerics/LinearAlgebra/Single/Solvers/Iterative/GpBiCg.cs
  27. 2
      src/Numerics/LinearAlgebra/Single/Solvers/Iterative/MlkBiCgStab.cs
  28. 2
      src/Numerics/LinearAlgebra/Single/Solvers/Iterative/TFQMR.cs
  29. 20
      src/Numerics/LinearAlgebra/Solvers/IIterativeSolver.cs
  30. 5
      src/Numerics/Numerics.csproj

3
src/Examples/LinearAlgebra/IterativeSolvers/CompositeSolverExample.cs

@ -31,6 +31,7 @@ using MathNet.Numerics.LinearAlgebra.Double;
using MathNet.Numerics.LinearAlgebra.Double.Solvers;
using MathNet.Numerics.LinearAlgebra.Double.Solvers.Iterative;
using MathNet.Numerics.LinearAlgebra.Double.Solvers.StopCriterium;
using MathNet.Numerics.LinearAlgebra.Solvers;
using MathNet.Numerics.LinearAlgebra.Solvers.StopCriterium;
namespace Examples.LinearAlgebra.IterativeSolversExamples
@ -175,7 +176,7 @@ namespace Examples.LinearAlgebra.IterativeSolversExamples
/// given by this setup.
/// </summary>
/// <returns>A new <see cref="IIterativeSolver"/>.</returns>
public IIterativeSolver CreateNew()
public IIterativeSolver<double> CreateNew()
{
return new BiCgStab();
}

104
src/Numerics/LinearAlgebra/Complex/Solvers/IIterativeSolver.cs

@ -1,104 +0,0 @@
// <copyright file="IIterativeSolver.cs" company="Math.NET">
// Math.NET Numerics, part of the Math.NET Project
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
//
// Copyright (c) 2009-2010 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
using MathNet.Numerics.LinearAlgebra.Solvers;
using MathNet.Numerics.LinearAlgebra.Solvers.Status;
namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers
{
#if NOSYSNUMERICS
using Complex = Numerics.Complex;
#else
using Complex = System.Numerics.Complex;
#endif
/// <summary>
/// Defines the interface for <see cref="IIterativeSolver"/> classes that solve the matrix equation Ax = b in
/// an iterative manner.
/// </summary>
public interface IIterativeSolver
{
/// <summary>
/// Stops the solve process.
/// </summary>
/// <remarks>
/// Note that it may take an indetermined amount of time for the solver to actually stop the process.
/// </remarks>
void StopSolve();
/// <summary>
/// Sets the <see cref="IIterator"/> that will be used to track the iterative process.
/// </summary>
/// <param name="iterator">The iterator.</param>
void SetIterator(IIterator<Complex> iterator);
/// <summary>
/// Gets the status of the iteration once the calculation is finished.
/// </summary>
ICalculationStatus IterationResult { get; }
/// <summary>
/// Solves the matrix equation Ax = b, where A is the coefficient matrix, b is the
/// solution vector and x is the unknown vector.
/// </summary>
/// <param name="matrix">The coefficient matrix, <c>A</c>.</param>
/// <param name="vector">The solution vector, <c>b</c>.</param>
/// <returns>The result vector, <c>x</c>.</returns>
Vector<Complex> Solve(Matrix<Complex> matrix, Vector<Complex> vector);
/// <summary>
/// Solves the matrix equation Ax = b, where A is the coefficient matrix, b is the
/// solution vector and x is the unknown vector.
/// </summary>
/// <param name="matrix">The coefficient matrix, <c>A</c>.</param>
/// <param name="input">The solution vector, <c>b</c></param>
/// <param name="result">The result vector, <c>x</c></param>
void Solve(Matrix<Complex> matrix, Vector<Complex> input, Vector<Complex> result);
/// <summary>
/// Solves the matrix equation AX = B, where A is the coefficient matrix, B is the
/// solution matrix and X is the unknown matrix.
/// </summary>
/// <param name="matrix">The coefficient matrix, <c>A</c>.</param>
/// <param name="input">The solution matrix, <c>B</c>.</param>
/// <returns>The result matrix, <c>X</c>.</returns>
Matrix<Complex> Solve(Matrix<Complex> matrix, Matrix<Complex> input);
/// <summary>
/// Solves the matrix equation AX = B, where A is the coefficient matrix, B is the
/// solution matrix and X is the unknown matrix.
/// </summary>
/// <param name="matrix">The coefficient matrix, <c>A</c>.</param>
/// <param name="input">The solution matrix, <c>B</c>.</param>
/// <param name="result">The result matrix, <c>X</c></param>
void Solve(Matrix<Complex> matrix, Matrix<Complex> input, Matrix<Complex> result);
}
}

12
src/Numerics/LinearAlgebra/Complex/Solvers/IIterativeSolverSetup.cs

@ -28,9 +28,17 @@
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
using System;
using MathNet.Numerics.LinearAlgebra.Solvers;
namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers
{
using System;
#if NOSYSNUMERICS
using Complex = Numerics.Complex;
#else
using Complex = System.Numerics.Complex;
#endif
/// <summary>
/// Defines the interface for objects that can create an iterative solver with
@ -54,7 +62,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers
/// given by this setup.
/// </summary>
/// <returns>A new <see cref="IIterativeSolver"/>.</returns>
IIterativeSolver CreateNew();
IIterativeSolver<Complex> CreateNew();
/// <summary>
/// Gets the relative speed of the solver.

2
src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/BiCgStab.cs

@ -73,7 +73,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Iterative
/// solver.
/// </para>
/// </remarks>
public sealed class BiCgStab : IIterativeSolver
public sealed class BiCgStab : IIterativeSolver<Complex>
{
/// <summary>
/// The status used if there is no status, i.e. the solver hasn't run yet and there is no

6
src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/CompositeSolver.cs

@ -61,7 +61,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Iterative
/// Note that if an iterator is passed to this solver it will be used for all the sub-solvers.
/// </para>
/// </remarks>
public sealed class CompositeSolver : IIterativeSolver
public sealed class CompositeSolver : IIterativeSolver<Complex>
{
#region Internal class - DoubleComparer
/// <summary>
@ -340,7 +340,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Iterative
/// <summary>
/// The collection of solvers that will be used to
/// </summary>
private readonly List<IIterativeSolver> _solvers = new List<IIterativeSolver>();
private readonly List<IIterativeSolver<Complex>> _solvers = new List<IIterativeSolver<Complex>>();
/// <summary>
/// The status of the calculation.
@ -361,7 +361,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Iterative
/// The solver that is currently running. Reference is used to be able to stop the
/// solver if the user cancels the solve process.
/// </summary>
private IIterativeSolver _currentSolver;
private IIterativeSolver<Complex> _currentSolver;
/// <summary>
/// Initializes a new instance of the <see cref="CompositeSolver"/> class with the default iterator.

2
src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/GpBiCg.cs

@ -71,7 +71,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Iterative
/// solver.
/// </para>
/// </remarks>
public sealed class GpBiCg : IIterativeSolver
public sealed class GpBiCg : IIterativeSolver<Complex>
{
/// <summary>
/// The status used if there is no status, i.e. the solver hasn't run yet and there is no

2
src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/MlkBiCgStab.cs

@ -71,7 +71,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Iterative
/// solver.
/// </para>
/// </remarks>
public sealed class MlkBiCgStab : IIterativeSolver
public sealed class MlkBiCgStab : IIterativeSolver<Complex>
{
/// <summary>
/// The default number of starting vectors.

2
src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/TFQMR.cs

@ -61,7 +61,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Iterative
/// solver.
/// </para>
/// </remarks>
public sealed class TFQMR : IIterativeSolver
public sealed class TFQMR : IIterativeSolver<Complex>
{
/// <summary>
/// The status used if there is no status, i.e. the solver hasn't run yet and there is no

99
src/Numerics/LinearAlgebra/Complex32/Solvers/IIterativeSolver.cs

@ -1,99 +0,0 @@
// <copyright file="IIterativeSolver.cs" company="Math.NET">
// Math.NET Numerics, part of the Math.NET Project
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
//
// Copyright (c) 2009-2010 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
using MathNet.Numerics.LinearAlgebra.Solvers;
using MathNet.Numerics.LinearAlgebra.Solvers.Status;
namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers
{
using Numerics;
/// <summary>
/// Defines the interface for <see cref="IIterativeSolver"/> classes that solve the matrix equation Ax = b in
/// an iterative manner.
/// </summary>
public interface IIterativeSolver
{
/// <summary>
/// Stops the solve process.
/// </summary>
/// <remarks>
/// Note that it may take an indetermined amount of time for the solver to actually stop the process.
/// </remarks>
void StopSolve();
/// <summary>
/// Sets the <see cref="IIterator"/> that will be used to track the iterative process.
/// </summary>
/// <param name="iterator">The iterator.</param>
void SetIterator(IIterator<Complex32> iterator);
/// <summary>
/// Gets the status of the iteration once the calculation is finished.
/// </summary>
ICalculationStatus IterationResult { get; }
/// <summary>
/// Solves the matrix equation Ax = b, where A is the coefficient matrix, b is the
/// solution vector and x is the unknown vector.
/// </summary>
/// <param name="matrix">The coefficient matrix, <c>A</c>.</param>
/// <param name="vector">The solution vector, <c>b</c>.</param>
/// <returns>The result vector, <c>x</c>.</returns>
Vector<Complex32> Solve(Matrix<Complex32> matrix, Vector<Complex32> vector);
/// <summary>
/// Solves the matrix equation Ax = b, where A is the coefficient matrix, b is the
/// solution vector and x is the unknown vector.
/// </summary>
/// <param name="matrix">The coefficient matrix, <c>A</c>.</param>
/// <param name="input">The solution vector, <c>b</c></param>
/// <param name="result">The result vector, <c>x</c></param>
void Solve(Matrix<Complex32> matrix, Vector<Complex32> input, Vector<Complex32> result);
/// <summary>
/// Solves the matrix equation AX = B, where A is the coefficient matrix, B is the
/// solution matrix and X is the unknown matrix.
/// </summary>
/// <param name="matrix">The coefficient matrix, <c>A</c>.</param>
/// <param name="input">The solution matrix, <c>B</c>.</param>
/// <returns>The result matrix, <c>X</c>.</returns>
Matrix<Complex32> Solve(Matrix<Complex32> matrix, Matrix<Complex32> input);
/// <summary>
/// Solves the matrix equation AX = B, where A is the coefficient matrix, B is the
/// solution matrix and X is the unknown matrix.
/// </summary>
/// <param name="matrix">The coefficient matrix, <c>A</c>.</param>
/// <param name="input">The solution matrix, <c>B</c>.</param>
/// <param name="result">The result matrix, <c>X</c></param>
void Solve(Matrix<Complex32> matrix, Matrix<Complex32> input, Matrix<Complex32> result);
}
}

9
src/Numerics/LinearAlgebra/Complex32/Solvers/IIterativeSolverSetup.cs

@ -28,9 +28,12 @@
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
using System;
using MathNet.Numerics.LinearAlgebra.Solvers;
namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers
{
using System;
using Numerics;
/// <summary>
/// Defines the interface for objects that can create an iterative solver with
@ -53,8 +56,8 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers
/// Creates a fully functional iterative solver with the default settings
/// given by this setup.
/// </summary>
/// <returns>A new <see cref="IIterativeSolver"/>.</returns>
IIterativeSolver CreateNew();
/// <returns>A new <see cref="IIterativeSolver{T}"/>.</returns>
IIterativeSolver<Complex32> CreateNew();
/// <summary>
/// Gets the relative speed of the solver.

2
src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/BiCgStab.cs

@ -67,7 +67,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Iterative
/// solver.
/// </para>
/// </remarks>
public sealed class BiCgStab : IIterativeSolver
public sealed class BiCgStab : IIterativeSolver<Complex32>
{
/// <summary>
/// The status used if there is no status, i.e. the solver hasn't run yet and there is no

6
src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/CompositeSolver.cs

@ -56,7 +56,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Iterative
/// Note that if an iterator is passed to this solver it will be used for all the sub-solvers.
/// </para>
/// </remarks>
public sealed class CompositeSolver : IIterativeSolver
public sealed class CompositeSolver : IIterativeSolver<Complex32>
{
#region Internal class - DoubleComparer
/// <summary>
@ -335,7 +335,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Iterative
/// <summary>
/// The collection of solvers that will be used to
/// </summary>
private readonly List<IIterativeSolver> _solvers = new List<IIterativeSolver>();
private readonly List<IIterativeSolver<Complex32>> _solvers = new List<IIterativeSolver<Complex32>>();
/// <summary>
/// The status of the calculation.
@ -356,7 +356,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Iterative
/// The solver that is currently running. Reference is used to be able to stop the
/// solver if the user cancels the solve process.
/// </summary>
private IIterativeSolver _currentSolver;
private IIterativeSolver<Complex32> _currentSolver;
/// <summary>
/// Initializes a new instance of the <see cref="CompositeSolver"/> class with the default iterator.

2
src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/GpBiCg.cs

@ -65,7 +65,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Iterative
/// solver.
/// </para>
/// </remarks>
public sealed class GpBiCg : IIterativeSolver
public sealed class GpBiCg : IIterativeSolver<Complex32>
{
/// <summary>
/// The status used if there is no status, i.e. the solver hasn't run yet and there is no

2
src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/MlkBiCgStab.cs

@ -65,7 +65,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Iterative
/// solver.
/// </para>
/// </remarks>
public sealed class MlkBiCgStab : IIterativeSolver
public sealed class MlkBiCgStab : IIterativeSolver<Complex32>
{
/// <summary>
/// The default number of starting vectors.

2
src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/TFQMR.cs

@ -55,7 +55,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Iterative
/// solver.
/// </para>
/// </remarks>
public sealed class TFQMR : IIterativeSolver
public sealed class TFQMR : IIterativeSolver<Complex32>
{
/// <summary>
/// The status used if there is no status, i.e. the solver hasn't run yet and there is no

97
src/Numerics/LinearAlgebra/Double/Solvers/IIterativeSolver.cs

@ -1,97 +0,0 @@
// <copyright file="IIterativeSolver.cs" company="Math.NET">
// Math.NET Numerics, part of the Math.NET Project
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
//
// Copyright (c) 2009-2010 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
using MathNet.Numerics.LinearAlgebra.Solvers;
using MathNet.Numerics.LinearAlgebra.Solvers.Status;
namespace MathNet.Numerics.LinearAlgebra.Double.Solvers
{
/// <summary>
/// Defines the interface for <see cref="IIterativeSolver"/> classes that solve the matrix equation Ax = b in
/// an iterative manner.
/// </summary>
public interface IIterativeSolver
{
/// <summary>
/// Stops the solve process.
/// </summary>
/// <remarks>
/// Note that it may take an indetermined amount of time for the solver to actually stop the process.
/// </remarks>
void StopSolve();
/// <summary>
/// Sets the <see cref="IIterator"/> that will be used to track the iterative process.
/// </summary>
/// <param name="iterator">The iterator.</param>
void SetIterator(IIterator<double> iterator);
/// <summary>
/// Gets the status of the iteration once the calculation is finished.
/// </summary>
ICalculationStatus IterationResult { get; }
/// <summary>
/// Solves the matrix equation Ax = b, where A is the coefficient matrix, b is the
/// solution vector and x is the unknown vector.
/// </summary>
/// <param name="matrix">The coefficient matrix, <c>A</c>.</param>
/// <param name="vector">The solution vector, <c>b</c>.</param>
/// <returns>The result vector, <c>x</c>.</returns>
Vector<double> Solve(Matrix<double> matrix, Vector<double> vector);
/// <summary>
/// Solves the matrix equation Ax = b, where A is the coefficient matrix, b is the
/// solution vector and x is the unknown vector.
/// </summary>
/// <param name="matrix">The coefficient matrix, <c>A</c>.</param>
/// <param name="input">The solution vector, <c>b</c></param>
/// <param name="result">The result vector, <c>x</c></param>
void Solve(Matrix<double> matrix, Vector<double> input, Vector<double> result);
/// <summary>
/// Solves the matrix equation AX = B, where A is the coefficient matrix, B is the
/// solution matrix and X is the unknown matrix.
/// </summary>
/// <param name="matrix">The coefficient matrix, <c>A</c>.</param>
/// <param name="input">The solution matrix, <c>B</c>.</param>
/// <returns>The result matrix, <c>X</c>.</returns>
Matrix<double> Solve(Matrix<double> matrix, Matrix<double> input);
/// <summary>
/// Solves the matrix equation AX = B, where A is the coefficient matrix, B is the
/// solution matrix and X is the unknown matrix.
/// </summary>
/// <param name="matrix">The coefficient matrix, <c>A</c>.</param>
/// <param name="input">The solution matrix, <c>B</c>.</param>
/// <param name="result">The result matrix, <c>X</c></param>
void Solve(Matrix<double> matrix, Matrix<double> input, Matrix<double> result);
}
}

4
src/Numerics/LinearAlgebra/Double/Solvers/IIterativeSolverSetup.cs

@ -28,6 +28,8 @@
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
using MathNet.Numerics.LinearAlgebra.Solvers;
namespace MathNet.Numerics.LinearAlgebra.Double.Solvers
{
using System;
@ -54,7 +56,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers
/// given by this setup.
/// </summary>
/// <returns>A new <see cref="IIterativeSolver"/>.</returns>
IIterativeSolver CreateNew();
IIterativeSolver<double> CreateNew();
/// <summary>
/// Gets the relative speed of the solver.

2
src/Numerics/LinearAlgebra/Double/Solvers/Iterative/BiCgStab.cs

@ -65,7 +65,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Iterative
/// solver.
/// </para>
/// </remarks>
public sealed class BiCgStab : IIterativeSolver
public sealed class BiCgStab : IIterativeSolver<double>
{
/// <summary>
/// The status used if there is no status, i.e. the solver hasn't run yet and there is no

6
src/Numerics/LinearAlgebra/Double/Solvers/Iterative/CompositeSolver.cs

@ -54,7 +54,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Iterative
/// Note that if an iterator is passed to this solver it will be used for all the sub-solvers.
/// </para>
/// </remarks>
public sealed class CompositeSolver : IIterativeSolver
public sealed class CompositeSolver : IIterativeSolver<double>
{
#region Internal class - DoubleComparer
/// <summary>
@ -330,7 +330,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Iterative
/// <summary>
/// The collection of solvers that will be used to
/// </summary>
private readonly List<IIterativeSolver> _solvers = new List<IIterativeSolver>();
private readonly List<IIterativeSolver<double>> _solvers = new List<IIterativeSolver<double>>();
/// <summary>
/// The status of the calculation.
@ -351,7 +351,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Iterative
/// The solver that is currently running. Reference is used to be able to stop the
/// solver if the user cancels the solve process.
/// </summary>
private IIterativeSolver _currentSolver;
private IIterativeSolver<double> _currentSolver;
/// <summary>
/// Initializes a new instance of the <see cref="CompositeSolver"/> class with the default iterator.

2
src/Numerics/LinearAlgebra/Double/Solvers/Iterative/GpBiCg.cs

@ -63,7 +63,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Iterative
/// solver.
/// </para>
/// </remarks>
public sealed class GpBiCg : IIterativeSolver
public sealed class GpBiCg : IIterativeSolver<double>
{
/// <summary>
/// The status used if there is no status, i.e. the solver hasn't run yet and there is no

2
src/Numerics/LinearAlgebra/Double/Solvers/Iterative/MlkBiCgStab.cs

@ -63,7 +63,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Iterative
/// solver.
/// </para>
/// </remarks>
public sealed class MlkBiCgStab : IIterativeSolver
public sealed class MlkBiCgStab : IIterativeSolver<double>
{
/// <summary>
/// The default number of starting vectors.

2
src/Numerics/LinearAlgebra/Double/Solvers/Iterative/TFQMR.cs

@ -53,7 +53,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Iterative
/// solver.
/// </para>
/// </remarks>
public sealed class TFQMR : IIterativeSolver
public sealed class TFQMR : IIterativeSolver<double>
{
/// <summary>
/// The status used if there is no status, i.e. the solver hasn't run yet and there is no

4
src/Numerics/LinearAlgebra/Single/Solvers/IIterativeSolverSetup.cs

@ -28,6 +28,8 @@
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
using MathNet.Numerics.LinearAlgebra.Solvers;
namespace MathNet.Numerics.LinearAlgebra.Single.Solvers
{
using System;
@ -54,7 +56,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers
/// given by this setup.
/// </summary>
/// <returns>A new <see cref="IIterativeSolver"/>.</returns>
IIterativeSolver CreateNew();
IIterativeSolver<float> CreateNew();
/// <summary>
/// Gets the relative speed of the solver.

2
src/Numerics/LinearAlgebra/Single/Solvers/Iterative/BiCgStab.cs

@ -65,7 +65,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Iterative
/// solver.
/// </para>
/// </remarks>
public sealed class BiCgStab : IIterativeSolver
public sealed class BiCgStab : IIterativeSolver<float>
{
/// <summary>
/// The status used if there is no status, i.e. the solver hasn't run yet and there is no

6
src/Numerics/LinearAlgebra/Single/Solvers/Iterative/CompositeSolver.cs

@ -54,7 +54,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Iterative
/// Note that if an iterator is passed to this solver it will be used for all the sub-solvers.
/// </para>
/// </remarks>
public sealed class CompositeSolver : IIterativeSolver
public sealed class CompositeSolver : IIterativeSolver<float>
{
#region Internal class - DoubleComparer
/// <summary>
@ -333,7 +333,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Iterative
/// <summary>
/// The collection of solvers that will be used to
/// </summary>
private readonly List<IIterativeSolver> _solvers = new List<IIterativeSolver>();
private readonly List<IIterativeSolver<float>> _solvers = new List<IIterativeSolver<float>>();
/// <summary>
/// The status of the calculation.
@ -354,7 +354,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Iterative
/// The solver that is currently running. Reference is used to be able to stop the
/// solver if the user cancels the solve process.
/// </summary>
private IIterativeSolver _currentSolver;
private IIterativeSolver<float> _currentSolver;
/// <summary>
/// Initializes a new instance of the <see cref="CompositeSolver"/> class with the default iterator.

2
src/Numerics/LinearAlgebra/Single/Solvers/Iterative/GpBiCg.cs

@ -63,7 +63,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Iterative
/// solver.
/// </para>
/// </remarks>
public sealed class GpBiCg : IIterativeSolver
public sealed class GpBiCg : IIterativeSolver<float>
{
/// <summary>
/// The status used if there is no status, i.e. the solver hasn't run yet and there is no

2
src/Numerics/LinearAlgebra/Single/Solvers/Iterative/MlkBiCgStab.cs

@ -62,7 +62,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Iterative
/// solver.
/// </para>
/// </remarks>
public sealed class MlkBiCgStab : IIterativeSolver
public sealed class MlkBiCgStab : IIterativeSolver<float>
{
/// <summary>
/// The default number of starting vectors.

2
src/Numerics/LinearAlgebra/Single/Solvers/Iterative/TFQMR.cs

@ -53,7 +53,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Iterative
/// solver.
/// </para>
/// </remarks>
public sealed class TFQMR : IIterativeSolver
public sealed class TFQMR : IIterativeSolver<float>
{
/// <summary>
/// The status used if there is no status, i.e. the solver hasn't run yet and there is no

20
src/Numerics/LinearAlgebra/Single/Solvers/IIterativeSolver.cs → src/Numerics/LinearAlgebra/Solvers/IIterativeSolver.cs

@ -28,16 +28,16 @@
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
using MathNet.Numerics.LinearAlgebra.Solvers;
using System;
using MathNet.Numerics.LinearAlgebra.Solvers.Status;
namespace MathNet.Numerics.LinearAlgebra.Single.Solvers
namespace MathNet.Numerics.LinearAlgebra.Solvers
{
/// <summary>
/// Defines the interface for <see cref="IIterativeSolver"/> classes that solve the matrix equation Ax = b in
/// Defines the interface for <see cref="IIterativeSolver{T}"/> classes that solve the matrix equation Ax = b in
/// an iterative manner.
/// </summary>
public interface IIterativeSolver
public interface IIterativeSolver<T> where T : struct, IEquatable<T>, IFormattable
{
/// <summary>
/// Stops the solve process.
@ -48,10 +48,10 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers
void StopSolve();
/// <summary>
/// Sets the <see cref="IIterator"/> that will be used to track the iterative process.
/// Sets the <see cref="IIterator{T}"/> that will be used to track the iterative process.
/// </summary>
/// <param name="iterator">The iterator.</param>
void SetIterator(IIterator<float> iterator);
void SetIterator(IIterator<T> iterator);
/// <summary>
/// Gets the status of the iteration once the calculation is finished.
@ -65,7 +65,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers
/// <param name="matrix">The coefficient matrix, <c>A</c>.</param>
/// <param name="vector">The solution vector, <c>b</c>.</param>
/// <returns>The result vector, <c>x</c>.</returns>
Vector<float> Solve(Matrix<float> matrix, Vector<float> vector);
Vector<T> Solve(Matrix<T> matrix, Vector<T> vector);
/// <summary>
/// Solves the matrix equation Ax = b, where A is the coefficient matrix, b is the
@ -74,7 +74,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers
/// <param name="matrix">The coefficient matrix, <c>A</c>.</param>
/// <param name="input">The solution vector, <c>b</c></param>
/// <param name="result">The result vector, <c>x</c></param>
void Solve(Matrix<float> matrix, Vector<float> input, Vector<float> result);
void Solve(Matrix<T> matrix, Vector<T> input, Vector<T> result);
/// <summary>
/// Solves the matrix equation AX = B, where A is the coefficient matrix, B is the
@ -83,7 +83,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers
/// <param name="matrix">The coefficient matrix, <c>A</c>.</param>
/// <param name="input">The solution matrix, <c>B</c>.</param>
/// <returns>The result matrix, <c>X</c>.</returns>
Matrix<float> Solve(Matrix<float> matrix, Matrix<float> input);
Matrix<T> Solve(Matrix<T> matrix, Matrix<T> input);
/// <summary>
/// Solves the matrix equation AX = B, where A is the coefficient matrix, B is the
@ -92,6 +92,6 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers
/// <param name="matrix">The coefficient matrix, <c>A</c>.</param>
/// <param name="input">The solution matrix, <c>B</c>.</param>
/// <param name="result">The result matrix, <c>X</c></param>
void Solve(Matrix<float> matrix, Matrix<float> input, Matrix<float> result);
void Solve(Matrix<T> matrix, Matrix<T> input, Matrix<T> result);
}
}

5
src/Numerics/Numerics.csproj

@ -190,7 +190,6 @@
<Compile Include="LinearAlgebra\Complex32\Factorization\QR.cs" />
<Compile Include="LinearAlgebra\Complex32\Factorization\Svd.cs" />
<Compile Include="LinearAlgebra\Complex32\Matrix.cs" />
<Compile Include="LinearAlgebra\Complex32\Solvers\IIterativeSolver.cs" />
<Compile Include="LinearAlgebra\Complex32\Solvers\IIterativeSolverSetup.cs" />
<Compile Include="LinearAlgebra\Complex32\Solvers\Preconditioners\IPreConditioner.cs" />
<Compile Include="LinearAlgebra\Complex32\SparseMatrix.cs" />
@ -208,7 +207,6 @@
<Compile Include="LinearAlgebra\Complex\Factorization\QR.cs" />
<Compile Include="LinearAlgebra\Complex\Factorization\Svd.cs" />
<Compile Include="LinearAlgebra\Complex\Matrix.cs" />
<Compile Include="LinearAlgebra\Complex\Solvers\IIterativeSolver.cs" />
<Compile Include="LinearAlgebra\Complex\Solvers\IIterativeSolverSetup.cs" />
<Compile Include="LinearAlgebra\Complex\Solvers\Preconditioners\IPreConditioner.cs" />
<Compile Include="LinearAlgebra\Complex\SparseMatrix.cs" />
@ -223,7 +221,7 @@
<Compile Include="LinearAlgebra\Double\Factorization\Svd.cs" />
<Compile Include="LinearAlgebra\Double\Factorization\LU.cs" />
<Compile Include="LinearAlgebra\Double\Matrix.cs" />
<Compile Include="LinearAlgebra\Double\Solvers\IIterativeSolver.cs" />
<Compile Include="LinearAlgebra\Solvers\IIterativeSolver.cs" />
<Compile Include="LinearAlgebra\Double\Solvers\IIterativeSolverSetup.cs" />
<Compile Include="LinearAlgebra\Solvers\IIterator.cs" />
<Compile Include="LinearAlgebra\Double\Solvers\Preconditioners\IPreConditioner.cs" />
@ -314,7 +312,6 @@
<Compile Include="LinearAlgebra\Single\Factorization\UserQR.cs" />
<Compile Include="LinearAlgebra\Single\Factorization\UserSvd.cs" />
<Compile Include="LinearAlgebra\Single\Matrix.cs" />
<Compile Include="LinearAlgebra\Single\Solvers\IIterativeSolver.cs" />
<Compile Include="LinearAlgebra\Single\Solvers\IIterativeSolverSetup.cs" />
<Compile Include="LinearAlgebra\Single\Solvers\Iterative\BiCgStab.cs" />
<Compile Include="LinearAlgebra\Single\Solvers\Iterative\CompositeSolver.cs" />

Loading…
Cancel
Save