Skip to content

MGroup.LinearAlgebra.Matrices.Builders

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

DokColMajor

Use this class for building large sparse matrices, e.g. MGroup.LinearAlgebra.Matrices.CscMatrix, not for operations. Convert to other matrix formats once finished and use them instead for matrix operations. The large matrices and their properties will be characterized as "global" in this namespace. This class is optimized for building global matrices with at least 1 entry per column and column major storage formats. Authors: Serafeim Bakalakos

public class MGroup.LinearAlgebra.Matrices.Builders.DokColMajor
    : ISparseMatrix, IIndexable2D, IGeneralMatrixBuilder, IMatrixBuilder

Properties

Type Name Summary
Double Item See MGroup.LinearAlgebra.Matrices.IIndexable2D.Item(System.Int32,System.Int32), MGroup.LinearAlgebra.Matrices.Builders.IMatrixBuilder.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
void AddSubmatrix(IIndexable2D subMatrix, IReadOnlyDictionary<Int32, Int32> subRowsToGlobalRows, IReadOnlyDictionary<Int32, Int32> subColsToGlobalCols) See MGroup.LinearAlgebra.Matrices.Builders.IGeneralMatrixBuilder.AddSubmatrix(MGroup.LinearAlgebra.Matrices.IIndexable2D,System.Collections.Generic.IReadOnlyDictionary{System.Int32,System.Int32},System.Collections.Generic.IReadOnlyDictionary{System.Int32,System.Int32}).
void AddSubmatrixSymmetric(IIndexable2D subMatrix, IReadOnlyDictionary<Int32, Int32> subIndicesToGlobalIndices) See MGroup.LinearAlgebra.Matrices.Builders.IGeneralMatrixBuilder.AddSubmatrixSymmetric(MGroup.LinearAlgebra.Matrices.IIndexable2D,System.Collections.Generic.IReadOnlyDictionary{System.Int32,System.Int32}).
void AddSubmatrixSymmetric(IIndexable2D subMatrix, Int32[] subMatrixIndices, Int32[] globalIndices) See MGroup.LinearAlgebra.Matrices.Builders.IGeneralMatrixBuilder.AddSubmatrixSymmetric(MGroup.LinearAlgebra.Matrices.IIndexable2D,System.Collections.Generic.IReadOnlyDictionary{System.Int32,System.Int32}).
void AddToEntry(Int32 rowIdx, Int32 colIdx, Double value) See MGroup.LinearAlgebra.Matrices.Builders.IMatrixBuilder.AddToEntry(System.Int32,System.Int32,System.Double)
ValueTuple<Double[], Int32[], Int32[]> BuildCscArrays(Boolean sortRowsOfEachCol) Creates the values and indexing arrays in CSC storage format of the current matrix. This method should be called after fully defining the matrix in MGroup.LinearAlgebra.Matrices.Builders.DokColMajor format.
CscMatrix BuildCscMatrix(Boolean sortRowsOfEachCol) Initializes a MGroup.LinearAlgebra.Matrices.CscMatrix representation of the current matrix. This method should be called after fully defining the matrix in MGroup.LinearAlgebra.Matrices.Builders.DokColMajor format.
void Clear() Frees all memory held by this MGroup.LinearAlgebra.Matrices.Builders.DokColMajor instance. Afterwards this object cannot be reused. Therefore this method should be called to save up space after building the matrix or its internal arrays.
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).
ValueTuple<Vector, Int32> GetDiagonal() Returns a MGroup.LinearAlgebra.Vectors.Vector with the entries of the matrix's main diagonal and the index of the first zero entry. If there are no zero entries, -1 is returned as the index. The MGroup.LinearAlgebra.Matrices.Builders.DokColMajor matrix must be square.
ValueTuple<Double[], Int32> GetDiagonalAsArray() Returns an array with the entries of the matrix's main diagonal and the index of the first zero entry. If there are no zero entries, -1 is returned as the index. The MGroup.LinearAlgebra.Matrices.Builders.DokColMajor matrix must be square.
SparseFormat GetSparseFormat() See MGroup.LinearAlgebra.Matrices.ISparseMatrix.GetSparseFormat.

Static Methods

Type Name Summary
DokColMajor CreateEmpty(Int32 numRows, Int32 numCols) Initializes a new instance of MGroup.LinearAlgebra.Matrices.Builders.DokColMajor with the specified matrix dimensions and all entries being equal to 0.
DokColMajor CreateFromSparseMatrix(ISparseMatrix matrix) Initializes a new instance of MGroup.LinearAlgebra.Matrices.Builders.DokColMajor with the specified matrix dimensions and the non-zero entries of the provided sparse matrix.
DokColMajor CreateFromSparsePattern(Int32 numRows, Int32 numColumns, IEnumerable<ValueTuple<Int32, Int32, Double>> nonZeroEntries) Initializes a new instance of MGroup.LinearAlgebra.Matrices.Builders.DokColMajor with the specified matrix dimensions and the non-zero entries defined by the provided pattern.
DokColMajor CreateIdentity(Int32 order) Initializes a new instance of MGroup.LinearAlgebra.Matrices.Builders.DokColMajor with the specified matrix dimensions and entries being the same as the identity matrix.

DokRowMajor

Use this class for building large sparse matrices, e.g. MGroup.LinearAlgebra.Matrices.CsrMatrix, not for operations. Convert to other matrix formats once finished and use them instead for matrix operations. The large matrices and their properties will be characterized as "global" in this namespace. This class is optimized for building global matrices with at least 1 entry per column and row major storage formats. Authors: Serafeim Bakalakos

public class MGroup.LinearAlgebra.Matrices.Builders.DokRowMajor
    : ISparseMatrix, IIndexable2D, IGeneralMatrixBuilder, IMatrixBuilder

Properties

Type Name Summary
Double Item See MGroup.LinearAlgebra.Matrices.IIndexable2D.Item(System.Int32,System.Int32), MGroup.LinearAlgebra.Matrices.Builders.IMatrixBuilder.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
void AddSubmatrix(IIndexable2D subMatrix, IReadOnlyDictionary<Int32, Int32> subRowsToGlobalRows, IReadOnlyDictionary<Int32, Int32> subColsToGlobalCols) See MGroup.LinearAlgebra.Matrices.Builders.IGeneralMatrixBuilder.AddSubmatrix(MGroup.LinearAlgebra.Matrices.IIndexable2D,System.Collections.Generic.IReadOnlyDictionary{System.Int32,System.Int32},System.Collections.Generic.IReadOnlyDictionary{System.Int32,System.Int32}).
void AddSubmatrixSymmetric(IIndexable2D subMatrix, IReadOnlyDictionary<Int32, Int32> subIndicesToGlobalIndices) See MGroup.LinearAlgebra.Matrices.Builders.IGeneralMatrixBuilder.AddSubmatrixSymmetric(MGroup.LinearAlgebra.Matrices.IIndexable2D,System.Collections.Generic.IReadOnlyDictionary{System.Int32,System.Int32}).
void AddSubmatrixSymmetric(IIndexable2D subMatrix, Int32[] subMatrixIndices, Int32[] globalIndices) See MGroup.LinearAlgebra.Matrices.Builders.IGeneralMatrixBuilder.AddSubmatrixSymmetric(MGroup.LinearAlgebra.Matrices.IIndexable2D,System.Collections.Generic.IReadOnlyDictionary{System.Int32,System.Int32}).
void AddToEntry(Int32 rowIdx, Int32 colIdx, Double value) See MGroup.LinearAlgebra.Matrices.Builders.IMatrixBuilder.AddToEntry(System.Int32,System.Int32,System.Double)
ValueTuple<Double[], Int32[], Int32[]> BuildCsrArrays(Boolean sortColsOfEachCol) Creates the values and indexing arrays in CSR storage format of the current matrix. This method should be called after fully defining the matrix in MGroup.LinearAlgebra.Matrices.Builders.DokRowMajor format.
CsrMatrix BuildCsrMatrix(Boolean sortColsOfEachRow) Initializes a MGroup.LinearAlgebra.Matrices.CsrMatrix representation of the current matrix. This method should be called after fully defining the matrix in MGroup.LinearAlgebra.Matrices.Builders.DokRowMajor format.
void Clear() Frees all memory held by this MGroup.LinearAlgebra.Matrices.Builders.DokRowMajor instance. Afterwards this object cannot be reused. Therefore this method should be called to save up space after building the matrix or its internal arrays.
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).
ValueTuple<Vector, Int32> GetDiagonal() Returns a MGroup.LinearAlgebra.Vectors.Vector with the entries of the matrix's main diagonal and the index of the first zero entry. If there are no zero entries, -1 is returned as the index. The MGroup.LinearAlgebra.Matrices.Builders.DokRowMajor matrix must be square.
ValueTuple<Double[], Int32> GetDiagonalAsArray() Returns an array with the entries of the matrix's main diagonal and the index of the first zero entry. If there are no zero entries, -1 is returned as the index. The MGroup.LinearAlgebra.Matrices.Builders.DokRowMajor matrix must be square.
SparseFormat GetSparseFormat() See MGroup.LinearAlgebra.Matrices.ISparseMatrix.GetSparseFormat.
Vector MultiplyRight(Vector vector, Boolean avoidBuilding = False) Performs the matrix-vector multiplication: this * ``. This method is at least as fast as creating a CSR matrix and multiplying it with 1 vector. If more than 1 multiplications are needed, then the CSR matrix should be created.

Static Methods

Type Name Summary
DokRowMajor CreateEmpty(Int32 numRows, Int32 numCols) Initializes a new instance of MGroup.LinearAlgebra.Matrices.Builders.DokRowMajor with the specified matrix dimensions and all entries being equal to 0.
DokRowMajor CreateFromSparseMatrix(ISparseMatrix matrix) Initializes a new instance of MGroup.LinearAlgebra.Matrices.Builders.DokRowMajor with the specified matrix dimensions and the non-zero entries of the provided sparse matrix.
DokRowMajor CreateFromSparsePattern(Int32 numRows, Int32 numColumns, IEnumerable<ValueTuple<Int32, Int32, Double>> nonZeroEntries) Initializes a new instance of MGroup.LinearAlgebra.Matrices.Builders.DokRowMajor with the specified matrix dimensions and the non-zero entries defined by the provided pattern.
DokRowMajor CreateIdentity(Int32 order) Initializes a new instance of MGroup.LinearAlgebra.Matrices.Builders.DokRowMajor with the specified matrix dimensions and entries being the same as the identity matrix.

DokSymmetric

Use this class for building large symmetric sparse matrices not for operations. Convert to other matrix formats once finished and use them instead for matrix operations. The large matrices and their properties will be characterized as "global" in this namespace. This class is optimized for building symmetric global matrices, where only entries of the upper triangle are explicitly stored, the storage format is column major and there is at least 1 entry per column. Authors: Serafeim Bakalakos

public class MGroup.LinearAlgebra.Matrices.Builders.DokSymmetric
    : ISparseSymmetricMatrix, ISymmetricMatrix, ISparseMatrix, IIndexable2D, ISymmetricMatrixBuilder, IMatrixBuilder

Properties

Type Name Summary
Double Item See MGroup.LinearAlgebra.Matrices.IIndexable2D.Item(System.Int32,System.Int32), MGroup.LinearAlgebra.Matrices.Builders.IMatrixBuilder.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
void AddSubmatrix(IIndexable2D subMatrix, IReadOnlyDictionary<Int32, Int32> subRowsToGlobalRows, IReadOnlyDictionary<Int32, Int32> subColsToGlobalCols) See MGroup.LinearAlgebra.Matrices.Builders.ISymmetricMatrixBuilder.AddSubmatrix(MGroup.LinearAlgebra.Matrices.IIndexable2D,System.Collections.Generic.IReadOnlyDictionary{System.Int32,System.Int32},System.Collections.Generic.IReadOnlyDictionary{System.Int32,System.Int32}).
void AddSubmatrixSymmetric(IIndexable2D subMatrix, IReadOnlyDictionary<Int32, Int32> subIndicesToGlobalIndices) See MGroup.LinearAlgebra.Matrices.Builders.ISymmetricMatrixBuilder.AddSubmatrixSymmetric(MGroup.LinearAlgebra.Matrices.IIndexable2D,System.Collections.Generic.IReadOnlyDictionary{System.Int32,System.Int32}).
void AddSubmatrixSymmetric(IIndexable2D subMatrix, Int32[] subMatrixIndices, Int32[] globalIndices) See MGroup.LinearAlgebra.Matrices.Builders.ISymmetricMatrixBuilder.AddSubmatrixSymmetric(MGroup.LinearAlgebra.Matrices.IIndexable2D,System.Collections.Generic.IReadOnlyDictionary{System.Int32,System.Int32}).
void AddSubmatrixToLowerTriangle(IIndexable2D subMatrix, IReadOnlyDictionary<Int32, Int32> subRowsToGlobalRows, IReadOnlyDictionary<Int32, Int32> subColsToGlobalCols) See MGroup.LinearAlgebra.Matrices.Builders.ISymmetricMatrixBuilder.AddSubmatrixToLowerTriangle(MGroup.LinearAlgebra.Matrices.IIndexable2D,System.Collections.Generic.IReadOnlyDictionary{System.Int32,System.Int32},System.Collections.Generic.IReadOnlyDictionary{System.Int32,System.Int32})
void AddSubmatrixToUpperTriangle(IIndexable2D subMatrix, IReadOnlyDictionary<Int32, Int32> subRowsToGlobalRows, IReadOnlyDictionary<Int32, Int32> subColsToGlobalCols) See MGroup.LinearAlgebra.Matrices.Builders.ISymmetricMatrixBuilder.AddSubmatrixToUpperTriangle(MGroup.LinearAlgebra.Matrices.IIndexable2D,System.Collections.Generic.IReadOnlyDictionary{System.Int32,System.Int32},System.Collections.Generic.IReadOnlyDictionary{System.Int32,System.Int32})
void AddToEntry(Int32 rowIdx, Int32 colIdx, Double value) See MGroup.LinearAlgebra.Matrices.Builders.IMatrixBuilder.AddToEntry(System.Int32,System.Int32,System.Double)
ValueTuple<Double[], Int32[], Int32[]> BuildSymmetricCscArrays(Boolean sortRowsOfEachCol) Creates the values and indexing arrays in CSC storage format of the upper triangle of the current symmetric matrix. This method should be called after fully defining the matrix in MGroup.LinearAlgebra.Matrices.Builders.DokSymmetric format.
SymmetricCscMatrix BuildSymmetricCscMatrix(Boolean sortRowsOfEachCol) Initializes a MGroup.LinearAlgebra.Matrices.SymmetricCscMatrix representation of the current matrix. This method should be called after fully defining the matrix in MGroup.LinearAlgebra.Matrices.Builders.DokSymmetric format.
void Clear() Frees all memory held by this MGroup.LinearAlgebra.Matrices.Builders.DokSymmetric instance. Afterwards this object cannot be reused. Therefore this method should be called to save up space after building the matrix or its internal arrays.
Int32 CountNonZeros() See MGroup.LinearAlgebra.Matrices.ISparseMatrix.CountNonZeros.
Int32 CountNonZerosUpper() See MGroup.LinearAlgebra.Matrices.ISparseSymmetricMatrix.CountNonZerosUpper.
IEnumerable<ValueTuple<Int32, Int32, Double>> EnumerateNonZeros() See MGroup.LinearAlgebra.Matrices.ISparseMatrix.EnumerateNonZeros.
IEnumerable<ValueTuple<Int32, Int32, Double>> EnumerateNonZerosUpper() See MGroup.LinearAlgebra.Matrices.ISparseSymmetricMatrix.EnumerateNonZerosUpper.
Boolean Equals(IIndexable2D other, Double tolerance = 1E-13) See MGroup.LinearAlgebra.Matrices.IIndexable2D.Equals(MGroup.LinearAlgebra.Matrices.IIndexable2D,System.Double).
SparseVector GetColumn(Int32 colIdx) Returns the column with index = as a sparse vector. Note that the length of the returned vector is equal to this.`MGroup.LinearAlgebra.Matrices.Builders.DokSymmetric.NumRows`. Since the matrix is symmetric, this method also works for getting the row with index =.
SparseVector GetColumnWithoutRows(Int32 colIdx, ISet<Int32> tabooRows) Returns the column with index = as a vector. However, the entries with row index that belongs in will be set to 0. More accurately, they will not be included in the sparsity pattern of the returned MGroup.LinearAlgebra.Vectors.SparseVector. Note that the length of the returned vector is equal to this.MGroup.LinearAlgebra.Matrices.Builders.DokSymmetric.NumRows. Since the matrix is symmetric, this method also works for getting the row with index = ``.
ValueTuple<Vector, Int32> GetDiagonal() Returns a MGroup.LinearAlgebra.Vectors.Vector with the entries of the matrix's main diagonal and the index of the first zero entry. If there are no zero entries, -1 is returned as the index.
ValueTuple<Double[], Int32> GetDiagonalAsArray() Returns an array with the entries of the matrix's main diagonal and the index of the first zero entry. If there are no zero entries, -1 is returned as the index.
SparseFormat GetSparseFormat() See MGroup.LinearAlgebra.Matrices.ISparseMatrix.GetSparseFormat.
void SetColumn(Int32 colIdx, SparseVector newColumn) Sets the column with index to be equal to the provided. Since the matrix is symmetric, this method also works for modifying the row with index = ``.
void SetColumnToIdentity(Int32 colIdx) Sets the column with index to have 1.0 at the main diagonal entry and 0.0 everywhere else. Since the matrix is symmetric, this method also works for modifying the row with index =.
void SetColumnToZero(Int32 colIdx) Sets the column with index to have 0.0 at all entries. Since the matrix is symmetric, this method also works for modifying the row with index =.
void SetStructuralZeroDiagonalEntriesToUnity() Sets all entries that are on the main diagonal and have not been explicitly modified by a previous method or constructor, and thus are equal to 0, to 1.

Static Methods

Type Name Summary
DokSymmetric CreateEmpty(Int32 order) Initializes a new instance of MGroup.LinearAlgebra.Matrices.Builders.DokColMajor with the specified matrix dimensions and all entries being equal to 0.
DokSymmetric CreateFromSparseMatrix(ISparseMatrix matrix) Initializes a new instance of MGroup.LinearAlgebra.Matrices.Builders.DokSymmetric with the specified matrix dimensions and the non-zero entries of the provided sparse matrix.
DokSymmetric CreateFromSparsePattern(Int32 order, IEnumerable<ValueTuple<Int32, Int32, Double>> nonZeroEntries) Initializes a new instance of MGroup.LinearAlgebra.Matrices.Builders.DokSymmetric with the specified matrix dimensions and the non-zero entries defined by the provided pattern.
DokSymmetric CreateFromSparseSymmetricMatrix(ISparseSymmetricMatrix matrix) Initializes a new instance of MGroup.LinearAlgebra.Matrices.Builders.DokSymmetric with the specified matrix dimensions and the non-zero entries of the provided symmetric sparse matrix.
DokSymmetric CreateFromSparseSymmetricPattern(Int32 order, IEnumerable<ValueTuple<Int32, Int32, Double>> nonZeroEntries) Initializes a new instance of MGroup.LinearAlgebra.Matrices.Builders.DokSymmetric with the specified matrix dimensions and the non-zero entries defined by the provided symmetric pattern.
DokSymmetric CreateIdentity(Int32 order) Initializes a new instance of MGroup.LinearAlgebra.Matrices.Builders.DokSymmetric with the specified matrix dimensions and entries being the same as the identity matrix. WARNING: if you initilize the DOK to identity, then you need to overwrite the diagonal entries with the new values (in FEM you only write to each diagonal entry once), instead of adding to them. This precludes the use of the methods that add a whole submatrix to the DOK. Therefore, it is more convenient to call MGroup.LinearAlgebra.Matrices.Builders.DokSymmetric.CreateEmpty(System.Int32) and after all submatrices have been added, call MGroup.LinearAlgebra.Matrices.Builders.DokSymmetric.SetStructuralZeroDiagonalEntriesToUnity.

IGeneralMatrixBuilder

Facilitates the construction of large sparse matrices, symmetric or not, usually by adding smaller submatrices. The large matrices and their properties will be characterized as "global" in this namespace. Authors: Serafeim Bakalakos

public interface MGroup.LinearAlgebra.Matrices.Builders.IGeneralMatrixBuilder
    : IMatrixBuilder, IIndexable2D

Methods

Type Name Summary
void AddSubmatrix(IIndexable2D subMatrix, IReadOnlyDictionary<Int32, Int32> subRowsToGlobalRows, IReadOnlyDictionary<Int32, Int32> subColsToGlobalCols) Adds the entries of to the corresponding entries of this matrix. The mapping between the rows and columns of the two matrices is given by and ``.
void AddSubmatrixSymmetric(IIndexable2D subMatrix, IReadOnlyDictionary<Int32, Int32> subIndicesToGlobalIndices) Adds the entries of to the corresponding entries of this matrix. Both matrices must be symmetric. The mapping between the rows and columns of the two matrices is given by and the resulting "global" row/column indices must be symmetrically placed around this MGroup.LinearAlgebra.Matrices.Builders.IGeneralMatrixBuilder's diagonal.
void AddSubmatrixSymmetric(IIndexable2D subMatrix, Int32[] subMatrixIndices, Int32[] globalIndices) Adds the entries of to the corresponding entries of this matrix. Both matrices must be symmetric. The mapping between the rows and columns of the two matrices is given by and the resulting "global" row/column indices must be symmetrically placed around this MGroup.LinearAlgebra.Matrices.Builders.IGeneralMatrixBuilder's diagonal.

IMatrixBuilder

Facilitates the construction of large sparse matrices, usually by adding smaller submatrices. The large matrices and their properties will be characterized as "global" in this namespace. Authors: Serafeim Bakalakos

public interface MGroup.LinearAlgebra.Matrices.Builders.IMatrixBuilder
    : IIndexable2D

Properties

Type Name Summary
Double Item Sets the entry (, ) to the provided value.

Methods

Type Name Summary
void AddToEntry(Int32 rowIdx, Int32 colIdx, Double value) Adds the provided to the entry (, ``).

ISymmetricMatrixBuilder

Facilitates the construction of large symmetric sparse matrices, usually by adding smaller submatrices. The large matrices and their properties will be characterized as "global" in this namespace. Authors: Serafeim Bakalakos

public interface MGroup.LinearAlgebra.Matrices.Builders.ISymmetricMatrixBuilder
    : IMatrixBuilder, IIndexable2D

Methods

Type Name Summary
void AddSubmatrix(IIndexable2D subMatrix, IReadOnlyDictionary<Int32, Int32> subRowsToGlobalRows, IReadOnlyDictionary<Int32, Int32> subColsToGlobalCols) Adds the entries of to the corresponding entries of this matrix. The mapping between the rows and columns of the two matrices is given by and ``. This method preprocesses each entry to find out if it is mapped to the upper or lower triangle. As such it is safe to use, even if the user does not know which triangle the "global" row/column indices, defined by the mapping, will end up to. If all entries are mapped to the same triangle and it is known, then MGroup.LinearAlgebra.Matrices.Builders.ISymmetricMatrixBuilder.AddSubmatrixToLowerTriangle(MGroup.LinearAlgebra.Matrices.IIndexable2D,System.Collections.Generic.IReadOnlyDictionary{System.Int32,System.Int32},System.Collections.Generic.IReadOnlyDictionary{System.Int32,System.Int32}) and `MGroup.LinearAlgebra.Matrices.Builders.ISymmetricMatrixBuilder.AddSubmatrixToUpperTriangle(MGroup.LinearAlgebra.Matrices.IIndexable2D,System.Collections.Generic.IReadOnlyDictionary{System.Int32,System.Int32},System.Collections.Generic.IReadOnlyDictionary{System.Int32,System.Int32})` are more efficient. WARNING: Do not add (symmetric) matrices that are mapped symmetrically around this `MGroup.LinearAlgebra.Matrices.Builders.ISymmetricMatrixBuilder`'s diagonal with this method, as most entries will be added twice. Instead use `MGroup.LinearAlgebra.Matrices.Builders.ISymmetricMatrixBuilder.AddSubmatrixSymmetric(MGroup.LinearAlgebra.Matrices.IIndexable2D,System.Collections.Generic.IReadOnlyDictionary{System.Int32,System.Int32})`.
void AddSubmatrixSymmetric(IIndexable2D subMatrix, IReadOnlyDictionary<Int32, Int32> subIndicesToGlobalIndices) Adds the entries of a symmetric to the corresponding entries of this matrix. The mapping between the rows and columns of the two matrices is given by and the resulting "global" row/column indices must be symmetrically placed around this MGroup.LinearAlgebra.Matrices.Builders.ISymmetricMatrixBuilder's diagonal.
void AddSubmatrixSymmetric(IIndexable2D subMatrix, Int32[] subMatrixIndices, Int32[] globalIndices) Adds the entries of a symmetric to the corresponding entries of this matrix. The mapping between the rows and columns of the two matrices is given by and the resulting "global" row/column indices must be symmetrically placed around this MGroup.LinearAlgebra.Matrices.Builders.ISymmetricMatrixBuilder's diagonal.
void AddSubmatrixToLowerTriangle(IIndexable2D subMatrix, IReadOnlyDictionary<Int32, Int32> subRowsToGlobalRows, IReadOnlyDictionary<Int32, Int32> subColsToGlobalCols) Adds the entries of to the corresponding lower triangular entries of this matrix. The mapping between the rows and columns of the two matrices is given by and ``. Optimized version of MGroup.LinearAlgebra.Matrices.Builders.ISymmetricMatrixBuilder.AddSubmatrix(MGroup.LinearAlgebra.Matrices.IIndexable2D,System.Collections.Generic.IReadOnlyDictionary{System.Int32,System.Int32},System.Collections.Generic.IReadOnlyDictionary{System.Int32,System.Int32}), in case the caller is sure that all "global" row/column indices will belong to the lower triangle, though this will not be checked explicitly.
void AddSubmatrixToUpperTriangle(IIndexable2D subMatrix, IReadOnlyDictionary<Int32, Int32> subRowsToGlobalRows, IReadOnlyDictionary<Int32, Int32> subColsToGlobalCols) Adds the entries of to the corresponding upper triangular entries of this matrix. The mapping between the rows and columns of the two matrices is given by and ``. Optimized version of MGroup.LinearAlgebra.Matrices.Builders.ISymmetricMatrixBuilder.AddSubmatrix(MGroup.LinearAlgebra.Matrices.IIndexable2D,System.Collections.Generic.IReadOnlyDictionary{System.Int32,System.Int32},System.Collections.Generic.IReadOnlyDictionary{System.Int32,System.Int32}), in case the caller is sure that all "global" row/column indices will belong to the upper triangle, though this will not be checked explicitly.

PartialMatrixColumns

Facilitates the construction of a square matrix when only some of its columns are needed explicitly. Authors: Serafeim Bakalakos

public class MGroup.LinearAlgebra.Matrices.Builders.PartialMatrixColumns

Properties

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

Methods

Type Name Summary
void AddToEntry(Int32 rowIdx, Int32 colIdx, Double value) Adds the provided to the entry (, ``).
SparseVector GetColumnWithoutRows(Int32 colIdx, HashSet<Int32> tabooRows) Returns the column with index = as a vector. However, the entries with row index that belongs in will be set to 0. More accurately, they will not be included in the sparsity pattern of the returned MGroup.LinearAlgebra.Vectors.SparseVector. Note that the length of the returned vector is equal to this.MGroup.LinearAlgebra.Matrices.Builders.PartialMatrixColumns.NumRows.
SparseVector GetColumnWithSelectedRows(Int32 colIdx, HashSet<Int32> wantedRows) Returns the column with index = as a vector. However, only the entries with row index that belongs in will be copied. The rest will be 0 and not stored explicitly. Note that the length of the returned vector is equal to this.MGroup.LinearAlgebra.Matrices.Builders.PartialMatrixColumns.NumRows.
void SetColumnToIdentity(Int32 colIdx) Sets the column with index `` to have 1.0 at the main diagonal entry and 0.0 everywhere else.

PartialMatrixRows

Facilitates the construction of a matrix when only some of its rows are needed explicitly. Authors: Serafeim Bakalakos

public class MGroup.LinearAlgebra.Matrices.Builders.PartialMatrixRows

Properties

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

Methods

Type Name Summary
void AddToEntry(Int32 rowIdx, Int32 colIdx, Double value) Adds the provided to the entry (, ``).
SparseVector MultiplyRight(Vector vector) Performs the matrix-vector multiplication: this * ``.

SkylineBuilder

Use this class for building large symmetric sparse matrices not for operations. Convert to other matrix formats once finished and use them instead for matrix operations. The large matrices and their properties will be characterized as "global" in this namespace. This class is meant for building symmetric global matrices in skyline storage format (see MGroup.LinearAlgebra.Matrices.SkylineMatrix), where only entries of the upper triangle are explicitly stored. Authors: Serafeim Bakalakos

public class MGroup.LinearAlgebra.Matrices.Builders.SkylineBuilder
    : ISymmetricMatrixBuilder, IMatrixBuilder, IIndexable2D

Properties

Type Name Summary
Double Item See MGroup.LinearAlgebra.Matrices.IIndexable2D.Item(System.Int32,System.Int32), MGroup.LinearAlgebra.Matrices.Builders.IMatrixBuilder.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
void AddSubmatrix(IIndexable2D subMatrix, IReadOnlyDictionary<Int32, Int32> subRowsToGlobalRows, IReadOnlyDictionary<Int32, Int32> subColsToGlobalCols) See MGroup.LinearAlgebra.Matrices.Builders.ISymmetricMatrixBuilder.AddSubmatrix(MGroup.LinearAlgebra.Matrices.IIndexable2D,System.Collections.Generic.IReadOnlyDictionary{System.Int32,System.Int32},System.Collections.Generic.IReadOnlyDictionary{System.Int32,System.Int32}).
void AddSubmatrixSymmetric(IIndexable2D subMatrix, IReadOnlyDictionary<Int32, Int32> subIndicesToGlobalIndices) See MGroup.LinearAlgebra.Matrices.Builders.ISymmetricMatrixBuilder.AddSubmatrixSymmetric(MGroup.LinearAlgebra.Matrices.IIndexable2D,System.Collections.Generic.IReadOnlyDictionary{System.Int32,System.Int32}).
void AddSubmatrixSymmetric(IIndexable2D subMatrix, Int32[] subMatrixIndices, Int32[] globalIndices) See MGroup.LinearAlgebra.Matrices.Builders.ISymmetricMatrixBuilder.AddSubmatrixSymmetric(MGroup.LinearAlgebra.Matrices.IIndexable2D,System.Collections.Generic.IReadOnlyDictionary{System.Int32,System.Int32}).
void AddSubmatrixToLowerTriangle(IIndexable2D subMatrix, IReadOnlyDictionary<Int32, Int32> subRowsToGlobalRows, IReadOnlyDictionary<Int32, Int32> subColsToGlobalCols) See MGroup.LinearAlgebra.Matrices.Builders.ISymmetricMatrixBuilder.AddSubmatrixToLowerTriangle(MGroup.LinearAlgebra.Matrices.IIndexable2D,System.Collections.Generic.IReadOnlyDictionary{System.Int32,System.Int32},System.Collections.Generic.IReadOnlyDictionary{System.Int32,System.Int32})
void AddSubmatrixToUpperTriangle(IIndexable2D subMatrix, IReadOnlyDictionary<Int32, Int32> subRowsToGlobalRows, IReadOnlyDictionary<Int32, Int32> subColsToGlobalCols) See MGroup.LinearAlgebra.Matrices.Builders.ISymmetricMatrixBuilder.AddSubmatrixToUpperTriangle(MGroup.LinearAlgebra.Matrices.IIndexable2D,System.Collections.Generic.IReadOnlyDictionary{System.Int32,System.Int32},System.Collections.Generic.IReadOnlyDictionary{System.Int32,System.Int32})
void AddToEntry(Int32 rowIdx, Int32 colIdx, Double value) See MGroup.LinearAlgebra.Matrices.Builders.IMatrixBuilder.AddToEntry(System.Int32,System.Int32,System.Double)
SkylineMatrix BuildSkylineMatrix() Initializes a MGroup.LinearAlgebra.Matrices.SkylineMatrix representation of the current matrix. This method should be called after fully defining the matrix in MGroup.LinearAlgebra.Matrices.Builders.SkylineBuilder format.
Boolean Equals(IIndexable2D other, Double tolerance = 1E-13) See MGroup.LinearAlgebra.Matrices.IIndexable2D.Equals(MGroup.LinearAlgebra.Matrices.IIndexable2D,System.Double).

Static Methods

Type Name Summary
SkylineBuilder Create(Int32 numColumns, Int32[] columnHeights) Initializes a new instance of MGroup.LinearAlgebra.Matrices.Builders.SkylineBuilder with the provided dimensions and sparsity bandwidth.
Clone this wiki locally