Skip to content

MGroup.LinearAlgebra.Factorizations

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

BunchKaufmanFactorization

The Bunch-Kaufman factorization of a symmetric matrix A is" A = transpose(U) * D * U. It is recommended for symmetric indefinite matrices, since Cholesky factorization cannot be used and Bunch-Kaufman is more efficient than LU factorization. Uses LAPACK. Authors: Serafeim Bakalakos

public class MGroup.LinearAlgebra.Factorizations.BunchKaufmanFactorization
    : ITriangulation

Methods

Type Name Summary
Double CalcDeterminant()
void SolveLinearSystem(Vector rhs, Vector solution)

CholeskyCSparseNet

Cholesky factorization of a sparse symmetric positive definite matrix using the CSparse.NET library. The original matrix must be in Compressed Sparse Columns format, with only the upper triangle stored. This class may serve as a managed alternative to MGroup.LinearAlgebra.Factorizations.CholeskySuiteSparse. Authors: Serafeim Bakalakos

public class MGroup.LinearAlgebra.Factorizations.CholeskyCSparseNet
    : ITriangulation

Properties

Type Name Summary
Int32 NumNonZerosUpper The number of non-zero entries (and explicitly stored zeros) in the explicitly stored upper triangular factor after Cholesky factorization.
Int32 Order The number of rows/columns of the square matrix.

Methods

Type Name Summary
Double CalcDeterminant() See MGroup.LinearAlgebra.Factorizations.ITriangulation.CalcDeterminant.
void SolveLinearSystem(Vector rhs, Vector solution) See .

Static Methods

Type Name Summary
CholeskyCSparseNet Factorize(Int32 order, Int32 numNonZerosUpper, Double[] cscValues, Int32[] cscRowIndices, Int32[] cscColOffsets) Performs the Cholesky factorization: A = L * L^T of a symmetric positive definite matrix A. Only the upper triangle of the original matrix is required and is provided in symmetric CSC format by , and ``. The user may choose between supernodal or simplicial factorization. It is also possible to automatically reorder the matrix, using the algorithms provided by SuiteSparse. The factorized data, which may be sufficiently larger than the original matrix due to fill-in, will be written to unmanaged memory.
CholeskyCSparseNet Factorize(SymmetricCscMatrix matrix) Performs the Cholesky factorization: A = L * L^T of a symmetric positive definite matrix A. Only the upper triangle of the original matrix is required and is provided in symmetric CSC format by , and ``. The user may choose between supernodal or simplicial factorization. It is also possible to automatically reorder the matrix, using the algorithms provided by SuiteSparse. The factorized data, which may be sufficiently larger than the original matrix due to fill-in, will be written to unmanaged memory.

CholeskyFull

Cholesky factorization of a symmetric positive definite matrix, stored in full column major format. Only the upper triangle part of the matrix is factorized. The subdiagonal part of the original matrix is still stored in the array but it is ignored. Uses Lapack. Authors: Serafeim Bakalakos

public class MGroup.LinearAlgebra.Factorizations.CholeskyFull
    : ITriangulation

Properties

Type Name Summary
Boolean IsOverwritten If true, the internal data of this object are overwritten and used by another object. No property or method of this object must be called as it would throw exceptions or lead to data corruption. If false, this object can be used normally.
Int32 Order The number of rows/columns of the original square matrix.

Methods

Type Name Summary
Double CalcDeterminant() See MGroup.LinearAlgebra.Factorizations.ITriangulation.CalcDeterminant.
Matrix GetFactorU() Explicitly creates the upper triangular matrix U that resulted from the Cholesky factorization: A = transpose(U) * U, where A and U are n-by-n. This method is safe to use as the factorization data are copied (if necessary). However, it is inefficient if the generated matrix is only used once.
Matrix Invert(Boolean inPlace) Calculates the inverse of the original matrix and returns it in a new MGroup.LinearAlgebra.Matrices.Matrix instance. WARNING: If `` is set to true, this object must not be used again, otherwise a System.InvalidOperationException will be thrown.
void SolveLinearSystem(Vector rhs, Vector solution) See MGroup.LinearAlgebra.Factorizations.ITriangulation.SolveLinearSystem(MGroup.LinearAlgebra.Vectors.Vector,MGroup.LinearAlgebra.Vectors.Vector).

Static Methods

Type Name Summary
CholeskyFull Factorize(Int32 order, Double[] matrix) Calculates the cholesky factorization of a symmetric positive definite matrix, such that A = transpose(U) * U.

CholeskyPacked

Cholesky factorization of a symmetric positive definite matrix, stored in packed column major format. Only the upper triangle part of the matrix is stored and factorized. Uses LAPACK. Authors: Serafeim Bakalakos

public class MGroup.LinearAlgebra.Factorizations.CholeskyPacked
    : ITriangulation

Properties

Type Name Summary
Boolean IsOverwritten If true, the internal data of this object are overwritten and used by another object. No property or method of this object must be called as it would throw exceptions or lead to data corruption. If false, this object can be used normally.
Int32 Order The number of rows/columns of the original square matrix.

Methods

Type Name Summary
Double CalcDeterminant() See MGroup.LinearAlgebra.Factorizations.ITriangulation.CalcDeterminant.
TriangularUpper GetFactorU() Explicitly creates the upper triangular matrix U that resulted from the Cholesky factorization: A = transpose(U) * U, where A and U are n-by-n. This method is safe to use as the factorization data are copied (if necessary). However, it is inefficient if the generated matrix is only used once.
SymmetricMatrix Invert(Boolean inPlace) Calculates the inverse of the original matrix and returns it in a new MGroup.LinearAlgebra.Matrices.SymmetricMatrix instance. WARNING: If `` is set to true, this object must not be used again, otherwise a System.InvalidOperationException will be thrown.
void SolveLinearSystem(Vector rhs, Vector solution) See MGroup.LinearAlgebra.Factorizations.ITriangulation.SolveLinearSystem(MGroup.LinearAlgebra.Vectors.Vector,MGroup.LinearAlgebra.Vectors.Vector).

Static Methods

Type Name Summary
CholeskyPacked Factorize(Int32 order, Double[] matrix) Calculates the cholesky factorization of a symmetric positive definite matrix, such that A = transpose(U) * U.

CholeskySkyline

Cholesky factorization of a symmetric positive definite matrix, stored in skyline format. Only the active columns of the upper triangle part of the matrix is stored and factorized. Authors: Serafeim Bakalakos

public class MGroup.LinearAlgebra.Factorizations.CholeskySkyline
    : IIndexable2D, ISparseMatrix, ITriangulation

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.

Methods

Type Name Summary
Double CalcDeterminant() See MGroup.LinearAlgebra.Factorizations.ITriangulation.CalcDeterminant.
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, TriangularUpper> GetFactorsDU() Copies the upper triangular matrix U and diagonal matrix D that resulted from the Cholesky factorization: A = transpose(U) * D * U to a new MGroup.LinearAlgebra.Matrices.TriangularUpper matrix.
SparseFormat GetSparseFormat() See MGroup.LinearAlgebra.Matrices.ISparseMatrix.GetSparseFormat.
void SolveLinearSystem(IVectorView rhs, IVector solution) Same as MGroup.LinearAlgebra.Factorizations.ITriangulation.SolveLinearSystem(MGroup.LinearAlgebra.Vectors.Vector,MGroup.LinearAlgebra.Vectors.Vector).
void SolveLinearSystem(Vector rhs, Vector solution) Same as MGroup.LinearAlgebra.Factorizations.ITriangulation.SolveLinearSystem(MGroup.LinearAlgebra.Vectors.Vector,MGroup.LinearAlgebra.Vectors.Vector).
void SolveLinearSystems(Matrix rhsVectors, Matrix solutionVectors) Solves the linear systems A * X = B, where A is the original matrix (before the factorization), B = and X is the matrix containing the solution vectors, which will overwrite the provided.

Static Fields

Type Name Summary
Double PivotTolerance The default value under which a diagonal entry (pivot) is considered to be 0 during Cholesky factorization.

Static Methods

Type Name Summary
CholeskySkyline Factorize(Int32 order, Double[] skyValues, Int32[] skyDiagOffsets, Double tolerance = 1E-15) Calculates the cholesky factorization of a symmetric positive definite matrix, such that A = transpose(U) * U. Does not need any extra memory.

CholeskySuiteSparse

Cholesky factorization of a sparse symmetric positive definite matrix using the SuiteSparse library. The original matrix must be in Compressed Sparse Columns format, with only the upper triangle stored. SuiteSparse is very efficient for sparse matrices and provides a lot of functionality, but requires handling unmanaged memory, which is abstracted in this class. If SuiteSparse dlls are not available, try using the managed alternative MGroup.LinearAlgebra.Factorizations.CholeskyCSparseNet instead. Authors: Serafeim Bakalakos

public class MGroup.LinearAlgebra.Factorizations.CholeskySuiteSparse
    : ITriangulation, IDisposable

Properties

Type Name Summary
Int32 NumNonZerosUpper The number of non-zero entries (and explicitly stored zeros) in the explicitly stored upper triangular factor after Cholesky factorization.
Int32 Order The number of rows/columns of the square matrix.

Methods

Type Name Summary
void AddRow(Int32 rowIdx, SparseVector newRow) Sets the -th row/column of the factorized matrix to the one it would have if was set as the -th row/column of the original matrix and then the factorization was performed. The existing -th row/column of the original matrix must be equal to the ``-th row/col of the identity matrix.
Vector BackSubstitution(Vector rhsVector) Solves the linear system L^T * x = b (or D * L^T * x = b), where L is the lower triangular factor (and D the diagonal factor) of the Cholesky factorization: A = L * L^T (or A = L * D * L^T).
Matrix BackSubstitutions(Matrix rhsVectors) Solves a series of linear systems L^T * x = b (or D * L^T * x = b), where L is the lower triangular factor (and D the diagonal factor) of the Cholesky factorization: A = L * L^T (or A = L * D * L^T).
Double CalcDeterminant() See MGroup.LinearAlgebra.Factorizations.ITriangulation.CalcDeterminant.
void DeleteRow(Int32 rowIdx) Sets the -th row/column of the factorized matrix to the one it would have if the -th row/column of the identity matrix was set as the ``-th row/column of the original matrix and then the factorization was performed.
void Dispose() See System.IDisposable.Dispose.
void Finalize()
Vector ForwardSubstitution(Vector rhsVector) Solves the linear system L * x = b (or L * D * x = b), where L is the lower triangular factor (and D the diagonal factor) of the Cholesky factorization: A = L * L^T (or A = L * D * L^T).
Matrix ForwardSubstitutions(Matrix rhsVectors) Solves a series of linear systems L * x = b (or L * D * x = b), where L is the lower triangular factor (and D the diagonal factor) of the Cholesky factorization: A = L * L^T (or A = L * D * L^T).
void SolveLinearSystem(Vector rhsVector, Vector solution) See MGroup.LinearAlgebra.Factorizations.ITriangulation.SolveLinearSystem(MGroup.LinearAlgebra.Vectors.Vector,MGroup.LinearAlgebra.Vectors.Vector).
Matrix SolveLinearSystems(Matrix rhsVectors) Solves a series of linear systems L * L^T * x = b (or L * D * L^T * x = b), where L is the lower triangular factor (and D the diagonal factor) of the Cholesky factorization: A = L * L^T (or A = L * D * L^T).

Static Methods

Type Name Summary
CholeskySuiteSparse Factorize(Int32 order, Int32 numNonZerosUpper, Double[] cscValues, Int32[] cscRowIndices, Int32[] cscColOffsets, Boolean superNodal) Performs the Cholesky factorization: A = L * L^T or A = L * D * L^T of a symmetric positive definite matrix A. Only the upper triangle of the original matrix is required and is provided in symmetric CSC format by , and ``. The user may choose between supernodal or simplicial factorization. It is also possible to automatically reorder the matrix, using the algorithms provided by SuiteSparse. The factorized data, which may be sufficiently larger than the original matrix due to fill-in, will be written to unmanaged memory.
CholeskySuiteSparse Factorize(SymmetricCscMatrix matrix, Boolean superNodal) Performs the Cholesky factorization: A = L * L^T or A = L * D * L^T of a symmetric positive definite matrix A. Only the upper triangle of the original matrix is required and is provided in symmetric CSC format by , and ``. The user may choose between supernodal or simplicial factorization. It is also possible to automatically reorder the matrix, using the algorithms provided by SuiteSparse. The factorized data, which may be sufficiently larger than the original matrix due to fill-in, will be written to unmanaged memory.

ITriangulation

Represents the factorization of a square matrix into triangular and possible diagonal matrices. Such factorizations are used to solve linear systems. Authors: Serafeim Bakalakos

public interface MGroup.LinearAlgebra.Factorizations.ITriangulation

Methods

Type Name Summary
Double CalcDeterminant() Calculates the determinant of the original matrix (before the factorization).
void SolveLinearSystem(Vector rhs, Vector solution) Solves the linear system A * x = b, where A is the original matrix (before the factorization), b = and x is the solution vector, which will overwrite the provided .

LQFactorization

LQ factorization of a matrix A: A = L * Q, where A is an m-by-n matrix with m <= n, L is an m-by-n lower trapezoidal matrix and Q is an n-by-n orthogonal matrix. Note that this is equivalent to taking the QR factorization of A^T: A^T = Qo * Ro => A = Ro^T * Qo^T => L = Ro^T and Q = Qo^T. Uses LAPACK. For more see: https://software.intel.com/en-us/mkl-developer-reference-c-orthogonal-factorizations-lapack-computational-routines#E832D468-0891-40EC-9468- Authors: Serafeim Bakalakos

public class MGroup.LinearAlgebra.Factorizations.LQFactorization

Properties

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

Methods

Type Name Summary
Matrix GetFactorL() Explicitly creates the lower trapezoidal matrix L that resulted from the factorization: A = L * Q, where A is m-by-n, L is m-by-n and Q is n-by-n. This method is safe to use as the factorization data are copied (if necessary). However, it is inefficient if the generated matrix is only used once.
Matrix GetFactorQ() Explicitly creates the orthogonal matrix Q that resulted from the factorization: A = L * Q, where A is m-by-n, L is m-by-n and Q is n-by-n. This method is safe to use as the factorization data are copied (if necessary). However, it is inefficient if the generated matrix is only used once.
Vector SolveMinNorm(Vector rhsVector) Solve the minimum norm problem A * x = b => transpose(Q) * inv(L) * b. The minimum nrom problem is defined as: from the infinite solutions of A * x = b, find the one with the minimum norm2(x). Warning: the rows of the original matrix must be independent for this to work: If A (m-by-n, with m <= n) has full row rank, r = m => the column space of A is an m dimensional subspace of R^m (every vector Az is m-by-1) => the column space of A is the whole R^m and Ax=b, always has at least one solution. The nullspace of A is an (n-m) dimensional subspace of R^n. Thus there are infinite solutions to A*x=b.

Static Methods

Type Name Summary
LQFactorization Factorize(Int32 numRows, Int32 numCols, Double[] matrix) Calculates the LQ factorization of a matrix, such that A = L * Q. Requires an extra min(, ) available memory.

LUFactorization

The LU factorization of a matrix A with partial pivoting (row exchanges) consists of a lower triangular matrix L (with 1 in its diagonal entries), an upper triangular matrix U and a permutation matrix P, such that A = PLU. This class stores L,U,P in an efficient manner and provides common methods to use them. A must be square. Uses LAPACK. Authors: Serafeim Bakalakos

public class MGroup.LinearAlgebra.Factorizations.LUFactorization
    : ITriangulation

Properties

Type Name Summary
Boolean IsOverwritten If true, the internal data of this object are overwritten and used by another object. No property or method of this object must be called as it would throw exceptions or lead to data corruption. If false, this object can be used normally.
Boolean IsSingular If true, the original matrix before the factorization is not invertible. In this case, and MGroup.LinearAlgebra.Factorizations.LUFactorization.Invert(System.Boolean) will throw an exception. If false, the original matrix is invertible and those methods are safe to call.
Int32 Order The number of rows/columns of the original square matrix.

Methods

Type Name Summary
Double CalcDeterminant() See MGroup.LinearAlgebra.Factorizations.ITriangulation.CalcDeterminant.
Matrix GetFactorL() Explicitly creates the lower triangular matrix L that resulted from the LU factorization: A = P * L * U, where A, L, U and P are n-by-n. This method is safe to use as the factorization data are copied (if necessary). However, it is inefficient if the generated matrix is only used once.
Matrix GetFactorU() Explicitly creates the upper triangular matrix U that resulted from the LU factorization: A = P * L * U, where A, L, U and P are n-by-n. This method is safe to use as the factorization data are copied (if necessary). However, it is inefficient if the generated matrix is only used once.
Matrix Invert(Boolean inPlace) Calculates the inverse of the original square matrix and returns it in a new MGroup.LinearAlgebra.Matrices.Matrix instance. This only works if the original matrix is not singular, which can be checked through MGroup.LinearAlgebra.Factorizations.LUFactorization.IsSingular. WARNING: If `` is set to true, this object must not be used again, otherwise a System.InvalidOperationException will be thrown.
void SolveLinearSystem(Vector rhs, Vector solution) See MGroup.LinearAlgebra.Factorizations.ITriangulation.SolveLinearSystem(MGroup.LinearAlgebra.Vectors.Vector,MGroup.LinearAlgebra.Vectors.Vector).

Static Methods

Type Name Summary
LUFactorization Factorize(Int32 order, Double[] matrix, Double pivotTolerance = 1E-13) Calculates the LUP factorization of a square matrix, such that A = P * L * U. Requires an extra O(n) available memory, where n is the ``.

QRFactorization

QR factorization of a matrix A: A = Q * R, where A is an m-by-n matrix with m >= n, Q is an m-by-m orthogonal matrix and R is an m-by-n upper trapezoidal matrix. Uses LAPACK. For more see: https://software.intel.com/en-us/mkl-developer-reference-c-orthogonal-factorizations-lapack-computational-routines#E832D468-0891-40EC-9468- , http://www.netlib.org/lapack/explore-html/dd/d9a/group__double_g_ecomputational_ga3766ea903391b5cf9008132f7440ec7b.html#ga3766ea903391b5cf9008132f7440ec7b. Authors: Serafeim Bakalakos

public class MGroup.LinearAlgebra.Factorizations.QRFactorization

Properties

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

Methods

Type Name Summary
Matrix GetEconomyFactorQ() Explicitly creates the matrix Q1, which consists of the first n columns of the orthogonal matrix Q that resulted from the factorization: A = Q * R = [Q1, Q2] * [R1; 0] (Matlab notation) = Q1 * R1, where A is m-by-n, Q is m-by-m, R is m-by-n, Q1 is m-by-n and R1 is (n-by-n). This method is safe to use as the factorization data are copied (if necessary). However, it is inefficient if the generated matrix is only used once.
TriangularUpper GetEconomyFactorR() Explicitly creates the upper triangular matrix R1, which consists of the first n rows of the matrix R that resulted from the factorization: A = Q * R = [Q1, Q2] * [R1; 0] (Matlab notation) = Q1 * R1, where A is m-by-n, Q is m-by-m, R is m-by-n, Q1 is m-by-n and R1 is (n-by-n). This method is safe to use as the factorization data are copied (if necessary). However, it is inefficient if the generated matrix is only used once.
Matrix GetFactorQ() Explicitly creates the orthogonal matrix Q that resulted from the factorization: A = Q * R, where A is m-by-n, Q is m-by-m and R is m-by-n. This method is safe to use as the factorization data are copied (if necessary). However, it is inefficient if the generated matrix is only used once.
Matrix GetFactorR() Explicitly creates the upper trapezoidal matrix R that resulted from the factorization: A = Q * R, where A is m-by-n, Q is m-by-m and R is m-by-n. This method is safe to use as the factorization data are copied (if necessary). However, it is inefficient if the generated matrix is only used once.
Vector SolveLeastSquares(Vector rhsVector) Solve the linear least squares problem A * x = b => x = inv(R) * transpose(Q) * b. Warning: the columns of the original matrix A must be independent for this to work.

Static Methods

Type Name Summary
QRFactorization Factorize(Int32 numRows, Int32 numCols, Double[] matrix) Calculates the QR factorization of a matrix, such that A = Q * R. Requires an extra min(, ) available memory.

TriangulationExtensions

public static class MGroup.LinearAlgebra.Factorizations.TriangulationExtensions

Static Methods

Type Name Summary
Vector SolveLinearSystem(this ITriangulation triangulation, Vector rhsVector)

Clone this wiki locally