Matrix.ZerosLike<T> Method

Creates a new matrix with the same shape as the template, initialized to zero.

Definition

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

Parameters

template  Matrix<T>
The matrix whose shape to copy.

Type Parameters

T
The element type of the matrix.

Return Value

DenseMatrix<T>
A new DenseMatrix<T> with the same shape as template, initialized to zero.

Example

C#
var original = Matrix.Random(3, 4);
var zeros = Matrix.ZerosLike(original);  // 3x4 matrix of zeros

Exceptions

ArgumentNullExceptiontemplate is null.

See Also