## Types in MathNet.Numerics.LinearAlgebra

Type CreateMatrix

Namespace MathNet.Numerics.LinearAlgebra

### Public Static Functions

#### Matrix<T>Dense<T>(int rows, int columns, Func<int, int, T> init)

Create a new dense matrix and initialize each value using the provided init function.

#### Matrix<T>Dense<T>(int rows, int columns, T value)

Create a new dense matrix and initialize each value to the same provided value.

#### Matrix<T>Dense<T>(int rows, int columns, T[] storage)

Create a new dense matrix with the given number of rows and columns directly binding to a raw array. The array is assumed to be in column-major order (column by column) and is used directly without copying. Very efficient, but changes to the array and the matrix will affect each other.

#### Matrix<T>Dense<T>(int rows, int columns)

Create a new dense matrix with the given number of rows and columns. All cells of the matrix will be initialized to zero.

#### Matrix<T>Dense<T>(DenseColumnMajorMatrixStorage<T> storage)

Create a new dense matrix straight from an initialized matrix storage instance. The storage is used directly without copying. Intended for advanced scenarios where you're working directly with storage for performance or interop reasons.

#### Matrix<T>DenseDiagonal<T>(int rows, int columns, Func<int, T> init)

Create a new diagonal dense matrix and initialize each diagonal value using the provided init function.

#### Matrix<T>DenseDiagonal<T>(int order, T value)

Create a new diagonal dense matrix and initialize each diagonal value to the same provided value.

#### Matrix<T>DenseDiagonal<T>(int rows, int columns, T value)

Create a new diagonal dense matrix and initialize each diagonal value to the same provided value.

#### Matrix<T>DenseIdentity<T>(int rows, int columns)

Create a new diagonal dense identity matrix with a one-diagonal.

#### Matrix<T>DenseIdentity<T>(int order)

Create a new diagonal dense identity matrix with a one-diagonal.

#### Matrix<T>DenseOfColumnArrays<T>(IEnumerable<T[]> columns)

Create a new dense matrix of T as a copy of the given column arrays. This new matrix will be independent from the arrays. A new memory block will be allocated for storing the matrix.

#### Matrix<T>DenseOfColumnMajor<T>(int rows, int columns, IEnumerable<T> columnMajor)

Create a new dense matrix as a copy of the given enumerable. The enumerable is assumed to be in column-major order (column by column). This new matrix will be independent from the enumerable. A new memory block will be allocated for storing the matrix.

#### Matrix<T>DenseOfColumns<T>(IEnumerable<IEnumerable<T>> data)

Create a new dense matrix as a copy of the given enumerable of enumerable columns. Each enumerable in the master enumerable specifies a column. This new matrix will be independent from the enumerables. A new memory block will be allocated for storing the matrix.

#### Matrix<T>DenseOfColumns<T>(int rows, int columns, IEnumerable<IEnumerable<T>> data)

Create a new dense matrix as a copy of the given enumerable of enumerable columns. Each enumerable in the master enumerable specifies a column. This new matrix will be independent from the enumerables. A new memory block will be allocated for storing the matrix.

#### Matrix<T>DenseOfColumnVectors<T>(IEnumerable<Vector<T>> columns)

Create a new dense matrix as a copy of the given column vectors. This new matrix will be independent from the vectors. A new memory block will be allocated for storing the matrix.

#### Matrix<T>DenseOfDiagonalArray<T>(int rows, int columns, T[] diagonal)

Create a new dense matrix with the diagonal as a copy of the given array. This new matrix will be independent from the array. A new memory block will be allocated for storing the matrix.

#### Matrix<T>DenseOfDiagonalArray<T>(T[] diagonal)

Create a new dense matrix with the diagonal as a copy of the given array. This new matrix will be independent from the array. A new memory block will be allocated for storing the matrix.

#### Matrix<T>DenseOfDiagonalVector<T>(int rows, int columns, Vector<T> diagonal)

Create a new dense matrix with the diagonal as a copy of the given vector. This new matrix will be independent from the vector. A new memory block will be allocated for storing the matrix.

#### Matrix<T>DenseOfDiagonalVector<T>(Vector<T> diagonal)

Create a new dense matrix with the diagonal as a copy of the given vector. This new matrix will be independent from the vector. A new memory block will be allocated for storing the matrix.

#### Matrix<T>DenseOfIndexed<T>(int rows, int columns, IEnumerable<Tuple<int, int, T>> enumerable)

Create a new dense matrix as a copy of the given indexed enumerable. Keys must be provided at most once, zero is assumed if a key is omitted. This new matrix will be independent from the enumerable. A new memory block will be allocated for storing the matrix.

#### Matrix<T>DenseOfMatrix<T>(Matrix<T> matrix)

Create a new dense matrix as a copy of the given other matrix. This new matrix will be independent from the other matrix. A new memory block will be allocated for storing the matrix.

#### Matrix<T>DenseOfRowArrays<T>(IEnumerable<T[]> rows)

Create a new dense matrix of T as a copy of the given row arrays. This new matrix will be independent from the arrays. A new memory block will be allocated for storing the matrix.

#### Matrix<T>DenseOfRows<T>(int rows, int columns, IEnumerable<IEnumerable<T>> data)

Create a new dense matrix as a copy of the given enumerable of enumerable rows. Each enumerable in the master enumerable specifies a row. This new matrix will be independent from the enumerables. A new memory block will be allocated for storing the matrix.

#### Matrix<T>DenseOfRows<T>(IEnumerable<IEnumerable<T>> data)

Create a new dense matrix as a copy of the given enumerable of enumerable rows. Each enumerable in the master enumerable specifies a row. This new matrix will be independent from the enumerables. A new memory block will be allocated for storing the matrix.

#### Matrix<T>DenseOfRowVectors<T>(IEnumerable<Vector<T>> rows)

Create a new dense matrix as a copy of the given row vectors. This new matrix will be independent from the vectors. A new memory block will be allocated for storing the matrix.

#### Matrix<T>Diagonal<T>(T[] storage)

Create a new square diagonal matrix directly binding to a raw array. The array is assumed to represent the diagonal values and is used directly without copying. Very efficient, but changes to the array and the matrix will affect each other.

#### Matrix<T>Diagonal<T>(int rows, int columns, Func<int, T> init)

Create a new diagonal matrix and initialize each diagonal value using the provided init function.

#### Matrix<T>Diagonal<T>(DiagonalMatrixStorage<T> storage)

Create a new diagonal matrix straight from an initialized matrix storage instance. The storage is used directly without copying. Intended for advanced scenarios where you're working directly with storage for performance or interop reasons.

#### Matrix<T>Diagonal<T>(int rows, int columns, T value)

Create a new diagonal matrix and initialize each diagonal value to the same provided value.

#### Matrix<T>Diagonal<T>(int rows, int columns)

Create a new diagonal matrix with the given number of rows and columns. All cells of the matrix will be initialized to zero.

#### Matrix<T>Diagonal<T>(int rows, int columns, T[] storage)

Create a new diagonal matrix with the given number of rows and columns directly binding to a raw array. The array is assumed to represent the diagonal values and is used directly without copying. Very efficient, but changes to the array and the matrix will affect each other.

#### Matrix<T>DiagonalIdentity<T>(int order)

Create a new diagonal identity matrix with a one-diagonal.

#### Matrix<T>DiagonalIdentity<T>(int rows, int columns)

Create a new diagonal identity matrix with a one-diagonal.

#### Matrix<T>DiagonalOfDiagonalArray<T>(int rows, int columns, T[] diagonal)

Create a new diagonal matrix with the diagonal as a copy of the given array. This new matrix will be independent from the array. A new memory block will be allocated for storing the matrix.

#### Matrix<T>DiagonalOfDiagonalArray<T>(T[] diagonal)

Create a new diagonal matrix with the diagonal as a copy of the given array. This new matrix will be independent from the array. A new memory block will be allocated for storing the matrix.

#### Matrix<T>DiagonalOfDiagonalVector<T>(Vector<T> diagonal)

Create a new diagonal matrix with the diagonal as a copy of the given vector. This new matrix will be independent from the vector. A new memory block will be allocated for storing the matrix.

#### Matrix<T>DiagonalOfDiagonalVector<T>(int rows, int columns, Vector<T> diagonal)

Create a new diagonal matrix with the diagonal as a copy of the given vector. This new matrix will be independent from the vector. A new memory block will be allocated for storing the matrix.

#### Matrix<T>Random<T>(int rows, int columns, int seed)

Create a new dense matrix with values sampled from the standard distribution with a system random source.

#### Matrix<T>Random<T>(int rows, int columns)

Create a new dense matrix with values sampled from the standard distribution with a system random source.

#### Matrix<T>Random<T>(int rows, int columns, IContinuousDistribution distribution)

Create a new dense matrix with values sampled from the provided random distribution.

#### Matrix<T>RandomPositiveDefinite<T>(int order)

Create a new positive definite dense matrix where each value is the product of two samples from the standard distribution.

#### Matrix<T>RandomPositiveDefinite<T>(int order, IContinuousDistribution distribution)

Create a new positive definite dense matrix where each value is the product of two samples from the provided random distribution.

#### Matrix<T>RandomPositiveDefinite<T>(int order, int seed)

Create a new positive definite dense matrix where each value is the product of two samples from the provided random distribution.

#### Matrix<T>SameAs<T>(Matrix<T> example, Matrix<T> otherExample)

Create a new matrix with a type that can represent and is closest to both provided samples and the dimensions of example.

#### Matrix<T>SameAs<T>(Matrix<T> example, Matrix<T> otherExample, int rows, int columns, bool fullyMutable)

Create a new matrix with a type that can represent and is closest to both provided samples.

#### Matrix<T>SameAs<T>(Vector<T> example, int rows, int columns)

Create a new matrix with the same kind of the provided example.

#### Matrix<T>SameAs<T, TU>(Matrix<T> example)

Create a new matrix with the same kind and dimensions of the provided example.

#### Matrix<T>SameAs<T, TU>(Matrix<T> example, int rows, int columns, bool fullyMutable)

Create a new matrix with the same kind of the provided example.

#### Matrix<T>Sparse<T>(int rows, int columns, Func<int, int, T> init)

Create a new sparse matrix and initialize each value using the provided init function.

#### Matrix<T>Sparse<T>(int rows, int columns, T value)

Create a new sparse matrix and initialize each value to the same provided value.

#### Matrix<T>Sparse<T>(int rows, int columns)

Create a sparse matrix of T with the given number of rows and columns.
##### Parameters
###### `int` rows

The number of rows.

###### `int` columns

The number of columns.

#### Matrix<T>Sparse<T>(SparseCompressedRowMatrixStorage<T> storage)

Create a new sparse matrix straight from an initialized matrix storage instance. The storage is used directly without copying. Intended for advanced scenarios where you're working directly with storage for performance or interop reasons.

#### Matrix<T>SparseDiagonal<T>(int rows, int columns, T value)

Create a new diagonal sparse matrix and initialize each diagonal value to the same provided value.

#### Matrix<T>SparseDiagonal<T>(int order, T value)

Create a new diagonal sparse matrix and initialize each diagonal value to the same provided value.

#### Matrix<T>SparseDiagonal<T>(int rows, int columns, Func<int, T> init)

Create a new diagonal sparse matrix and initialize each diagonal value using the provided init function.

#### Matrix<T>SparseFromCompressedSparseColumnFormat<T>(int rows, int columns, int valueCount, Int32[] rowIndices, Int32[] columnPointers, T[] values)

Create a new sparse matrix from a compressed sparse column format. This new matrix will be independent from the given arrays. A new memory block will be allocated for storing the matrix.
Duplicate entries will be summed together and explicit zeros will be not intentionally removed.
##### Parameters
###### `int` rows

The number of rows.

###### `int` columns

The number of columns.

###### `int` valueCount

The number of stored values including explicit zeros.

###### `Int32[]` rowIndices

The row index array of the compressed sparse column format.

###### `Int32[]` columnPointers

The column pointer array of the compressed sparse column format.

###### `T[]` values

The data array of the compressed sparse column format.

##### Return
###### `Matrix<T>`

The sparse matrix from the compressed sparse column format.

#### Matrix<T>SparseFromCompressedSparseRowFormat<T>(int rows, int columns, int valueCount, Int32[] rowPointers, Int32[] columnIndices, T[] values)

Create a new sparse matrix from a compressed sparse row format. This new matrix will be independent from the given arrays. A new memory block will be allocated for storing the matrix.
Duplicate entries will be summed together and explicit zeros will be not intentionally removed.
##### Parameters
###### `int` rows

The number of rows.

###### `int` columns

The number of columns.

###### `int` valueCount

The number of stored values including explicit zeros.

###### `Int32[]` rowPointers

The row pointer array of the compressed sparse row format.

###### `Int32[]` columnIndices

The column index array of the compressed sparse row format.

###### `T[]` values

The data array of the compressed sparse row format.

##### Return
###### `Matrix<T>`

The sparse matrix from the compressed sparse row format.

#### Matrix<T>SparseFromCoordinateFormat<T>(int rows, int columns, int valueCount, Int32[] rowIndices, Int32[] columnIndices, T[] values)

Create a new sparse matrix from a coordinate format. This new matrix will be independent from the given arrays. A new memory block will be allocated for storing the matrix.
Duplicate entries will be summed together and explicit zeros will be not intentionally removed.
##### Parameters
###### `int` rows

The number of rows.

###### `int` columns

The number of columns.

###### `int` valueCount

The number of stored values including explicit zeros.

###### `Int32[]` rowIndices

The row index array of the coordinate format.

###### `Int32[]` columnIndices

The column index array of the coordinate format.

###### `T[]` values

The data array of the coordinate format.

##### Return
###### `Matrix<T>`

The sparse matrix from the coordinate format.

#### Matrix<T>SparseIdentity<T>(int rows, int columns)

Create a new diagonal dense identity matrix with a one-diagonal.

#### Matrix<T>SparseIdentity<T>(int order)

Create a new diagonal dense identity matrix with a one-diagonal.

#### Matrix<T>SparseOfColumnArrays<T>(IEnumerable<T[]> columns)

Create a new sparse matrix as a copy of the given column arrays. This new matrix will be independent from the arrays. A new memory block will be allocated for storing the matrix.

#### Matrix<T>SparseOfColumnMajor<T>(int rows, int columns, IList<T> columnMajor)

Create a new sparse matrix with the given number of rows and columns as a copy of the given array. The array is assumed to be in column-major order (column by column). This new matrix will be independent from the provided array. A new memory block will be allocated for storing the matrix.

#### Matrix<T>SparseOfColumns<T>(IEnumerable<IEnumerable<T>> data)

Create a new sparse matrix as a copy of the given enumerable of enumerable columns. Each enumerable in the master enumerable specifies a column. This new matrix will be independent from the enumerables. A new memory block will be allocated for storing the matrix.

#### Matrix<T>SparseOfColumns<T>(int rows, int columns, IEnumerable<IEnumerable<T>> data)

Create a new sparse matrix as a copy of the given enumerable of enumerable columns. Each enumerable in the master enumerable specifies a column. This new matrix will be independent from the enumerables. A new memory block will be allocated for storing the matrix.

#### Matrix<T>SparseOfColumnVectors<T>(IEnumerable<Vector<T>> columns)

Create a new sparse matrix as a copy of the given column vectors. This new matrix will be independent from the vectors. A new memory block will be allocated for storing the matrix.

#### Matrix<T>SparseOfDiagonalArray<T>(int rows, int columns, T[] diagonal)

Create a new sparse matrix with the diagonal as a copy of the given array. This new matrix will be independent from the array. A new memory block will be allocated for storing the matrix.

#### Matrix<T>SparseOfDiagonalArray<T>(T[] diagonal)

Create a new sparse matrix with the diagonal as a copy of the given array. This new matrix will be independent from the array. A new memory block will be allocated for storing the matrix.

#### Matrix<T>SparseOfDiagonalVector<T>(int rows, int columns, Vector<T> diagonal)

Create a new sparse matrix with the diagonal as a copy of the given vector. This new matrix will be independent from the vector. A new memory block will be allocated for storing the matrix.

#### Matrix<T>SparseOfDiagonalVector<T>(Vector<T> diagonal)

Create a new sparse matrix with the diagonal as a copy of the given vector. This new matrix will be independent from the vector. A new memory block will be allocated for storing the matrix.

#### Matrix<T>SparseOfIndexed<T>(int rows, int columns, IEnumerable<Tuple<int, int, T>> enumerable)

Create a new sparse matrix as a copy of the given indexed enumerable. Keys must be provided at most once, zero is assumed if a key is omitted. This new matrix will be independent from the enumerable. A new memory block will be allocated for storing the matrix.

#### Matrix<T>SparseOfMatrix<T>(Matrix<T> matrix)

Create a new sparse matrix as a copy of the given other matrix. This new matrix will be independent from the other matrix. A new memory block will be allocated for storing the matrix.

#### Matrix<T>SparseOfRowArrays<T>(IEnumerable<T[]> rows)

Create a new sparse matrix as a copy of the given row arrays. This new matrix will be independent from the arrays. A new memory block will be allocated for storing the matrix.

#### Matrix<T>SparseOfRowMajor<T>(int rows, int columns, IEnumerable<T> rowMajor)

Create a new sparse matrix as a copy of the given enumerable. The enumerable is assumed to be in row-major order (row by row). This new matrix will be independent from the enumerable. A new memory block will be allocated for storing the vector.

#### Matrix<T>SparseOfRows<T>(int rows, int columns, IEnumerable<IEnumerable<T>> data)

Create a new sparse matrix as a copy of the given enumerable of enumerable rows. Each enumerable in the master enumerable specifies a row. This new matrix will be independent from the enumerables. A new memory block will be allocated for storing the matrix.

#### Matrix<T>SparseOfRows<T>(IEnumerable<IEnumerable<T>> data)

Create a new sparse matrix as a copy of the given enumerable of enumerable rows. Each enumerable in the master enumerable specifies a row. This new matrix will be independent from the enumerables. A new memory block will be allocated for storing the matrix.

#### Matrix<T>SparseOfRowVectors<T>(IEnumerable<Vector<T>> rows)

Create a new sparse matrix as a copy of the given row vectors. This new matrix will be independent from the vectors. A new memory block will be allocated for storing the matrix.

#### Matrix<T>WithStorage<T>(MatrixStorage<T> storage)

Create a new matrix straight from an initialized matrix storage instance. If you have an instance of a discrete storage type instead, use their direct methods instead.