- java.lang.Object
-
- org.ojalgo.matrix.decomposition.AbstractDecomposition<java.lang.Double,R064Store>
-
- org.ojalgo.matrix.decomposition.SparseLU
-
- All Implemented Interfaces:
LDU<java.lang.Double>,LU<java.lang.Double>,MatrixDecomposition<java.lang.Double>,MatrixDecomposition.Determinant<java.lang.Double>,MatrixDecomposition.Ordered<java.lang.Double>,MatrixDecomposition.Pivoting<java.lang.Double>,MatrixDecomposition.RankRevealing<java.lang.Double>,MatrixDecomposition.Solver<java.lang.Double>,MatrixDecomposition.Updatable<java.lang.Double>,Provider2D,Provider2D.Determinant<java.lang.Double>,Provider2D.Inverse<java.util.Optional<MatrixStore<java.lang.Double>>>,Provider2D.Rank,Provider2D.Solution<java.util.Optional<MatrixStore<java.lang.Double>>>,DeterminantTask<java.lang.Double>,InverterTask<java.lang.Double>,MatrixTask<java.lang.Double>,SolverTask<java.lang.Double>,InvertibleFactor<java.lang.Double>,Structure1D,Structure2D
final class SparseLU extends AbstractDecomposition<java.lang.Double,R064Store> implements LU<java.lang.Double>
A sparse, primitive double based, LU decomposition with support for incremental Forrest-Tomlin updates.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classSparseLU.PermutationEta-
Nested classes/interfaces inherited from interface org.ojalgo.matrix.transformation.InvertibleFactor
InvertibleFactor.IdentityFactor<N extends java.lang.Comparable<N>>
-
Nested classes/interfaces inherited from interface org.ojalgo.matrix.decomposition.LU
LU.Factory<N extends java.lang.Comparable<N>>
-
Nested classes/interfaces inherited from interface org.ojalgo.matrix.decomposition.MatrixDecomposition
MatrixDecomposition.Determinant<N extends java.lang.Comparable<N>>, MatrixDecomposition.EconomySize<N extends java.lang.Comparable<N>>, MatrixDecomposition.Factory<D extends MatrixDecomposition<?>>, MatrixDecomposition.Hermitian<N extends java.lang.Comparable<N>>, MatrixDecomposition.Ordered<N extends java.lang.Comparable<N>>, MatrixDecomposition.Pivoting<N extends java.lang.Comparable<N>>, MatrixDecomposition.RankRevealing<N extends java.lang.Comparable<N>>, MatrixDecomposition.Solver<N extends java.lang.Comparable<N>>, MatrixDecomposition.Updatable<N extends java.lang.Comparable<N>>, MatrixDecomposition.Values<N extends java.lang.Comparable<N>>
-
Nested classes/interfaces inherited from interface org.ojalgo.matrix.Provider2D
Provider2D.Condition, Provider2D.Determinant<N extends java.lang.Comparable<N>>, Provider2D.Eigenpairs, Provider2D.Hermitian, Provider2D.Inverse<M>, Provider2D.Rank, Provider2D.Solution<M>, Provider2D.Symmetric, Provider2D.Trace<N extends java.lang.Comparable<N>>
-
Nested classes/interfaces inherited from interface org.ojalgo.structure.Structure1D
Structure1D.BasicMapper<T>, Structure1D.IndexMapper<T>, Structure1D.IntIndex, Structure1D.LongIndex, Structure1D.LoopCallback
-
Nested classes/interfaces inherited from interface org.ojalgo.structure.Structure2D
Structure2D.IntRowColumn, Structure2D.Logical<S extends Structure2D,B extends Structure2D.Logical<S,B>>, Structure2D.LongRowColumn, Structure2D.ReducibleTo1D<R extends Structure1D>, Structure2D.Reshapable, Structure2D.RowColumnKey<R,C>, Structure2D.RowColumnMapper<R,C>
-
-
Field Summary
Fields Modifier and Type Field Description private PivotmyColPivotprivate double[]myDiagUU diagonal elementsprivate java.util.List<InvertibleFactor<java.lang.Double>>myFactorsprivate RowsSupplier<java.lang.Double>myLprivate PivotmyPivotprivate RowsSupplier<java.lang.Double>myUprivate R064StoremyWorkerColumnprivate R064StoremyWorkerRow-
Fields inherited from interface org.ojalgo.matrix.decomposition.MatrixDecomposition
TYPICAL
-
-
Constructor Summary
Constructors Constructor Description SparseLU()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbtran(double[] arg)voidbtran(PhysicalStore<java.lang.Double> arg)Backwards-transformationprivate voidbtranL(int r, PhysicalStore<java.lang.Double> arg)private voidbtranU(int r, PhysicalStore<java.lang.Double> arg)java.lang.DoublecalculateDeterminant(Access2D<?> matrix)private static Access2D.Sliceable<java.lang.Double>cast(Access2D.Collectable<java.lang.Double,? super TransformableRegion<java.lang.Double>> matrix)protected booleancheckSolvability()intcountSignificant(double threshold)booleandecompose(Access2D.Collectable<java.lang.Double,? super TransformableRegion<java.lang.Double>> matrix)voidftran(double[] arg)voidftran(PhysicalStore<java.lang.Double> arg)Forward-transformationprivate voidftranInternal(PhysicalStore<java.lang.Double> arg)private voidftranL(int r, PhysicalStore<java.lang.Double> arg)private voidftranU(PhysicalStore<java.lang.Double> arg, int r)intgetColDim()java.lang.DoublegetDeterminant()A matrix' determinant is the product of its eigenvalues.MatrixStore<java.lang.Double>getInverse(PhysicalStore<java.lang.Double> preallocated)Implementing this method is optional.MatrixStore<java.lang.Double>getL()int[]getPivotOrder()doublegetRankThreshold()int[]getReversePivotOrder()intgetRowDim()MatrixStore<java.lang.Double>getSolution(Access2D.Collectable<java.lang.Double,? super PhysicalStore<java.lang.Double>> rhs, PhysicalStore<java.lang.Double> preallocated)Implementing this method is optional.MatrixStore<java.lang.Double>getU()IfupdateColumn(int, Access1D.Collectable)or#updateColumn(int, Access1D.Collectable, PhysicalStore)has been invoked, then this is no longer guaranteed to be triangular.(package private) R064StoregetWorkerColumn(int nbRows)(package private) R064StoregetWorkerRow(int nbCols)MatrixStore<java.lang.Double>invert(Access2D<?> original, PhysicalStore<java.lang.Double> preallocated)Exactly how (if at all) a specific implementation makes use ofpreallocatedis not specified by this interface.booleanisPivoted()booleanisSolvable()Please 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.PhysicalStore<java.lang.Double>preallocate(int nbEquations, int nbVariables, int nbSolutions)(package private) voidreset(Structure2D matrix)MatrixStore<java.lang.Double>solve(Access2D<?> body, Access2D<?> rhs, PhysicalStore<java.lang.Double> preallocated)Exactly how (if at all) a specific implementation makes use ofpreallocatedis not specified by this interface.booleanupdateColumn(int specifiedColumn, Access1D.Collectable<java.lang.Double,? super TransformableRegion<java.lang.Double>> newColumn)The Forrest-Tomlin update algorithm-
Methods inherited from class org.ojalgo.matrix.decomposition.AbstractDecomposition
aggregator, applyPivotOrder, applyReverseOrder, collect, computed, copyColumn, copyRow, function, getDimensionalEpsilon, isAspectRatioNormal, isComputed, makeArray, makeDiagonal, makeEye, makeHouseholder, makeIdentity, makeRotation, makeRotation, makeZero, makeZero, reset, scalar, wrap
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.ojalgo.matrix.task.InverterTask
invert, preallocate
-
Methods inherited from interface org.ojalgo.matrix.decomposition.LU
getSolution, reconstruct
-
Methods inherited from interface org.ojalgo.matrix.decomposition.MatrixDecomposition
isComputed, reset
-
Methods inherited from interface org.ojalgo.matrix.decomposition.MatrixDecomposition.Determinant
toDeterminantProvider
-
Methods inherited from interface org.ojalgo.matrix.decomposition.MatrixDecomposition.Pivoting
decomposeWithoutPivoting
-
Methods inherited from interface org.ojalgo.matrix.decomposition.MatrixDecomposition.RankRevealing
getRank, isFullRank
-
Methods inherited from interface org.ojalgo.matrix.decomposition.MatrixDecomposition.Solver
compute, getInverse, invert, preallocate, solve, toInverseProvider, toSolutionProvider
-
Methods inherited from interface org.ojalgo.matrix.task.SolverTask
preallocate, solve
-
Methods inherited from interface org.ojalgo.structure.Structure2D
count, countColumns, countRows, firstInColumn, firstInRow, getMaxDim, getMinDim, isEmpty, isFat, isScalar, isSquare, isTall, isVector, limitOfColumn, limitOfRow, size
-
-
-
-
Field Detail
-
myColPivot
private Pivot myColPivot
-
myDiagU
private double[] myDiagU
U diagonal elements
-
myFactors
private final java.util.List<InvertibleFactor<java.lang.Double>> myFactors
-
myL
private RowsSupplier<java.lang.Double> myL
-
myPivot
private final Pivot myPivot
-
myU
private RowsSupplier<java.lang.Double> myU
-
myWorkerColumn
private transient R064Store myWorkerColumn
-
myWorkerRow
private transient R064Store myWorkerRow
-
-
Method Detail
-
cast
private static Access2D.Sliceable<java.lang.Double> cast(Access2D.Collectable<java.lang.Double,? super TransformableRegion<java.lang.Double>> matrix)
-
btran
public void btran(double[] arg)
- Specified by:
btranin interfaceInvertibleFactor<java.lang.Double>- See Also:
InvertibleFactor.IdentityFactor.btran(PhysicalStore)
-
btran
public void btran(PhysicalStore<java.lang.Double> arg)
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<java.lang.Double>- Parameters:
arg- [b] transformed into [x]
-
calculateDeterminant
public java.lang.Double calculateDeterminant(Access2D<?> matrix)
- Specified by:
calculateDeterminantin interfaceDeterminantTask<java.lang.Double>
-
countSignificant
public int countSignificant(double threshold)
- Specified by:
countSignificantin interfaceMatrixDecomposition.RankRevealing<java.lang.Double>- Parameters:
threshold- Significance limit- Returns:
- The number of elements in the diagonal matrix that are greater than the threshold
-
decompose
public boolean decompose(Access2D.Collectable<java.lang.Double,? super TransformableRegion<java.lang.Double>> matrix)
- Specified by:
decomposein interfaceMatrixDecomposition<java.lang.Double>- Parameters:
matrix- A matrix to decompose- Returns:
- true if decomposition suceeded; false if not
-
ftran
public void ftran(double[] arg)
- Specified by:
ftranin interfaceInvertibleFactor<java.lang.Double>- See Also:
InvertibleFactor.IdentityFactor.ftran(PhysicalStore)
-
ftran
public void ftran(PhysicalStore<java.lang.Double> arg)
Description copied from interface:InvertibleFactorForward-transformationSolve [A][x] = [b] by transforming [b] into [x] in-place.
- Specified by:
ftranin interfaceInvertibleFactor<java.lang.Double>- Parameters:
arg- [b] transformed into [x]
-
getColDim
public int getColDim()
- Specified by:
getColDimin interfaceStructure2D- Returns:
- The number of columns
-
getDeterminant
public java.lang.Double getDeterminant()
Description copied from interface:MatrixDecomposition.DeterminantA matrix' determinant is the product of its eigenvalues.
- Specified by:
getDeterminantin interfaceMatrixDecomposition.Determinant<java.lang.Double>- Specified by:
getDeterminantin interfaceProvider2D.Determinant<java.lang.Double>- Returns:
- The matrix' determinant
-
getInverse
public MatrixStore<java.lang.Double> getInverse(PhysicalStore<java.lang.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.getInverse().- Specified by:
getInversein interfaceMatrixDecomposition.Solver<java.lang.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
public MatrixStore<java.lang.Double> getL()
-
getPivotOrder
public int[] getPivotOrder()
- Specified by:
getPivotOrderin interfaceMatrixDecomposition.Pivoting<java.lang.Double>- Returns:
- The pivot (row and/or columnn) order
-
getRankThreshold
public double getRankThreshold()
- Specified by:
getRankThresholdin interfaceMatrixDecomposition.RankRevealing<java.lang.Double>
-
getReversePivotOrder
public int[] getReversePivotOrder()
- Specified by:
getReversePivotOrderin interfaceMatrixDecomposition.Pivoting<java.lang.Double>
-
getRowDim
public int getRowDim()
- Specified by:
getRowDimin interfaceStructure2D- Returns:
- The number of rows
-
getSolution
public MatrixStore<java.lang.Double> getSolution(Access2D.Collectable<java.lang.Double,? super PhysicalStore<java.lang.Double>> rhs, PhysicalStore<java.lang.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<java.lang.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
public MatrixStore<java.lang.Double> getU()
IfupdateColumn(int, Access1D.Collectable)or#updateColumn(int, Access1D.Collectable, PhysicalStore)has been invoked, then this is no longer guaranteed to be triangular.- Specified by:
getUin interfaceLU<java.lang.Double>- See Also:
MatrixDecomposition.Pivoting.getPivotOrder(),LU.getL()
-
invert
public MatrixStore<java.lang.Double> invert(Access2D<?> original, PhysicalStore<java.lang.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<java.lang.Double>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<java.lang.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<java.lang.Double>- Overrides:
isSolvablein classAbstractDecomposition<java.lang.Double,R064Store>- 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
public PhysicalStore<java.lang.Double> preallocate(int nbEquations, int nbVariables, int nbSolutions)
- Specified by:
preallocatein interfaceSolverTask<java.lang.Double>
-
solve
public MatrixStore<java.lang.Double> solve(Access2D<?> body, Access2D<?> rhs, PhysicalStore<java.lang.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<java.lang.Double>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<java.lang.Double,? super TransformableRegion<java.lang.Double>> newColumn)The Forrest-Tomlin update algorithm- Specified by:
updateColumnin interfaceMatrixDecomposition.Updatable<java.lang.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.
-
btranL
private void btranL(int r, PhysicalStore<java.lang.Double> arg)
-
btranU
private void btranU(int r, PhysicalStore<java.lang.Double> arg)
-
ftranInternal
private void ftranInternal(PhysicalStore<java.lang.Double> arg)
-
ftranL
private void ftranL(int r, PhysicalStore<java.lang.Double> arg)
-
ftranU
private void ftranU(PhysicalStore<java.lang.Double> arg, int r)
-
checkSolvability
protected boolean checkSolvability()
- Overrides:
checkSolvabilityin classAbstractDecomposition<java.lang.Double,R064Store>
-
getWorkerColumn
R064Store getWorkerColumn(int nbRows)
-
getWorkerRow
R064Store getWorkerRow(int nbCols)
-
reset
void reset(Structure2D matrix)
-
-