Show / Hide Table of Contents

Class SparseLUSolver<T>

A base class for sparse linear systems that can be solved using LU decomposition. Pivoting is controlled by the Parameters property. The implementation is optimized for sparse matrices through the ISparseMatrix<T> interface.

Inheritance
object
ParameterSet
ParameterSetCollection
PivotingSolver<ISparseMatrix<T>, ISparseVector<T>, T>
SparseLUSolver<T>
SparseComplexSolver
SparseRealSolver
Implements
ISparsePivotingSolver<T>
ISparseSolver<T>
IPivotingSolver<ISparseMatrix<T>, ISparseVector<T>, T>
ISolver<T>
IParameterSetCollection
IParameterSet
IParameterized<Markowitz<T>>
Inherited Members
PivotingSolver<ISparseMatrix<T>, ISparseVector<T>, T>.IsFactored
PivotingSolver<ISparseMatrix<T>, ISparseVector<T>, T>.NeedsReordering
PivotingSolver<ISparseMatrix<T>, ISparseVector<T>, T>.Size
PivotingSolver<ISparseMatrix<T>, ISparseVector<T>, T>.this[int, int]
PivotingSolver<ISparseMatrix<T>, ISparseVector<T>, T>.this[MatrixLocation]
PivotingSolver<ISparseMatrix<T>, ISparseVector<T>, T>.this[int]
PivotingSolver<ISparseMatrix<T>, ISparseVector<T>, T>.Row
PivotingSolver<ISparseMatrix<T>, ISparseVector<T>, T>.Column
PivotingSolver<ISparseMatrix<T>, ISparseVector<T>, T>.Matrix
PivotingSolver<ISparseMatrix<T>, ISparseVector<T>, T>.Vector
PivotingSolver<ISparseMatrix<T>, ISparseVector<T>, T>.Precondition(PreconditioningMethod<ISparseMatrix<T>, ISparseVector<T>, T>)
PivotingSolver<ISparseMatrix<T>, ISparseVector<T>, T>.SwapRows(int, int)
PivotingSolver<ISparseMatrix<T>, ISparseVector<T>, T>.SwapColumns(int, int)
PivotingSolver<ISparseMatrix<T>, ISparseVector<T>, T>.Reset()
PivotingSolver<ISparseMatrix<T>, ISparseVector<T>, T>.Clear()
PivotingSolver<ISparseMatrix<T>, ISparseVector<T>, T>.ExternalToInternal(MatrixLocation)
PivotingSolver<ISparseMatrix<T>, ISparseVector<T>, T>.InternalToExternal(MatrixLocation)
PivotingSolver<ISparseMatrix<T>, ISparseVector<T>, T>.ToString()
PivotingSolver<ISparseMatrix<T>, ISparseVector<T>, T>.Factor()
PivotingSolver<ISparseMatrix<T>, ISparseVector<T>, T>.OrderAndFactor()
PivotingSolver<ISparseMatrix<T>, ISparseVector<T>, T>.SetParameter<P>(string, P)
PivotingSolver<ISparseMatrix<T>, ISparseVector<T>, T>.ForwardSubstitute(IVector<T>)
PivotingSolver<ISparseMatrix<T>, ISparseVector<T>, T>.BackwardSubstitute(IVector<T>)
PivotingSolver<ISparseMatrix<T>, ISparseVector<T>, T>.ComputeDegenerateContribution(int)
PivotingSolver<ISparseMatrix<T>, ISparseVector<T>, T>.ForwardSubstituteTransposed(IVector<T>)
PivotingSolver<ISparseMatrix<T>, ISparseVector<T>, T>.BackwardSubstituteTransposed(IVector<T>)
PivotingSolver<ISparseMatrix<T>, ISparseVector<T>, T>.ComputeDegenerateContributionTransposed(int)
PivotingSolver<ISparseMatrix<T>, ISparseVector<T>, T>.Degeneracy
PivotingSolver<ISparseMatrix<T>, ISparseVector<T>, T>.PivotSearchReduction
ParameterSetCollection.GetParameterSet<P>()
ParameterSetCollection.TryGetParameterSet<P>(out P)
ParameterSetCollection.ParameterSets
ParameterSetCollection.SetParameter<P>(string, P)
ParameterSetCollection.TrySetParameter<P>(string, P)
ParameterSetCollection.GetProperty<P>(string)
ParameterSetCollection.TryGetProperty<P>(string, out P)
ParameterSetCollection.CreateParameterSetter<P>(string)
ParameterSetCollection.CreatePropertyGetter<P>(string)
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: SpiceSharp.Algebra.Solve
Assembly: SpiceSharp.dll
Syntax
public abstract class SparseLUSolver<T> : PivotingSolver<ISparseMatrix<T>, ISparseVector<T>, T>, ISparsePivotingSolver<T>, ISparseSolver<T>, IPivotingSolver<ISparseMatrix<T>, ISparseVector<T>, T>, ISolver<T>, IParameterSetCollection, IParameterSet, IParameterized<Markowitz<T>>
Type Parameters
Name Description
T

The base value type.

Constructors

SparseLUSolver(Func<T, double>)

Initializes a new instance of the SparseLUSolver<T> class.

Declaration
protected SparseLUSolver(Func<T, double> magnitude)
Parameters
Type Name Description
Func<T, double> magnitude

The magnitude function.

Exceptions
Type Condition
ArgumentNullException

Thrown if magnitude is null.

Properties

Fillins

Number of fill-ins in the matrix generated by the solver.

Declaration
public int Fillins { get; }
Property Value
Type Description
int
Remarks

Fill-ins are elements that were auto-generated as a consequence of the solver trying to solve the matrix. To save memory, this number should remain small.

Parameters

Gets the pivoting strategy being used.

Declaration
public Markowitz<T> Parameters { get; }
Property Value
Type Description
Markowitz<T>

The pivoting strategy.

Methods

Clear()

Clears the solver of any elements. The size of the solver becomes 0.

Declaration
public override void Clear()
Overrides
PivotingSolver<ISparseMatrix<T>, ISparseVector<T>, T>.Clear()
Remarks

The method is only redefined here to avoid ambiguity issues between IMatrix<T> and IVector<T>.

CreateFillin(MatrixLocation)

Creates a fillin. The fillin is an element that appeared as a by-product of elimination/factoring the matrix.

Declaration
protected ISparseMatrixElement<T> CreateFillin(MatrixLocation location)
Parameters
Type Name Description
MatrixLocation location

The location.

Returns
Type Description
ISparseMatrixElement<T>

The created fillin element.

Eliminate(ISparseMatrixElement<T>)

Eliminates the matrix right and below the pivot.

Declaration
protected abstract void Eliminate(ISparseMatrixElement<T> pivot)
Parameters
Type Name Description
ISparseMatrixElement<T> pivot

The pivot element.

Exceptions
Type Condition
AlgebraException

Thrown if the pivot is null or has a magnitude of zero.

Factor()

Factor the equation matrix and right hand side vector. This method can save time when factoring similar matrices in succession.

Declaration
public override bool Factor()
Returns
Type Description
bool

true if the factoring was successful; otherwise, false.

Overrides
PivotingSolver<ISparseMatrix<T>, ISparseVector<T>, T>.Factor()

FindDiagonalElement(int)

Finds the diagonal element at the specified row/column.

Declaration
public Element<T> FindDiagonalElement(int index)
Parameters
Type Name Description
int index

The row/column index.

Returns
Type Description
Element<T>

The matrix element.

Exceptions
Type Condition
ArgumentOutOfRangeException

Thrown if index is negative.

FindElement(MatrixLocation)

Finds the element at the specified location in the matrix.

Declaration
public Element<T> FindElement(MatrixLocation location)
Parameters
Type Name Description
MatrixLocation location

The location.

Returns
Type Description
Element<T>

The element if it exists; otherwise null.

FindElement(int)

Finds the element at the specified position in the right-hand side vector.

Declaration
public Element<T> FindElement(int row)
Parameters
Type Name Description
int row

The row index.

Returns
Type Description
Element<T>

The element if it exists; otherwise null.

Exceptions
Type Condition
ArgumentOutOfRangeException

Thrown if row is negative.

GetElement(MatrixLocation)

Gets the element at the specified location in the matrix. A new element is created if it doesn't exist yet.

Declaration
public Element<T> GetElement(MatrixLocation location)
Parameters
Type Name Description
MatrixLocation location

The location.

Returns
Type Description
Element<T>

The matrix element.

GetElement(int)

Gets the element at the specified position in the right-hand side vector. A new element is created if it doesn't exist yet.

Declaration
public Element<T> GetElement(int row)
Parameters
Type Name Description
int row

The row.

Returns
Type Description
Element<T>

The vector element.

Exceptions
Type Condition
ArgumentOutOfRangeException

Thrown if row is negative.

MovePivot(ISparseMatrixElement<T>, int)

Moves a chosen pivot to the diagonal.

Declaration
protected void MovePivot(ISparseMatrixElement<T> pivot, int step)
Parameters
Type Name Description
ISparseMatrixElement<T> pivot

The pivot element.

int step

The current step of factoring.

Exceptions
Type Condition
ArgumentNullException

Thrown if pivot is null.

OrderAndFactor()

Order and factor the equation matrix and right hand side vector. This method will reorder the matrix as it sees fit.

Declaration
public override int OrderAndFactor()
Returns
Type Description
int

The number of rows that were successfully eliminated.

Overrides
PivotingSolver<ISparseMatrix<T>, ISparseVector<T>, T>.OrderAndFactor()

Precondition(PreconditioningMethod<ISparseMatrix<T>, ISparseVector<T>, T>)

Preconditions the solver matrix and right hand side vector.

Declaration
public override void Precondition(PreconditioningMethod<ISparseMatrix<T>, ISparseVector<T>, T> method)
Parameters
Type Name Description
PreconditioningMethod<ISparseMatrix<T>, ISparseVector<T>, T> method

The method.

Overrides
PivotingSolver<ISparseMatrix<T>, ISparseVector<T>, T>.Precondition(PreconditioningMethod<ISparseMatrix<T>, ISparseVector<T>, T>)

RemoveElement(MatrixLocation)

Removes a matrix element at the specified location.

Declaration
public bool RemoveElement(MatrixLocation location)
Parameters
Type Name Description
MatrixLocation location

The location.

Returns
Type Description
bool

true if the element was removed; otherwise, false.

RemoveElement(int)

Removes a right-hand side vector element.

Declaration
public bool RemoveElement(int row)
Parameters
Type Name Description
int row

The row.

Returns
Type Description
bool

true if the element was removed; otherwise, false.

Implements

ISparsePivotingSolver<T>
ISparseSolver<T>
IPivotingSolver<M, V, T>
ISolver<T>
IParameterSetCollection
IParameterSet
IParameterized<P>

Extension Methods

Utility.ThrowIfNull<T>(T, string)
Documentation.ParameterValues<T>(IParameterSet, bool)
Documentation.Parameters(IParameterSet)
Documentation.ParameterValues<T>(IParameterSetCollection, bool)
Documentation.Parameters(IParameterSetCollection)

See Also

PivotingSolver<M, V, T>
ISparsePivotingSolver<T>
ISparseMatrix<T>
ISparseVector<T>
IParameterized<P>
Markowitz<T>
In this article
Back to top Generated by DocFX