Class PivotingSolver<M, V, T>
A standard implementation for pivoting solvers.
Inheritance
Inherited Members
Namespace: SpiceSharp.Algebra.Solve
Assembly: SpiceSharp.dll
Syntax
public abstract class PivotingSolver<M, V, T> : ParameterSetCollection, IPivotingSolver<M, V, T>, ISolver<T>, IParameterSetCollection, IParameterSet where M : IMatrix<T> where V : IVector<T>
Type Parameters
Name | Description |
---|---|
M | The matrix type. |
V | The vector type. |
T | The base value type. |
Constructors
PivotingSolver(M, V)
Initializes a new instance of the PivotingSolver<M, V, T> class.
Declaration
protected PivotingSolver(M matrix, V vector)
Parameters
Type | Name | Description |
---|---|---|
M | matrix | |
V | vector |
See Also
Properties
Column
Gets the column translation.
Declaration
protected Translation Column { get; }
Property Value
Type | Description |
---|---|
Translation | The column translation. |
See Also
Degeneracy
Gets or sets the degeneracy of the matrix. For example, specifying 1 will let the solver know that one equation is expected to be linearly dependent on the others.
Declaration
[GreaterThanOrEquals(0)]
public int Degeneracy { get; set; }
Property Value
Type | Description |
---|---|
int | The degeneracy. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Thrown if the value is negative. |
See Also
IsFactored
Gets a value indicating whether this solver has been factored. A solver needs to be factored becore it can solve for a solution.
Declaration
public bool IsFactored { get; protected set; }
Property Value
Type | Description |
---|---|
bool |
|
See Also
this[MatrixLocation]
Gets or sets the value of the matrix at the specified location.
Declaration
public T this[MatrixLocation location] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
MatrixLocation | location | The location. |
Property Value
Type | Description |
---|---|
T | The value of the matrix element. |
See Also
this[int]
Gets or sets the value of the right hand side vector at the specified row.
Declaration
public T this[int row] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
int | row | The row. |
Property Value
Type | Description |
---|---|
T | The value of the right hand side vector. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Thrown if |
See Also
this[int, int]
Gets or sets the value of the matrix at the specified row and column.
Declaration
public T this[int row, int column] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
int | row | The row. |
int | column | The column. |
Property Value
Type | Description |
---|---|
T | The value. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Thrown if |
See Also
Matrix
Gets the reordered equation matrix.
Declaration
protected M Matrix { get; }
Property Value
Type | Description |
---|---|
M | The reordered equation matrix. |
See Also
NeedsReordering
Gets or sets a value indicating whether the solver needs to be reordered all the way from the start.
Declaration
public bool NeedsReordering { get; set; }
Property Value
Type | Description |
---|---|
bool |
|
Remarks
If this flag is false, the solver will still reorder when using OrderAndFactor(), but it will try to stay away from reordering as long as possible. This flag will force the solver to immediately start reordering.
See Also
PivotSearchReduction
Gets or sets the pivot search reduction. This makes sure that pivots cannot be chosen from the last N rows. The default, 0, lets the pivot strategy to choose from the whole matrix.
Declaration
[GreaterThanOrEquals(0)]
public int PivotSearchReduction { get; set; }
Property Value
Type | Description |
---|---|
int | The pivot search reduction. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Thrown if the value is negative. |
See Also
Row
Gets the row translation.
Declaration
protected Translation Row { get; }
Property Value
Type | Description |
---|---|
Translation | The row translation. |
See Also
Size
Gets the size of the solver. This is the total number of equations.
Declaration
public int Size { get; }
Property Value
Type | Description |
---|---|
int | The size. |
See Also
Vector
Gets the reordered right hand side vector.
Declaration
protected V Vector { get; }
Property Value
Type | Description |
---|---|
V | The reordered right hand side vector. |
See Also
Methods
Clear()
Clears the solver of any elements. The size of the solver becomes 0.
Declaration
public virtual void Clear()
Remarks
The method is only redefined here to avoid ambiguity issues between IMatrix<T> and IVector<T>.
See Also
ExternalToInternal(MatrixLocation)
Maps an external matrix location to an internal one.
Declaration
public MatrixLocation ExternalToInternal(MatrixLocation indices)
Parameters
Type | Name | Description |
---|---|---|
MatrixLocation | indices | The external matrix location. |
Returns
Type | Description |
---|---|
MatrixLocation | The internal matrix location. |
See Also
Factor()
Factor the equation matrix and right hand side vector. This method can save time when factoring similar matrices in succession.
Declaration
public abstract bool Factor()
Returns
Type | Description |
---|---|
bool |
|
See Also
InternalToExternal(MatrixLocation)
Maps an internal matrix location to an external one.
Declaration
public MatrixLocation InternalToExternal(MatrixLocation indices)
Parameters
Type | Name | Description |
---|---|---|
MatrixLocation | indices | The internal matrix location. |
Returns
Type | Description |
---|---|
MatrixLocation | The external matrix location. |
See Also
OrderAndFactor()
Order and factor the equation matrix and right hand side vector. This method will reorder the matrix as it sees fit.
Declaration
public abstract int OrderAndFactor()
Returns
Type | Description |
---|---|
int | The number of rows that were successfully eliminated. |
See Also
Precondition(PreconditioningMethod<M, V, T>)
Preconditions the solver matrix and right hand side vector.
Declaration
public abstract void Precondition(PreconditioningMethod<M, V, T> method)
Parameters
Type | Name | Description |
---|---|---|
PreconditioningMethod<M, V, T> | method | The method. |
See Also
Reset()
Clears all matrix and vector elements.
Declaration
public virtual void Reset()
Remarks
This method is only redefined here to avoid ambiguity issues between IMatrix<T> and IVector<T>.
See Also
SetParameter<P>(string, P)
Declaration
public ISolver<T> SetParameter<P>(string name, P value)
Parameters
Type | Name | Description |
---|---|---|
string | name | |
P | value |
Returns
Type | Description |
---|---|
ISolver<T> |
Type Parameters
Name | Description |
---|---|
P |
See Also
Solve(IVector<T>)
Solves the equations using the factored matrix and right hand side vector.
Declaration
public abstract void Solve(IVector<T> solution)
Parameters
Type | Name | Description |
---|---|---|
IVector<T> | solution | The solution. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
AlgebraException | Thrown if the solver is not factored yet. |
ArgumentException | Thrown if |
See Also
SolveTransposed(IVector<T>)
Solves the equations using the transposed factored matrix and right hand side vector.
Declaration
public abstract void SolveTransposed(IVector<T> solution)
Parameters
Type | Name | Description |
---|---|---|
IVector<T> | solution | The solution. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
AlgebraException | Thrown if the solver is not factored yet. |
ArgumentException | Thrown if |
See Also
SwapColumns(int, int)
Swap two (internal) columns in the system.
Declaration
protected void SwapColumns(int column1, int column2)
Parameters
Type | Name | Description |
---|---|---|
int | column1 | The first column index. |
int | column2 | The second column index. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Thrown if |
See Also
SwapRows(int, int)
Swap two (internal) rows in the linear system. This method keeps the matrix and vector synchronized.
Declaration
protected void SwapRows(int row1, int row2)
Parameters
Type | Name | Description |
---|---|---|
int | row1 | The first row index. |
int | row2 | The second row index. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Thrown if |
See Also
ToString()
Returns a string that represents this instance.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | A string that represents this instance. |