Matrix.Create Method
Definition
Namespace: Numerics.NET
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.9.0
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.9.0
Constructs a new matrix.
Overload List
Create<T>(T[,], ArrayMutability)
Constructs a new matrix from a
two-dimensional array.
[ObsoleteAttribute("Use Matrix.CopyFrom(source, mutability) instead.")]
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
| Argument | values is null. |
Create<T>(Int32, Int32)
Constructs a new matrix with the specified
number of rows and columns
[ObsoleteAttribute("Use Matrix.Zeros<T>(rowCount, columnCount) instead.")]
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
| Argument | 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.
[ObsoleteAttribute("Use Matrix.FromRows(values, ...) or Matrix.FromColumns(values, ...) instead depending on the order parameter.")]
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
| Argument | values is null. |
Create<T>(Int32, Int32, MatrixElementOrder, Boolean)
Constructs a new matrix with the specified
number of rows and columns
[ObsoleteAttribute("Use Matrix.Zeros<T>(rowCount, columnCount, elementOrder, checkMissingValues) instead.")]
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
| Argument | rowCount is less than zero. -or- columnCount is less than zero. |
Create<T>(Int32, Int32, Array2D<T>, MatrixElementOrder, ArrayMutability)
Constructs a new matrix.
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, Memory2D<T>, MatrixElementOrder, ArrayMutability)
Constructs a new matrix.
public static DenseMatrix<T> Create<T>(
int rowCount,
int columnCount,
Memory2D<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 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.
Type Parameters
- T
Return Value
DenseMatrix<T>A DenseMatrix<T>.
Create<T>(Int32, Int32, Func<Int32, Int32, T>, ArrayMutability, Boolean)
Creates a new matrix initialized using a function.
[ObsoleteAttribute("Use Matrix.FromFunction<T>(rowCount, columnCount, initializer, mutability, checkMissingValues) 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.
- columnCount Int32
- The number of columns.
- initializer Func<Int32, Int32, T>
- A function that returns the value of each element.
- mutability ArrayMutability (Optional)
- Specifies how the resulting object's values may be changed.
- checkMissingValues Boolean (Optional)
- Specifies whether operations involving the matrix should check for the presence of missing values.
Type Parameters
- T
- The element type of the matrix.
Return Value
DenseMatrix<T>A new DenseMatrix<T> initialized using the specified function.
Exceptions
| Argument | rowCount or columnCount is less than zero. |
| Argument | initializer is null. |
Create<T>(Int32, Int32, Array2D<T>, MatrixElementOrder, ArrayMutability, Boolean)
Constructs a new matrix.
public static DenseMatrix<T> Create<T>(
int rowCount,
int columnCount,
Array2D<T> values,
MatrixElementOrder elementOrder,
ArrayMutability mutability,
bool checkMissingValues
)
Parameters
- rowCount Int32
- The number of rows.
- columnCount Int32
- The number of columns.
- values Array2D<T>
- The storage containing the matrix values.
- elementOrder MatrixElementOrder
- The order in which matrix elements are stored.
- mutability ArrayMutability
- Specifies how the resulting object's values may be changed.
- checkMissingValues Boolean
- Specifies whether operations involving the matrix should check for the presence of missing values.
Type Parameters
- T
Return Value
DenseMatrix<T>A DenseMatrix<T>.
Create<T>(Int32, Int32, Memory2D<T>, MatrixElementOrder, ArrayMutability, Boolean)
Constructs a new matrix.
public static DenseMatrix<T> Create<T>(
int rowCount,
int columnCount,
Memory2D<T> values,
MatrixElementOrder elementOrder,
ArrayMutability mutability,
bool checkMissingValues
)
Parameters
- rowCount Int32
- The number of rows.
- columnCount Int32
- The number of columns.
- values Memory2D<T>
- The storage containing the matrix values.
- elementOrder MatrixElementOrder
- The order in which matrix elements are stored.
- mutability ArrayMutability
- Specifies how the resulting object's values may be changed.
- checkMissingValues Boolean
- Specifies whether operations involving the matrix should check for the presence of missing values.
Type Parameters
- T
Return Value
DenseMatrix<T>A DenseMatrix<T>.
Create<T>(Int32, Int32, T[], MatrixElementOrder, Boolean, ArrayMutability, Boolean)
Constructs a new matrix of the specified
dimensions using the specified values array.
[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
| Argument | values is null. |
| Argument | rowCount is less than zero. -or- columnCount is less than zero. |
Create<T>(Int32, Int32, T[], Int32, Int32, MatrixElementOrder, ArrayMutability)
Constructs a new matrix.
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>.
Create<T>(Int32, Int32, T[], Int32, Int32, MatrixElementOrder, ArrayMutability, Boolean)
Constructs a new matrix.
public static DenseMatrix<T> Create<T>(
int rowCount,
int columnCount,
T[] values,
int offset,
int leadingDimension,
MatrixElementOrder elementOrder,
ArrayMutability mutability,
bool checkMissingValues
)
Parameters
- rowCount Int32
- The number of rows.
- columnCount Int32
- The number of columns.
- values T[]
- The storage containing the matrix values.
- offset Int32
- The zero-based offset of the first element.
- leadingDimension Int32
- The leading dimension of the storage.
- elementOrder MatrixElementOrder
- The order in which matrix elements are stored.
- mutability ArrayMutability
- Specifies how the resulting object's values may be changed.
- checkMissingValues Boolean
- Specifies whether operations involving the matrix should check for the presence of missing values.
Type Parameters
- T
Return Value
DenseMatrix<T>A DenseMatrix<T>.