Matrix.Create Method

Definition

Namespace: Extreme.Mathematics
Assembly: Extreme.Numerics (in Extreme.Numerics.dll) Version: 8.1.23
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) Constructs a new matrix from a jagged array.
Create<T>(Int32, Int32, MatrixElementOrder) Constructs a new matrix with the specified number of rows and columns
Create<T>(Int32, Int32, Func<Int32, Int32, T>, ArrayMutability) Constructs a new matrix with the specified number of rows and columns whose elements are all equal to the specified value.
Create<T>(Int32, Int32, Array2D<T>, MatrixElementOrder, ArrayMutability) Constructs a new matrix.
Create<T>(Int32, Int32, T[], MatrixElementOrder, Boolean, ArrayMutability) Constructs a new matrix of the specified dimensions using the specified values array.
Create<T>(Int32, Int32, T[], Int32, Int32, MatrixElementOrder, ArrayMutability) 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

ArgumentNullExceptionvalues 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)

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
)

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.

Type Parameters

T

Return Value

DenseMatrix<T>
A DenseMatrix<T>.

Remarks

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

Exceptions

ArgumentNullExceptionvalues is null

Create<T>(Int32, Int32, MatrixElementOrder)

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
)

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.

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)

Constructs a new matrix with the specified number of rows and columns whose elements are all equal to the specified value.
C#
public static DenseMatrix<T> Create<T>(
	int rowCount,
	int columnCount,
	Func<int, int, T> initializer,
	ArrayMutability mutability = ArrayMutability.MutableValues
)

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.

Type Parameters

T

Return Value

DenseMatrix<T>
A DenseMatrix<T>.

Exceptions

ArgumentOutOfRangeException

rowCount is less than zero.

-or-

columnCount is less than zero.

ArgumentNullExceptioninitializer is null.

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

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

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.

Type Parameters

T

Return Value

DenseMatrix<T>
A DenseMatrix<T>.

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

Constructs a new matrix of the specified dimensions using the specified values array.
C#
public static DenseMatrix<T> Create<T>(
	int rowCount,
	int columnCount,
	T[] values,
	MatrixElementOrder elementOrder,
	bool reuseComponentArray = false,
	ArrayMutability mutability = ArrayMutability.MutableValues
)

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.
reuseComponentArray  Boolean  (Optional)
If true, the array referenced by Specifies how the matrix's values may be changed. The default is mutable values.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)
 

Type Parameters

T

Return Value

DenseMatrix<T>
A DenseMatrix<T>.

Exceptions

ArgumentNullExceptionvalues is null
ArgumentOutOfRangeException

rowCount is less than zero.

-or-

columnCount is less than zero.

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

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
)

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.

Type Parameters

T

Return Value

DenseMatrix<T>
A DenseMatrix<T>.

See Also