Skip to content

MGroup.LinearAlgebra.Matrices

Dimitris Tsapetis edited this page Apr 17, 2019 · 1 revision

CscMatrix

Sparse matrix stored in Compressed Sparse Columns format (3-array version). The CSR format is optimized for matrix-vector and matrix-matrix multiplications, where the CSC matrix is on the left transposed or on the right untransposed. The other multiplicationss are more efficient using MGroup.LinearAlgebra.Matrices.CsrMatrix. To build a MGroup.LinearAlgebra.Matrices.CscMatrix conveniently, use MGroup.LinearAlgebra.Matrices.Builders.DokColMajor. Authors: Serafeim Bakalakos

public class MGroup.LinearAlgebra.Matrices.CscMatrix
    : IMatrix, IMatrixView, IIndexable2D, IReducible, ISparseMatrix

Properties

Type Name Summary
Double Item See MGroup.LinearAlgebra.Matrices.IIndexable2D.Item(System.Int32,System.Int32).
Int32 NumColumns The number of columns of the matrix.
Int32 NumRows The number of rows of the matrix.
Int32[] RawColOffsets The internal array that stores the index into the arrays MGroup.LinearAlgebra.Matrices.CscMatrix.RawValues and MGroup.LinearAlgebra.Matrices.CscMatrix.RawRowIndices of the first entry of each column. Its length is equal to `` + 1. The last entry is the number of non-zero entries, which must be equal to MGroup.LinearAlgebra.Matrices.CscMatrix.RawValues.Length == `MGroup.LinearAlgebra.Matrices.CscMatrix.RawRowIndices`.Length. It should only be used for passing the raw array to linear algebra libraries.
Int32[] RawRowIndices The internal array that stores the row indices of the non-zero entries in MGroup.LinearAlgebra.Matrices.CscMatrix.RawValues. Its length is equal to the number of non-zero entries. It should only be used for passing the raw array to linear algebra libraries.
Double[] RawValues The internal array that stores the non-zero entries of the matrix. The non-zero entries of each column are consecutive. Its length is equal to the number of non-zero entries. It should only be used for passing the raw array to linear algebra libraries.

Methods

Type Name Summary
IMatrix Axpy(IMatrixView otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrixView.Axpy(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
CscMatrix Axpy(CscMatrix otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrixView.Axpy(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
void AxpyIntoThis(IMatrixView otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrix.AxpyIntoThis(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
void AxpyIntoThis(CscMatrix otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrix.AxpyIntoThis(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
void Clear() See MGroup.LinearAlgebra.Matrices.IMatrix.Clear.
CscMatrix Copy(Boolean copyIndexingData) Copies the entries of this matrix.
Matrix CopyToFullMatrix() Initializes a new MGroup.LinearAlgebra.Matrices.Matrix instance by copying the entries of this MGroup.LinearAlgebra.Matrices.CscMatrix. Warning: there may not be enough memory.
Int32 CountNonZeros() See MGroup.LinearAlgebra.Matrices.ISparseMatrix.CountNonZeros
IMatrix DoEntrywise(IMatrixView other, Func<Double, Double, Double> binaryOperation) See MGroup.LinearAlgebra.Matrices.IMatrixView.DoEntrywise(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Func{System.Double,System.Double,System.Double}).
void DoEntrywiseIntoThis(IMatrixView other, Func<Double, Double, Double> binaryOperation) See MGroup.LinearAlgebra.Matrices.IMatrix.DoEntrywiseIntoThis(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Func{System.Double,System.Double,System.Double}).
void DoEntrywiseIntoThis(CscMatrix other, Func<Double, Double, Double> binaryOperation) See MGroup.LinearAlgebra.Matrices.IMatrix.DoEntrywiseIntoThis(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Func{System.Double,System.Double,System.Double}).
void DoToAllEntriesIntoThis(Func<Double, Double> unaryOperation) See MGroup.LinearAlgebra.Matrices.IMatrix.DoToAllEntriesIntoThis(System.Func{System.Double,System.Double}).
IEnumerable<ValueTuple<Int32, Int32, Double>> EnumerateNonZeros() See MGroup.LinearAlgebra.Matrices.ISparseMatrix.EnumerateNonZeros.
Boolean Equals(IIndexable2D other, Double tolerance = 1E-13) See MGroup.LinearAlgebra.Matrices.IIndexable2D.Equals(MGroup.LinearAlgebra.Matrices.IIndexable2D,System.Double).
SparseFormat GetSparseFormat() See MGroup.LinearAlgebra.Matrices.ISparseMatrix.GetSparseFormat.
IMatrix LinearCombination(Double thisCoefficient, IMatrixView otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrixView.LinearCombination(System.Double,MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
void LinearCombinationIntoThis(Double thisCoefficient, IMatrixView otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrix.LinearCombinationIntoThis(System.Double,MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
void LinearCombinationIntoThis(Double thisCoefficient, CscMatrix otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrix.LinearCombinationIntoThis(System.Double,MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
IVector Multiply(IVectorView vector, Boolean transposeThis = False) See MGroup.LinearAlgebra.Matrices.IMatrixView.Multiply(MGroup.LinearAlgebra.Vectors.IVectorView,System.Boolean).
Vector Multiply(Vector vector, Boolean transposeThis = False) See MGroup.LinearAlgebra.Matrices.IMatrixView.Multiply(MGroup.LinearAlgebra.Vectors.IVectorView,System.Boolean).
void MultiplyIntoResult(IVectorView lhsVector, IVector rhsVector, Boolean transposeThis = False) See MGroup.LinearAlgebra.Matrices.IMatrixView.MultiplyIntoResult(MGroup.LinearAlgebra.Vectors.IVectorView,MGroup.LinearAlgebra.Vectors.IVector,System.Boolean).
void MultiplyIntoResult(Vector lhsVector, Vector rhsVector, Boolean transposeThis = False) See MGroup.LinearAlgebra.Matrices.IMatrixView.MultiplyIntoResult(MGroup.LinearAlgebra.Vectors.IVectorView,MGroup.LinearAlgebra.Vectors.IVector,System.Boolean).
Matrix MultiplyLeft(IMatrixView other, Boolean transposeThis = False, Boolean transposeOther = False) See MGroup.LinearAlgebra.Matrices.IMatrixView.MultiplyLeft(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Boolean,System.Boolean).
Matrix MultiplyRight(IMatrixView other, Boolean transposeThis = False, Boolean transposeOther = False) See MGroup.LinearAlgebra.Matrices.IMatrixView.MultiplyRight(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Boolean,System.Boolean).
Matrix MultiplyRight(Matrix other, Boolean transposeThis) See MGroup.LinearAlgebra.Matrices.IMatrixView.MultiplyRight(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Boolean,System.Boolean).
Double Reduce(Double identityValue, ProcessEntry processEntry, ProcessZeros processZeros, Finalize finalize) See MGroup.LinearAlgebra.Reduction.IReducible.Reduce(System.Double,MGroup.LinearAlgebra.Reduction.ProcessEntry,MGroup.LinearAlgebra.Reduction.ProcessZeros,MGroup.LinearAlgebra.Reduction.Finalize).
CscMatrix Scale(Double scalar) Performs the following operation for the non-zero entries (i, j), such that 0 <= i < MGroup.LinearAlgebra.Matrices.CscMatrix.NumRows, 0 <= j < MGroup.LinearAlgebra.Matrices.CscMatrix.NumColumns: result[i, j] = `` * this[i, j]. The resulting matrix is written to a new MGroup.LinearAlgebra.Matrices.CscMatrix and then returned.
void ScaleIntoThis(Double scalar) See MGroup.LinearAlgebra.Matrices.IMatrix.ScaleIntoThis(System.Double).
void SetEntryRespectingPattern(Int32 rowIdx, Int32 colIdx, Double value) See MGroup.LinearAlgebra.Matrices.IMatrix.SetEntryRespectingPattern(System.Int32,System.Int32,System.Double).
IMatrix Transpose() See MGroup.LinearAlgebra.Matrices.IMatrixView.Transpose.
CscMatrix TransposeToCSC() Creates a new MGroup.LinearAlgebra.Matrices.CscMatrix instance, that is transpose to this: result[i, j] = this[j, i].
CsrMatrix TransposeToCSR(Boolean copyInternalArrays) Creates a new MGroup.LinearAlgebra.Matrices.CsrMatrix instance, that is transpose to this: result[i, j] = this[j, i]. The internal arrays can be copied or shared with this MGroup.LinearAlgebra.Matrices.CscMatrix instance.

Static Methods

Type Name Summary
CscMatrix CreateFromArrays(Int32 numRows, Int32 numCols, Double[] values, Int32[] rowIndices, Int32[] colOffsets, Boolean checkInput) Initializes a new MGroup.LinearAlgebra.Matrices.CscMatrix with the specified dimensions and the provided arrays (, and ``) as its internal data.

CsrMatrix

Sparse matrix stored in Compressed Sparse Rows format (3-array version). The CSR format is optimized for matrix-vector and matrix-matrix multiplications, where the CSR matrix is on the left untransposed or on the right transposed. The other multiplicationss are more efficient using MGroup.LinearAlgebra.Matrices.CscMatrix. To build a MGroup.LinearAlgebra.Matrices.CsrMatrix conveniently, use MGroup.LinearAlgebra.Matrices.Builders.DokRowMajor. Authors: Serafeim Bakalakos

public class MGroup.LinearAlgebra.Matrices.CsrMatrix
    : IMatrix, IMatrixView, IIndexable2D, IReducible, ISparseMatrix

Properties

Type Name Summary
Double Item See MGroup.LinearAlgebra.Matrices.IIndexable2D.Item(System.Int32,System.Int32).
Int32 NumColumns The number of columns of the matrix.
Int32 NumRows The number of rows of the matrix.
Int32[] RawColIndices The internal array that stores the column indices of the non-zero entries in MGroup.LinearAlgebra.Matrices.CsrMatrix.RawValues. Its length is equal to the number of non-zero entries. It should only be used for passing the raw array to linear algebra libraries.
Int32[] RawRowOffsets The internal array that stores the index into the arrays MGroup.LinearAlgebra.Matrices.CsrMatrix.RawValues and MGroup.LinearAlgebra.Matrices.CsrMatrix.RawColIndices of the first entry of each row. Its length is equal to `` + 1. The last entry is the number of non-zero entries, which must be equal to MGroup.LinearAlgebra.Matrices.CsrMatrix.RawValues.Length == `MGroup.LinearAlgebra.Matrices.CsrMatrix.RawColIndices`.Length. It should only be used for passing the raw array to linear algebra libraries.
Double[] RawValues The internal array that stores the non-zero entries of the matrix. The non-zero entries of each row are consecutive. Its length is equal to the number of non-zero entries. It should only be used for passing the raw array to linear algebra libraries.

Methods

Type Name Summary
IMatrix Axpy(IMatrixView otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrixView.Axpy(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
CsrMatrix Axpy(CsrMatrix otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrixView.Axpy(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
void AxpyIntoThis(IMatrixView otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrix.AxpyIntoThis(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
void AxpyIntoThis(CsrMatrix otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrix.AxpyIntoThis(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
void Clear() See MGroup.LinearAlgebra.Matrices.IMatrix.Clear.
CsrMatrix Copy(Boolean copyIndexingData) Copies the entries of this matrix.
Matrix CopyToFullMatrix() Initializes a new MGroup.LinearAlgebra.Matrices.Matrix instance by copying the entries of this MGroup.LinearAlgebra.Matrices.CsrMatrix. Warning: there may not be enough memory.
Int32 CountNonZeros() See MGroup.LinearAlgebra.Matrices.ISparseMatrix.CountNonZeros
IMatrix DoEntrywise(IMatrixView other, Func<Double, Double, Double> binaryOperation) See MGroup.LinearAlgebra.Matrices.IMatrixView.DoEntrywise(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Func{System.Double,System.Double,System.Double}).
void DoEntrywiseIntoThis(IMatrixView other, Func<Double, Double, Double> binaryOperation) See MGroup.LinearAlgebra.Matrices.IMatrix.DoEntrywiseIntoThis(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Func{System.Double,System.Double,System.Double}).
void DoEntrywiseIntoThis(CsrMatrix other, Func<Double, Double, Double> binaryOperation) See MGroup.LinearAlgebra.Matrices.IMatrix.DoEntrywiseIntoThis(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Func{System.Double,System.Double,System.Double}).
void DoToAllEntriesIntoThis(Func<Double, Double> unaryOperation) See MGroup.LinearAlgebra.Matrices.IMatrix.DoToAllEntriesIntoThis(System.Func{System.Double,System.Double}).
IEnumerable<ValueTuple<Int32, Int32, Double>> EnumerateNonZeros() See MGroup.LinearAlgebra.Matrices.ISparseMatrix.EnumerateNonZeros.
Boolean Equals(IIndexable2D other, Double tolerance = 1E-13) See MGroup.LinearAlgebra.Matrices.IIndexable2D.Equals(MGroup.LinearAlgebra.Matrices.IIndexable2D,System.Double).
SparseFormat GetSparseFormat() See MGroup.LinearAlgebra.Matrices.ISparseMatrix.GetSparseFormat.
IMatrix LinearCombination(Double thisCoefficient, IMatrixView otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrixView.LinearCombination(System.Double,MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
void LinearCombinationIntoThis(Double thisCoefficient, IMatrixView otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrix.LinearCombinationIntoThis(System.Double,MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
void LinearCombinationIntoThis(Double thisCoefficient, CsrMatrix otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrix.LinearCombinationIntoThis(System.Double,MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
IVector Multiply(IVectorView vector, Boolean transposeThis = False) See MGroup.LinearAlgebra.Matrices.IMatrixView.Multiply(MGroup.LinearAlgebra.Vectors.IVectorView,System.Boolean).
Vector Multiply(Vector vector, Boolean transposeThis = False) See MGroup.LinearAlgebra.Matrices.IMatrixView.Multiply(MGroup.LinearAlgebra.Vectors.IVectorView,System.Boolean).
void MultiplyIntoResult(IVectorView lhsVector, IVector rhsVector, Boolean transposeThis = False) See MGroup.LinearAlgebra.Matrices.IMatrixView.MultiplyIntoResult(MGroup.LinearAlgebra.Vectors.IVectorView,MGroup.LinearAlgebra.Vectors.IVector,System.Boolean).
void MultiplyIntoResult(Vector lhsVector, Vector rhsVector, Boolean transposeThis = False) See MGroup.LinearAlgebra.Matrices.IMatrixView.MultiplyIntoResult(MGroup.LinearAlgebra.Vectors.IVectorView,MGroup.LinearAlgebra.Vectors.IVector,System.Boolean).
Matrix MultiplyLeft(IMatrixView other, Boolean transposeThis = False, Boolean transposeOther = False) See MGroup.LinearAlgebra.Matrices.IMatrixView.MultiplyLeft(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Boolean,System.Boolean).
Matrix MultiplyRight(IMatrixView other, Boolean transposeThis = False, Boolean transposeOther = False) See MGroup.LinearAlgebra.Matrices.IMatrixView.MultiplyRight(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Boolean,System.Boolean).
Matrix MultiplyRight(Matrix other, Boolean transposeThis) See MGroup.LinearAlgebra.Matrices.IMatrixView.MultiplyRight(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Boolean,System.Boolean).
void MultiplyVectorSection(IVectorView vectorRight, Int32 vectorStart, Vector result, Int32 resultStart) Performs the matrix-subvector multiplication (Matlab notation): [, :] = this * [, :]. The resulting vector overwrites the entries of starting from the entry with index .
Double Reduce(Double identityValue, ProcessEntry processEntry, ProcessZeros processZeros, Finalize finalize) See MGroup.LinearAlgebra.Reduction.IReducible.Reduce(System.Double,MGroup.LinearAlgebra.Reduction.ProcessEntry,MGroup.LinearAlgebra.Reduction.ProcessZeros,MGroup.LinearAlgebra.Reduction.Finalize).
CsrMatrix Scale(Double scalar) Performs the following operation for the non-zero entries (i, j), such that 0 <= i < MGroup.LinearAlgebra.Matrices.CsrMatrix.NumRows, 0 <= j < MGroup.LinearAlgebra.Matrices.CsrMatrix.NumColumns: result[i, j] = `` * this[i, j]. The resulting matrix is written to a new MGroup.LinearAlgebra.Matrices.CsrMatrix and then returned.
void ScaleIntoThis(Double scalar) See MGroup.LinearAlgebra.Matrices.IMatrix.ScaleIntoThis(System.Double).
void SetEntryRespectingPattern(Int32 rowIdx, Int32 colIdx, Double value) See MGroup.LinearAlgebra.Matrices.IMatrix.SetEntryRespectingPattern(System.Int32,System.Int32,System.Double).
IMatrix Transpose() See MGroup.LinearAlgebra.Matrices.IMatrixView.Transpose.
CscMatrix TransposeToCSC(Boolean copyInternalArrays) Creates a new MGroup.LinearAlgebra.Matrices.CscMatrix instance, that is transpose to this: result[i, j] = this[j, i]. The internal arrays can be copied or shared with this MGroup.LinearAlgebra.Matrices.CsrMatrix instance.
CsrMatrix TransposeToCSR() Creates a new MGroup.LinearAlgebra.Matrices.CsrMatrix instance, that is transpose to this: result[i, j] = this[j, i].

Static Methods

Type Name Summary
CsrMatrix CreateFromArrays(Int32 numRows, Int32 numCols, Double[] values, Int32[] colIndices, Int32[] rowOffsets, Boolean checkInput) Initializes a new MGroup.LinearAlgebra.Matrices.CsrMatrix with the specified dimensions and the provided arrays (, and ``) as its internal data.

IIndexable2D

A matrix that supports indexing and dimension querying. These are the most basic operations all matrix classes must implement. As such, it can be used for matrix formats that do not support linear algebra operations, such as DOKs and other builders. Authors: Serafeim Bakalakos

public interface MGroup.LinearAlgebra.Matrices.IIndexable2D

Properties

Type Name Summary
Double Item The entry with row index = rowIdx and column index = colIdx.
Int32 NumColumns The number of columns of the matrix.
Int32 NumRows The number of rows of the matrix.

Methods

Type Name Summary
Boolean Equals(IIndexable2D other, Double tolerance = 1E-13) Returns true if 1) this and have the same `MGroup.LinearAlgebra.Matrices.IIndexable2D.NumRows` and `MGroup.LinearAlgebra.Matrices.IIndexable2D.NumColumns` 2) this[i, j] -[i, j] is within the acceptable `` for all (i, j).

IMatrix

Operations specified by this interface modify the matrix. Therefore it is possible that they may throw exceptions if they are used on sparse or triangular storage matrix formats. Authors: Serafeim Bakalakos

public interface MGroup.LinearAlgebra.Matrices.IMatrix
    : IMatrixView, IIndexable2D, IReducible

Methods

Type Name Summary
void AxpyIntoThis(IMatrixView otherMatrix, Double otherCoefficient) Performs the following operation for all (i, j): this[i, j] = *[i, j] + this[i, j]. Optimized version of MGroup.LinearAlgebra.Matrices.IMatrix.DoEntrywiseIntoThis(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Func{System.Double,System.Double,System.Double}) and MGroup.LinearAlgebra.Matrices.IMatrix.LinearCombinationIntoThis(System.Double,MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double). Named after BLAS axpy (y = a*x plus y). The resulting matrix overwrites the entries of this.
void Clear() Sets all entries to 0. For sparse or block matrices: the indexing arrays will not be mutated. Therefore the sparsity pattern will be preserved. The non-zero entries will be set to 0, but they will still be stored explicitly.
void DoEntrywiseIntoThis(IMatrixView matrix, Func<Double, Double, Double> binaryOperation) Performs a binary operation on each pair of entries: this[i, j] = (this[i,j], [i,j]). The resulting matrix overwrites the entries of this.
void DoToAllEntriesIntoThis(Func<Double, Double> unaryOperation) Performs a unary operation on each entry: this[i] = ``(this[i, j]). he resulting matrix overwrites the entries of this.
void LinearCombinationIntoThis(Double thisCoefficient, IMatrixView otherMatrix, Double otherCoefficient) Performs the following operation for all (i, j): this[i, j] = * this[i, j] + * ``[i, j]. Optimized version of MGroup.LinearAlgebra.Matrices.IMatrix.DoEntrywiseIntoThis(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Func{System.Double,System.Double,System.Double}). The resulting matrix overwrites the entries of this.
void ScaleIntoThis(Double scalar) Performs the following operation for all (i, j): this[i, j] = `` * this[i, j]. The resulting matrix overwrites the entries of this.
void SetEntryRespectingPattern(Int32 rowIdx, Int32 colIdx, Double value) Setter that will work as expected for general dense matrices. For sparse matrices it will throw a MGroup.LinearAlgebra.Exceptions.SparsityPatternModifiedException if a structural zero entry is written to. For symmetric matrices, this will set both (, ) and (, ).

IMatrixView

It supports common operations that do not mutate the underlying matrix. If you need to store a matrix and then pass it around or allow acceess to it, consider using this interface instead of MGroup.LinearAlgebra.Matrices.Matrix for extra safety. Authors: Serafeim Bakalakos

public interface MGroup.LinearAlgebra.Matrices.IMatrixView
    : IIndexable2D, IReducible

Methods

Type Name Summary
IMatrix Axpy(IMatrixView otherMatrix, Double otherCoefficient) Performs the following operation for all (i, j): result[i, j] = *[i, j] + this[i, j]. Optimized version of MGroup.LinearAlgebra.Matrices.IMatrixView.DoEntrywise(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Func{System.Double,System.Double,System.Double}) and MGroup.LinearAlgebra.Matrices.IMatrixView.LinearCombination(System.Double,MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double). Named after BLAS axpy (y = a * x plus y). The resulting matrix is written in a new object and then returned.
IMatrix Copy(Boolean copyIndexingData = False) Copies this MGroup.LinearAlgebra.Matrices.IMatrixView object. A new matrix of the same type as this object is initialized and returned.
IMatrix DoEntrywise(IMatrixView matrix, Func<Double, Double, Double> binaryOperation) Performs a binary operation on each pair of entries: result[i, j] = (this[i, j], [i]). The resulting matrix is written in a new object and then returned.
IMatrix DoToAllEntries(Func<Double, Double> unaryOperation) Performs a unary operation on each entry: result[i] = ``(this[i, j]). The resulting matrix is written in a new object and then returned.
IMatrix LinearCombination(Double thisCoefficient, IMatrixView otherMatrix, Double otherCoefficient) Performs the following operation for all (i, j): result[i, j] = * this[i, j] + * ``[i, j]. Optimized version of MGroup.LinearAlgebra.Matrices.IMatrixView.DoEntrywise(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Func{System.Double,System.Double,System.Double}). The resulting matrix is written in a new object and then returned.
IVector Multiply(IVectorView vector, Boolean transposeThis = False) Performs the matrix-vector multiplication: oper(this) * . To multiply this * columnVector, set to false. To multiply rowVector * this, set `` to true. The resulting vector will be written in a new vector and returned.
void MultiplyIntoResult(IVectorView lhsVector, IVector rhsVector, Boolean transposeThis = False) Performs the matrix-vector multiplication: = oper(this) *. To multiply this * columnVector, set to false. To multiply rowVector * this, set to true. The resulting vector will overwrite the entries of ``.
Matrix MultiplyLeft(IMatrixView other, Boolean transposeThis = False, Boolean transposeOther = False) Performs the matrix-matrix multiplication: oper(``) * oper(this).
Matrix MultiplyRight(IMatrixView other, Boolean transposeThis = False, Boolean transposeOther = False) Performs the matrix-matrix multiplication: oper(this) * oper(``).
IMatrix Scale(Double scalar) Performs the following operation for all (i, j): result[i, j] = `` * this[i, j]. The resulting matrix is written in a new object and then returned.
IMatrix Transpose() Returns a matrix that is transpose to this: result[i, j] = this[j, i]. The entries will be explicitly copied. Some implementations of MGroup.LinearAlgebra.Matrices.IMatrixView may offer more efficient transpositions, that do not copy the entries. If the transposed matrix will be used only for multiplications, MGroup.LinearAlgebra.Matrices.IMatrixView.MultiplyLeft(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Boolean,System.Boolean), MGroup.LinearAlgebra.Matrices.IMatrixView.MultiplyRight(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Boolean,System.Boolean) and MGroup.LinearAlgebra.Matrices.IMatrixView.Multiply(MGroup.LinearAlgebra.Vectors.IVectorView,System.Boolean) are more effient generally.

ISliceable2D

Can return subvectors and submatices containing select entries. Authors: Serafeim Bakalakos

public interface MGroup.LinearAlgebra.Matrices.ISliceable2D
    : IIndexable2D

Methods

Type Name Summary
Vector GetColumn(Int32 colIndex) Returns a vector with the entries of the original matrix's column at index = ``.
Vector GetRow(Int32 rowIndex) Returns a vector with the entries of the original matrix's row at index = ``.
Matrix GetSubmatrix(Int32[] rowIndices, Int32[] colIndices) Returns a submatrix with the rows and columns of the original matrix that correspond to the provided index arrays. The relative order of the rows and columns in the returned subvector can be different than the original one. It is defined by the order of the index arrays and respectively.
Matrix GetSubmatrix(Int32 rowStartInclusive, Int32 rowEndExclusive, Int32 colStartInclusive, Int32 colEndExclusive) Returns a submatrix with the rows and columns of the original matrix that correspond to the provided index arrays. The relative order of the rows and columns in the returned subvector can be different than the original one. It is defined by the order of the index arrays and respectively.

ISparseMatrix

A matrix that does not explicitly store all/most of its zero entries. Authors: Serafeim Bakalakos

public interface MGroup.LinearAlgebra.Matrices.ISparseMatrix
    : IIndexable2D

Methods

Type Name Summary
Int32 CountNonZeros() Counts how many non zero entries are stored in the matrix. This includes zeros that are explicitly stored.
IEnumerable<ValueTuple<Int32, Int32, Double>> EnumerateNonZeros() Iterates over the non zero entries of the matrix. This includes zeros that are explicitly stored.
SparseFormat GetSparseFormat() Returns a data transfer object that contains the internal data structures of this matrix.

ISparseSymmetricMatrix

A matrix that explicitly stores only the upper triangular non zero entries. Some zero entries may also be stored. Authors: Serafeim Bakalakos

public interface MGroup.LinearAlgebra.Matrices.ISparseSymmetricMatrix
    : ISymmetricMatrix, ISparseMatrix, IIndexable2D

Methods

Type Name Summary
Int32 CountNonZerosUpper() Counts how many non zero entries are stored in the upper triangle of the matrix, including the diagonal. This includes zeros that are explicitly stored.
IEnumerable<ValueTuple<Int32, Int32, Double>> EnumerateNonZerosUpper() Iterates over the non zero entries of the upper part of the matrix, including the diagonal. This includes zeros that are explicitly stored.

ISymmetricMatrix

Tagging interface for symmetric matrices. Authors: Serafeim Bakalakos

public interface MGroup.LinearAlgebra.Matrices.ISymmetricMatrix

Matrix

General purpose matrix class. All entries are stored in an 1D column major array. Uses LAPACK for most operations. Authors: Serafeim Bakalakos

public class MGroup.LinearAlgebra.Matrices.Matrix
    : IMatrix, IMatrixView, IIndexable2D, IReducible, ISliceable2D

Properties

Type Name Summary
Boolean IsSquare Returns true if MGroup.LinearAlgebra.Matrices.Matrix.NumRows == MGroup.LinearAlgebra.Matrices.Matrix.NumColumns.
Double Item See MGroup.LinearAlgebra.Matrices.IIndexable2D.Item(System.Int32,System.Int32).
Int32 NumColumns The number of columns of the matrix.
Int32 NumNonZeros The number of non-zero and explicitly stored zero entries, which is the number of all entries in this MGroup.LinearAlgebra.Matrices.Matrix.
Int32 NumRows The number of rows of the matrix.
Double[] RawData It should only be used for passing the raw array to linear algebra libraries. The internal array that stores the entries of the matrix in column major layout.

Methods

Type Name Summary
Matrix AppendBottom(Matrix matrix) Creates a new MGroup.LinearAlgebra.Matrices.Matrix that contains all rows of this MGroup.LinearAlgebra.Matrices.Matrix instance, followed by all rows of . If this is m1-by-n1 and is m2-by-n2, then n2 must be equal to n1 and the resulting matrix will be (m1+m2)-by-n1.
Matrix AppendRight(Matrix matrix) Creates a new MGroup.LinearAlgebra.Matrices.Matrix that contains all columns of this MGroup.LinearAlgebra.Matrices.Matrix instance, followed by all columns of . If this is m1-by-n1 and is m2-by-n2, then m2 must be equal to mn1 and the resulting matrix will be m1-by-(n1+n2).
IMatrix Axpy(IMatrixView otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrixView.Axpy(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
Matrix Axpy(Matrix otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrixView.Axpy(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
void AxpyIntoThis(IMatrixView otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrix.AxpyIntoThis(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
void AxpyIntoThis(Matrix otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrix.AxpyIntoThis(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
Double CalcDeterminant() Calculates the determinant of this matrix, which must be square. If the inverse matrix is also needed, use MGroup.LinearAlgebra.Matrices.Matrix.InvertAndDetermninant instead.
void Clear() See MGroup.LinearAlgebra.Matrices.IMatrix.Clear.
Matrix Copy() Initializes a new instance of MGroup.LinearAlgebra.Matrices.Matrix by copying the entries of this instance.
Double[,] CopyToArray2D() Copies the entries of the matrix into a 2-dimensional array. The returned array has length(0) = MGroup.LinearAlgebra.Matrices.Matrix.NumRows and length(1) = MGroup.LinearAlgebra.Matrices.Matrix.NumColumns.
IMatrix DoEntrywise(IMatrixView matrix, Func<Double, Double, Double> binaryOperation) See MGroup.LinearAlgebra.Matrices.IMatrixView.DoEntrywise(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Func{System.Double,System.Double,System.Double}).
Matrix DoEntrywise(Matrix matrix, Func<Double, Double, Double> binaryOperation) See MGroup.LinearAlgebra.Matrices.IMatrixView.DoEntrywise(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Func{System.Double,System.Double,System.Double}).
void DoEntrywiseIntoThis(IMatrixView matrix, Func<Double, Double, Double> binaryOperation) See MGroup.LinearAlgebra.Matrices.IMatrix.DoEntrywiseIntoThis(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Func{System.Double,System.Double,System.Double}).
void DoEntrywiseIntoThis(Matrix matrix, Func<Double, Double, Double> binaryOperation) See MGroup.LinearAlgebra.Matrices.IMatrix.DoEntrywiseIntoThis(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Func{System.Double,System.Double,System.Double}).
Matrix DoToAllEntries(Func<Double, Double> unaryOperation) Performs the following operation for 0 <= i < MGroup.LinearAlgebra.Matrices.Matrix.NumRows, 0 <= j < MGroup.LinearAlgebra.Matrices.Matrix.NumColumns: result[i, j] = ``(this[i,j]). The resulting matrix is written to a new MGroup.LinearAlgebra.Matrices.Matrix and then returned.
void DoToAllEntriesIntoThis(Func<Double, Double> unaryOperation) See MGroup.LinearAlgebra.Matrices.IMatrix.DoToAllEntriesIntoThis(System.Func{System.Double,System.Double}).
Boolean Equals(IIndexable2D other, Double tolerance = 1E-13) See MGroup.LinearAlgebra.Matrices.IIndexable2D.Equals(MGroup.LinearAlgebra.Matrices.IIndexable2D,System.Double).
CholeskyFull FactorCholesky(Boolean inPlace = False) Calculates the Cholesky factorization of a symmetric positive definite matrix with n = MGroup.LinearAlgebra.Matrices.Matrix.NumRows = MGroup.LinearAlgebra.Matrices.Matrix.NumColumns, such that A = L^T * L. L is a lower triangular n-by-n matrix. This only works if the matrix is symmetric positive definite. Requires extra available memory n^2 entries.
LQFactorization FactorLQ() Calculates the LQ factorization of a matrix with m = MGroup.LinearAlgebra.Matrices.Matrix.NumRows <= MGroup.LinearAlgebra.Matrices.Matrix.NumColumns = n, such that A = L * Q. Q is an orthogonal n-by-n matrix and L is a lower trapezoidal m-by-n matrix. Requires extra available memory form * n + min(m, n) entries.
LUFactorization FactorLU() Calculates the LUP factorization of a square matrix with n = MGroup.LinearAlgebra.Matrices.Matrix.NumRows = MGroup.LinearAlgebra.Matrices.Matrix.NumColumns, such that A = P * L * U. L is a lower triangular n-by-n matrix. U is an upper triangular n-by-n matrix. P is an n-by-n permutation matrix. Requires extra available memory n^2 + n entries.
QRFactorization FactorQR() Calculates the QR factorization of a matrix with m = MGroup.LinearAlgebra.Matrices.Matrix.NumRows >= MGroup.LinearAlgebra.Matrices.Matrix.NumColumns = n, such that A = Q * R. Q is an orthogonal m-by-m matrix and R is an upper trapezoidal m-by-n matrix. Requires extra available memory for m * n + min(m, n) entries.
Vector GetColumn(Int32 colIndex) See MGroup.LinearAlgebra.Matrices.ISliceable2D.GetColumn(System.Int32).
Vector GetDiagonal() Returns a MGroup.LinearAlgebra.Vectors.Vector with the entries of the matrix's main diagonal. The matrix must be square.
Double[] GetDiagonalAsArray() Returns an array with the entries of the matrix's main diagonal. The matrix must be square.
Vector GetRow(Int32 rowIndex) See MGroup.LinearAlgebra.Matrices.ISliceable2D.GetRow(System.Int32).
Matrix GetSubmatrix(Int32[] rowIndices, Int32[] colIndices) See MGroup.LinearAlgebra.Matrices.ISliceable2D.GetSubmatrix(System.Int32[],System.Int32[]).
Matrix GetSubmatrix(Int32 rowStartInclusive, Int32 rowEndExclusive, Int32 colStartInclusive, Int32 colEndExclusive) See MGroup.LinearAlgebra.Matrices.ISliceable2D.GetSubmatrix(System.Int32[],System.Int32[]).
Matrix Invert() Calculates the inverse matrix and returns it in a new MGroup.LinearAlgebra.Matrices.Matrix instance. This only works if this MGroup.LinearAlgebra.Matrices.Matrix is square and invertible. If the determinant matrix is also needed, use MGroup.LinearAlgebra.Matrices.Matrix.InvertAndDetermninant instead.
ValueTuple<Matrix, Double> InvertAndDetermninant() Calculates the determinant and the inverse matrix and returns the latter in a new MGroup.LinearAlgebra.Matrices.Matrix instance. This only works if this MGroup.LinearAlgebra.Matrices.Matrix is square and invertible.
Boolean IsZero(Double tolerance) Returns true if: this[i, j] <= ``, for 0 <= i < MGroup.LinearAlgebra.Matrices.Matrix.NumRows, 0 <= j < `MGroup.LinearAlgebra.Matrices.Matrix.NumColumns`. Otherwise false is returned.
IMatrix LinearCombination(Double thisCoefficient, IMatrixView otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrixView.LinearCombination(System.Double,MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
Matrix LinearCombination(Double thisCoefficient, Matrix otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrixView.LinearCombination(System.Double,MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
void LinearCombinationIntoThis(Double thisCoefficient, IMatrixView otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrix.LinearCombinationIntoThis(System.Double,MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
void LinearCombinationIntoThis(Double thisCoefficient, Matrix otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrix.LinearCombinationIntoThis(System.Double,MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
IVector Multiply(IVectorView vector, Boolean transposeThis = False) See MGroup.LinearAlgebra.Matrices.IMatrixView.Multiply(MGroup.LinearAlgebra.Vectors.IVectorView,System.Boolean).
Vector Multiply(Vector vector, Boolean transposeThis = False) See MGroup.LinearAlgebra.Matrices.IMatrixView.Multiply(MGroup.LinearAlgebra.Vectors.IVectorView,System.Boolean).
void MultiplyIntoResult(IVectorView lhsVector, IVector rhsVector, Boolean transposeThis = False) See MGroup.LinearAlgebra.Matrices.IMatrixView.MultiplyIntoResult(MGroup.LinearAlgebra.Vectors.IVectorView,MGroup.LinearAlgebra.Vectors.IVector,System.Boolean).
void MultiplyIntoResult(Vector lhsVector, Vector rhsVector, Boolean transposeThis = False) See MGroup.LinearAlgebra.Matrices.IMatrixView.MultiplyIntoResult(MGroup.LinearAlgebra.Vectors.IVectorView,MGroup.LinearAlgebra.Vectors.IVector,System.Boolean).
Matrix MultiplyLeft(IMatrixView other, Boolean transposeThis = False, Boolean transposeOther = False) See MGroup.LinearAlgebra.Matrices.IMatrixView.MultiplyLeft(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Boolean,System.Boolean).
Matrix MultiplyRight(IMatrixView other, Boolean transposeThis = False, Boolean transposeOther = False) See MGroup.LinearAlgebra.Matrices.IMatrixView.MultiplyRight(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Boolean,System.Boolean).
Matrix MultiplyRight(Matrix other, Boolean transposeThis = False, Boolean transposeOther = False) See MGroup.LinearAlgebra.Matrices.IMatrixView.MultiplyRight(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Boolean,System.Boolean).
void MultiplySubvectorIntoResult(Vector lhsVector, Int32 lhsOffset, Double lhsScale, Vector rhsVector, Int32 rhsOffset, Double rhsScale, Boolean transposeThis = False) Performs the matrix-vector multiplication y = alpha * oper(A) * x + beta * y, where: alpha = , x = , beta = , y = , oper(A) = this (if == false) or transpose(this) (if == true). The input vectors can be longer (taking into account the offsets) than the corresponding dimensions of this matrix. The resulting vector will overwrite starting from.
Double Reduce(Double identityValue, ProcessEntry processEntry, ProcessZeros processZeros, Finalize finalize) See MGroup.LinearAlgebra.Reduction.IReducible.Reduce(System.Double,MGroup.LinearAlgebra.Reduction.ProcessEntry,MGroup.LinearAlgebra.Reduction.ProcessZeros,MGroup.LinearAlgebra.Reduction.Finalize).
Matrix Reorder(IReadOnlyList<Int32> permutation, Boolean oldToNew) Creates a new MGroup.LinearAlgebra.Matrices.Matrix that contains the entries of this MGroup.LinearAlgebra.Matrices.Matrix with a different order, which is specified by the provided and.
Matrix Scale(Double scalar) Performs the following operation for 0 <= i < MGroup.LinearAlgebra.Matrices.Matrix.NumRows, 0 <= j < MGroup.LinearAlgebra.Matrices.Matrix.NumColumns: result[i, j] = `` * this[i, j]. The resulting matrix is written to a new MGroup.LinearAlgebra.Matrices.Matrix and then returned.
void ScaleIntoThis(Double scalar) See MGroup.LinearAlgebra.Matrices.IMatrix.ScaleIntoThis(System.Double).
void SetAll(Double value) Sets all entries of this matrix to be equal to ``.
void SetEntryRespectingPattern(Int32 rowIdx, Int32 colIdx, Double value) See MGroup.LinearAlgebra.Matrices.IMatrix.SetEntryRespectingPattern(System.Int32,System.Int32,System.Double).
void SetSubcolumn(Int32 colIdx, Vector colValues, Int32 rowStart = 0) Sets some consecutive entries of the column with index = to be equal to , starting from the entry with row index = ``.
void SetSubmatrix(Int32 rowStart, Int32 colStart, Matrix submatrix) Sets some consecutive entries of this matrix to be equal to the entries of , starting from the entry at (, ``).
void SetSubrow(Int32 rowIdx, Vector rowValues, Int32 colStart = 0) Sets some consecutive entries of the row with index = to be equal to , starting from the entry with column index = ``.
void SVD(Double[] w, Double[,] v) Calculates the Singular Value Decomposition of a matrix.
Matrix Transpose() Initializes a new MGroup.LinearAlgebra.Matrices.Matrix instance, that is transpose to this: result[i, j] = this[j, i]. The entries will be explicitly copied.
void TransposeIntoThis() Transposes the matrix by modifying the entries of this : this[i, j] = this[j, i].

Static Methods

Type Name Summary
Matrix CreateFromArray(Double[,] array2D) Initializes a new instance of MGroup.LinearAlgebra.Matrices.Matrix by copying the entries of ``.
Matrix CreateFromArray(Double[] array1D, Int32 numRows, Int32 numColumns, Boolean copyArray = False) Initializes a new instance of MGroup.LinearAlgebra.Matrices.Matrix by copying the entries of ``.
Matrix CreateIdentity(Int32 order) Initializes a new instance of MGroup.LinearAlgebra.Matrices.Matrix that is equal to the identity matrix, namely a square matrix with non-diagonal entries being equal to 0 and diagonal entries being equal to 1.
Matrix CreateWithValue(Int32 numRows, Int32 numColumns, Double value) Initializes a new instance of MGroup.LinearAlgebra.Matrices.Matrix with all entries being equal to ``.
Matrix CreateZero(Int32 numRows, Int32 numColumns) Initializes a new instance of MGroup.LinearAlgebra.Matrices.Matrix with all entries being equal to 0.

Matrix2by2

A matrix with 2 rows and 2 columns. Optimized version of MGroup.LinearAlgebra.Matrices.Matrix. Authors: Serafeim Bakalakos

public class MGroup.LinearAlgebra.Matrices.Matrix2by2
    : IMatrix, IMatrixView, IIndexable2D, IReducible

Properties

Type Name Summary
Double[,] InternalData The internal array that stores the entries of the matrix. It should only be used for passing the raw array to linear algebra libraries.
Boolean IsSquare Returns true if MGroup.LinearAlgebra.Matrices.Matrix2by2.NumRows == MGroup.LinearAlgebra.Matrices.Matrix2by2.NumColumns.
Double Item See MGroup.LinearAlgebra.Matrices.IIndexable2D.Item(System.Int32,System.Int32).
Int32 NumColumns The number of columns of the matrix.
Int32 NumRows The number of rows of the matrix.

Methods

Type Name Summary
IMatrix Axpy(IMatrixView otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrixView.Axpy(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
Matrix2by2 Axpy(Matrix2by2 otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrixView.Axpy(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
void AxpyIntoThis(IMatrixView otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrix.AxpyIntoThis(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
void AxpyIntoThis(Matrix2by2 other, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrix.AxpyIntoThis(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
Double CalcDeterminant() Calculates the determinant of this matrix. If the inverse matrix is also needed, use MGroup.LinearAlgebra.Matrices.Matrix2by2.InvertAndDetermninant instead.
void Clear() See MGroup.LinearAlgebra.Matrices.IMatrix.Clear.
Matrix2by2 Copy() Initializes a new instance of MGroup.LinearAlgebra.Matrices.Matrix2by2 by copying the entries of this instance.
Double[,] CopyToArray2D() Copies the entries of the matrix into a 2-dimensional array. The returned array has length(0) = length(1) = 2.
IMatrix DoEntrywise(IMatrixView matrix, Func<Double, Double, Double> binaryOperation) See MGroup.LinearAlgebra.Matrices.IMatrixView.DoEntrywise(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Func{System.Double,System.Double,System.Double}).
Matrix2by2 DoEntrywise(Matrix2by2 matrix, Func<Double, Double, Double> binaryOperation) See MGroup.LinearAlgebra.Matrices.IMatrixView.DoEntrywise(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Func{System.Double,System.Double,System.Double}).
void DoEntrywiseIntoThis(IMatrixView matrix, Func<Double, Double, Double> binaryOperation) See MGroup.LinearAlgebra.Matrices.IMatrix.DoEntrywiseIntoThis(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Func{System.Double,System.Double,System.Double}).
void DoEntrywiseIntoThis(Matrix2by2 matrix, Func<Double, Double, Double> binaryOperation) See MGroup.LinearAlgebra.Matrices.IMatrix.DoEntrywiseIntoThis(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Func{System.Double,System.Double,System.Double}).
Matrix2by2 DoToAllEntries(Func<Double, Double> unaryOperation) Performs the following operation for 0 <= i, j < 2: result[i, j] = ``(this[i,j]) The resulting matrix is written to a new MGroup.LinearAlgebra.Matrices.Matrix2by2 and then returned.
void DoToAllEntriesIntoThis(Func<Double, Double> unaryOperation) See MGroup.LinearAlgebra.Matrices.IMatrix.DoToAllEntriesIntoThis(System.Func{System.Double,System.Double}).
Boolean Equals(IIndexable2D other, Double tolerance = 1E-13) See MGroup.LinearAlgebra.Matrices.IIndexable2D.Equals(MGroup.LinearAlgebra.Matrices.IIndexable2D,System.Double).
Matrix2by2 Invert() Calculates the inverse matrix and returns it in a new MGroup.LinearAlgebra.Matrices.Matrix2by2 instance. This only works if this MGroup.LinearAlgebra.Matrices.Matrix2by2 is invertible. If the determinant matrix is also needed, use MGroup.LinearAlgebra.Matrices.Matrix2by2.InvertAndDetermninant instead.
ValueTuple<Matrix2by2, Double> InvertAndDetermninant() Calculates the determinant and the inverse matrix and returns the latter in a new MGroup.LinearAlgebra.Matrices.Matrix instance. This only works if this MGroup.LinearAlgebra.Matrices.Matrix2by2 is invertible.
IMatrix LinearCombination(Double thisCoefficient, IMatrixView otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrixView.LinearCombination(System.Double,MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
Matrix2by2 LinearCombination(Double thisCoefficient, Matrix2by2 otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrixView.LinearCombination(System.Double,MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
void LinearCombinationIntoThis(Double thisCoefficient, IMatrixView otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrix.LinearCombinationIntoThis(System.Double,MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
void LinearCombinationIntoThis(Double thisCoefficient, Matrix2by2 otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrix.LinearCombinationIntoThis(System.Double,MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
IVector Multiply(IVectorView vector, Boolean transposeThis = False) See MGroup.LinearAlgebra.Matrices.IMatrixView.Multiply(MGroup.LinearAlgebra.Vectors.IVectorView,System.Boolean).
Vector2 Multiply(Vector2 vector, Boolean transposeThis = False) See MGroup.LinearAlgebra.Matrices.IMatrixView.Multiply(MGroup.LinearAlgebra.Vectors.IVectorView,System.Boolean).
void MultiplyIntoResult(IVectorView lhsVector, IVector rhsVector, Boolean transposeThis = False) See MGroup.LinearAlgebra.Matrices.IMatrixView.MultiplyIntoResult(MGroup.LinearAlgebra.Vectors.IVectorView,MGroup.LinearAlgebra.Vectors.IVector,System.Boolean).
void MultiplyIntoResult(Vector2 lhsVector, Vector2 rhsVector, Boolean transposeThis = False) See MGroup.LinearAlgebra.Matrices.IMatrixView.MultiplyIntoResult(MGroup.LinearAlgebra.Vectors.IVectorView,MGroup.LinearAlgebra.Vectors.IVector,System.Boolean).
Matrix MultiplyLeft(IMatrixView matrix, Boolean transposeThis = False, Boolean transposeOther = False) See MGroup.LinearAlgebra.Matrices.IMatrixView.MultiplyLeft(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Boolean,System.Boolean).
Matrix MultiplyRight(IMatrixView matrix, Boolean transposeThis = False, Boolean transposeOther = False) See MGroup.LinearAlgebra.Matrices.IMatrixView.MultiplyRight(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Boolean,System.Boolean).
Matrix2by2 MultiplyRight(Matrix2by2 matrix, Boolean transposeThis = False, Boolean transposeOther = False) See MGroup.LinearAlgebra.Matrices.IMatrixView.MultiplyRight(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Boolean,System.Boolean).
Double Reduce(Double identityValue, ProcessEntry processEntry, ProcessZeros processZeros, Finalize finalize) See MGroup.LinearAlgebra.Reduction.IReducible.Reduce(System.Double,MGroup.LinearAlgebra.Reduction.ProcessEntry,MGroup.LinearAlgebra.Reduction.ProcessZeros,MGroup.LinearAlgebra.Reduction.Finalize).
Matrix2by2 Scale(Double scalar) Performs the following operation for 0 <= i, j < 2: result[i, j] = *[i, j]. The resulting matrix is written to a new MGroup.LinearAlgebra.Matrices.Matrix2by2 and then returned.
void ScaleIntoThis(Double scalar) See MGroup.LinearAlgebra.Matrices.IMatrix.ScaleIntoThis(System.Double).
void SetAll(Double value) Sets all entries of this matrix to be equal to ``.
void SetEntryRespectingPattern(Int32 rowIdx, Int32 colIdx, Double value) See MGroup.LinearAlgebra.Matrices.IMatrix.SetEntryRespectingPattern(System.Int32,System.Int32,System.Double).
Matrix2by2 Transpose() Initializes a new MGroup.LinearAlgebra.Matrices.Matrix2by2 instance, that is transpose to this: result[i, j] = this[j, i]. The entries will be explicitly copied.

Static Methods

Type Name Summary
Matrix2by2 Create(Double entry00, Double entry01, Double entry10, Double entry11) Initializes a new instance of MGroup.LinearAlgebra.Matrices.Matrix2by2 that contains the provided entries: {{, }, {, }}.
Matrix2by2 CreateFromArray(Double[,] array2D, Boolean copyArray = False) Initializes a new instance of MGroup.LinearAlgebra.Matrices.Matrix2by2 with `` or a clone as its internal array.
Matrix2by2 CreateIdentity() Initializes a new instance of MGroup.LinearAlgebra.Matrices.Matrix2by2 that is equal to the identity matrix, namely a square matrix with non-diagonal entries being equal to 0 and diagonal entries being equal to 1.
Matrix2by2 CreateWithValue(Double value) Initializes a new instance of MGroup.LinearAlgebra.Matrices.Matrix2by2 with all entries being equal to ``.
Matrix2by2 CreateZero() Initializes a new instance of MGroup.LinearAlgebra.Matrices.Matrix2by2 with all entries being equal to 0.

Matrix3by3

A matrix with 3 rows and 3 columns. Optimized version of MGroup.LinearAlgebra.Matrices.Matrix. Authors: Serafeim Bakalakos

public class MGroup.LinearAlgebra.Matrices.Matrix3by3
    : IMatrix, IMatrixView, IIndexable2D, IReducible

Properties

Type Name Summary
Double[,] InternalData The internal array that stores the entries of the matrix. It should only be used for passing the raw array to linear algebra libraries.
Boolean IsSquare Returns true if MGroup.LinearAlgebra.Matrices.Matrix3by3.NumRows == MGroup.LinearAlgebra.Matrices.Matrix3by3.NumColumns.
Double Item See MGroup.LinearAlgebra.Matrices.IIndexable2D.Item(System.Int32,System.Int32).
Int32 NumColumns The number of columns of the matrix.
Int32 NumRows The number of rows of the matrix.

Methods

Type Name Summary
IMatrix Axpy(IMatrixView otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrixView.Axpy(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
Matrix3by3 Axpy(Matrix3by3 otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrixView.Axpy(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
void AxpyIntoThis(IMatrixView otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrix.AxpyIntoThis(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
void AxpyIntoThis(Matrix3by3 other, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrix.AxpyIntoThis(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
Double CalcDeterminant() Calculates the determinant of this matrix, which must be square. If the inverse matrix is also needed, use MGroup.LinearAlgebra.Matrices.Matrix3by3.InvertAndDetermninant instead.
void Clear() See MGroup.LinearAlgebra.Matrices.IMatrix.Clear.
Matrix3by3 Copy() Initializes a new instance of MGroup.LinearAlgebra.Matrices.Matrix3by3 by copying the entries of this instance.
Double[,] CopyToArray2D() Copies the entries of the matrix into a 2-dimensional array. The returned array has length(0) = length(1) = 3.
IMatrix DoEntrywise(IMatrixView matrix, Func<Double, Double, Double> binaryOperation) Performs the following operation for 0 <= i, j < 3: result[i, j] = (this[i,j], [i, j]) The resulting matrix is written to a new MGroup.LinearAlgebra.Matrices.Matrix3by3 and then returned.
Matrix3by3 DoEntrywise(Matrix3by3 matrix, Func<Double, Double, Double> binaryOperation) Performs the following operation for 0 <= i, j < 3: result[i, j] = (this[i,j], [i, j]) The resulting matrix is written to a new MGroup.LinearAlgebra.Matrices.Matrix3by3 and then returned.
void DoEntrywiseIntoThis(IMatrixView matrix, Func<Double, Double, Double> binaryOperation) Performs the following operation for 0 <= i, j < 3: this[i, j] = (this[i,j], [i, j]) The resulting matrix overwrites the entries of this MGroup.LinearAlgebra.Matrices.Matrix3by3 instance.
void DoEntrywiseIntoThis(Matrix3by3 matrix, Func<Double, Double, Double> binaryOperation) Performs the following operation for 0 <= i, j < 3: this[i, j] = (this[i,j], [i, j]) The resulting matrix overwrites the entries of this MGroup.LinearAlgebra.Matrices.Matrix3by3 instance.
Matrix3by3 DoToAllEntries(Func<Double, Double> unaryOperation) Performs the following operation for 0 <= i, j < 3: result[i, j] = ``(this[i,j]) The resulting matrix is written to a new MGroup.LinearAlgebra.Matrices.Matrix3by3 and then returned.
void DoToAllEntriesIntoThis(Func<Double, Double> unaryOperation) See MGroup.LinearAlgebra.Matrices.IMatrix.DoToAllEntriesIntoThis(System.Func{System.Double,System.Double}).
Boolean Equals(IIndexable2D other, Double tolerance = 1E-13) See MGroup.LinearAlgebra.Matrices.IIndexable2D.Equals(MGroup.LinearAlgebra.Matrices.IIndexable2D,System.Double).
Matrix3by3 Invert() Calculates the inverse matrix and returns it in a new MGroup.LinearAlgebra.Matrices.Matrix3by3 instance. This only works if this MGroup.LinearAlgebra.Matrices.Matrix3by3 is invertible. If the determinant matrix is also needed, use MGroup.LinearAlgebra.Matrices.Matrix3by3.InvertAndDetermninant instead.
ValueTuple<Matrix3by3, Double> InvertAndDetermninant() Calculates the determinant and the inverse matrix and returns the latter in a new MGroup.LinearAlgebra.Matrices.Matrix instance. This only works if this MGroup.LinearAlgebra.Matrices.Matrix3by3 is invertible.
IMatrix LinearCombination(Double thisCoefficient, IMatrixView otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrixView.LinearCombination(System.Double,MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
Matrix3by3 LinearCombination(Double thisCoefficient, Matrix3by3 otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrixView.LinearCombination(System.Double,MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
void LinearCombinationIntoThis(Double thisCoefficient, IMatrixView otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrix.LinearCombinationIntoThis(System.Double,MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
void LinearCombinationIntoThis(Double thisCoefficient, Matrix3by3 otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrix.LinearCombinationIntoThis(System.Double,MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
IVector Multiply(IVectorView vector, Boolean transposeThis = False) See MGroup.LinearAlgebra.Matrices.IMatrixView.Multiply(MGroup.LinearAlgebra.Vectors.IVectorView,System.Boolean).
Vector3 Multiply(Vector3 vector, Boolean transposeThis = False) See MGroup.LinearAlgebra.Matrices.IMatrixView.Multiply(MGroup.LinearAlgebra.Vectors.IVectorView,System.Boolean).
void MultiplyIntoResult(IVectorView lhsVector, IVector rhsVector, Boolean transposeThis = False) See MGroup.LinearAlgebra.Matrices.IMatrixView.MultiplyIntoResult(MGroup.LinearAlgebra.Vectors.IVectorView,MGroup.LinearAlgebra.Vectors.IVector,System.Boolean).
void MultiplyIntoResult(Vector3 lhsVector, Vector3 rhsVector, Boolean transposeThis = False) See MGroup.LinearAlgebra.Matrices.IMatrixView.MultiplyIntoResult(MGroup.LinearAlgebra.Vectors.IVectorView,MGroup.LinearAlgebra.Vectors.IVector,System.Boolean).
Matrix MultiplyLeft(IMatrixView matrix, Boolean transposeThis = False, Boolean transposeOther = False) See MGroup.LinearAlgebra.Matrices.IMatrixView.MultiplyLeft(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Boolean,System.Boolean).
Matrix MultiplyRight(IMatrixView matrix, Boolean transposeThis = False, Boolean transposeOther = False) See MGroup.LinearAlgebra.Matrices.IMatrixView.MultiplyRight(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Boolean,System.Boolean).
Matrix3by3 MultiplyRight(Matrix3by3 matrix, Boolean transposeThis = False, Boolean transposeOther = False) See MGroup.LinearAlgebra.Matrices.IMatrixView.MultiplyRight(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Boolean,System.Boolean).
Double Reduce(Double identityValue, ProcessEntry processEntry, ProcessZeros processZeros, Finalize finalize) See MGroup.LinearAlgebra.Reduction.IReducible.Reduce(System.Double,MGroup.LinearAlgebra.Reduction.ProcessEntry,MGroup.LinearAlgebra.Reduction.ProcessZeros,MGroup.LinearAlgebra.Reduction.Finalize).
Matrix3by3 Scale(Double scalar) Performs the following operation for 0 <= i, j < 2: result[i, j] = *[i, j]. The resulting matrix is written to a new MGroup.LinearAlgebra.Matrices.Matrix3by3 and then returned.
void ScaleIntoThis(Double scalar) See MGroup.LinearAlgebra.Matrices.IMatrix.ScaleIntoThis(System.Double).
void SetAll(Double value) Sets all entries of this matrix to be equal to ``.
void SetEntryRespectingPattern(Int32 rowIdx, Int32 colIdx, Double value) See MGroup.LinearAlgebra.Matrices.IMatrix.SetEntryRespectingPattern(System.Int32,System.Int32,System.Double).
Matrix3by3 Transpose() Initializes a new MGroup.LinearAlgebra.Matrices.Matrix3by3 instance, that is transpose to this: result[i, j] = this[j, i]. The entries will be explicitly copied.

Static Methods

Type Name Summary
Matrix3by3 Create(Double x00, Double x01, Double x02, Double x10, Double x11, Double x12, Double x20, Double x21, Double x22) Initializes a new instance of MGroup.LinearAlgebra.Matrices.Matrix3by3 that contains the provided entries: {{, , }, {, , }, {, , ``}}
Matrix3by3 CreateFromArray(Double[,] array2D, Boolean copyArray) Initializes a new instance of MGroup.LinearAlgebra.Matrices.Matrix3by3 with `` or a clone as its internal array.
Matrix3by3 CreateIdentity() Initializes a new instance of MGroup.LinearAlgebra.Matrices.Matrix3by3 that is equal to the identity matrix, namely a square matrix with non-diagonal entries being equal to 0 and diagonal entries being equal to 1.
Matrix3by3 CreateWithValue(Double value) Initializes a new instance of MGroup.LinearAlgebra.Matrices.Matrix3by3 with all entries being equal to ``.
Matrix3by3 CreateZero() Initializes a new instance of MGroup.LinearAlgebra.Matrices.Matrix3by3 with all entries being equal to 0.

MatrixExtensions

Defines common matrix operations that can be used as extensions for methods for matrix classes or interfaces. If one of the following methods is also implemented in a concrete class, use that one, as it will be far more efficient. Authors: Serafeim Bakalakos

public static class MGroup.LinearAlgebra.Matrices.MatrixExtensions

Static Methods

Type Name Summary
IMatrixView Add(this IMatrixView matrix1, IMatrixView matrix2) Performs the operation: result[i, j] = [i, j] + [i, j], for 0 <= i < MGroup.LinearAlgebra.Matrices.IIndexable2D.NumRows, 0 <= j < MGroup.LinearAlgebra.Matrices.IIndexable2D.NumColumns. The resulting entries are written to a new MGroup.LinearAlgebra.Matrices.IMatrixView instance.
void AddIntoThis(this IMatrix matrix1, IMatrixView matrix2) Performs the operation: [i, j] = [i, j] + [i, j], for 0 &lt;= i &lt; `MGroup.LinearAlgebra.Matrices.IIndexable2D.NumRows`, 0 &lt;= j &lt; `MGroup.LinearAlgebra.Matrices.IIndexable2D.NumColumns`. The resulting matrix overwrites the entries of .
IEnumerable<ValueTuple<Int32, Int32, Double>> EnumerateNonZeros(this IIndexable2D matrix) Iterates over the non-zero entries of the matrix, which are defined as the entries such that: ``[i,j].
IEnumerable<ValueTuple<Int32, Int32, Double>> EnumerateNonZeros(this IIndexable2D matrix, Double tolerance) Iterates over the non-zero entries of the matrix, which are defined as the entries such that: ``[i,j].
Vector GetDiagonal(this IMatrixView matrix) Returns a MGroup.LinearAlgebra.Vectors.Vector with the entries of the matrix's main diagonal.
Double[] GetDiagonalAsArray(this IMatrixView matrix) Returns an array with the entries of the matrix's main diagonal.
Boolean IsSymmetric(this IIndexable2D matrix, Double tolerance = 4.94065645841247E-324) Returns true if [i, j] and [j, i] are equal or at least within the specified `` for all 0 <= i < MGroup.LinearAlgebra.Matrices.IIndexable2D.NumRows, 0 <= j < `MGroup.LinearAlgebra.Matrices.IIndexable2D.NumColumns`.
Matrix Reorder(this IIndexable2D matrix, IReadOnlyList<Int32> permutation, Boolean oldToNew) Creates a new MGroup.LinearAlgebra.Matrices.Matrix that contains the entries of with a different order, which is specified by the provided and ``.
IMatrixView Subtract(this IMatrixView matrix1, IMatrixView matrix2) Performs the operation: result[i, j] = [i, j] - [i, j], for 0 <= i < MGroup.LinearAlgebra.Matrices.IIndexable2D.NumRows, 0 <= j < MGroup.LinearAlgebra.Matrices.IIndexable2D.NumColumns. The resulting entries are written to a new MGroup.LinearAlgebra.Matrices.IMatrixView instance.
void SubtractIntoThis(this IMatrix matrix1, IMatrixView matrix2) Performs the operation: [i, j] = [i, j] + [i, j], for 0 &lt;= i &lt; `MGroup.LinearAlgebra.Matrices.IIndexable2D.NumRows`, 0 &lt;= j &lt; `MGroup.LinearAlgebra.Matrices.IIndexable2D.NumColumns`. The resulting matrix overwrites the entries of .

MatrixMultiplicationExtensions

public static class MGroup.LinearAlgebra.Matrices.MatrixMultiplicationExtensions

Static Methods

Type Name Summary
Double[] MultiplyRight(this CscMatrix matrix, Double[] vector, Boolean transposeThis) Performs the matrix-vector multiplication: oper() * . To multiply * columnVector, set to false. To multiply rowVector * , set to true.
Matrix ThisTimesOtherTimesThisTranspose(this CsrMatrix csr, IMatrixView other) Performs the operation: result = transpose() * * `` in an efficient way, by appropriately selecting which methods should be called for these matrices and in what order.
Matrix ThisTimesOtherTimesThisTranspose(this CsrMatrix csr, Matrix other) Performs the operation: result = transpose() * * `` in an efficient way, by appropriately selecting which methods should be called for these matrices and in what order.
Matrix ThisTimesOtherTimesThisTranspose(this CsrMatrix csr, SymmetricMatrix other) Performs the operation: result = transpose() * * `` in an efficient way, by appropriately selecting which methods should be called for these matrices and in what order.
Matrix ThisTransposeTimesOtherTimesThis(this CscMatrix csc, IMatrixView other) Performs the operation: result = transpose() * * `` in an efficient way, by appropriately selecting which methods should be called for these matrices and in what order.
Matrix ThisTransposeTimesOtherTimesThis(this CscMatrix csc, Matrix other) Performs the operation: result = transpose() * * `` in an efficient way, by appropriately selecting which methods should be called for these matrices and in what order.
Matrix ThisTransposeTimesOtherTimesThis(this CscMatrix csc, SymmetricMatrix other) Performs the operation: result = transpose() * * `` in an efficient way, by appropriately selecting which methods should be called for these matrices and in what order.
Matrix ThisTransposeTimesOtherTimesThis(this Matrix dense, IMatrixView other) Performs the operation: result = transpose() * * `` in an efficient way, by appropriately selecting which methods should be called for these matrices and in what order.
Matrix ThisTransposeTimesOtherTimesThis(this Matrix dense, Matrix other) Performs the operation: result = transpose() * * `` in an efficient way, by appropriately selecting which methods should be called for these matrices and in what order.
Matrix ThisTransposeTimesOtherTimesThis(this Matrix dense, SymmetricMatrix other) Performs the operation: result = transpose() * * `` in an efficient way, by appropriately selecting which methods should be called for these matrices and in what order.

PermutationMatrix

Efficient implementation for permutation matrices, namely matrices that change the order of vector entries, matrix rows or matrix columns. Authors: Serafeim Bakalakos

public class MGroup.LinearAlgebra.Matrices.PermutationMatrix

Properties

Type Name Summary
Int32 NumColumns The number of columns of the permutation matrix.
Int32 NumRows The number of rows of the permutation matrix.

Methods

Type Name Summary
void ExchangeRows(Int32 rowIdx1, Int32 rowIdx2) Modifies this MGroup.LinearAlgebra.Matrices.PermutationMatrix instance, such that it defines a row-exchange operation: becomes and vice versa.
Vector MultiplyRight(Vector vector, Boolean transposeThis) Multiplies this permutation matrix or its transpose with a vector: result = oper(this) * . This is equivalent to applying the permutation defined by this `MGroup.LinearAlgebra.Matrices.PermutationMatrix` to . If (== true) this permutation is new-to-old: result[i] =[permutation[i]]. Otherwise it is old-to-new: result[permutation[i]] = ``[i]

Static Methods

Type Name Summary
PermutationMatrix CreateIdentity(Int32 order) Initializes a new instance of MGroup.LinearAlgebra.Matrices.PermutationMatrix that is equal to the identity matrix, namely a square matrix with non-diagonal entries being equal to 0 and diagonal entries being equal to 1. This permutation does not change modify the vector/matrix it is applied to. However, it can be used as a starting point to define other permutations.

SignedBooleanMatrix

Sparse matrix with the non-zero entries being 1 or -1. Its main use is in domain decomposition solvers. In this context, a MGroup.LinearAlgebra.Matrices.SignedBooleanMatrix represents the equations that enforce continuity between the freedom degrees of subdomains. Each row corresponds to a displacement continuity equation. If this matrix is for the whole domain, all rows will have exactly 2 non zero entries (1 and -1). If it is only for a subdomain then some rows may be empty. Each column corresponds to a freedom degree of one of the subdomains. Columns that correspond to freedom degrees with multiplicity = 2 will have 1 non zero entry (1 or -1). Columns that correspond to freedom degrees with multiplicity > 2, will have at most 2 non zero entries (1 and/or -1). The other columns do not correspond to boundary dofs and will be empty. The internal data structures that store the non-zero entries are row major. Authors: Serafeim Bakalakos

public class MGroup.LinearAlgebra.Matrices.SignedBooleanMatrix
    : IIndexable2D, ISparseMatrix

Properties

Type Name Summary
Int32 Item The entry with row index = rowIdx and column index = colIdx.
Int32 NumColumns The number of columns of the matrix.
Int32 NumRows The number of rows of the matrix.

Methods

Type Name Summary
void AddEntry(Int32 rowIdx, Int32 colIdx, Boolean sign) Sets the entry with indices (, ) to +1 or -1.
Dictionary<Int32, Vector> CopyNonZeroRowsToVectors() Returns a dictionary, such that: The keys are indices of rows with at least 1 non-zero entry. The values are vectors copied from these rows.
Double[,] CopyToArray2D() Copies the entries of the matrix into a 2-dimensional array. The returned array has length(0) = MGroup.LinearAlgebra.Matrices.SignedBooleanMatrix.NumRows and length(1) = MGroup.LinearAlgebra.Matrices.SignedBooleanMatrix.NumColumns.
Matrix CopyToFullMatrix(Boolean transpose) Initializes a new MGroup.LinearAlgebra.Matrices.Matrix instance by copying the entries of this MGroup.LinearAlgebra.Matrices.SignedBooleanMatrix.
Int32 CountNonZeros() See MGroup.LinearAlgebra.Matrices.ISparseMatrix.CountNonZeros.
IEnumerable<ValueTuple<Int32, Int32, Double>> EnumerateNonZeros() See MGroup.LinearAlgebra.Matrices.ISparseMatrix.EnumerateNonZeros.
Boolean Equals(IIndexable2D other, Double tolerance = 1E-13) See MGroup.LinearAlgebra.Matrices.IIndexable2D.Equals(MGroup.LinearAlgebra.Matrices.IIndexable2D,System.Double).
IReadOnlyList<Int32> FindNonZeroRows() Returns a list with the indices of the rows that have at least 1 non-zero entry (which is either 1.0 or -1.0).
Vector GetRow(Int32 rowIdx) Returns a vector with the entries of the original matrix's row at index = ``.
SparseFormat GetSparseFormat() See MGroup.LinearAlgebra.Matrices.ISparseMatrix.GetSparseFormat.
void IsContinuityEquationsMatrix() Returns true if this matrix describes the equations that enforce continuity between boundary freedom degrees that appear in more than one subdomains. Otherwise returns false.
Vector MultiplyRight(Vector vector, Boolean transposeThis) Performs the matrix-vector multiplication: oper(this) * . To multiply this * columnVector, set to false. To multiply rowVector * this, set `` to true.
SignedBooleanMatrix Transpose() Initializes a new MGroup.LinearAlgebra.Matrices.SignedBooleanMatrix instance, that is transpose to this: result[i, j] = this[j, i]. The entries will be explicitly copied. This method is meant for testing purposes and thus is not efficient.

SkylineMatrix

Symmetric sparse matrix stored in Skyline format (3-array version). Only the non-zero entries of the upper triangle are stored. The Skyline format is optimized for Cholesky factorizations. To build a MGroup.LinearAlgebra.Matrices.SkylineMatrix conveniently, use MGroup.LinearAlgebra.Matrices.Builders.SkylineBuilder. Authors: Serafeim Bakalakos

public class MGroup.LinearAlgebra.Matrices.SkylineMatrix
    : IMatrix, IMatrixView, IIndexable2D, IReducible, ISparseMatrix, ISymmetricMatrix

Properties

Type Name Summary
Double Item See MGroup.LinearAlgebra.Matrices.IIndexable2D.Item(System.Int32,System.Int32).
Int32 NumColumns The number of columns of the matrix.
Int32 NumRows The number of rows of the matrix.
Int32[] RawDiagOffsets The internal array that stores the indices into MGroup.LinearAlgebra.Matrices.SkylineMatrix.RawValues of the diagonal entries of the matrix. Its length = order + 1, with the last entry being equal to nnz. It should only be used for passing the raw array to linear algebra libraries.
Double[] RawValues The internal array that stores the non-zero entries of the matrix's upper triangle in column major order, starting from the diagonal and going upwards. Its length is equal to the number of non-zero entries. It should only be used for passing the raw array to linear algebra libraries.

Methods

Type Name Summary
IMatrix Axpy(IMatrixView otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrixView.Axpy(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
SkylineMatrix Axpy(SkylineMatrix otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrixView.Axpy(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
void AxpyIntoThis(IMatrixView otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrix.AxpyIntoThis(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
void AxpyIntoThis(SkylineMatrix otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrix.AxpyIntoThis(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
void Clear() See MGroup.LinearAlgebra.Matrices.IMatrix.Clear.
SkylineMatrix Copy(Boolean copyIndexingData) Copies the entries of this matrix.
Double[,] CopyToArray2D() Copies the entries of the matrix into a 2-dimensional array. The returned array has length(0) = MGroup.LinearAlgebra.Matrices.SkylineMatrix.NumRows and length(1) = MGroup.LinearAlgebra.Matrices.SkylineMatrix.NumColumns.
Matrix CopyToFullMatrix() Initializes a new MGroup.LinearAlgebra.Matrices.Matrix instance by copying the entries of this MGroup.LinearAlgebra.Matrices.SkylineMatrix. Warning: there may not be enough memory.
Int32 CountNonZeros() See MGroup.LinearAlgebra.Matrices.ISparseMatrix.CountNonZeros
IMatrix DoEntrywise(IMatrixView other, Func<Double, Double, Double> binaryOperation) See MGroup.LinearAlgebra.Matrices.IMatrixView.DoEntrywise(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Func{System.Double,System.Double,System.Double}).
void DoEntrywiseIntoThis(IMatrixView other, Func<Double, Double, Double> binaryOperation) See MGroup.LinearAlgebra.Matrices.IMatrix.DoEntrywiseIntoThis(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Func{System.Double,System.Double,System.Double}).
void DoEntrywiseIntoThis(SkylineMatrix other, Func<Double, Double, Double> binaryOperation) See MGroup.LinearAlgebra.Matrices.IMatrix.DoEntrywiseIntoThis(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Func{System.Double,System.Double,System.Double}).
IMatrix DoToAllEntries(Func<Double, Double> unaryOperation) See MGroup.LinearAlgebra.Matrices.IMatrixView.DoToAllEntries(System.Func{System.Double,System.Double}).
void DoToAllEntriesIntoThis(Func<Double, Double> unaryOperation) See MGroup.LinearAlgebra.Matrices.IMatrix.DoToAllEntriesIntoThis(System.Func{System.Double,System.Double}).
IEnumerable<ValueTuple<Int32, Int32, Double>> EnumerateNonZeros() See MGroup.LinearAlgebra.Matrices.ISparseMatrix.EnumerateNonZeros.
Boolean Equals(IIndexable2D other, Double tolerance = 1E-13) See MGroup.LinearAlgebra.Matrices.IIndexable2D.Equals(MGroup.LinearAlgebra.Matrices.IIndexable2D,System.Double).
CholeskySkyline FactorCholesky(Boolean inPlace, Double tolerance = 1E-15) Calculate the cholesky factorization. The matrix must be positive definite, otherwise an MGroup.LinearAlgebra.Exceptions.IndefiniteMatrixException will be thrown. If inPlace is set to true, this object must not be used again, otherwise a System.NullReferenceException will be thrown.
Vector GetDiagonal() Returns a MGroup.LinearAlgebra.Vectors.Vector with the entries of the matrix's main diagonal.
Double[] GetDiagonalAsArray() Returns an array with the entries of the matrix's main diagonal.
SparseFormat GetSparseFormat() See MGroup.LinearAlgebra.Matrices.ISparseMatrix.GetSparseFormat.
IMatrix LinearCombination(Double thisCoefficient, IMatrixView otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrixView.LinearCombination(System.Double,MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
void LinearCombinationIntoThis(Double thisCoefficient, IMatrixView otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrix.LinearCombinationIntoThis(System.Double,MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
void LinearCombinationIntoThis(Double thisCoefficient, SkylineMatrix otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrix.LinearCombinationIntoThis(System.Double,MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
IVector Multiply(IVectorView vector, Boolean transposeThis = False) See MGroup.LinearAlgebra.Matrices.IMatrixView.Multiply(MGroup.LinearAlgebra.Vectors.IVectorView,System.Boolean).
Vector Multiply(Vector vector) See MGroup.LinearAlgebra.Matrices.IMatrixView.Multiply(MGroup.LinearAlgebra.Vectors.IVectorView,System.Boolean).
void MultiplyIntoResult(IVectorView lhsVector, IVector rhsVector, Boolean transposeThis = False) See MGroup.LinearAlgebra.Matrices.IMatrixView.MultiplyIntoResult(MGroup.LinearAlgebra.Vectors.IVectorView,MGroup.LinearAlgebra.Vectors.IVector,System.Boolean).
void MultiplyIntoResult(Vector lhsVector, Vector rhsVector) See MGroup.LinearAlgebra.Matrices.IMatrixView.MultiplyIntoResult(MGroup.LinearAlgebra.Vectors.IVectorView,MGroup.LinearAlgebra.Vectors.IVector,System.Boolean).
Matrix MultiplyLeft(IMatrixView other, Boolean transposeThis = False, Boolean transposeOther = False) See MGroup.LinearAlgebra.Matrices.IMatrixView.MultiplyLeft(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Boolean,System.Boolean).
Matrix MultiplyRight(IMatrixView other, Boolean transposeThis = False, Boolean transposeOther = False) See MGroup.LinearAlgebra.Matrices.IMatrixView.MultiplyRight(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Boolean,System.Boolean).
Double Reduce(Double identityValue, ProcessEntry processEntry, ProcessZeros processZeros, Finalize finalize) See MGroup.LinearAlgebra.Reduction.IReducible.Reduce(System.Double,MGroup.LinearAlgebra.Reduction.ProcessEntry,MGroup.LinearAlgebra.Reduction.ProcessZeros,MGroup.LinearAlgebra.Reduction.Finalize).
SkylineMatrix Scale(Double scalar) Performs the following operation for the non-zero entries (i, j), such that 0 <= j < MGroup.LinearAlgebra.Matrices.SkylineMatrix.NumColumns, 0 <= i <= j: result[i, j] = `` * this[i, j]. The resulting matrix is written to a new MGroup.LinearAlgebra.Matrices.SkylineMatrix and then returned.
void ScaleIntoThis(Double scalar) See MGroup.LinearAlgebra.Matrices.IMatrix.ScaleIntoThis(System.Double).
void SetEntryRespectingPattern(Int32 rowIdx, Int32 colIdx, Double value) See MGroup.LinearAlgebra.Matrices.IMatrix.SetEntryRespectingPattern(System.Int32,System.Int32,System.Double).
IMatrix Transpose() See MGroup.LinearAlgebra.Matrices.IMatrixView.Transpose.

Static Methods

Type Name Summary
SkylineMatrix CreateFromArrays(Int32 order, Double[] values, Int32[] diagOffsets, Boolean checkInput, Boolean copyArrays = False) Initializes a new MGroup.LinearAlgebra.Matrices.SkylineMatrix with the specified dimensions and the provided arrays (and) as its internal data.
SkylineMatrix CreateZeroWithPattern(Int32 order, Int32[] diagOffsets, Boolean checkInput) Initializes a new MGroup.LinearAlgebra.Matrices.SkylineMatrix with the specified dimensions and the sparsity pattern defined by ``. The stored entries will initially be 0.
void ProcessIndices(Int32& rowIdx, Int32& colIdx) Perhaps this should be manually inlined. Testing needed.

SymmetricCscMatrix

Symmetric sparse matrix in Compressed Sparse Columns format, with only the non-zero entries of the upper triangle being explicitly stored. This matrix format is better used for factorizations using SuiteSparse or CSparse libraries. Authors: Serafeim Bakalakos

public class MGroup.LinearAlgebra.Matrices.SymmetricCscMatrix
    : IMatrix, IMatrixView, IIndexable2D, IReducible

Properties

Type Name Summary
Double Item See MGroup.LinearAlgebra.Matrices.IIndexable2D.Item(System.Int32,System.Int32).
Int32 NumColumns The number of columns of the matrix.
Int32 NumNonZerosUpper The number of the upper triangle's non zero entries. These are the only ones being explicitly stored.
Int32 NumRows The number of rows of the matrix.
Int32[] RawColOffsets The internal array that stores the index into the arrays MGroup.LinearAlgebra.Matrices.SymmetricCscMatrix.RawValues and MGroup.LinearAlgebra.Matrices.SymmetricCscMatrix.RawRowIndices of the first entry of each column. Its length is equal to `` + 1. The last entry is the number of the upper triangle's non-zero entries, which must be equal to MGroup.LinearAlgebra.Matrices.SymmetricCscMatrix.RawValues.Length == `MGroup.LinearAlgebra.Matrices.SymmetricCscMatrix.RawRowIndices`.Length. It should only be used for passing the raw array to linear algebra libraries.
Int32[] RawRowIndices The internal array that stores the row indices of the non-zero entries in MGroup.LinearAlgebra.Matrices.SymmetricCscMatrix.RawValues. Its length is equal to the number of the upper triangle's non-zero entries. It should only be used for passing the raw array to linear algebra libraries.
Double[] RawValues The internal array that stores the non-zero entries of the upper triangle. The non-zero entries of each column are consecutive. Its length is equal to the number of the upper triangle's non-zero entries. It should only be used for passing the raw array to linear algebra libraries.

Methods

Type Name Summary
IMatrix Axpy(IMatrixView otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrixView.Axpy(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
void AxpyIntoThis(IMatrixView otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrix.AxpyIntoThis(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
void Clear() See MGroup.LinearAlgebra.Matrices.IMatrix.Clear.
SymmetricCscMatrix Copy(Boolean copyIndexingArrays) Copies the entries of this matrix.
Matrix CopyToFullMatrix() Initializes a new MGroup.LinearAlgebra.Matrices.Matrix instance by copying the entries of this MGroup.LinearAlgebra.Matrices.SymmetricCscMatrix. Warning: there may not be enough memory.
IMatrix DoEntrywise(IMatrixView other, Func<Double, Double, Double> binaryOperation) See MGroup.LinearAlgebra.Matrices.IMatrixView.DoEntrywise(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Func{System.Double,System.Double,System.Double}).
void DoEntrywiseIntoThis(IMatrixView matrix, Func<Double, Double, Double> binaryOperation) See MGroup.LinearAlgebra.Matrices.IMatrix.DoEntrywiseIntoThis(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Func{System.Double,System.Double,System.Double}).
IMatrix DoToAllEntries(Func<Double, Double> unaryOperation) See MGroup.LinearAlgebra.Matrices.IMatrixView.DoToAllEntries(System.Func{System.Double,System.Double}).
void DoToAllEntriesIntoThis(Func<Double, Double> unaryOperation) See MGroup.LinearAlgebra.Matrices.IMatrix.DoToAllEntriesIntoThis(System.Func{System.Double,System.Double}).
Boolean Equals(IIndexable2D other, Double tolerance = 1E-13) See MGroup.LinearAlgebra.Matrices.IIndexable2D.Equals(MGroup.LinearAlgebra.Matrices.IIndexable2D,System.Double).
IMatrix LinearCombination(Double thisCoefficient, IMatrixView otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrixView.LinearCombination(System.Double,MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
void LinearCombinationIntoThis(Double thisCoefficient, IMatrixView otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrix.LinearCombinationIntoThis(System.Double,MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
IVector Multiply(IVectorView vector, Boolean transposeThis = False) See MGroup.LinearAlgebra.Matrices.IMatrixView.Multiply(MGroup.LinearAlgebra.Vectors.IVectorView,System.Boolean).
void MultiplyIntoResult(IVectorView lhsVector, IVector rhsVector, Boolean transposeThis) See MGroup.LinearAlgebra.Matrices.IMatrixView.MultiplyIntoResult(MGroup.LinearAlgebra.Vectors.IVectorView,MGroup.LinearAlgebra.Vectors.IVector,System.Boolean).
Matrix MultiplyLeft(IMatrixView other, Boolean transposeThis = False, Boolean transposeOther = False) See MGroup.LinearAlgebra.Matrices.IMatrixView.MultiplyLeft(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Boolean,System.Boolean).
Matrix MultiplyRight(IMatrixView other, Boolean transposeThis = False, Boolean transposeOther = False) See MGroup.LinearAlgebra.Matrices.IMatrixView.MultiplyRight(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Boolean,System.Boolean).
Vector MultiplyRight(Vector vector, Boolean transposeThis = False) See MGroup.LinearAlgebra.Matrices.IMatrixView.MultiplyRight(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Boolean,System.Boolean).
Double Reduce(Double identityValue, ProcessEntry processEntry, ProcessZeros processZeros, Finalize finalize) See MGroup.LinearAlgebra.Reduction.IReducible.Reduce(System.Double,MGroup.LinearAlgebra.Reduction.ProcessEntry,MGroup.LinearAlgebra.Reduction.ProcessZeros,MGroup.LinearAlgebra.Reduction.Finalize).
IMatrix Scale(Double scalar) See MGroup.LinearAlgebra.Matrices.IMatrixView.Scale(System.Double).
void ScaleIntoThis(Double scalar) See MGroup.LinearAlgebra.Matrices.IMatrix.ScaleIntoThis(System.Double).
void SetEntryRespectingPattern(Int32 rowIdx, Int32 colIdx, Double value) See MGroup.LinearAlgebra.Matrices.IMatrix.SetEntryRespectingPattern(System.Int32,System.Int32,System.Double).
IMatrix Transpose() See MGroup.LinearAlgebra.Matrices.IMatrixView.Transpose.

Static Methods

Type Name Summary
SymmetricCscMatrix CreateFromArrays(Int32 order, Double[] values, Int32[] rowIndices, Int32[] colOffsets, Boolean checkInput) Initializes a new MGroup.LinearAlgebra.Matrices.SymmetricCscMatrix with the specified dimensions and the provided arrays (, and ``) as its internal data.

SymmetricMatrix

Symmetric matrix. Only the upper triangle is stored in Packed format (only stores the n*(n+1)/2 non zeros) and column major order. Uses LAPACK. Do not use this, since it is an experimantal class, which will probably be removed. Authors: Serafeim Bakalakos

public class MGroup.LinearAlgebra.Matrices.SymmetricMatrix
    : IMatrix, IMatrixView, IIndexable2D, IReducible, ISymmetricMatrix

Properties

Type Name Summary
DefiniteProperty Definiteness Used to query if the matrix is positive definite etc. Usually this is not known beforehand, which corresponds to MGroup.LinearAlgebra.Commons.DefiniteProperty.Unknown. Cholesky factorization reveals this and sets this property to MGroup.LinearAlgebra.Commons.DefiniteProperty.PositiveDefinite or MGroup.LinearAlgebra.Commons.DefiniteProperty.Indefinite. Mutating the matrix will reset it to MGroup.LinearAlgebra.Commons.DefiniteProperty.Unknown. If the MGroup.LinearAlgebra.Matrices.SymmetricMatrix is created from a known matrix/array, the caller can assume responsibility for setting this property. WARNING: only set this propetry if you are absolutely sure.
Double Item The entry with row index = i and column index = j. Setting an entry A[i, j] = value, will also set A[j, i] = value. Therefore the matrix will stay symmetric This property is not that efficient, due to the necessary bound checking.
Int32 NumColumns The number of columns of the matrix.
Int32 NumRows The number of rows of the matrix.
Int32 Order The number of rows or columns of the matrix.
Double[] RawData The internal array that stores the entries of the upper triangle (packed storage format) in column major layout. It should only be used for passing the raw array to linear algebra libraries.

Methods

Type Name Summary
IMatrix Axpy(IMatrixView otherMatrix, Double otherCoefficient)
SymmetricMatrix Axpy(SymmetricMatrix otherMatrix, Double otherCoefficient)
void AxpyIntoThis(IMatrixView otherMatrix, Double otherCoefficient)
void AxpyIntoThis(SymmetricMatrix otherMatrix, Double otherCoefficient)
Double CalcDeterminant() Calculate the determinant of this matrix. If MGroup.LinearAlgebra.Matrices.SymmetricMatrix.Definiteness != MGroup.LinearAlgebra.Commons.DefiniteProperty.PositiveDefinite, the calculation will be very cumbersome and require an extra O(n^2) space: It will expand the packed storage format into a full data array, factorize it using LU and then calculate the determinant. For positive definite matrices, it is more efficient, since it uses the Cholesky factorization directly.
void Clear() See MGroup.LinearAlgebra.Matrices.IMatrix.Clear.
SymmetricMatrix Copy() Copies the entries of this matrix.
Double[,] CopyToArray2D() Copy the entries of the matrix into a 2-dimensional array. The returned array has length(0) = MGroup.LinearAlgebra.Matrices.SymmetricMatrix.Order and length(1) = MGroup.LinearAlgebra.Matrices.SymmetricMatrix.Order.
Matrix CopyToFullMatrix()
IMatrix DoEntrywise(IMatrixView other, Func<Double, Double, Double> binaryOperation)
SymmetricMatrix DoEntrywise(SymmetricMatrix other, Func<Double, Double, Double> binaryOperation)
void DoEntrywiseIntoThis(IMatrixView other, Func<Double, Double, Double> binaryOperation)
void DoEntrywiseIntoThis(SymmetricMatrix other, Func<Double, Double, Double> binaryOperation)
SymmetricMatrix DoToAllEntries(Func<Double, Double> unaryOperation)
Boolean Equals(IIndexable2D other, Double tolerance = 1E-13)
BunchKaufmanFactorization FactorBunchKaufman()
CholeskyPacked FactorCholesky() Calculates the Cholesky factorization of the matrix. Will throw MGroup.LinearAlgebra.Exceptions.IndefiniteMatrixException if the matrix is not positive definite.
ITriangulation Factorize(Boolean tryCholesky = True) Calculates some factorization of the symmetric matrix.
IMatrix LinearCombination(Double thisCoefficient, IMatrixView otherMatrix, Double otherCoefficient)
SymmetricMatrix LinearCombination(Double thisCoefficient, SymmetricMatrix otherMatrix, Double otherCoefficient)
void LinearCombinationIntoThis(Double thisCoefficient, IMatrixView otherMatrix, Double otherCoefficient)
void LinearCombinationIntoThis(Double thisCoefficient, SymmetricMatrix otherMatrix, Double otherCoefficient)
IVector Multiply(IVectorView vector, Boolean transposeThis = False) Matrix vector multiplication, with the vector on the right: matrix * vector.
Vector Multiply(Vector vector) Matrix vector multiplication, with the vector on the right: matrix * vector.
void MultiplyIntoResult(IVectorView lhsVector, IVector rhsVector, Boolean transposeThis = False) See MGroup.LinearAlgebra.Matrices.IMatrixView.MultiplyIntoResult(MGroup.LinearAlgebra.Vectors.IVectorView,MGroup.LinearAlgebra.Vectors.IVector,System.Boolean).
void MultiplyIntoResult(Vector lhsVector, Vector rhsVector) See MGroup.LinearAlgebra.Matrices.IMatrixView.MultiplyIntoResult(MGroup.LinearAlgebra.Vectors.IVectorView,MGroup.LinearAlgebra.Vectors.IVector,System.Boolean).
Matrix MultiplyLeft(IMatrixView other, Boolean transposeThis = False, Boolean transposeOther = False)
Matrix MultiplyRight(IMatrixView other, Boolean transposeThis = False, Boolean transposeOther = False)
Double Reduce(Double identityValue, ProcessEntry processEntry, ProcessZeros processZeros, Finalize finalize)
SymmetricMatrix Scale(Double scalar) result = scalar * this
void ScaleIntoThis(Double scalar)
void SetEntryRespectingPattern(Int32 rowIdx, Int32 colIdx, Double value)
IMatrix Transpose()
SymmetricMatrix Transpose(Boolean copyInternalArray)

Static Methods

Type Name Summary
SymmetricMatrix CreateFromArray(Double[,] array2D, DefiniteProperty definiteness = Unknown) Create a new MGroup.LinearAlgebra.Matrices.SymmetricMatrix from the lower (subdiagonal) or upper (superdiagonal) portion of the provided array. The array entries will be copied.
SymmetricMatrix CreateFromMatrix(Matrix originalMatrix) The caller is responsible for the original matrix being symmetric
SymmetricMatrix CreateFromPackedColumnMajorArray(Double[] array1D, Int32 order = 0, DefiniteProperty definiteness = Unknown, Boolean copyArray = False) Create a new MGroup.LinearAlgebra.Matrices.SymmetricMatrix from a provided array. The array can be copied (for extra safety) or not (for extra performance).
SymmetricMatrix CreateFromPackedRowMajorArray(Double[] array1D, Int32 order = 0, DefiniteProperty definiteness = Unknown) Create a new MGroup.LinearAlgebra.Matrices.SymmetricMatrix from a provided array. The array can be copied (for extra safety) or not (for extra performance).
SymmetricMatrix CreateZero(Int32 order) Create a new MGroup.LinearAlgebra.Matrices.SymmetricMatrix with the specified order and all entries equal to 0.

TriangularLower

Lower triangular square matrix in row major Packed storage format (only stores the n*(n+1)/2 non zeros). Uses LAPACK. For the more information about the layout, see Authors: Serafeim Bakalakos

public class MGroup.LinearAlgebra.Matrices.TriangularLower
    : IMatrix, IMatrixView, IIndexable2D, IReducible

Properties

Type Name Summary
Double Item See MGroup.LinearAlgebra.Matrices.IIndexable2D.Item(System.Int32,System.Int32).
Int32 NumColumns The number of columns of the square matrix.
Int32 NumRows The number of rows of the square matrix.
Int32 Order The number of rows/columns of the square matrix.
Double[] RawData The internal array that stores the entries of the lower triangle (packed storage format) in row major layout. It should only be used for passing the raw array to linear algebra libraries.

Methods

Type Name Summary
IMatrix Axpy(IMatrixView otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrixView.Axpy(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
TriangularLower Axpy(TriangularLower otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrixView.Axpy(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
void AxpyIntoThis(IMatrixView otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrix.AxpyIntoThis(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
void AxpyIntoThis(TriangularLower otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrix.AxpyIntoThis(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
Double CalcDeterminant() Calculates the determinant of this matrix.
void Clear() See MGroup.LinearAlgebra.Matrices.IMatrix.Clear.
TriangularLower Copy() Copies the entries of this matrix.
Double[,] CopyToArray2D() Copies the entries of the matrix into a 2-dimensional array. The returned array has length(0) = length(1) = MGroup.LinearAlgebra.Matrices.TriangularLower.Order.
Matrix CopyToFullMatrix() Initializes a new MGroup.LinearAlgebra.Matrices.Matrix instance by copying the entries of this MGroup.LinearAlgebra.Matrices.TriangularLower into the lower triangle of the new matrix.
IMatrix DoEntrywise(IMatrixView matrix, Func<Double, Double, Double> binaryOperation) See MGroup.LinearAlgebra.Matrices.IMatrixView.DoEntrywise(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Func{System.Double,System.Double,System.Double}).
void DoEntrywiseIntoThis(IMatrixView matrix, Func<Double, Double, Double> binaryOperation) See MGroup.LinearAlgebra.Matrices.IMatrix.DoEntrywiseIntoThis(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Func{System.Double,System.Double,System.Double}).
void DoEntrywiseIntoThis(TriangularLower matrix, Func<Double, Double, Double> binaryOperation) See MGroup.LinearAlgebra.Matrices.IMatrix.DoEntrywiseIntoThis(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Func{System.Double,System.Double,System.Double}).
IMatrix DoToAllEntries(Func<Double, Double> unaryOperation) See MGroup.LinearAlgebra.Matrices.IMatrixView.DoToAllEntries(System.Func{System.Double,System.Double}).
void DoToAllEntriesIntoThis(Func<Double, Double> unaryOperation) See MGroup.LinearAlgebra.Matrices.IMatrix.DoToAllEntriesIntoThis(System.Func{System.Double,System.Double}).
Boolean Equals(IIndexable2D other, Double tolerance = 1E-13) See MGroup.LinearAlgebra.Matrices.IIndexable2D.Equals(MGroup.LinearAlgebra.Matrices.IIndexable2D,System.Double).
IMatrix LinearCombination(Double thisCoefficient, IMatrixView otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrixView.LinearCombination(System.Double,MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
TriangularLower LinearCombination(Double thisCoefficient, TriangularLower otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrixView.LinearCombination(System.Double,MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
void LinearCombinationIntoThis(Double thisCoefficient, IMatrixView otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrix.LinearCombinationIntoThis(System.Double,MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
void LinearCombinationIntoThis(Double thisCoefficient, TriangularLower otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrix.LinearCombinationIntoThis(System.Double,MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
IVector Multiply(IVectorView vector, Boolean transposeThis = False) See MGroup.LinearAlgebra.Matrices.IMatrixView.Multiply(MGroup.LinearAlgebra.Vectors.IVectorView,System.Boolean).
Vector Multiply(Vector vector, Boolean transposeThis = False) See MGroup.LinearAlgebra.Matrices.IMatrixView.Multiply(MGroup.LinearAlgebra.Vectors.IVectorView,System.Boolean).
void MultiplyIntoResult(IVectorView lhsVector, IVector rhsVector, Boolean transposeThis = False) See MGroup.LinearAlgebra.Matrices.IMatrixView.MultiplyIntoResult(MGroup.LinearAlgebra.Vectors.IVectorView,MGroup.LinearAlgebra.Vectors.IVector,System.Boolean).
void MultiplyIntoResult(Vector lhsVector, Vector rhsVector, Boolean transposeThis = False) See MGroup.LinearAlgebra.Matrices.IMatrixView.MultiplyIntoResult(MGroup.LinearAlgebra.Vectors.IVectorView,MGroup.LinearAlgebra.Vectors.IVector,System.Boolean).
Matrix MultiplyLeft(IMatrixView matrix, Boolean transposeThis = False, Boolean transposeOther = False) See MGroup.LinearAlgebra.Matrices.IMatrixView.MultiplyLeft(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Boolean,System.Boolean).
Matrix MultiplyRight(IMatrixView matrix, Boolean transposeThis = False, Boolean transposeOther = False) See MGroup.LinearAlgebra.Matrices.IMatrixView.MultiplyRight(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Boolean,System.Boolean).
Double Reduce(Double identityValue, ProcessEntry processEntry, ProcessZeros processZeros, Finalize finalize) See MGroup.LinearAlgebra.Reduction.IReducible.Reduce(System.Double,MGroup.LinearAlgebra.Reduction.ProcessEntry,MGroup.LinearAlgebra.Reduction.ProcessZeros,MGroup.LinearAlgebra.Reduction.Finalize).
TriangularLower Scale(Double scalar) Performs the following operation for 0 <= i < MGroup.LinearAlgebra.Matrices.TriangularLower.Order, 0 <= j <= i: result[i, j] = `` * this[i, j]. The resulting matrix is written to a new MGroup.LinearAlgebra.Matrices.TriangularLower and then returned.
void ScaleIntoThis(Double scalar) See MGroup.LinearAlgebra.Matrices.IMatrix.ScaleIntoThis(System.Double).
void SetEntryRespectingPattern(Int32 rowIdx, Int32 colIdx, Double value) See MGroup.LinearAlgebra.Matrices.IMatrix.SetEntryRespectingPattern(System.Int32,System.Int32,System.Double).
Vector SolveLinearSystem(Vector rhs, Boolean transposeThis = False) Solves the linear equations system: this * result = `` by forward substitution. WARNING: this matrix must be invertible. No exception will be thrown if the matrix is singular.
IMatrix Transpose() See MGroup.LinearAlgebra.Matrices.IMatrixView.Transpose.
TriangularUpper Transpose(Boolean copyInternalArray) See MGroup.LinearAlgebra.Matrices.IMatrixView.Transpose.

Static Methods

Type Name Summary
TriangularLower CreateFromArray(Double[,] array2D) Initializes a new instance of MGroup.LinearAlgebra.Matrices.TriangularLower by copying the lower triangle of the provided 2D array.
TriangularLower CreateFromArray(Int32 order, Double[] array1D, Boolean copyArray = False) Initializes a new instance of MGroup.LinearAlgebra.Matrices.TriangularLower by copying the lower triangle of the provided 2D array.
TriangularLower CreateZero(Int32 order) Initializes a new instance of MGroup.LinearAlgebra.Matrices.TriangularLower with all entries being equal to 0. Only the lower triangle zero entries are explictily stored though.

TriangularUpper

Upper triangular square matrix in column major Packed storage format (only stores the n*(n+1)/2 non zeros). Uses LAPACK. For the more information about the layout, see Authors: Serafeim Bakalakos

public class MGroup.LinearAlgebra.Matrices.TriangularUpper
    : IMatrix, IMatrixView, IIndexable2D, IReducible

Properties

Type Name Summary
Double Item See MGroup.LinearAlgebra.Matrices.IIndexable2D.Item(System.Int32,System.Int32).
Int32 NumColumns The number of columns of the square matrix.
Int32 NumRows The number of rows of the square matrix.
Int32 Order The number of rows/columns of the square matrix.
Double[] RawData The internal array that stores the entries of the upper triangle (packed storage format) in column major layout. It should only be used for passing the raw array to linear algebra libraries.

Methods

Type Name Summary
IMatrix Axpy(IMatrixView otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrixView.Axpy(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
TriangularUpper Axpy(TriangularUpper otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrixView.Axpy(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
void AxpyIntoThis(IMatrixView otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrix.AxpyIntoThis(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
void AxpyIntoThis(TriangularUpper otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrix.AxpyIntoThis(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
Double CalcDeterminant() Calculates the determinant of this matrix.
void Clear() See MGroup.LinearAlgebra.Matrices.IMatrix.Clear.
TriangularUpper Copy() Copies the entries of this matrix.
Double[,] CopyToArray2D() Copies the entries of the matrix into a 2-dimensional array. The returned array has length(0) = length(1) = MGroup.LinearAlgebra.Matrices.TriangularUpper.Order.
Matrix CopyToFullMatrix() Initializes a new MGroup.LinearAlgebra.Matrices.Matrix instance by copying the entries of this MGroup.LinearAlgebra.Matrices.TriangularUpper into the lower triangle of the new matrix.
IMatrix DoEntrywise(IMatrixView matrix, Func<Double, Double, Double> binaryOperation) See MGroup.LinearAlgebra.Matrices.IMatrixView.DoEntrywise(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Func{System.Double,System.Double,System.Double}).
void DoEntrywiseIntoThis(IMatrixView matrix, Func<Double, Double, Double> binaryOperation) See MGroup.LinearAlgebra.Matrices.IMatrix.DoEntrywiseIntoThis(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Func{System.Double,System.Double,System.Double}).
void DoEntrywiseIntoThis(TriangularUpper matrix, Func<Double, Double, Double> binaryOperation) See MGroup.LinearAlgebra.Matrices.IMatrix.DoEntrywiseIntoThis(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Func{System.Double,System.Double,System.Double}).
IMatrix DoToAllEntries(Func<Double, Double> unaryOperation) See MGroup.LinearAlgebra.Matrices.IMatrixView.DoToAllEntries(System.Func{System.Double,System.Double}).
void DoToAllEntriesIntoThis(Func<Double, Double> unaryOperation) See MGroup.LinearAlgebra.Matrices.IMatrix.DoToAllEntriesIntoThis(System.Func{System.Double,System.Double}).
Boolean Equals(IIndexable2D other, Double tolerance = 1E-13) See MGroup.LinearAlgebra.Matrices.IIndexable2D.Equals(MGroup.LinearAlgebra.Matrices.IIndexable2D,System.Double).
IMatrix LinearCombination(Double thisCoefficient, IMatrixView otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrixView.LinearCombination(System.Double,MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
TriangularUpper LinearCombination(Double thisCoefficient, TriangularUpper otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrixView.LinearCombination(System.Double,MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
void LinearCombinationIntoThis(Double thisCoefficient, IMatrixView otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrix.LinearCombinationIntoThis(System.Double,MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
void LinearCombinationIntoThis(Double thisCoefficient, TriangularUpper otherMatrix, Double otherCoefficient) See MGroup.LinearAlgebra.Matrices.IMatrix.LinearCombinationIntoThis(System.Double,MGroup.LinearAlgebra.Matrices.IMatrixView,System.Double).
IVector Multiply(IVectorView vector, Boolean transposeThis = False) See MGroup.LinearAlgebra.Matrices.IMatrixView.Multiply(MGroup.LinearAlgebra.Vectors.IVectorView,System.Boolean).
Vector Multiply(Vector vector, Boolean transposeThis = False) See MGroup.LinearAlgebra.Matrices.IMatrixView.Multiply(MGroup.LinearAlgebra.Vectors.IVectorView,System.Boolean).
void MultiplyIntoResult(IVectorView lhsVector, IVector rhsVector, Boolean transposeThis = False) See MGroup.LinearAlgebra.Matrices.IMatrixView.MultiplyIntoResult(MGroup.LinearAlgebra.Vectors.IVectorView,MGroup.LinearAlgebra.Vectors.IVector,System.Boolean).
void MultiplyIntoResult(Vector lhsVector, Vector rhsVector, Boolean transposeThis = False) See MGroup.LinearAlgebra.Matrices.IMatrixView.MultiplyIntoResult(MGroup.LinearAlgebra.Vectors.IVectorView,MGroup.LinearAlgebra.Vectors.IVector,System.Boolean).
Matrix MultiplyLeft(IMatrixView matrix, Boolean transposeThis = False, Boolean transposeOther = False) See MGroup.LinearAlgebra.Matrices.IMatrixView.MultiplyLeft(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Boolean,System.Boolean).
Matrix MultiplyRight(IMatrixView matrix, Boolean transposeThis = False, Boolean transposeOther = False) See MGroup.LinearAlgebra.Matrices.IMatrixView.MultiplyRight(MGroup.LinearAlgebra.Matrices.IMatrixView,System.Boolean,System.Boolean).
Double Reduce(Double identityValue, ProcessEntry processEntry, ProcessZeros processZeros, Finalize finalize) See MGroup.LinearAlgebra.Reduction.IReducible.Reduce(System.Double,MGroup.LinearAlgebra.Reduction.ProcessEntry,MGroup.LinearAlgebra.Reduction.ProcessZeros,MGroup.LinearAlgebra.Reduction.Finalize).
TriangularUpper Scale(Double scalar) Performs the following operation for 0 <= j < MGroup.LinearAlgebra.Matrices.TriangularUpper.Order, 0 <= i <= j: result[i, j] = `` * this[i, j]. The resulting matrix is written to a new MGroup.LinearAlgebra.Matrices.TriangularUpper and then returned.
void ScaleIntoThis(Double scalar) See MGroup.LinearAlgebra.Matrices.IMatrix.ScaleIntoThis(System.Double).
void SetEntryRespectingPattern(Int32 rowIdx, Int32 colIdx, Double value) See MGroup.LinearAlgebra.Matrices.IMatrix.SetEntryRespectingPattern(System.Int32,System.Int32,System.Double).
Vector SolveLinearSystem(Vector rhs, Boolean transposeThis = False) Solves the linear equations system: this * result = `` by back substitution. WARNING: this matrix must be invertible. No exception will be thrown if the matrix is singular.
IMatrix Transpose() See MGroup.LinearAlgebra.Matrices.IMatrixView.Transpose.
TriangularLower Transpose(Boolean copyInternalArray) See MGroup.LinearAlgebra.Matrices.IMatrixView.Transpose.

Static Methods

Type Name Summary
TriangularUpper CreateFromArray(Double[,] array2D) Initializes a new instance of MGroup.LinearAlgebra.Matrices.TriangularUpper by copying the upper triangle of the provided 2D array.
TriangularUpper CreateFromArray(Int32 order, Double[] array1D, Boolean copyArray = False) Initializes a new instance of MGroup.LinearAlgebra.Matrices.TriangularUpper by copying the upper triangle of the provided 2D array.
TriangularUpper CreateZero(Int32 order) Initializes a new instance of MGroup.LinearAlgebra.Matrices.TriangularUpper with all entries being equal to 0. Only the upper triangle zero entries are explictily stored though.