# Vector.Create Method

## Definition

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

 Create(T[]) Constructs a new vector with the specified elements. Create(Int32) Constructs a new vector with the specified length. Create(IList, ArrayMutability) Constructs a new vector with the specified elements. Create(T[], Boolean, ArrayMutability) Constructs a new dense vector with the specified elements. Create(Int32, ArraySlice, ArrayMutability) Constructs a new dense vector. Create(Int32, Func, ArrayMutability) Constructs a new dense vector. Create(Int32, T[], Boolean, ArrayMutability) Constructs a new dense vector with the specified elements. Create(Int32, T[], Int32, Int32, ArrayMutability) Constructs a new dense vector. Create(IDictionary) Creates an indexed vector from a dictionary. Create(IDictionary, IList) Creates an indexed vector from a dictionary. Create(Int32, Index) Creates an indexed vector of the specified length with the specified index. Create(IList, IList, 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.

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>.

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>(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>(IList<T>, ArrayMutability)

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

#### 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.

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>(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>(T[], Boolean, ArrayMutability)

Constructs a new dense vector with the specified elements.
C#
``````public static DenseVector<T> Create<T>(
T[] values,
bool reuseComponentArray,
ArrayMutability mutability = ArrayMutability.Immutable
)
``````

#### Parameters

values  T[]
An array that contains the elements of the new DenseVector<T>.
reuseComponentArray  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.

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>(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>(Int32, ArraySlice<T>, ArrayMutability)

Constructs a new dense vector.
C#
``````public static DenseVector<T> Create<T>(
int length,
ArraySlice<T> values,
ArrayMutability mutability
)
``````

#### 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.

T

#### Return Value

DenseVector<T>
A DenseVector<T>.

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

Constructs a new dense vector.
C#
``````public static DenseVector<T> Create<T>(
int length,
Func<int, T> initializer,
ArrayMutability mutability = ArrayMutability.MutableValues
)
``````

#### 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.

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)

Constructs a new dense vector with the specified elements.
C#
``````public static DenseVector<T> Create<T>(
int length,
T[] values,
bool reuseComponentArray,
ArrayMutability mutability
)
``````

#### Parameters

length  Int32
The number of elements in the new vector.
values  T[]
An array that contains the elements of the new DenseVector<T>.
reuseComponentArray  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.

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)

Constructs a new dense vector.
C#
``````public static DenseVector<T> Create<T>(
int length,
T[] values,
int offset,
int stride,
ArrayMutability mutability
)
``````

#### Parameters

length  Int32
The length of the vector.
values  T[]
A Double 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.

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.