Vector.Create Method

Definition

Namespace: Numerics.NET
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 9.0.0

Overload List

Create<T>(T[]) Constructs a new vector with the specified elements.
Create<T>(Int32) Constructs a new vector with the specified length.
Create<T>(ReadOnlySpan<T>) Constructs a new vector with the specified elements.
Create<T>(Int32, Boolean) Constructs a new vector with the specified length.
Create<T>(IList<T>, ArrayMutability, Boolean) Constructs a new vector with the specified elements.
Create<T>(T[], Boolean, ArrayMutability, Boolean) Constructs a new dense vector with the specified elements.
Obsolete.
Create<T>(Int32, T[], ArrayMutability, Boolean) Constructs a new dense vector.
Obsolete.
Create<T>(Int32, ArraySlice<T>, ArrayMutability, Boolean) Constructs a new dense vector.
Obsolete.
Create<T>(Int32, Func<Int32, T>, ArrayMutability, Boolean) Constructs a new dense vector.
Obsolete.
Create<T>(Int32, T[], Boolean, ArrayMutability, Boolean) Constructs a new dense vector with the specified elements.
Obsolete.
Create<T>(Int32, T[], Int32, Int32, ArrayMutability, Boolean) Constructs a new dense vector.
Obsolete.
Create<T, K>(IDictionary<K, T>) Creates an indexed vector from a dictionary.
Create<T, K>(IDictionary<K, T>, IList<K>) Creates an indexed vector from a dictionary.
Create<T, K>(Int32, Index<K>) Creates an indexed vector of the specified length with the specified index.
Create<T, TSlice>(Int32, Boolean) Constructs a new vector with the specified length.
Create<T, K>(IList<T>, IList<K>, ArrayMutability) Creates an indexed vector with the specified values and corresponding keys.

Create<T>(T[])

Constructs a new vector with the specified elements.
C#
public static DenseVector<T> Create<T>(
	params T[] values
)

Parameters

values  T[]
A variable length list of T parameters specifying the elements of the vector, or an array of values.

Type Parameters

T

Return Value

DenseVector<T>
A DenseVector<T>.

Remarks

The length of the new vector is equal to the length of values.

Exceptions

ArgumentNullException

values is null.

Create<T, K>(IDictionary<K, T>)

Creates an indexed vector from a dictionary.
C#
public static Vector<T> Create<T, K>(
	IDictionary<K, T> dictionary
)

Parameters

dictionary  IDictionary<K, T>
A dictionary.

Type Parameters

T
The element type of the vector.
K
The type of the keys in the dictionary.

Return Value

Vector<T>
An indexed vector with key values of type K.

Create<T>(Int32)

Constructs a new vector with the specified length.
C#
public static DenseVector<T> Create<T>(
	int length
)

Parameters

length  Int32
The length of the new DenseVector<T>.

Type Parameters

T

Return Value

DenseVector<T>
A DenseVector<T>.

Remarks

The elements of the vector are set to zero.

Exceptions

ArgumentOutOfRangeException

length is less than zero.

Create<T>(ReadOnlySpan<T>)

Constructs a new vector with the specified elements.
C#
public static DenseVector<T> Create<T>(
	ReadOnlySpan<T> values
)

Parameters

values  ReadOnlySpan<T>
A span containing the elements of the new vector.

Type Parameters

T

Return Value

DenseVector<T>
A DenseVector<T>.

Remarks

The elements of the vector are set to zero.

Create<T, K>(IDictionary<K, T>, IList<K>)

Creates an indexed vector from a dictionary.
C#
public static Vector<T> Create<T, K>(
	IDictionary<K, T> dictionary,
	IList<K> index
)

Parameters

dictionary  IDictionary<K, T>
A dictionary.
index  IList<K>
An index.

Type Parameters

T
The element type of the vector.
K
The type of the keys in the dictionary.

Return Value

Vector<T>
An indexed vector with key values of type K.

Remarks

If any of the keys in index are not found in dictionary, a missing value is inserted.

Exceptions

ArgumentNullException

dictionary is null.

Create<T>(Int32, Boolean)

Constructs a new vector with the specified length.
C#
public static DenseVector<T> Create<T>(
	int length,
	bool checkMissingValues
)

Parameters

length  Int32
The length of the new DenseVector<T>.
checkMissingValues  Boolean
Specifies whether operations involving the vector should check for the presence of missing values.

Type Parameters

T

Return Value

DenseVector<T>
A DenseVector<T>.

Remarks

The elements of the vector are set to zero.

Exceptions

ArgumentOutOfRangeException

length is less than zero.

Create<T, K>(Int32, Index<K>)

Creates an indexed vector of the specified length with the specified index.
C#
public static Vector<T> Create<T, K>(
	int length,
	Index<K> index
)

Parameters

length  Int32
The length of the new vector.
index  Index<K>
An index of values of type K.

Type Parameters

T
The element type of the vector.
K
The type of the keys of the index.

Return Value

Vector<T>
A vector of the specified lenght.

Create<T, TSlice>(Int32, Boolean)

Constructs a new vector with the specified length.
C#
public static DenseVector<T, TSlice> Create<T, TSlice>(
	int length,
	bool checkMissingValues = false
)
where TSlice : Object, IStorageSlice<T, TSlice>

Parameters

length  Int32
The length of the new DenseVector<T>.
checkMissingValues  Boolean  (Optional)
Optional. Specifies whether operations involving the vector should check for the presence of missing values. The default is false.

Type Parameters

T
TSlice

Return Value

DenseVector<T, TSlice>
A DenseVector<T>.

Remarks

The elements of the vector are set to zero.

Exceptions

ArgumentOutOfRangeException

length is less than zero.

Create<T>(IList<T>, ArrayMutability, Boolean)

Constructs a new vector with the specified elements.
C#
public static DenseVector<T> Create<T>(
	IList<T> values,
	ArrayMutability mutability,
	bool checkMissingValues = false
)

Parameters

values  IList<T>
An IList<T> specifying the elements of the vector.
mutability  ArrayMutability
Specifies how the vector's values may be changed. The default is mutable values.
checkMissingValues  Boolean  (Optional)
Optional. Specifies whether operations involving the vector should check for the presence of missing values. The default is false.

Type Parameters

T

Return Value

DenseVector<T>
A DenseVector<T>.

Remarks

The length of the new vector is equal to the length of values. The elements are copied to a new array.

Exceptions

ArgumentNullException

values is null.

Create<T, K>(IList<T>, IList<K>, ArrayMutability)

Creates an indexed vector with the specified values and corresponding keys.
C#
public static Vector<T> Create<T, K>(
	IList<T> values,
	IList<K> keys,
	ArrayMutability mutability = ArrayMutability.Immutable
)

Parameters

values  IList<T>
A list of values.
keys  IList<K>
A list of keys.
mutability  ArrayMutability  (Optional)
Specifies how the vector's values may be changed. The default is immutable.

Type Parameters

T
The element type of the vector.
K
The type of the keys.

Return Value

Vector<T>
A vector with elements specified by values and an index defined by keys.

Create<T>(T[], Boolean, ArrayMutability, Boolean)

Note: This API is now obsolete.
Constructs a new dense vector with the specified elements.
C#
[ObsoleteAttribute("Use the CreateFromArray method instead.")]
public static DenseVector<T> Create<T>(
	T[] values,
	bool createView,
	ArrayMutability mutability = ArrayMutability.Immutable,
	bool checkMissingValues = false
)

Parameters

values  T[]
An array that contains the elements of the new DenseVector<T>.
createView  Boolean
If true, the array referenced by values is used directly. Any changes to the elements of this DenseVector<T> will also affect the original array.If false, the elements are copied from values to a new array.
mutability  ArrayMutability  (Optional)
Specifies how the vector's values may be changed. The default is mutable values.
checkMissingValues  Boolean  (Optional)
Optional. Specifies whether operations involving the vector should check for the presence of missing values. The default is false.

Type Parameters

T

Return Value

DenseVector<T>
A DenseVector<T>.

Remarks

The length of the new vector is equal to the length of values.

Exceptions

ArgumentNullException

values is null.

Create<T>(Int32, T[], ArrayMutability, Boolean)

Note: This API is now obsolete.
Constructs a new dense vector.
C#
[ObsoleteAttribute("Use the CreateFromArray method instead.")]
public static DenseVector<T> Create<T>(
	int length,
	T[] values,
	ArrayMutability mutability,
	bool checkMissingValues = false
)

Parameters

length  Int32
The length of the vector.
values  T[]
A strided structure containing the elements.
mutability  ArrayMutability
Specifies how the vector's values may be changed.
checkMissingValues  Boolean  (Optional)
Optional. Specifies whether operations involving the vector should check for the presence of missing values. The default is false.

Type Parameters

T

Return Value

DenseVector<T>
A DenseVector<T>.

Create<T>(Int32, ArraySlice<T>, ArrayMutability, Boolean)

Note: This API is now obsolete.
Constructs a new dense vector.
C#
[ObsoleteAttribute("Use the CreateFromArray method instead.")]
public static DenseVector<T> Create<T>(
	int length,
	ArraySlice<T> values,
	ArrayMutability mutability,
	bool checkMissingValues = false
)

Parameters

length  Int32
The length of the vector.
values  ArraySlice<T>
A strided structure containing the elements.
mutability  ArrayMutability
Specifies how the vector's values may be changed.
checkMissingValues  Boolean  (Optional)
Optional. Specifies whether operations involving the vector should check for the presence of missing values. The default is false.

Type Parameters

T

Return Value

DenseVector<T>
A DenseVector<T>.

Create<T>(Int32, Func<Int32, T>, ArrayMutability, Boolean)

Note: This API is now obsolete.
Constructs a new dense vector.
C#
[ObsoleteAttribute("Use the FromFunction method instead.")]
public static DenseVector<T> Create<T>(
	int length,
	Func<int, T> initializer,
	ArrayMutability mutability = ArrayMutability.MutableValues,
	bool checkMissingValues = false
)

Parameters

length  Int32
The length of the vector.
initializer  Func<Int32, T>
A delegate that returns the value of a element given its index.
mutability  ArrayMutability  (Optional)
Specifies how the vector's values may be changed. The default is mutable values.
checkMissingValues  Boolean  (Optional)
Optional. Specifies whether operations involving the vector should check for the presence of missing values. The default is false.

Type Parameters

T

Return Value

DenseVector<T>
A DenseVector<T> whose elements are initialized using initializer.

Exceptions

ArgumentNullException

initializer is null.

ArgumentOutOfRangeException

length is less than zero.

Create<T>(Int32, T[], Boolean, ArrayMutability, Boolean)

Note: This API is now obsolete.
Constructs a new dense vector with the specified elements.
C#
[ObsoleteAttribute("Use the CreateFromArray method instead.")]
public static DenseVector<T> Create<T>(
	int length,
	T[] values,
	bool reuseValuesArray,
	ArrayMutability mutability,
	bool checkMissingValues = false
)

Parameters

length  Int32
The number of elements in the new vector.
values  T[]
An array that contains the elements of the new DenseVector<T>.
reuseValuesArray  Boolean
If true, the array referenced by values is used directly. Any changes to the elements of this DenseVector<T> will also affect the original array. If false, the elements are copied from values to a new array.
mutability  ArrayMutability
Specifies how the vector's values may be changed. The default is mutable values.
checkMissingValues  Boolean  (Optional)
Optional. Specifies whether operations involving the vector should check for the presence of missing values. The default is false.

Type Parameters

T

Return Value

DenseVector<T>
A DenseVector<T>.

Exceptions

ArgumentNullException

values is null.

ArgumentOutOfRangeException

length is less than zero.

-or-

The length of values is less than length.

Create<T>(Int32, T[], Int32, Int32, ArrayMutability, Boolean)

Note: This API is now obsolete.
Constructs a new dense vector.
C#
[ObsoleteAttribute("Use the CreateFromArray method instead.")]
public static DenseVector<T> Create<T>(
	int length,
	T[] values,
	int offset,
	int stride,
	ArrayMutability mutability,
	bool checkMissingValues = false
)

Parameters

length  Int32
The length of the vector.
values  T[]
A array that contains the elements.
offset  Int32
The offset of the first element of the vector in values.
stride  Int32
The stride between successive elements of the vector.
mutability  ArrayMutability
Specifies how the vector's values may be changed.
checkMissingValues  Boolean  (Optional)
Optional. Specifies whether operations involving the vector should check for the presence of missing values. The default is false.

Type Parameters

T

Return Value

DenseVector<T>
A DenseVector<T>.

Exceptions

ArgumentNullException

values is null.

ArgumentOutOfRangeException

length is less than zero.

-or-

The length of values is less than length.

See Also