Class SparseLU
- All Implemented Interfaces:
LDU<Double>, LU<Double>, MatrixDecomposition<Double>, MatrixDecomposition.Determinant<Double>, MatrixDecomposition.Ordered<Double>, MatrixDecomposition.Pivoting<Double>, MatrixDecomposition.RankRevealing<Double>, MatrixDecomposition.Solver<Double>, MatrixDecomposition.Updatable<Double>, Provider2D, Provider2D.Determinant<Double>, Provider2D.Inverse<Optional<MatrixStore<Double>>>, Provider2D.Rank, Provider2D.Solution<Optional<MatrixStore<Double>>>, DeterminantTask<Double>, InverterTask<Double>, MatrixTask<Double>, SolverTask<Double>, InvertibleFactor<Double>, Structure1D, Structure2D
-
Nested Class Summary
Nested classes/interfaces inherited from interface InvertibleFactor
InvertibleFactor.IdentityFactor<N>Nested classes/interfaces inherited from interface LU
LU.Factory<N>Nested classes/interfaces inherited from interface MatrixDecomposition
MatrixDecomposition.Determinant<N>, MatrixDecomposition.EconomySize<N>, MatrixDecomposition.Factor<N>, MatrixDecomposition.Factory<D>, MatrixDecomposition.Hermitian<N>, MatrixDecomposition.Ordered<N>, MatrixDecomposition.Pivoting<N>, MatrixDecomposition.RankRevealing<N>, MatrixDecomposition.Solver<N>, MatrixDecomposition.Updatable<N>, MatrixDecomposition.Values<N>Nested classes/interfaces inherited from interface Provider2D
Provider2D.Condition, Provider2D.Determinant<N>, Provider2D.Eigenpairs, Provider2D.Hermitian, Provider2D.Inverse<M>, Provider2D.Rank, Provider2D.Solution<M>, Provider2D.Symmetric, Provider2D.Trace<N>Nested classes/interfaces inherited from interface Structure1D
Structure1D.BasicMapper<T>, Structure1D.IndexMapper<T>, Structure1D.IntIndex, Structure1D.LongIndex, Structure1D.LoopCallback, Structure1D.SparseNested classes/interfaces inherited from interface Structure2D
Structure2D.IntRowColumn, Structure2D.Logical<S,B>, Structure2D.LongRowColumn, Structure2D.ReducibleTo1D<R>, Structure2D.Reshapable, Structure2D.RowColumnKey<R, C>, Structure2D.RowColumnMapper<R, C> -
Field Summary
Fields inherited from interface MatrixDecomposition
TYPICAL -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbtran(double[] arg) voidbtran(PhysicalStore<Double> arg) Backwards-transformationcalculateDeterminant(Access2D<?> matrix) protected booleanintTotal nonzeros across all eta factors accumulated since the last factorisation.intTotal nonzeros in the L and U factors at the time of the last full factorisation (excluding the U diagonal which is always dense).intcountSignificant(double threshold) booleandecompose(Access2D.Collectable<Double, ? super TransformableRegion<Double>> matrix) booleanFactorises the basis formed by selecting columns from a CSC matrix.voidftran(double[] arg) voidftran(PhysicalStore<Double> arg) Forward-transformationintA matrix' determinant is the product of its eigenvalues.doublegetMaxPivotMagnitude()as snapshotted at the moment of the last factorisation.doublegetMinPivotMagnitude()as snapshotted at the moment of the last factorisation.[A]=[P][L][U][etas...]getInverse(PhysicalStore<Double> preallocated) Implementing this method is optional.getL()doubleLargest pivot magnitude observed across the U diagonal — both the initial entries from factorisation and the new diagonals produced by FT updates since.doubleSmallest pivot magnitude observed across the U diagonal — both the initial entries from factorisation and the new diagonals produced by FT updates since.int[]doubleint[]intgetSolution(Access2D.Collectable<Double, ? super PhysicalStore<Double>> rhs, PhysicalStore<Double> preallocated) Implementing this method is optional.getU()IfupdateColumn(int, Access1D.Collectable)orhas been invoked, then this is no longer guaranteed to be triangular.invalid reference
#updateColumn(int, Access1D.Collectable, PhysicalStore)invert(Access2D<?> original, PhysicalStore<Double> preallocated) Exactly how (if at all) a specific implementation makes use ofpreallocatedis not specified by this interface.final booleanbooleanbooleanPlease note that producing a pseudoinverse and/or a least squares solution is ok!preallocate(int nbEquations, int nbVariables, int nbSolutions) voidreset()Delete computed results, and resets attributes to default valuessolve(Access2D<?> body, Access2D<?> rhs, PhysicalStore<Double> preallocated) Exactly how (if at all) a specific implementation makes use ofpreallocatedis not specified by this interface.booleanupdateColumn(int specifiedColumn, R064CSC matrix, int sourceColumn) Forrest-Tomlin update reading the new column directly from a CSC matrix.booleanupdateColumn(int specifiedColumn, Access1D.Collectable<Double, ? super TransformableRegion<Double>> newColumn) The Forrest-Tomlin update algorithmMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface InverterTask
invert, preallocateMethods inherited from interface LU
getSolution, reconstructMethods inherited from interface MatrixDecomposition
isComputed, resetMethods inherited from interface MatrixDecomposition.Determinant
toDeterminantProviderMethods inherited from interface MatrixDecomposition.Pivoting
decomposeWithoutPivotingMethods inherited from interface MatrixDecomposition.RankRevealing
getRank, isFullRankMethods inherited from interface MatrixDecomposition.Solver
compute, getInverse, invert, preallocate, solve, toInverseProvider, toSolutionProviderMethods inherited from interface SolverTask
preallocate, solveMethods inherited from interface Structure2D
count, countColumns, countRows, firstInColumn, firstInRow, getMaxDim, getMinDim, isEmpty, isFat, isScalar, isSquare, isTall, isVector, limitOfColumn, limitOfRow, size
-
Constructor Details
-
SparseLU
public SparseLU()
-
-
Method Details
-
btran
public void btran(double[] arg) - Specified by:
btranin interfaceInvertibleFactor<Double>- See Also:
-
btran
Description copied from interface:InvertibleFactorBackwards-transformationSolve [x]T[A] = [b]T (equivalent to [A]T[x] = [b]) by transforming [b] into [x] in-place.
- Specified by:
btranin interfaceInvertibleFactor<Double>- Parameters:
arg- [b] transformed into [x]
-
calculateDeterminant
- Specified by:
calculateDeterminantin interfaceDeterminantTask<Double>
-
countEtaNonzeros
public int countEtaNonzeros()Total nonzeros across all eta factors accumulated since the last factorisation. Each eta factor corresponds to one Forrest-Tomlin update (column replacement in the basis). -
countFactorNonzeros
public int countFactorNonzeros()Total nonzeros in the L and U factors at the time of the last full factorisation (excluding the U diagonal which is always dense). Returns 0 before the first factorisation. -
getMaxPivotMagnitude
public double getMaxPivotMagnitude()Largest pivot magnitude observed across the U diagonal — both the initial entries from factorisation and the new diagonals produced by FT updates since. -
getMinPivotMagnitude
public double getMinPivotMagnitude()Smallest pivot magnitude observed across the U diagonal — both the initial entries from factorisation and the new diagonals produced by FT updates since. -
getFactorMaxPivotMagnitude
public double getFactorMaxPivotMagnitude()getMaxPivotMagnitude()as snapshotted at the moment of the last factorisation. Captures the basis-only diagonal range, before any FT updates contributed. -
getFactorMinPivotMagnitude
public double getFactorMinPivotMagnitude()getMinPivotMagnitude()as snapshotted at the moment of the last factorisation. Captures the basis-only diagonal range, before any FT updates contributed. -
countSignificant
public int countSignificant(double threshold) - Specified by:
countSignificantin interfaceMatrixDecomposition.RankRevealing<Double>- Parameters:
threshold- Significance limit- Returns:
- The number of elements in the diagonal matrix that are greater than the threshold
-
decompose
- Specified by:
decomposein interfaceMatrixDecomposition<Double>- Parameters:
matrix- A matrix to decompose- Returns:
- true if decomposition suceeded; false if not
-
factor
Factorises the basis formed by selecting columns from a CSC matrix. This is the primary entry point for the revised simplex solver.- Parameters:
matrix- The full constraint matrix in CSC formatcolumns- The indices of the columns that form the basis
-
ftran
public void ftran(double[] arg) - Specified by:
ftranin interfaceInvertibleFactor<Double>- See Also:
-
ftran
Description copied from interface:InvertibleFactorForward-transformationSolve [A][x] = [b] by transforming [b] into [x] in-place.
- Specified by:
ftranin interfaceInvertibleFactor<Double>- Parameters:
arg- [b] transformed into [x]
-
getColDim
public int getColDim()- Specified by:
getColDimin interfaceStructure2D- Returns:
- The number of columns
-
getDeterminant
Description copied from interface:MatrixDecomposition.DeterminantA matrix' determinant is the product of its eigenvalues.
- Specified by:
getDeterminantin interfaceMatrixDecomposition.Determinant<Double>- Specified by:
getDeterminantin interfaceProvider2D.Determinant<Double>- Returns:
- The matrix' determinant
-
getFactors
[A]=[P][L][U][etas...][Q]- Specified by:
getFactorsin interfaceMatrixDecomposition.Solver<Double>
-
getInverse
Description copied from interface:MatrixDecomposition.SolverImplementing this method is optional.
Exactly how a specific implementation makes use of
preallocatedis not specified by this interface. It must be documented for each implementation.Should produce the same results as calling
MatrixDecomposition.Solver.getInverse().- Specified by:
getInversein interfaceMatrixDecomposition.Solver<Double>- Parameters:
preallocated- Preallocated memory for the results, possibly some intermediate results. You must assume this is modified, but you cannot assume it will contain the full/final/correct solution. UseMatrixDecomposition.Solver.preallocate(int, int)orInverterTask.preallocate(Structure2D)to get a suitable instance.- Returns:
- The inverse, this is where you get the solution
-
getL
-
getPivotOrder
public int[] getPivotOrder()- Specified by:
getPivotOrderin interfaceMatrixDecomposition.Pivoting<Double>- Returns:
- The pivot (row and/or columnn) order
-
getRankThreshold
public double getRankThreshold()- Specified by:
getRankThresholdin interfaceMatrixDecomposition.RankRevealing<Double>
-
getReversePivotOrder
public int[] getReversePivotOrder()- Specified by:
getReversePivotOrderin interfaceMatrixDecomposition.Pivoting<Double>
-
getRowDim
public int getRowDim()- Specified by:
getRowDimin interfaceStructure2D- Returns:
- The number of rows
-
getSolution
public MatrixStore<Double> getSolution(Access2D.Collectable<Double, ? super PhysicalStore<Double>> rhs, PhysicalStore<Double> preallocated) Description copied from interface:MatrixDecomposition.SolverImplementing this method is optional.
Exactly how a specific implementation makes use of
preallocatedis not specified by this interface. It must be documented for each implementation.Should produce the same results as calling
MatrixDecomposition.Solver.getSolution(Collectable).- Specified by:
getSolutionin interfaceMatrixDecomposition.Solver<Double>- Parameters:
rhs- The Right Hand Side, wont be modfiedpreallocated- Preallocated memory for the results, possibly some intermediate results. You must assume this is modified, but you cannot assume it will contain the full/final/correct solution. UseSolverTask.preallocate(int, int, int)orSolverTask.preallocate(Structure2D, Structure2D)to get a suitable instance.- Returns:
- The solution
-
getU
IfupdateColumn(int, Access1D.Collectable)orhas been invoked, then this is no longer guaranteed to be triangular.invalid reference
#updateColumn(int, Access1D.Collectable, PhysicalStore) -
invert
public MatrixStore<Double> invert(Access2D<?> original, PhysicalStore<Double> preallocated) throws RecoverableCondition Description copied from interface:InverterTaskExactly how (if at all) a specific implementation makes use of
preallocatedis not specified by this interface. It must be documented for each implementation.Should produce the same results as calling
InverterTask.invert(Access2D).Use
InverterTask.preallocate(Structure2D)to obtain a suitbalepreallocated.- Specified by:
invertin interfaceInverterTask<Double>- Parameters:
preallocated- Preallocated memory for the results, possibly some intermediate results. You must assume this is modified, but you cannot assume it will contain the full/final/correct solution.- Returns:
- The inverse
- Throws:
RecoverableCondition- TODO
-
isPivoted
public boolean isPivoted()- Specified by:
isPivotedin interfaceMatrixDecomposition.Pivoting<Double>- Returns:
- true if any pivoting was actually done
-
isSolvable
public boolean isSolvable()Description copied from interface:MatrixDecomposition.SolverPlease note that producing a pseudoinverse and/or a least squares solution is ok! The return value, of this method, is not an indication of if the decomposed matrix is square, has full rank, is postive definite or whatever. It's that in combination with the specific decomposition algorithm's capabilities.- Specified by:
isSolvablein interfaceMatrixDecomposition.Solver<Double>- Returns:
- true if this matrix decomposition is in a state to be able to deliver an inverse or an equation system solution (with some degree of numerical stability).
-
preallocate
- Specified by:
preallocatein interfaceSolverTask<Double>
-
solve
public MatrixStore<Double> solve(Access2D<?> body, Access2D<?> rhs, PhysicalStore<Double> preallocated) throws RecoverableCondition Description copied from interface:SolverTaskExactly how (if at all) a specific implementation makes use of
preallocatedis not specified by this interface. It must be documented for each implementation.Should produce the same results as calling
SolverTask.solve(Access2D, Access2D).Use
SolverTask.preallocate(Structure2D, Structure2D)to obtain a suitbalepreallocated.- Specified by:
solvein interfaceSolverTask<Double>- Parameters:
rhs- The Right Hand Side, wont be modfiedpreallocated- Preallocated memory for the results, possibly some intermediate results. You must assume this is modified, but you cannot assume it will contain the full/ /correct solution.- Returns:
- The solution
- Throws:
RecoverableCondition
-
updateColumn
public boolean updateColumn(int specifiedColumn, Access1D.Collectable<Double, ? super TransformableRegion<Double>> newColumn) The Forrest-Tomlin update algorithm- Specified by:
updateColumnin interfaceMatrixDecomposition.Updatable<Double>- Parameters:
specifiedColumn- The index of the column, in the original matrix, to replacenewColumn- The new column values- Returns:
- true if update was successful, false if not.
-
updateColumn
Forrest-Tomlin update reading the new column directly from a CSC matrix.- Parameters:
specifiedColumn- The basis position being replacedmatrix- The full constraint matrix in CSC formatsourceColumn- The column index in the CSC matrix to read- Returns:
- true if the update succeeded
-
checkSolvability
protected boolean checkSolvability() -
isComputed
public final boolean isComputed()- Specified by:
isComputedin interfaceMatrixDecomposition<N extends Comparable<N>>- Returns:
- true if decomposition has been attemped and was successful; false if not.
- See Also:
-
reset
public void reset()Description copied from interface:MatrixDecompositionDelete computed results, and resets attributes to default values- Specified by:
resetin interfaceMatrixDecomposition<N extends Comparable<N>>
-