Vector.CopyFrom Method

Definition

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

Overload List

CopyFrom<T>(T[]) Constructs a new dense vector by copying elements from the specified array.
CopyFrom<T>(ReadOnlySpan<T>) Constructs a new dense vector by copying elements from the specified span.
CopyFrom<T>(T[], ArrayMutability, Boolean) Constructs a new dense vector by copying elements from the specified array.
CopyFrom<T>(IEnumerable<T>, ArrayMutability, Boolean) Constructs a new dense vector by copying elements from the specified collection.
CopyFrom<T>(T[], Int32, ArrayMutability, Boolean) Constructs a new dense vector by copying elements from the specified array.
CopyFrom<T>(T[], Int32, Int32, Int32, ArrayMutability, Boolean) Constructs a new dense vector by copying elements from the specified array with stride.
CopyFrom<K, T>(IDictionary<K, T>, ArrayMutability, Boolean) Constructs a new dense vector by copying elements from the specified dictionary.

CopyFrom<T>(T[])

Constructs a new dense vector by copying elements from the specified array.
C#
public static DenseVector<T> CopyFrom<T>(
	T[] values
)

Parameters

values  T[]
An array containing the elements of the vector.

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 from the array.

Exceptions

ArgumentNullException

values is null.

CopyFrom<T>(ReadOnlySpan<T>)

Constructs a new dense vector by copying elements from the specified span.
C#
public static DenseVector<T> CopyFrom<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>.

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

Constructs a new dense vector by copying elements from the specified array.
C#
public static DenseVector<T> CopyFrom<T>(
	T[] source,
	ArrayMutability mutability,
	bool checkMissingValues = false
)

Parameters

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

source is null.

CopyFrom<K, T>(IDictionary<K, T>, ArrayMutability, Boolean)

Constructs a new dense vector by copying elements from the specified dictionary.
C#
public static DenseVector<T> CopyFrom<K, T>(
	IDictionary<K, T> source,
	ArrayMutability mutability = ArrayMutability.MutableValues,
	bool checkMissingValues = false
)

Parameters

source  IDictionary<K, T>
A dictionary containing the elements of the new vector.
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

K
T

Return Value

DenseVector<T>
A DenseVector<T>.

Exceptions

ArgumentNullException

source is null.

CopyFrom<T>(IEnumerable<T>, ArrayMutability, Boolean)

Constructs a new dense vector by copying elements from the specified collection.
C#
public static DenseVector<T> CopyFrom<T>(
	IEnumerable<T> source,
	ArrayMutability mutability = ArrayMutability.MutableValues,
	bool checkMissingValues = false
)

Parameters

source  IEnumerable<T>
An IEnumerable<T> specifying the elements of the vector.
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 source. The elements are copied to a new array.

Exceptions

ArgumentNullException

source is null.

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

Constructs a new dense vector by copying elements from the specified array.
C#
public static DenseVector<T> CopyFrom<T>(
	T[] source,
	int length,
	ArrayMutability mutability = ArrayMutability.MutableValues,
	bool checkMissingValues = false
)

Parameters

source  T[]
An array that contains the elements of the new DenseVector<T>.
length  Int32
The number of elements to copy from source.
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 first length elements are copied from source to a new array.

Exceptions

ArgumentNullException

source is null.

ArgumentOutOfRangeException

length is less than zero.

-or-

The length of source is less than length.

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

Constructs a new dense vector by copying elements from the specified array with stride.
C#
public static DenseVector<T> CopyFrom<T>(
	T[] source,
	int startIndex,
	int length,
	int stride = 1,
	ArrayMutability mutability = ArrayMutability.MutableValues,
	bool checkMissingValues = false
)

Parameters

source  T[]
An array that contains the elements.
startIndex  Int32
The offset of the first element of the vector in source.
length  Int32
The length of the vector.
stride  Int32  (Optional)
The stride between successive elements of the vector.
mutability  ArrayMutability  (Optional)
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

source is null.

ArgumentOutOfRangeException

length is less than zero.

-or-

The length of source is less than required for the specified parameters.

See Also