Matrix.Full Like<T> Method
Creates a new matrix with the same shape as the template, initialized to the specified value.
Definition
Namespace: Numerics.NET
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.1.0
C#
A ConstantMatrix<T> with the same shape as template, initialized to value if mutability is Immutable, or a DenseMatrix<T> otherwise.
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.1.0
public static Matrix<T> FullLike<T>(
Matrix<T> template,
T value,
ArrayMutability mutability = ArrayMutability.Immutable
)
Parameters
- template Matrix<T>
- The matrix whose shape to copy.
- value T
- The value to assign to all elements.
- mutability ArrayMutability (Optional)
- Specifies how the matrix's values may be changed. The default is immutable (constant matrix).
Type Parameters
- T
- The element type of the matrix.
Return Value
Matrix<T>A ConstantMatrix<T> with the same shape as template, initialized to value if mutability is Immutable, or a DenseMatrix<T> otherwise.
Example
var original = Matrix.Random(3, 4);
var fives = Matrix.FullLike(original, 5.0); // 3x4 matrix filled with 5.0Exceptions
| Argument | template is null. |