Namespaces

Types in MathNet.Numerics.LinearAlgebra

Type MatrixBuilder<T>

Namespace MathNet.Numerics.LinearAlgebra

Generic linear algebra type builder, for situations where a matrix or vector must be created in a generic way. Usage of generic builders should not be required in normal user code.

Methods

Properties

Public Methods

Matrix<T> Dense(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(int rows, int columns, T value)

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

Matrix<T> Dense(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(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(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(int rows, int columns, T value)

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

Matrix<T> DenseDiagonal(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(int order, T value)

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

Matrix<T> DenseIdentity(int order)

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

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

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

Matrix<T> DenseOfArray(T[,] array)

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

Matrix<T> DenseOfColumnArrays(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(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(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> DenseOfColumns(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(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> DenseOfColumnVectors(Vector`1[] columns)

Matrix<T> DenseOfDiagonalArray(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(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> DenseOfDiagonalVector(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(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> DenseOfIndexed(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(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> DenseOfMatrixArray(Matrix`1[,] matrices)

Matrix<T> DenseOfRowArrays(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> DenseOfRowArrays(T[][] rows)

Matrix<T> DenseOfRowMajor(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 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 matrix.

Matrix<T> DenseOfRows(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(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(Vector`1[] rows)

Matrix<T> DenseOfRowVectors(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[] 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(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> Diagonal(int rows, int columns, T value)

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

Matrix<T> Diagonal(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(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(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> DiagonalIdentity(int rows, int columns)

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

Matrix<T> DiagonalIdentity(int order)

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

Matrix<T> DiagonalOfDiagonalArray(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[] 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(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(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.

bool Equals(object obj)

int GetHashCode()

Type GetType()

IIterationStopCriterion`1[] IterativeSolverStopCriteria(int maxIterations)

Matrix<T> OfStorage(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.

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

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

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

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

Matrix<T> Random(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> RandomPositiveDefinite(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(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(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(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(Vector<T> example, int rows, int columns)

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

Matrix<T> SameAs(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<TU>(Matrix<T> example)

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

Matrix<T> SameAs<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(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(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.
Parameters
SparseCompressedRowMatrixStorage<T> storage

The SparseCompressedRowMatrixStorage

Matrix<T> Sparse(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(int rows, int columns, T value)

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

Matrix<T> SparseDiagonal(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(int order, T value)

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

Matrix<T> SparseDiagonal(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(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(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(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(int rows, int columns)

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

Matrix<T> SparseIdentity(int order)

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

Matrix<T> SparseOfArray(T[,] array)

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

Matrix<T> SparseOfColumnArrays(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(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(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> SparseOfColumns(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(Vector`1[] columns)

Matrix<T> SparseOfColumnVectors(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(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[] 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(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(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(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(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> SparseOfMatrixArray(Matrix`1[,] matrices)

Matrix<T> SparseOfRowArrays(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> SparseOfRowArrays(T[][] rows)

Matrix<T> SparseOfRowMajor(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(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(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(Vector`1[] rows)

Matrix<T> SparseOfRowVectors(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.

string ToString()

Public Properties

T One get;

Gets the value of 1.0 for type T.

T Zero get;

Gets the value of 0.0 for type T.