Vector.FullLike<T> Method

Constructs a new vector with the same length as the template, initialized to the specified value.

Definition

Namespace: Numerics.NET
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.1.0
C#
public static Vector<T> FullLike<T>(
	Vector<T> template,
	T value,
	ArrayMutability mutability = ArrayMutability.Immutable
)

Parameters

template  Vector<T>
The vector whose length to copy.
value  T
The value to assign to all elements.
mutability  ArrayMutability  (Optional)
Specifies how the vector's values may be changed. The default is immutable (constant vector).

Type Parameters

T
The element type of the vector.

Return Value

Vector<T>
A ConstantVector<T> with the same length as template, initialized to value if mutability is Immutable, or a DenseVector<T> otherwise.

Example

C#
var original = Vector.Random(10);
var fives = Vector.FullLike(original, 5.0);  // Vector filled with 5.0

Exceptions

ArgumentNullExceptiontemplate is null.

See Also