Vector.Create Sparse Method
Definition
Namespace: Numerics.NET
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 9.0.4
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 9.0.4
Overload List
Create | Constructs a new sparse vector of the specified length. |
Create | Constructs a new sparse vector of the specified length. |
Create | Constructs a new sparse vector of the specified length. |
Create | Constructs a new sparse vector with the specified elements. |
CreateSparse<T>(Int32)
Constructs a new sparse vector of the specified length.
public static SparseVector<T> CreateSparse<T>(
int length
)
Parameters
- length Int32
- The length of the SparseVector<T>.
Type Parameters
- T
Return Value
SparseVector<T>A SparseVector<T>.
Exceptions
Argument | length is less than zero. |
CreateSparse<T>(Int32, Double)
Constructs a new sparse vector of the specified length.
public static SparseVector<T> CreateSparse<T>(
int length,
double fillFactor
)
Parameters
- length Int32
- The length of the SparseVector<T>.
- fillFactor Double
- A value between 0 and 1 that specifies the initial capacity of nonzero elements as a proportion of the total number of elements of the matrix.
Type Parameters
- T
Return Value
SparseVector<T>A SparseVector<T>.
Exceptions
Argument | length is less than zero. -or- fillFactor is less than or equal to zero or greater than 1. |
CreateSparse<T>(Int32, Int32)
Constructs a new sparse vector of the specified length.
public static SparseVector<T> CreateSparse<T>(
int length,
int capacity
)
Parameters
- length Int32
- The length of the SparseVector<T>.
- capacity Int32
- An integer specifying the expected number of nonzero elements of the vector.
Type Parameters
- T
Return Value
SparseVector<T>A SparseVector<T>.
Remarks
The effective capacity is never greater than length
even if capacity is larger.
Exceptions
Argument | length is less than zero. -or- capacity is less than zero. |
CreateSparse<T>(Int32, Int32[], T[], ArrayMutability)
Constructs a new sparse vector with the specified elements.
public static SparseVector<T> CreateSparse<T>(
int length,
int[] indexes,
T[] values,
ArrayMutability mutability = ArrayMutability.Immutable
)
Parameters
- length Int32
- The length of the new vector.
- indexes Int32[]
- An integer array that contains the zero-based indexes of the nonzero elements.
- values T[]
- A Double array that contains the corresponding values.
- mutability ArrayMutability (Optional)
- Specifies how the vector's values may be changed. The default is mutable values.
Type Parameters
- T
Return Value
SparseVector<T>A SparseVector<T>.
Remarks
If an index occurs more than once in indexes, the actual value is the sum of the corresponding values.
Exceptions
Argument | length is less than zero. |
Argument | indexes is null. -or- values is null. |
Dimension | The length of values is not equal to the length of indexes. |
Argument | One or more elements of indexes is less than zero or greater than or equal to length. |