Class DictionaryOfKeys
Class defining a dictionary of keys storage for sparse matrix.
Namespace: BRIDGES.LinearAlgebra.Matrices.Storage
Assembly: BRIDGES.dll
Syntax
public sealed class DictionaryOfKeys : IEnumerable<((int, int), double)>
Constructors
| Improve this Doc View SourceDictionaryOfKeys(Double[], Int32[], Int32[])
Initialises a new instance of the DictionaryOfKeys class.
Declaration
public DictionaryOfKeys(double[] values, int[] rows, int[] columns)
Parameters
Type | Name | Description |
---|---|---|
Double[] | values | Values of the new DictionaryOfKeys. |
Int32[] | rows | Row indices of the new DictionaryOfKeys. |
Int32[] | columns | Column indices of the new DictionaryOfKeys. |
DictionaryOfKeys(Int32)
Initialises a new instance of the DictionaryOfKeys class.
Declaration
public DictionaryOfKeys(int capacity)
Parameters
Type | Name | Description |
---|---|---|
Int32 | capacity | Capacity of the dictionnary of keys. |
Properties
| Improve this Doc View SourceCount
Gets the number of elements in the DictionaryOfKeys.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
Int32 |
Methods
| Improve this Doc View SourceAdd(Double, Int32, Int32)
Adds an element to the storage. If the storage contains an element at the given row and column, the value is added to the existing one.
Declaration
public void Add(double value, int row, int column)
Parameters
Type | Name | Description |
---|---|---|
Double | value | Value to add. |
Int32 | row | Row index of the value. |
Int32 | column | Column index of the value. |
AddOrReplace(Double, Int32, Int32)
Adds an element to the storage. If the storage contains an element at the given row and column, the value replaces the existing one.
Declaration
public void AddOrReplace(double value, int row, int column)
Parameters
Type | Name | Description |
---|---|---|
Double | value | Value to add. |
Int32 | row | Row index of the value. |
Int32 | column | Column index of the value. |
Clean(Double)
Removes all zeros in the storage.
Declaration
public void Clean(double tolerance)
Parameters
Type | Name | Description |
---|---|---|
Double | tolerance | Tolerance around the zero. |
GetEnumerator()
Returns an enumerator which reads through the non-zero components of the current DictionaryOfKeys.
The
Declaration
public IEnumerator<((int, int), double)> GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator<(, )<(, )<Int32, Int32>, Double>> | The enumerator of the DictionaryOfKeys. |
IsEmpty(Int32, Int32)
Evaluates whether the DictionaryOfKeys contains an element at the given row and column index.
Declaration
public bool IsEmpty(int row, int column)
Parameters
Type | Name | Description |
---|---|---|
Int32 | row | Row index. |
Int32 | column | Column index. |
Returns
Type | Description |
---|---|
Boolean | true if the storage doesn't have element at the specified row and column index, false otherwise. |
Remove(Int32, Int32)
Removes an element of the storage at the given row and column.
Declaration
public void Remove(int row, int column)
Parameters
Type | Name | Description |
---|---|---|
Int32 | row | Row index of the value. |
Int32 | column | Column index of the value. |
Replace(Double, Int32, Int32)
Replaces an element of the storage at the given row and column.
Declaration
public void Replace(double value, int row, int column)
Parameters
Type | Name | Description |
---|---|---|
Double | value | Value to replace with. |
Int32 | row | Row index of the value. |
Int32 | column | Column index of the value. |