Class DenseVector<T>
A vector with real values
Implements
Inherited Members
Namespace: SpiceSharp.Algebra
Assembly: SpiceSharp.dll
Syntax
public class DenseVector<T> : IVector<T>
Type Parameters
Name | Description |
---|---|
T | The base value type. |
Remarks
The element at index 0 is considered a "trashcan" element under the hood, consistent to SparseMatrix<T>. This doesn't really make a difference for indexing the vector, but it does give different meanings to the length of the vector.
This vector does not automatically expand size if necessary. Under the hood it is basically just an array.
Constructors
DenseVector()
Initializes a new instance of the DenseVector<T> class.
Declaration
public DenseVector()
DenseVector(int)
Initializes a new instance of the DenseVector<T> class.
Declaration
public DenseVector(int length)
Parameters
Type | Name | Description |
---|---|---|
int | length | The length of the vector. |
Properties
this[int]
Gets or sets the value at the specified index.
Declaration
public T this[int index] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
int | index | The index. |
Property Value
Type | Description |
---|---|
T | The value. |
Length
Gets the length of the vector.
Declaration
public int Length { get; }
Property Value
Type | Description |
---|---|
int | The length. |
Methods
Clear()
Clears all elements in the vector. The size of the vector becomes 0.
Declaration
public void Clear()
CopyTo(IVector<T>)
Copies the contents of the vector to another one.
Declaration
public void CopyTo(IVector<T> target)
Parameters
Type | Name | Description |
---|---|---|
IVector<T> | target | The target vector. |
GetVectorValue(int)
Gets the value of the vector at the specified index.
Declaration
public T GetVectorValue(int index)
Parameters
Type | Name | Description |
---|---|---|
int | index | The index. |
Returns
Type | Description |
---|---|
T | The value. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Thrown if |
Reset()
Resets all elements in the vector.
Declaration
public void Reset()
SetVectorValue(int, T)
Sets the value of the vector at the specified index.
Declaration
public void SetVectorValue(int index, T value)
Parameters
Type | Name | Description |
---|---|---|
int | index | The index. |
T | value | The value. |
SwapElements(int, int)
Swaps two elements in the vector.
Declaration
public void SwapElements(int index1, int index2)
Parameters
Type | Name | Description |
---|---|---|
int | index1 | The first index. |
int | index2 | The second index. |
ToString()
Returns a string that represents this instance.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | A string that represents this instance. |