Vector.Ones Like<T> Method
Constructs a new vector with the same length as the template, initialized to one.
Definition
Namespace: Numerics.NET
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.1.0
C#
A ConstantVector<T> with the same length as template, initialized to one if mutability is Immutable, or a DenseVector<T> otherwise.
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.1.0
public static Vector<T> OnesLike<T>(
Vector<T> template,
ArrayMutability mutability = ArrayMutability.Immutable
)
Parameters
- template Vector<T>
- The vector whose length to copy.
- 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 one if mutability is Immutable, or a DenseVector<T> otherwise.
Example
var original = Vector.Random(10);
var ones = Vector.OnesLike(original); // Vector of 10 onesExceptions
| Argument | template is null. |