Matrix.Create Method

Definition

Namespace: Numerics.NET
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 9.0.0
Constructs a new matrix.

Overload List

Create<T>(T[,], ArrayMutability) Constructs a new matrix from a two-dimensional array.
Create<T>(Int32, Int32) Constructs a new matrix with the specified number of rows and columns
Create<T>(IEnumerable<T[]>, MatrixElementOrder, ArrayMutability, Boolean) Constructs a new matrix from a jagged array.
Create<T>(Int32, Int32, MatrixElementOrder, Boolean) Constructs a new matrix with the specified number of rows and columns
Create<T>(Int32, Int32, Func<Int32, Int32, T>, ArrayMutability, Boolean) Constructs a new matrix with the specified number of rows and columns whose elements are all equal to the specified value.
Obsolete.
Create<T>(Int32, Int32, Array2D<T>, MatrixElementOrder, ArrayMutability, Boolean) Constructs a new matrix.
Create<T>(Int32, Int32, Memory2D<T>, MatrixElementOrder, ArrayMutability, Boolean) Constructs a new matrix.
Create<T>(Int32, Int32, T[], MatrixElementOrder, Boolean, ArrayMutability, Boolean) Constructs a new matrix of the specified dimensions using the specified values array.
Obsolete.
Create<T>(Int32, Int32, T[], Int32, Int32, MatrixElementOrder, ArrayMutability, Boolean) Constructs a new matrix.

Create<T>(T[,], ArrayMutability)

Constructs a new matrix from a two-dimensional array.
C#
public static DenseMatrix<T> Create<T>(
	T[,] values,
	ArrayMutability mutability = ArrayMutability.MutableValues
)

Parameters

values  T[2]
A two-dimensional array of values. The first dimension enumerates the rows. The second dimension enumerates the columns.
mutability  ArrayMutability  (Optional)
Specifies how the matrix's values may be changed. The default is mutable values.

Type Parameters

T

Return Value

DenseMatrix<T>
A DenseMatrix<T>.

Remarks

The values of the matrix are stored in row-major order.

Exceptions

ArgumentNullException

values is null.

Create<T>(Int32, Int32)

Constructs a new matrix with the specified number of rows and columns
C#
public static DenseMatrix<T> Create<T>(
	int rowCount,
	int columnCount
)

Parameters

rowCount  Int32
The number of rows in the new matrix.
columnCount  Int32
The number of columns in the new matrix.

Type Parameters

T

Return Value

DenseMatrix<T>
A DenseMatrix<T>.

Exceptions

ArgumentOutOfRangeException

rowCount is less than zero.

-or-

columnCount is less than zero.

Create<T>(IEnumerable<T[]>, MatrixElementOrder, ArrayMutability, Boolean)

Constructs a new matrix from a jagged array.
C#
public static DenseMatrix<T> Create<T>(
	IEnumerable<T[]> values,
	MatrixElementOrder order = MatrixElementOrder.RowMajor,
	ArrayMutability mutability = ArrayMutability.MutableValues,
	bool checkMissingValues = false
)

Parameters

values  IEnumerable<T[]>
A jagged array or enumerable list of arrays of values.
order  MatrixElementOrder  (Optional)
Specifies whether values contains the rows or columns of the matrix.
mutability  ArrayMutability  (Optional)
Specifies how the matrix's values may be changed. The default is mutable values.
checkMissingValues  Boolean  (Optional)
Optional. Specifies whether operations involving the matrix should check for the presence of missing values. The default is false.

Type Parameters

T

Return Value

DenseMatrix<T>
A DenseMatrix<T>.

Remarks

The values of the matrix are stored in row-major order.

Exceptions

ArgumentNullException

values is null.

Create<T>(Int32, Int32, MatrixElementOrder, Boolean)

Constructs a new matrix with the specified number of rows and columns
C#
public static DenseMatrix<T> Create<T>(
	int rowCount,
	int columnCount,
	MatrixElementOrder elementOrder,
	bool checkMissingValues = false
)

Parameters

rowCount  Int32
The number of rows in the new matrix.
columnCount  Int32
The number of columns in the new matrix.
elementOrder  MatrixElementOrder
A MatrixElementOrder value that specifies the order in which the matrix components are stored in the storage array.
checkMissingValues  Boolean  (Optional)
Optional. Specifies whether operations involving the matrix should check for the presence of missing values. The default is false.

Type Parameters

T

Return Value

DenseMatrix<T>
A DenseMatrix<T>.

Exceptions

ArgumentOutOfRangeException

rowCount is less than zero.

-or-

columnCount is less than zero.

Create<T>(Int32, Int32, Func<Int32, Int32, T>, ArrayMutability, Boolean)

Note: This API is now obsolete.
Constructs a new matrix with the specified number of rows and columns whose elements are all equal to the specified value.
C#
[ObsoleteAttribute("Use the CreateFromFunction method instead.")]
public static DenseMatrix<T> Create<T>(
	int rowCount,
	int columnCount,
	Func<int, int, T> initializer,
	ArrayMutability mutability = ArrayMutability.MutableValues,
	bool checkMissingValues = false
)

Parameters

rowCount  Int32
The number of rows in the new matrix.
columnCount  Int32
The number of columns in the new matrix.
initializer  Func<Int32, Int32, T>
A delegate that takes a row, column pair and returns the value of the corresponding element.
mutability  ArrayMutability  (Optional)
Specifies how the matrix's values may be changed. The default is mutable values.
checkMissingValues  Boolean  (Optional)
Optional. Specifies whether operations involving the matrix should check for the presence of missing values. The default is false.

Type Parameters

T

Return Value

DenseMatrix<T>
A DenseMatrix<T>.

Exceptions

ArgumentOutOfRangeException

rowCount is less than zero.

-or-

columnCount is less than zero.

ArgumentNullException

initializer is null.

Create<T>(Int32, Int32, Array2D<T>, MatrixElementOrder, ArrayMutability, Boolean)

Constructs a new matrix.
C#
public static DenseMatrix<T> Create<T>(
	int rowCount,
	int columnCount,
	Array2D<T> values,
	MatrixElementOrder elementOrder,
	ArrayMutability mutability = ArrayMutability.MutableValues,
	bool checkMissingValues = false
)

Parameters

rowCount  Int32
The number of rows in the matrix.
columnCount  Int32
The number of columns in the matrix.
values  Array2D<T>
A strided array that contains the values of the matrix.
elementOrder  MatrixElementOrder
A MatrixElementOrder value that indicates whether rows or columns are stored contiguously.
mutability  ArrayMutability  (Optional)
Specifies how the matrix's values may be changed. The default is mutable values.
checkMissingValues  Boolean  (Optional)
Optional. Specifies whether operations involving the matrix should check for the presence of missing values. The default is false.

Type Parameters

T

Return Value

DenseMatrix<T>
A DenseMatrix<T>.

Create<T>(Int32, Int32, Memory2D<T>, MatrixElementOrder, ArrayMutability, Boolean)

Constructs a new matrix.
C#
public static DenseMatrix<T> Create<T>(
	int rowCount,
	int columnCount,
	Memory2D<T> values,
	MatrixElementOrder elementOrder,
	ArrayMutability mutability = ArrayMutability.MutableValues,
	bool checkMissingValues = false
)

Parameters

rowCount  Int32
The number of rows in the matrix.
columnCount  Int32
The number of columns in the matrix.
values  Memory2D<T>
A 2D memory block that contains the values of the matrix.
elementOrder  MatrixElementOrder
A MatrixElementOrder value that indicates whether rows or columns are stored contiguously.
mutability  ArrayMutability  (Optional)
Specifies how the matrix's values may be changed. The default is mutable values.
checkMissingValues  Boolean  (Optional)
Optional. Specifies whether operations involving the matrix should check for the presence of missing values. The default is false.

Type Parameters

T

Return Value

DenseMatrix<T>
A DenseMatrix<T>.

Create<T>(Int32, Int32, T[], MatrixElementOrder, Boolean, ArrayMutability, Boolean)

Note: This API is now obsolete.
Constructs a new matrix of the specified dimensions using the specified values array.
C#
[ObsoleteAttribute("Use the CreateFromArray method instead.")]
public static DenseMatrix<T> Create<T>(
	int rowCount,
	int columnCount,
	T[] values,
	MatrixElementOrder elementOrder,
	bool createView = false,
	ArrayMutability mutability = ArrayMutability.MutableValues,
	bool checkMissingValues = false
)

Parameters

rowCount  Int32
The number of rows.
columnCount  Int32
The number of columns.
values  T[]
An array of values that contain the elements of the matrix in column-major order.
elementOrder  MatrixElementOrder
A MatrixElementOrder value that specifies the order in which the matrix elements are stored in the storage array values.
createView  Boolean  (Optional)
If true, the array referenced by values is used directly for element storage without being copied. Any changes to the elements of this matrix will also affect the original array, and vice versa. If false, the elements are copied from values to a new array.
mutability  ArrayMutability  (Optional)
Specifies how the matrix's values may be changed. The default is mutable values.
checkMissingValues  Boolean  (Optional)
Optional. Specifies whether operations involving the matrix should check for the presence of missing values. The default is false.

Type Parameters

T

Return Value

DenseMatrix<T>
A DenseMatrix<T>.

Exceptions

ArgumentNullException

values is null.

ArgumentOutOfRangeException

rowCount is less than zero.

-or-

columnCount is less than zero.

Create<T>(Int32, Int32, T[], Int32, Int32, MatrixElementOrder, ArrayMutability, Boolean)

Constructs a new matrix.
C#
public static DenseMatrix<T> Create<T>(
	int rowCount,
	int columnCount,
	T[] values,
	int offset,
	int leadingDimension,
	MatrixElementOrder elementOrder,
	ArrayMutability mutability = ArrayMutability.MutableValues,
	bool checkMissingValues = false
)

Parameters

rowCount  Int32
The number of rows in the matrix.
columnCount  Int32
The number of columns in the matrix.
values  T[]
An array that contains the values of the matrix.
offset  Int32
Offset of the first element of the matrix in values.
leadingDimension  Int32
Distance between the first element of each row or column.
elementOrder  MatrixElementOrder
A MatrixElementOrder value that indicates whether rows or columns are stored contiguously.
mutability  ArrayMutability  (Optional)
Specifies how the matrix's values may be changed. The default is mutable values.
checkMissingValues  Boolean  (Optional)
Optional. Specifies whether operations involving the matrix should check for the presence of missing values. The default is false.

Type Parameters

T

Return Value

DenseMatrix<T>
A DenseMatrix<T>.

See Also