forked from tsai/mathnet-numerics
133 changed files with 3247 additions and 2114 deletions
@ -0,0 +1,96 @@ |
|||
// <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>
|
|||
|
|||
namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers |
|||
{ |
|||
using Generic.Solvers.Status; |
|||
|
|||
/// <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 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 Solve(Matrix matrix, Vector 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 matrix, Vector input, Vector 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 Solve(Matrix matrix, Matrix 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 matrix, Matrix input, Matrix result); |
|||
} |
|||
} |
|||
@ -0,0 +1,71 @@ |
|||
// <copyright file="IIterativeSolverSetup.cs" company="Math.NET">
|
|||
// Math.NET Numerics, part of the Math.NET Project
|
|||
// http://numerics.mathdotnet.com
|
|||
// http://github.com/mathnet/mathnet-numerics
|
|||
// http://mathnetnumerics.codeplex.com
|
|||
//
|
|||
// Copyright (c) 2009-2010 Math.NET
|
|||
//
|
|||
// Permission is hereby granted, free of charge, to any person
|
|||
// obtaining a copy of this software and associated documentation
|
|||
// files (the "Software"), to deal in the Software without
|
|||
// restriction, including without limitation the rights to use,
|
|||
// copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|||
// copies of the Software, and to permit persons to whom the
|
|||
// Software is furnished to do so, subject to the following
|
|||
// conditions:
|
|||
//
|
|||
// The above copyright notice and this permission notice shall be
|
|||
// included in all copies or substantial portions of the Software.
|
|||
//
|
|||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|||
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|||
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|||
// OTHER DEALINGS IN THE SOFTWARE.
|
|||
// </copyright>
|
|||
|
|||
namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers |
|||
{ |
|||
using System; |
|||
|
|||
/// <summary>
|
|||
/// Defines the interface for objects that can create an iterative solver with
|
|||
/// specific settings. This interface is used to pass iterative solver creation
|
|||
/// setup information around.
|
|||
/// </summary>
|
|||
public interface IIterativeSolverSetup |
|||
{ |
|||
/// <summary>
|
|||
/// Gets the type of the solver that will be created by this setup object.
|
|||
/// </summary>
|
|||
Type SolverType { get; } |
|||
|
|||
/// <summary>
|
|||
/// Gets type of preconditioner, if any, that will be created by this setup object.
|
|||
/// </summary>
|
|||
Type PreconditionerType { get; } |
|||
|
|||
/// <summary>
|
|||
/// Creates a fully functional iterative solver with the default settings
|
|||
/// given by this setup.
|
|||
/// </summary>
|
|||
/// <returns>A new <see cref="IIterativeSolver"/>.</returns>
|
|||
IIterativeSolver CreateNew(); |
|||
|
|||
/// <summary>
|
|||
/// Gets the relative speed of the solver.
|
|||
/// </summary>
|
|||
/// <value>Returns a value between 0 and 1, inclusive.</value>
|
|||
double SolutionSpeed { get; } |
|||
|
|||
/// <summary>
|
|||
/// Gets the relative reliability of the solver.
|
|||
/// </summary>
|
|||
/// <value>Returns a value between 0 and 1 inclusive.</value>
|
|||
double Reliability { get; } |
|||
} |
|||
} |
|||
@ -0,0 +1,108 @@ |
|||
// <copyright file="IIterator.cs" company="Math.NET">
|
|||
// Math.NET Numerics, part of the Math.NET Project
|
|||
// http://numerics.mathdotnet.com
|
|||
// http://github.com/mathnet/mathnet-numerics
|
|||
// http://mathnetnumerics.codeplex.com
|
|||
//
|
|||
// Copyright (c) 2009-2010 Math.NET
|
|||
//
|
|||
// Permission is hereby granted, free of charge, to any person
|
|||
// obtaining a copy of this software and associated documentation
|
|||
// files (the "Software"), to deal in the Software without
|
|||
// restriction, including without limitation the rights to use,
|
|||
// copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|||
// copies of the Software, and to permit persons to whom the
|
|||
// Software is furnished to do so, subject to the following
|
|||
// conditions:
|
|||
//
|
|||
// The above copyright notice and this permission notice shall be
|
|||
// included in all copies or substantial portions of the Software.
|
|||
//
|
|||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|||
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|||
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|||
// OTHER DEALINGS IN THE SOFTWARE.
|
|||
// </copyright>
|
|||
|
|||
namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers |
|||
{ |
|||
using System; |
|||
using Generic.Solvers.Status; |
|||
using StopCriterium; |
|||
|
|||
/// <summary>
|
|||
/// Defines the base interface for iterators that help control an iterative calculation.
|
|||
/// </summary>
|
|||
public interface IIterator |
|||
#if !SILVERLIGHT
|
|||
: ICloneable |
|||
#endif
|
|||
{ |
|||
/// <summary>
|
|||
/// Adds an <see cref="IIterationStopCriterium"/> to the internal collection of stop-criteria. Only a
|
|||
/// single stop criterium of each type can be stored.
|
|||
/// </summary>
|
|||
/// <param name="stopCriterium">The stop criterium to add.</param>
|
|||
/// <exception cref="ArgumentNullException">Thrown if <paramref name="stopCriterium"/> is <see langword="null" />.</exception>
|
|||
/// <exception cref="ArgumentException">Thrown if <paramref name="stopCriterium"/> is of the same type as an already stored criterium.</exception>
|
|||
void Add(IIterationStopCriterium stopCriterium); |
|||
|
|||
/// <summary>
|
|||
/// Removes the <see cref="IIterationStopCriterium"/> from the internal collection.
|
|||
/// </summary>
|
|||
/// <param name="stopCriterium">The stop criterium that must be removed.</param>
|
|||
void Remove(IIterationStopCriterium stopCriterium); |
|||
|
|||
/// <summary>
|
|||
/// Indicates if the specific stop criterium is stored by the <see cref="IIterator"/>.
|
|||
/// </summary>
|
|||
/// <param name="stopCriterium">The stop criterium.</param>
|
|||
/// <returns><c>true</c> if the <see cref="IIterator"/> contains the stop criterium; otherwise <c>false</c>.</returns>
|
|||
bool Contains(IIterationStopCriterium stopCriterium); |
|||
|
|||
/// <summary>
|
|||
/// Indicates to the iterator that the iterative process has been cancelled.
|
|||
/// </summary>
|
|||
/// <remarks>Does not reset the stop-criteria.</remarks>
|
|||
void IterationCancelled(); |
|||
|
|||
/// <summary>
|
|||
/// Determines the status of the iterative calculation based on the stop criteria stored
|
|||
/// by the current <see cref="IIterator"/>. Status is set to <c>Status</c> field of current object.
|
|||
/// </summary>
|
|||
/// <param name="iterationNumber">The number of iterations that have passed so far.</param>
|
|||
/// <param name="solutionVector">The vector containing the current solution values.</param>
|
|||
/// <param name="sourceVector">The right hand side vector.</param>
|
|||
/// <param name="residualVector">The vector containing the current residual vectors.</param>
|
|||
/// <remarks>
|
|||
/// The individual iterators may internally track the progress of the calculation based
|
|||
/// on the invocation of this method. Therefore this method should only be called if the
|
|||
/// calculation has moved forwards at least one step.
|
|||
/// </remarks>
|
|||
void DetermineStatus(int iterationNumber, Vector solutionVector, Vector sourceVector, Vector residualVector); |
|||
|
|||
/// <summary>
|
|||
/// Gets the current calculation status.
|
|||
/// </summary>
|
|||
/// <remarks><see langword="null" /> is not a legal value. Status should be set in <see cref="DetermineStatus"/> implementation.</remarks>.
|
|||
ICalculationStatus Status { get; } |
|||
|
|||
/// <summary>
|
|||
/// Resets the <see cref="IIterator"/> to the pre-calculation state.
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// Note to implementers: Invoking this method should not clear the user defined
|
|||
/// property values, only the state that is used to track the progress of the
|
|||
/// calculation.
|
|||
/// </remarks>
|
|||
void ResetToPrecalculationState(); |
|||
|
|||
#if SILVERLIGHT
|
|||
IIterator Clone(); |
|||
#endif
|
|||
} |
|||
} |
|||
@ -0,0 +1,73 @@ |
|||
// <copyright file="IPreConditioner.cs" company="Math.NET">
|
|||
// Math.NET Numerics, part of the Math.NET Project
|
|||
// http://numerics.mathdotnet.com
|
|||
// http://github.com/mathnet/mathnet-numerics
|
|||
// http://mathnetnumerics.codeplex.com
|
|||
//
|
|||
// Copyright (c) 2009-2010 Math.NET
|
|||
//
|
|||
// Permission is hereby granted, free of charge, to any person
|
|||
// obtaining a copy of this software and associated documentation
|
|||
// files (the "Software"), to deal in the Software without
|
|||
// restriction, including without limitation the rights to use,
|
|||
// copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|||
// copies of the Software, and to permit persons to whom the
|
|||
// Software is furnished to do so, subject to the following
|
|||
// conditions:
|
|||
//
|
|||
// The above copyright notice and this permission notice shall be
|
|||
// included in all copies or substantial portions of the Software.
|
|||
//
|
|||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|||
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|||
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|||
// OTHER DEALINGS IN THE SOFTWARE.
|
|||
// </copyright>
|
|||
|
|||
namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Preconditioners |
|||
{ |
|||
/// <summary>
|
|||
/// The base interface for preconditioner classes.
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// <para>
|
|||
/// Preconditioners are used by iterative solvers to improve the convergence
|
|||
/// speed of the solving process. Increase in convergence speed
|
|||
/// is related to the number of iterations necessary to get a converged solution.
|
|||
/// So while in general the use of a preconditioner means that the iterative
|
|||
/// solver will perform fewer iterations it does not guarantee that the actual
|
|||
/// solution time decreases given that some preconditioners can be expensive to
|
|||
/// setup and run.
|
|||
/// </para>
|
|||
/// <para>
|
|||
/// Note that in general changes to the matrix will invalidate the preconditioner
|
|||
/// if the changes occur after creating the preconditioner.
|
|||
/// </para>
|
|||
/// </remarks>
|
|||
public interface IPreConditioner |
|||
{ |
|||
/// <summary>
|
|||
/// Initializes the preconditioner and loads the internal data structures.
|
|||
/// </summary>
|
|||
/// <param name="matrix">The matrix on which the preconditioner is based.</param>
|
|||
void Initialize(Matrix matrix); |
|||
|
|||
/// <summary>
|
|||
/// Approximates the solution to the matrix equation <b>Mx = b</b>.
|
|||
/// </summary>
|
|||
/// <param name="rhs">The right hand side vector.</param>
|
|||
/// <returns>The left hand side vector.</returns>
|
|||
Vector Approximate(Vector rhs); |
|||
|
|||
/// <summary>
|
|||
/// Approximates the solution to the matrix equation <b>Mx = b</b>.
|
|||
/// </summary>
|
|||
/// <param name="rhs">The right hand side vector.</param>
|
|||
/// <param name="lhs">The left hand side vector. Also known as the result vector.</param>
|
|||
void Approximate(Vector rhs, Vector lhs); |
|||
} |
|||
} |
|||
@ -0,0 +1,80 @@ |
|||
// <copyright file="IIterationStopCriterium.cs" company="Math.NET">
|
|||
// Math.NET Numerics, part of the Math.NET Project
|
|||
// http://numerics.mathdotnet.com
|
|||
// http://github.com/mathnet/mathnet-numerics
|
|||
// http://mathnetnumerics.codeplex.com
|
|||
// Copyright (c) 2009-2010 Math.NET
|
|||
// Permission is hereby granted, free of charge, to any person
|
|||
// obtaining a copy of this software and associated documentation
|
|||
// files (the "Software"), to deal in the Software without
|
|||
// restriction, including without limitation the rights to use,
|
|||
// copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|||
// copies of the Software, and to permit persons to whom the
|
|||
// Software is furnished to do so, subject to the following
|
|||
// conditions:
|
|||
// The above copyright notice and this permission notice shall be
|
|||
// included in all copies or substantial portions of the Software.
|
|||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|||
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|||
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|||
// OTHER DEALINGS IN THE SOFTWARE.
|
|||
// </copyright>
|
|||
|
|||
namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.StopCriterium |
|||
{ |
|||
using System; |
|||
using Generic.Solvers.Status; |
|||
using Generic.Solvers.StopCriterium; |
|||
|
|||
/// <summary>
|
|||
/// The base interface for classes that provide stop criteria for iterative calculations.
|
|||
/// </summary>
|
|||
public interface IIterationStopCriterium |
|||
#if !SILVERLIGHT
|
|||
: ICloneable |
|||
#endif
|
|||
{ |
|||
/// <summary>
|
|||
/// Determines the status of the iterative calculation based on the stop criteria stored
|
|||
/// by the current <see cref="IIterationStopCriterium"/>. Status is set to <c>Status</c> field of current object.
|
|||
/// </summary>
|
|||
/// <param name="iterationNumber">The number of iterations that have passed so far.</param>
|
|||
/// <param name="solutionVector">The vector containing the current solution values.</param>
|
|||
/// <param name="sourceVector">The right hand side vector.</param>
|
|||
/// <param name="residualVector">The vector containing the current residual vectors.</param>
|
|||
/// <remarks>
|
|||
/// The individual stop criteria may internally track the progress of the calculation based
|
|||
/// on the invocation of this method. Therefore this method should only be called if the
|
|||
/// calculation has moved forwards at least one step.
|
|||
/// </remarks>
|
|||
void DetermineStatus(int iterationNumber, Vector solutionVector, Vector sourceVector, Vector residualVector); |
|||
|
|||
/// <summary>
|
|||
/// Gets the current calculation status.
|
|||
/// </summary>
|
|||
/// <remarks><see langword="null" /> is not a legal value. Status should be set in <see cref="DetermineStatus"/> implementation.</remarks>
|
|||
ICalculationStatus Status { get; } |
|||
|
|||
/// <summary>
|
|||
/// Resets the <see cref="IIterationStopCriterium"/> to the pre-calculation state.
|
|||
/// </summary>
|
|||
/// <remarks>To implementers: Invoking this method should not clear the user defined
|
|||
/// property values, only the state that is used to track the progress of the
|
|||
/// calculation.</remarks>
|
|||
void ResetToPrecalculationState(); |
|||
|
|||
/// <summary>
|
|||
/// Gets the <see cref="StopLevel"/> which indicates what sort of stop criterium this
|
|||
/// <see cref="IIterationStopCriterium"/> monitors.
|
|||
/// </summary>
|
|||
StopLevel StopLevel { get; } |
|||
|
|||
#if SILVERLIGHT
|
|||
IIterationStopCriterium Clone(); |
|||
#endif
|
|||
} |
|||
} |
|||
@ -0,0 +1,96 @@ |
|||
// <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>
|
|||
|
|||
namespace MathNet.Numerics.LinearAlgebra.Double.Solvers |
|||
{ |
|||
using Generic.Solvers.Status; |
|||
|
|||
/// <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 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 Solve(Matrix matrix, Vector 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 matrix, Vector input, Vector 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 Solve(Matrix matrix, Matrix 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 matrix, Matrix input, Matrix result); |
|||
} |
|||
} |
|||
@ -0,0 +1,71 @@ |
|||
// <copyright file="IIterativeSolverSetup.cs" company="Math.NET">
|
|||
// Math.NET Numerics, part of the Math.NET Project
|
|||
// http://numerics.mathdotnet.com
|
|||
// http://github.com/mathnet/mathnet-numerics
|
|||
// http://mathnetnumerics.codeplex.com
|
|||
//
|
|||
// Copyright (c) 2009-2010 Math.NET
|
|||
//
|
|||
// Permission is hereby granted, free of charge, to any person
|
|||
// obtaining a copy of this software and associated documentation
|
|||
// files (the "Software"), to deal in the Software without
|
|||
// restriction, including without limitation the rights to use,
|
|||
// copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|||
// copies of the Software, and to permit persons to whom the
|
|||
// Software is furnished to do so, subject to the following
|
|||
// conditions:
|
|||
//
|
|||
// The above copyright notice and this permission notice shall be
|
|||
// included in all copies or substantial portions of the Software.
|
|||
//
|
|||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|||
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|||
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|||
// OTHER DEALINGS IN THE SOFTWARE.
|
|||
// </copyright>
|
|||
|
|||
namespace MathNet.Numerics.LinearAlgebra.Double.Solvers |
|||
{ |
|||
using System; |
|||
|
|||
/// <summary>
|
|||
/// Defines the interface for objects that can create an iterative solver with
|
|||
/// specific settings. This interface is used to pass iterative solver creation
|
|||
/// setup information around.
|
|||
/// </summary>
|
|||
public interface IIterativeSolverSetup |
|||
{ |
|||
/// <summary>
|
|||
/// Gets the type of the solver that will be created by this setup object.
|
|||
/// </summary>
|
|||
Type SolverType { get; } |
|||
|
|||
/// <summary>
|
|||
/// Gets type of preconditioner, if any, that will be created by this setup object.
|
|||
/// </summary>
|
|||
Type PreconditionerType { get; } |
|||
|
|||
/// <summary>
|
|||
/// Creates a fully functional iterative solver with the default settings
|
|||
/// given by this setup.
|
|||
/// </summary>
|
|||
/// <returns>A new <see cref="IIterativeSolver"/>.</returns>
|
|||
IIterativeSolver CreateNew(); |
|||
|
|||
/// <summary>
|
|||
/// Gets the relative speed of the solver.
|
|||
/// </summary>
|
|||
/// <value>Returns a value between 0 and 1, inclusive.</value>
|
|||
double SolutionSpeed { get; } |
|||
|
|||
/// <summary>
|
|||
/// Gets the relative reliability of the solver.
|
|||
/// </summary>
|
|||
/// <value>Returns a value between 0 and 1 inclusive.</value>
|
|||
double Reliability { get; } |
|||
} |
|||
} |
|||
@ -0,0 +1,108 @@ |
|||
// <copyright file="IIterator.cs" company="Math.NET">
|
|||
// Math.NET Numerics, part of the Math.NET Project
|
|||
// http://numerics.mathdotnet.com
|
|||
// http://github.com/mathnet/mathnet-numerics
|
|||
// http://mathnetnumerics.codeplex.com
|
|||
//
|
|||
// Copyright (c) 2009-2010 Math.NET
|
|||
//
|
|||
// Permission is hereby granted, free of charge, to any person
|
|||
// obtaining a copy of this software and associated documentation
|
|||
// files (the "Software"), to deal in the Software without
|
|||
// restriction, including without limitation the rights to use,
|
|||
// copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|||
// copies of the Software, and to permit persons to whom the
|
|||
// Software is furnished to do so, subject to the following
|
|||
// conditions:
|
|||
//
|
|||
// The above copyright notice and this permission notice shall be
|
|||
// included in all copies or substantial portions of the Software.
|
|||
//
|
|||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|||
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|||
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|||
// OTHER DEALINGS IN THE SOFTWARE.
|
|||
// </copyright>
|
|||
|
|||
namespace MathNet.Numerics.LinearAlgebra.Double.Solvers |
|||
{ |
|||
using System; |
|||
using Generic.Solvers.Status; |
|||
using StopCriterium; |
|||
|
|||
/// <summary>
|
|||
/// Defines the base interface for iterators that help control an iterative calculation.
|
|||
/// </summary>
|
|||
public interface IIterator |
|||
#if !SILVERLIGHT
|
|||
: ICloneable |
|||
#endif
|
|||
{ |
|||
/// <summary>
|
|||
/// Adds an <see cref="IIterationStopCriterium"/> to the internal collection of stop-criteria. Only a
|
|||
/// single stop criterium of each type can be stored.
|
|||
/// </summary>
|
|||
/// <param name="stopCriterium">The stop criterium to add.</param>
|
|||
/// <exception cref="ArgumentNullException">Thrown if <paramref name="stopCriterium"/> is <see langword="null" />.</exception>
|
|||
/// <exception cref="ArgumentException">Thrown if <paramref name="stopCriterium"/> is of the same type as an already stored criterium.</exception>
|
|||
void Add(IIterationStopCriterium stopCriterium); |
|||
|
|||
/// <summary>
|
|||
/// Removes the <see cref="IIterationStopCriterium"/> from the internal collection.
|
|||
/// </summary>
|
|||
/// <param name="stopCriterium">The stop criterium that must be removed.</param>
|
|||
void Remove(IIterationStopCriterium stopCriterium); |
|||
|
|||
/// <summary>
|
|||
/// Indicates if the specific stop criterium is stored by the <see cref="IIterator"/>.
|
|||
/// </summary>
|
|||
/// <param name="stopCriterium">The stop criterium.</param>
|
|||
/// <returns><c>true</c> if the <see cref="IIterator"/> contains the stop criterium; otherwise <c>false</c>.</returns>
|
|||
bool Contains(IIterationStopCriterium stopCriterium); |
|||
|
|||
/// <summary>
|
|||
/// Indicates to the iterator that the iterative process has been cancelled.
|
|||
/// </summary>
|
|||
/// <remarks>Does not reset the stop-criteria.</remarks>
|
|||
void IterationCancelled(); |
|||
|
|||
/// <summary>
|
|||
/// Determines the status of the iterative calculation based on the stop criteria stored
|
|||
/// by the current <see cref="IIterator"/>. Status is set to <c>Status</c> field of current object.
|
|||
/// </summary>
|
|||
/// <param name="iterationNumber">The number of iterations that have passed so far.</param>
|
|||
/// <param name="solutionVector">The vector containing the current solution values.</param>
|
|||
/// <param name="sourceVector">The right hand side vector.</param>
|
|||
/// <param name="residualVector">The vector containing the current residual vectors.</param>
|
|||
/// <remarks>
|
|||
/// The individual iterators may internally track the progress of the calculation based
|
|||
/// on the invocation of this method. Therefore this method should only be called if the
|
|||
/// calculation has moved forwards at least one step.
|
|||
/// </remarks>
|
|||
void DetermineStatus(int iterationNumber, Vector solutionVector, Vector sourceVector, Vector residualVector); |
|||
|
|||
/// <summary>
|
|||
/// Gets the current calculation status.
|
|||
/// </summary>
|
|||
/// <remarks><see langword="null" /> is not a legal value. Status should be set in <see cref="DetermineStatus"/> implementation.</remarks>.
|
|||
ICalculationStatus Status { get; } |
|||
|
|||
/// <summary>
|
|||
/// Resets the <see cref="IIterator"/> to the pre-calculation state.
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// Note to implementers: Invoking this method should not clear the user defined
|
|||
/// property values, only the state that is used to track the progress of the
|
|||
/// calculation.
|
|||
/// </remarks>
|
|||
void ResetToPrecalculationState(); |
|||
|
|||
#if SILVERLIGHT
|
|||
IIterator Clone(); |
|||
#endif
|
|||
} |
|||
} |
|||
@ -0,0 +1,73 @@ |
|||
// <copyright file="IPreConditioner.cs" company="Math.NET">
|
|||
// Math.NET Numerics, part of the Math.NET Project
|
|||
// http://numerics.mathdotnet.com
|
|||
// http://github.com/mathnet/mathnet-numerics
|
|||
// http://mathnetnumerics.codeplex.com
|
|||
//
|
|||
// Copyright (c) 2009-2010 Math.NET
|
|||
//
|
|||
// Permission is hereby granted, free of charge, to any person
|
|||
// obtaining a copy of this software and associated documentation
|
|||
// files (the "Software"), to deal in the Software without
|
|||
// restriction, including without limitation the rights to use,
|
|||
// copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|||
// copies of the Software, and to permit persons to whom the
|
|||
// Software is furnished to do so, subject to the following
|
|||
// conditions:
|
|||
//
|
|||
// The above copyright notice and this permission notice shall be
|
|||
// included in all copies or substantial portions of the Software.
|
|||
//
|
|||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|||
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|||
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|||
// OTHER DEALINGS IN THE SOFTWARE.
|
|||
// </copyright>
|
|||
|
|||
namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Preconditioners |
|||
{ |
|||
/// <summary>
|
|||
/// The base interface for preconditioner classes.
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// <para>
|
|||
/// Preconditioners are used by iterative solvers to improve the convergence
|
|||
/// speed of the solving process. Increase in convergence speed
|
|||
/// is related to the number of iterations necessary to get a converged solution.
|
|||
/// So while in general the use of a preconditioner means that the iterative
|
|||
/// solver will perform fewer iterations it does not guarantee that the actual
|
|||
/// solution time decreases given that some preconditioners can be expensive to
|
|||
/// setup and run.
|
|||
/// </para>
|
|||
/// <para>
|
|||
/// Note that in general changes to the matrix will invalidate the preconditioner
|
|||
/// if the changes occur after creating the preconditioner.
|
|||
/// </para>
|
|||
/// </remarks>
|
|||
public interface IPreConditioner |
|||
{ |
|||
/// <summary>
|
|||
/// Initializes the preconditioner and loads the internal data structures.
|
|||
/// </summary>
|
|||
/// <param name="matrix">The matrix on which the preconditioner is based.</param>
|
|||
void Initialize(Matrix matrix); |
|||
|
|||
/// <summary>
|
|||
/// Approximates the solution to the matrix equation <b>Mx = b</b>.
|
|||
/// </summary>
|
|||
/// <param name="rhs">The right hand side vector.</param>
|
|||
/// <returns>The left hand side vector.</returns>
|
|||
Vector Approximate(Vector rhs); |
|||
|
|||
/// <summary>
|
|||
/// Approximates the solution to the matrix equation <b>Mx = b</b>.
|
|||
/// </summary>
|
|||
/// <param name="rhs">The right hand side vector.</param>
|
|||
/// <param name="lhs">The left hand side vector. Also known as the result vector.</param>
|
|||
void Approximate(Vector rhs, Vector lhs); |
|||
} |
|||
} |
|||
@ -0,0 +1,80 @@ |
|||
// <copyright file="IIterationStopCriterium.cs" company="Math.NET">
|
|||
// Math.NET Numerics, part of the Math.NET Project
|
|||
// http://numerics.mathdotnet.com
|
|||
// http://github.com/mathnet/mathnet-numerics
|
|||
// http://mathnetnumerics.codeplex.com
|
|||
// Copyright (c) 2009-2010 Math.NET
|
|||
// Permission is hereby granted, free of charge, to any person
|
|||
// obtaining a copy of this software and associated documentation
|
|||
// files (the "Software"), to deal in the Software without
|
|||
// restriction, including without limitation the rights to use,
|
|||
// copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|||
// copies of the Software, and to permit persons to whom the
|
|||
// Software is furnished to do so, subject to the following
|
|||
// conditions:
|
|||
// The above copyright notice and this permission notice shall be
|
|||
// included in all copies or substantial portions of the Software.
|
|||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|||
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|||
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|||
// OTHER DEALINGS IN THE SOFTWARE.
|
|||
// </copyright>
|
|||
|
|||
namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.StopCriterium |
|||
{ |
|||
using System; |
|||
using Generic.Solvers.Status; |
|||
using Generic.Solvers.StopCriterium; |
|||
|
|||
/// <summary>
|
|||
/// The base interface for classes that provide stop criteria for iterative calculations.
|
|||
/// </summary>
|
|||
public interface IIterationStopCriterium |
|||
#if !SILVERLIGHT
|
|||
: ICloneable |
|||
#endif
|
|||
{ |
|||
/// <summary>
|
|||
/// Determines the status of the iterative calculation based on the stop criteria stored
|
|||
/// by the current <see cref="IIterationStopCriterium"/>. Status is set to <c>Status</c> field of current object.
|
|||
/// </summary>
|
|||
/// <param name="iterationNumber">The number of iterations that have passed so far.</param>
|
|||
/// <param name="solutionVector">The vector containing the current solution values.</param>
|
|||
/// <param name="sourceVector">The right hand side vector.</param>
|
|||
/// <param name="residualVector">The vector containing the current residual vectors.</param>
|
|||
/// <remarks>
|
|||
/// The individual stop criteria may internally track the progress of the calculation based
|
|||
/// on the invocation of this method. Therefore this method should only be called if the
|
|||
/// calculation has moved forwards at least one step.
|
|||
/// </remarks>
|
|||
void DetermineStatus(int iterationNumber, Vector solutionVector, Vector sourceVector, Vector residualVector); |
|||
|
|||
/// <summary>
|
|||
/// Gets the current calculation status.
|
|||
/// </summary>
|
|||
/// <remarks><see langword="null" /> is not a legal value. Status should be set in <see cref="DetermineStatus"/> implementation.</remarks>
|
|||
ICalculationStatus Status { get; } |
|||
|
|||
/// <summary>
|
|||
/// Resets the <see cref="IIterationStopCriterium"/> to the pre-calculation state.
|
|||
/// </summary>
|
|||
/// <remarks>To implementers: Invoking this method should not clear the user defined
|
|||
/// property values, only the state that is used to track the progress of the
|
|||
/// calculation.</remarks>
|
|||
void ResetToPrecalculationState(); |
|||
|
|||
/// <summary>
|
|||
/// Gets the <see cref="StopLevel"/> which indicates what sort of stop criterium this
|
|||
/// <see cref="IIterationStopCriterium"/> monitors.
|
|||
/// </summary>
|
|||
StopLevel StopLevel { get; } |
|||
|
|||
#if SILVERLIGHT
|
|||
IIterationStopCriterium Clone(); |
|||
#endif
|
|||
} |
|||
} |
|||
@ -0,0 +1,96 @@ |
|||
// <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>
|
|||
|
|||
namespace MathNet.Numerics.LinearAlgebra.Single.Solvers |
|||
{ |
|||
using Generic.Solvers.Status; |
|||
|
|||
/// <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 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 Solve(Matrix matrix, Vector 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 matrix, Vector input, Vector 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 Solve(Matrix matrix, Matrix 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 matrix, Matrix input, Matrix result); |
|||
} |
|||
} |
|||
@ -0,0 +1,71 @@ |
|||
// <copyright file="IIterativeSolverSetup.cs" company="Math.NET">
|
|||
// Math.NET Numerics, part of the Math.NET Project
|
|||
// http://numerics.mathdotnet.com
|
|||
// http://github.com/mathnet/mathnet-numerics
|
|||
// http://mathnetnumerics.codeplex.com
|
|||
//
|
|||
// Copyright (c) 2009-2010 Math.NET
|
|||
//
|
|||
// Permission is hereby granted, free of charge, to any person
|
|||
// obtaining a copy of this software and associated documentation
|
|||
// files (the "Software"), to deal in the Software without
|
|||
// restriction, including without limitation the rights to use,
|
|||
// copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|||
// copies of the Software, and to permit persons to whom the
|
|||
// Software is furnished to do so, subject to the following
|
|||
// conditions:
|
|||
//
|
|||
// The above copyright notice and this permission notice shall be
|
|||
// included in all copies or substantial portions of the Software.
|
|||
//
|
|||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|||
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|||
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|||
// OTHER DEALINGS IN THE SOFTWARE.
|
|||
// </copyright>
|
|||
|
|||
namespace MathNet.Numerics.LinearAlgebra.Single.Solvers |
|||
{ |
|||
using System; |
|||
|
|||
/// <summary>
|
|||
/// Defines the interface for objects that can create an iterative solver with
|
|||
/// specific settings. This interface is used to pass iterative solver creation
|
|||
/// setup information around.
|
|||
/// </summary>
|
|||
public interface IIterativeSolverSetup |
|||
{ |
|||
/// <summary>
|
|||
/// Gets the type of the solver that will be created by this setup object.
|
|||
/// </summary>
|
|||
Type SolverType { get; } |
|||
|
|||
/// <summary>
|
|||
/// Gets type of preconditioner, if any, that will be created by this setup object.
|
|||
/// </summary>
|
|||
Type PreconditionerType { get; } |
|||
|
|||
/// <summary>
|
|||
/// Creates a fully functional iterative solver with the default settings
|
|||
/// given by this setup.
|
|||
/// </summary>
|
|||
/// <returns>A new <see cref="IIterativeSolver"/>.</returns>
|
|||
IIterativeSolver CreateNew(); |
|||
|
|||
/// <summary>
|
|||
/// Gets the relative speed of the solver.
|
|||
/// </summary>
|
|||
/// <value>Returns a value between 0 and 1, inclusive.</value>
|
|||
double SolutionSpeed { get; } |
|||
|
|||
/// <summary>
|
|||
/// Gets the relative reliability of the solver.
|
|||
/// </summary>
|
|||
/// <value>Returns a value between 0 and 1 inclusive.</value>
|
|||
double Reliability { get; } |
|||
} |
|||
} |
|||
@ -0,0 +1,108 @@ |
|||
// <copyright file="IIterator.cs" company="Math.NET">
|
|||
// Math.NET Numerics, part of the Math.NET Project
|
|||
// http://numerics.mathdotnet.com
|
|||
// http://github.com/mathnet/mathnet-numerics
|
|||
// http://mathnetnumerics.codeplex.com
|
|||
//
|
|||
// Copyright (c) 2009-2010 Math.NET
|
|||
//
|
|||
// Permission is hereby granted, free of charge, to any person
|
|||
// obtaining a copy of this software and associated documentation
|
|||
// files (the "Software"), to deal in the Software without
|
|||
// restriction, including without limitation the rights to use,
|
|||
// copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|||
// copies of the Software, and to permit persons to whom the
|
|||
// Software is furnished to do so, subject to the following
|
|||
// conditions:
|
|||
//
|
|||
// The above copyright notice and this permission notice shall be
|
|||
// included in all copies or substantial portions of the Software.
|
|||
//
|
|||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|||
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|||
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|||
// OTHER DEALINGS IN THE SOFTWARE.
|
|||
// </copyright>
|
|||
|
|||
namespace MathNet.Numerics.LinearAlgebra.Single.Solvers |
|||
{ |
|||
using System; |
|||
using Generic.Solvers.Status; |
|||
using StopCriterium; |
|||
|
|||
/// <summary>
|
|||
/// Defines the base interface for iterators that help control an iterative calculation.
|
|||
/// </summary>
|
|||
public interface IIterator |
|||
#if !SILVERLIGHT
|
|||
: ICloneable |
|||
#endif
|
|||
{ |
|||
/// <summary>
|
|||
/// Adds an <see cref="IIterationStopCriterium"/> to the internal collection of stop-criteria. Only a
|
|||
/// single stop criterium of each type can be stored.
|
|||
/// </summary>
|
|||
/// <param name="stopCriterium">The stop criterium to add.</param>
|
|||
/// <exception cref="ArgumentNullException">Thrown if <paramref name="stopCriterium"/> is <see langword="null" />.</exception>
|
|||
/// <exception cref="ArgumentException">Thrown if <paramref name="stopCriterium"/> is of the same type as an already stored criterium.</exception>
|
|||
void Add(IIterationStopCriterium stopCriterium); |
|||
|
|||
/// <summary>
|
|||
/// Removes the <see cref="IIterationStopCriterium"/> from the internal collection.
|
|||
/// </summary>
|
|||
/// <param name="stopCriterium">The stop criterium that must be removed.</param>
|
|||
void Remove(IIterationStopCriterium stopCriterium); |
|||
|
|||
/// <summary>
|
|||
/// Indicates if the specific stop criterium is stored by the <see cref="IIterator"/>.
|
|||
/// </summary>
|
|||
/// <param name="stopCriterium">The stop criterium.</param>
|
|||
/// <returns><c>true</c> if the <see cref="IIterator"/> contains the stop criterium; otherwise <c>false</c>.</returns>
|
|||
bool Contains(IIterationStopCriterium stopCriterium); |
|||
|
|||
/// <summary>
|
|||
/// Indicates to the iterator that the iterative process has been cancelled.
|
|||
/// </summary>
|
|||
/// <remarks>Does not reset the stop-criteria.</remarks>
|
|||
void IterationCancelled(); |
|||
|
|||
/// <summary>
|
|||
/// Determines the status of the iterative calculation based on the stop criteria stored
|
|||
/// by the current <see cref="IIterator"/>. Status is set to <c>Status</c> field of current object.
|
|||
/// </summary>
|
|||
/// <param name="iterationNumber">The number of iterations that have passed so far.</param>
|
|||
/// <param name="solutionVector">The vector containing the current solution values.</param>
|
|||
/// <param name="sourceVector">The right hand side vector.</param>
|
|||
/// <param name="residualVector">The vector containing the current residual vectors.</param>
|
|||
/// <remarks>
|
|||
/// The individual iterators may internally track the progress of the calculation based
|
|||
/// on the invocation of this method. Therefore this method should only be called if the
|
|||
/// calculation has moved forwards at least one step.
|
|||
/// </remarks>
|
|||
void DetermineStatus(int iterationNumber, Vector solutionVector, Vector sourceVector, Vector residualVector); |
|||
|
|||
/// <summary>
|
|||
/// Gets the current calculation status.
|
|||
/// </summary>
|
|||
/// <remarks><see langword="null" /> is not a legal value. Status should be set in <see cref="DetermineStatus"/> implementation.</remarks>.
|
|||
ICalculationStatus Status { get; } |
|||
|
|||
/// <summary>
|
|||
/// Resets the <see cref="IIterator"/> to the pre-calculation state.
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// Note to implementers: Invoking this method should not clear the user defined
|
|||
/// property values, only the state that is used to track the progress of the
|
|||
/// calculation.
|
|||
/// </remarks>
|
|||
void ResetToPrecalculationState(); |
|||
|
|||
#if SILVERLIGHT
|
|||
IIterator Clone(); |
|||
#endif
|
|||
} |
|||
} |
|||
@ -0,0 +1,73 @@ |
|||
// <copyright file="IPreConditioner.cs" company="Math.NET">
|
|||
// Math.NET Numerics, part of the Math.NET Project
|
|||
// http://numerics.mathdotnet.com
|
|||
// http://github.com/mathnet/mathnet-numerics
|
|||
// http://mathnetnumerics.codeplex.com
|
|||
//
|
|||
// Copyright (c) 2009-2010 Math.NET
|
|||
//
|
|||
// Permission is hereby granted, free of charge, to any person
|
|||
// obtaining a copy of this software and associated documentation
|
|||
// files (the "Software"), to deal in the Software without
|
|||
// restriction, including without limitation the rights to use,
|
|||
// copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|||
// copies of the Software, and to permit persons to whom the
|
|||
// Software is furnished to do so, subject to the following
|
|||
// conditions:
|
|||
//
|
|||
// The above copyright notice and this permission notice shall be
|
|||
// included in all copies or substantial portions of the Software.
|
|||
//
|
|||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|||
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|||
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|||
// OTHER DEALINGS IN THE SOFTWARE.
|
|||
// </copyright>
|
|||
|
|||
namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Preconditioners |
|||
{ |
|||
/// <summary>
|
|||
/// The base interface for preconditioner classes.
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// <para>
|
|||
/// Preconditioners are used by iterative solvers to improve the convergence
|
|||
/// speed of the solving process. Increase in convergence speed
|
|||
/// is related to the number of iterations necessary to get a converged solution.
|
|||
/// So while in general the use of a preconditioner means that the iterative
|
|||
/// solver will perform fewer iterations it does not guarantee that the actual
|
|||
/// solution time decreases given that some preconditioners can be expensive to
|
|||
/// setup and run.
|
|||
/// </para>
|
|||
/// <para>
|
|||
/// Note that in general changes to the matrix will invalidate the preconditioner
|
|||
/// if the changes occur after creating the preconditioner.
|
|||
/// </para>
|
|||
/// </remarks>
|
|||
public interface IPreConditioner |
|||
{ |
|||
/// <summary>
|
|||
/// Initializes the preconditioner and loads the internal data structures.
|
|||
/// </summary>
|
|||
/// <param name="matrix">The matrix on which the preconditioner is based.</param>
|
|||
void Initialize(Matrix matrix); |
|||
|
|||
/// <summary>
|
|||
/// Approximates the solution to the matrix equation <b>Mx = b</b>.
|
|||
/// </summary>
|
|||
/// <param name="rhs">The right hand side vector.</param>
|
|||
/// <returns>The left hand side vector.</returns>
|
|||
Vector Approximate(Vector rhs); |
|||
|
|||
/// <summary>
|
|||
/// Approximates the solution to the matrix equation <b>Mx = b</b>.
|
|||
/// </summary>
|
|||
/// <param name="rhs">The right hand side vector.</param>
|
|||
/// <param name="lhs">The left hand side vector. Also known as the result vector.</param>
|
|||
void Approximate(Vector rhs, Vector lhs); |
|||
} |
|||
} |
|||
@ -0,0 +1,80 @@ |
|||
// <copyright file="IIterationStopCriterium.cs" company="Math.NET">
|
|||
// Math.NET Numerics, part of the Math.NET Project
|
|||
// http://numerics.mathdotnet.com
|
|||
// http://github.com/mathnet/mathnet-numerics
|
|||
// http://mathnetnumerics.codeplex.com
|
|||
// Copyright (c) 2009-2010 Math.NET
|
|||
// Permission is hereby granted, free of charge, to any person
|
|||
// obtaining a copy of this software and associated documentation
|
|||
// files (the "Software"), to deal in the Software without
|
|||
// restriction, including without limitation the rights to use,
|
|||
// copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|||
// copies of the Software, and to permit persons to whom the
|
|||
// Software is furnished to do so, subject to the following
|
|||
// conditions:
|
|||
// The above copyright notice and this permission notice shall be
|
|||
// included in all copies or substantial portions of the Software.
|
|||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|||
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|||
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|||
// OTHER DEALINGS IN THE SOFTWARE.
|
|||
// </copyright>
|
|||
|
|||
namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.StopCriterium |
|||
{ |
|||
using System; |
|||
using Generic.Solvers.Status; |
|||
using Generic.Solvers.StopCriterium; |
|||
|
|||
/// <summary>
|
|||
/// The base interface for classes that provide stop criteria for iterative calculations.
|
|||
/// </summary>
|
|||
public interface IIterationStopCriterium |
|||
#if !SILVERLIGHT
|
|||
: ICloneable |
|||
#endif
|
|||
{ |
|||
/// <summary>
|
|||
/// Determines the status of the iterative calculation based on the stop criteria stored
|
|||
/// by the current <see cref="IIterationStopCriterium"/>. Status is set to <c>Status</c> field of current object.
|
|||
/// </summary>
|
|||
/// <param name="iterationNumber">The number of iterations that have passed so far.</param>
|
|||
/// <param name="solutionVector">The vector containing the current solution values.</param>
|
|||
/// <param name="sourceVector">The right hand side vector.</param>
|
|||
/// <param name="residualVector">The vector containing the current residual vectors.</param>
|
|||
/// <remarks>
|
|||
/// The individual stop criteria may internally track the progress of the calculation based
|
|||
/// on the invocation of this method. Therefore this method should only be called if the
|
|||
/// calculation has moved forwards at least one step.
|
|||
/// </remarks>
|
|||
void DetermineStatus(int iterationNumber, Vector solutionVector, Vector sourceVector, Vector residualVector); |
|||
|
|||
/// <summary>
|
|||
/// Gets the current calculation status.
|
|||
/// </summary>
|
|||
/// <remarks><see langword="null" /> is not a legal value. Status should be set in <see cref="DetermineStatus"/> implementation.</remarks>
|
|||
ICalculationStatus Status { get; } |
|||
|
|||
/// <summary>
|
|||
/// Resets the <see cref="IIterationStopCriterium"/> to the pre-calculation state.
|
|||
/// </summary>
|
|||
/// <remarks>To implementers: Invoking this method should not clear the user defined
|
|||
/// property values, only the state that is used to track the progress of the
|
|||
/// calculation.</remarks>
|
|||
void ResetToPrecalculationState(); |
|||
|
|||
/// <summary>
|
|||
/// Gets the <see cref="StopLevel"/> which indicates what sort of stop criterium this
|
|||
/// <see cref="IIterationStopCriterium"/> monitors.
|
|||
/// </summary>
|
|||
StopLevel StopLevel { get; } |
|||
|
|||
#if SILVERLIGHT
|
|||
IIterationStopCriterium Clone(); |
|||
#endif
|
|||
} |
|||
} |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue