Class Markowitz<T>
A search strategy based on methods outlined by Markowitz.
Inherited Members
Namespace: SpiceSharp.Algebra.Solve
Assembly: SpiceSharp.dll
Syntax
public class Markowitz<T> : ParameterSet, IParameterSet, ICloneable<Markowitz<T>>
Type Parameters
Name | Description |
---|---|
T | The base value type. |
Constructors
Markowitz(Func<T, double>)
Initializes a new instance of the Markowitz<T> class.
Declaration
public Markowitz(Func<T, double> magnitude)
Parameters
Type | Name | Description |
---|---|---|
Func<T, double> | magnitude | The function for turning elements into a scalar. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
Properties
AbsolutePivotThreshold
Gets or sets the absolute threshold for choosing a pivot.
Declaration
[ParameterName("pivtol")]
[ParameterInfo("The absolute threshold for validating pivots")]
[GreaterThanOrEquals(0)]
[Finite]
public double AbsolutePivotThreshold { get; set; }
Property Value
Type | Description |
---|---|
double | The absolute pivot threshold. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Thrown if the value is negative. |
Magnitude
Gets the magnitude.
Declaration
public Func<T, double> Magnitude { get; }
Property Value
Type | Description |
---|---|
Func<T, double> | The magnitude. |
RelativePivotThreshold
Gets or sets the relative threshold for choosing a pivot.
Declaration
[ParameterName("pivrel")]
[ParameterInfo("The relative threshold for validating pivots")]
[GreaterThan(0)]
[Finite]
public double RelativePivotThreshold { get; set; }
Property Value
Type | Description |
---|---|
double | The relative pivot threshold. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Thrown if the value is not greater than 0. |
Singletons
Gets the number of singletons.
Declaration
public int Singletons { get; }
Property Value
Type | Description |
---|---|
int |
Strategies
Gets the strategies used for finding a pivot.
Declaration
public Collection<MarkowitzSearchStrategy<T>> Strategies { get; }
Property Value
Type | Description |
---|---|
Collection<MarkowitzSearchStrategy<T>> | The strategies. |
Methods
Clear()
Clears the pivot strategy.
Declaration
public void Clear()
Clone()
Clones the instance.
Declaration
public Markowitz<T> Clone()
Returns
Type | Description |
---|---|
Markowitz<T> | The cloned instance. |
ColumnCount(int)
Gets the Markowitz column counts.
Declaration
public int ColumnCount(int column)
Parameters
Type | Name | Description |
---|---|---|
int | column |
Returns
Type | Description |
---|---|
int |
Exceptions
Type | Condition |
---|---|
IndexOutOfRangeException | Thrown if |
CreateFillin(ISparseMatrix<T>, ISparseMatrixElement<T>)
Notifies the strategy that a fill-in has been created
Declaration
public void CreateFillin(ISparseMatrix<T> matrix, ISparseMatrixElement<T> fillin)
Parameters
Type | Name | Description |
---|---|---|
ISparseMatrix<T> | matrix | The matrix. |
ISparseMatrixElement<T> | fillin | The fill-in. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
FindPivot(ISparseMatrix<T>, int, int)
Find a pivot in the matrix.
Declaration
public Pivot<ISparseMatrixElement<T>> FindPivot(ISparseMatrix<T> matrix, int eliminationStep, int max)
Parameters
Type | Name | Description |
---|---|---|
ISparseMatrix<T> | matrix | The matrix. |
int | eliminationStep | The current elimination step. |
int | max | The maximum row/column index of any pivot. |
Returns
Type | Description |
---|---|
Pivot<ISparseMatrixElement<T>> | The pivot information. |
Remarks
The pivot should be searched for in the submatrix towards the right and down of the
current diagonal at row/column eliminationStep
. This pivot element
will be moved to the diagonal for this elimination step.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
ArgumentOutOfRangeException | Thrown if |
Initialize(IMatrix<T>)
Initializes the pivot searching algorithm.
Declaration
public void Initialize(IMatrix<T> matrix)
Parameters
Type | Name | Description |
---|---|---|
IMatrix<T> | matrix | The matrix to use for initialization. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
IsValidPivot(ISparseMatrixElement<T>, int)
This method will check whether or not a pivot element is valid or not. It checks for the submatrix right/below of the pivot.
Declaration
public bool IsValidPivot(ISparseMatrixElement<T> pivot, int max)
Parameters
Type | Name | Description |
---|---|---|
ISparseMatrixElement<T> | pivot | The pivot candidate. |
int | max | The maximum index that a pivot can have. |
Returns
Type | Description |
---|---|
bool | True if the pivot can be used. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
MovePivot(ISparseMatrix<T>, ISparseVector<T>, ISparseMatrixElement<T>, int)
Move the pivot to the diagonal for this elimination step.
Declaration
public void MovePivot(ISparseMatrix<T> matrix, ISparseVector<T> rhs, ISparseMatrixElement<T> pivot, int eliminationStep)
Parameters
Type | Name | Description |
---|---|---|
ISparseMatrix<T> | matrix | The matrix. |
ISparseVector<T> | rhs | The right-hand side vector. |
ISparseMatrixElement<T> | pivot | The pivot element. |
int | eliminationStep | The elimination step. |
Remarks
This is done by swapping the rows and columns of the diagonal and that of the pivot.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
Product(int)
Gets the Markowitz products.
Declaration
public int Product(int index)
Parameters
Type | Name | Description |
---|---|---|
int | index |
Returns
Type | Description |
---|---|
int |
Exceptions
Type | Condition |
---|---|
IndexOutOfRangeException | Thrown if |
RowCount(int)
Gets the Markowitz row counts.
Declaration
public int RowCount(int row)
Parameters
Type | Name | Description |
---|---|---|
int | row |
Returns
Type | Description |
---|---|
int |
Exceptions
Type | Condition |
---|---|
IndexOutOfRangeException | Thrown if |
Setup(ISparseMatrix<T>, ISparseVector<T>, int, int)
Setup the pivot strategy.
Declaration
public void Setup(ISparseMatrix<T> matrix, ISparseVector<T> rhs, int eliminationStep, int max)
Parameters
Type | Name | Description |
---|---|---|
ISparseMatrix<T> | matrix | The matrix. |
ISparseVector<T> | rhs | The right-hand side vector. |
int | eliminationStep | The current elimination step. |
int | max | The maximum row/column index. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
Update(ISparseMatrix<T>, ISparseMatrixElement<T>, int)
Update the strategy after the pivot was moved.
Declaration
public void Update(ISparseMatrix<T> matrix, ISparseMatrixElement<T> pivot, int limit)
Parameters
Type | Name | Description |
---|---|---|
ISparseMatrix<T> | matrix | The matrix. |
ISparseMatrixElement<T> | pivot | The pivot element. |
int | limit | The maximum row/column for pivots. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |