Vector.ZerosLike<T> Method

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

Definition

Namespace: Numerics.NET
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.1.0
C#
public static DenseVector<T> ZerosLike<T>(
	Vector<T> template
)

Parameters

template  Vector<T>
The vector whose length to copy.

Type Parameters

T
The element type of the vector.

Return Value

DenseVector<T>
A new DenseVector<T> with the same length as template, initialized to zero.

Example

C#
var original = Vector.Random(10);
var zeros = Vector.ZerosLike(original);  // Vector of 10 zeros

Exceptions

ArgumentNullExceptiontemplate is null.

See Also