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
Implements
Inherited Members
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 |
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
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 |
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 |
|
Overrides
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 |
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 |
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 |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown if |
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 |
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 |
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
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
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 |
|
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 |
|