Vector.CreateSparse Method

Definition

Namespace: Extreme.Mathematics
Assembly: Extreme.Numerics (in Extreme.Numerics.dll) Version: 8.1.23

Overload List

CreateSparse<T>(Int32) Constructs a new sparse vector of the specified length.
CreateSparse<T>(Int32, Double) Constructs a new sparse vector of the specified length.
CreateSparse<T>(Int32, Int32) Constructs a new sparse vector of the specified length.
CreateSparse<T>(Int32, Int32[], T[], ArrayMutability) Constructs a new sparse vector with the specified elements.

Vector.CreateSparse<T>(Int32)

Constructs a new sparse vector of the specified length.
C#
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

ArgumentOutOfRangeExceptionlength is less than zero.

Vector.CreateSparse<T>(Int32, Double)

Constructs a new sparse vector of the specified length.
C#
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

ArgumentOutOfRangeExceptionlength is less than zero.

-or-

fillFactor is less than or equal to zero or greater than 1.

Vector.CreateSparse<T>(Int32, Int32)

Constructs a new sparse vector of the specified length.
C#
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

ArgumentOutOfRangeExceptionlength is less than zero.

-or-

capacity is less than zero.

Vector.CreateSparse<T>(Int32, Int32[], T[], ArrayMutability)

Constructs a new sparse vector with the specified elements.
C#
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

ArgumentOutOfRangeExceptionlength is less than zero.
ArgumentNullException

indexes is null

-or-

values is null

DimensionMismatchException

The length of values is not equal to the length of indexes.

ArgumentException One or more elements of indexes is less than zero or greater than or equal to length.

See Also