Vector.Full<T> Method
Constructs a new vector with all elements initialized to the specified value.
Definition
Namespace: Numerics.NET
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.1.0
C#
A ConstantVector<T> with all elements set to value if mutability is Immutable, or a DenseVector<T> otherwise.
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.1.0
public static Vector<T> Full<T>(
int length,
T value,
ArrayMutability mutability = ArrayMutability.Immutable
)
Parameters
- length Int32
- The length of the vector.
- 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 all elements set to value if mutability is Immutable, or a DenseVector<T> otherwise.
Example
// Create a constant vector filled with 5.0
var fives = Vector.Full<double>(5, 5.0);
// Create a mutable vector filled with 2.5
var mutableFull = Vector.Full<double>(5, 2.5, ArrayMutability.MutableValues);Exceptions
| Argument | length is less than zero. |