Matrix.Full<T> Method

Creates a new matrix with all elements initialized to the specified value.

Definition

Namespace: Numerics.NET
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.1.0
C#
public static Matrix<T> Full<T>(
	int rowCount,
	int columnCount,
	T value,
	ArrayMutability mutability = ArrayMutability.Immutable
)

Parameters

rowCount  Int32
The number of rows in the new matrix.
columnCount  Int32
The number of columns in the new matrix.
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 all elements set to value if mutability is Immutable, or a DenseMatrix<T> otherwise.

Example

C#
// Create a 3x4 constant matrix filled with 5.0
var fives = Matrix.Full<double>(3, 4, 5.0);

// Create a mutable 3x4 matrix filled with 2.5
var mutableFull = Matrix.Full<double>(3, 4, 2.5, ArrayMutability.MutableValues);

Exceptions

ArgumentOutOfRangeExceptionrowCount or columnCount is less than zero.

See Also