Class DenseSingularValue<N extends Comparable<N>>
- All Implemented Interfaces:
MatrixDecomposition<N>, MatrixDecomposition.EconomySize<N>, MatrixDecomposition.Ordered<N>, MatrixDecomposition.RankRevealing<N>, MatrixDecomposition.Solver<N>, MatrixDecomposition.Values<N>, SingularValue<N>, Provider2D, Provider2D.Condition, Provider2D.Inverse<Optional<MatrixStore<N>>>, Provider2D.Rank, Provider2D.Solution<Optional<MatrixStore<N>>>, InverterTask<N>, MatrixTask<N>, SolverTask<N>, InvertibleFactor<N>, Structure1D, Structure2D
- Direct Known Subclasses:
DenseSingularValue.C128, DenseSingularValue.H256, DenseSingularValue.Q128, DenseSingularValue.R064, DenseSingularValue.R128
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final class(package private) static final class(package private) static final class(package private) static final class(package private) static final classNested classes/interfaces inherited from interface InvertibleFactor
InvertibleFactor.IdentityFactor<N>Nested classes/interfaces inherited from interface MatrixDecomposition
MatrixDecomposition.Determinant<N>, MatrixDecomposition.EconomySize<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 SingularValue
SingularValue.Factory<N>Nested classes/interfaces inherited from interface Structure1D
Structure1D.BasicMapper<T>, Structure1D.IndexMapper<T>, Structure1D.IntIndex, Structure1D.LongIndex, Structure1D.LoopCallbackNested 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
FieldsModifier and TypeFieldDescriptionprivate double[]private final DenseBidiagonal<N> private final booleanprivate final Structure2Dprivate MatrixStore<N> private MatrixStore<N> private booleanprivate MatrixStore<N> private MatrixStore<N> private booleanprivate double[]private static final double≈ 1.6E-291Fields inherited from interface MatrixDecomposition
TYPICAL -
Constructor Summary
ConstructorsConstructorDescriptionDenseSingularValue(PhysicalStore.Factory<N, ? extends DecompositionStore<N>> factory, DenseBidiagonal<N> bidiagonal, boolean fullSize) -
Method Summary
Modifier and TypeMethodDescriptionvoidbtran(double[] arg) final voidbtran(PhysicalStore<N> arg) Backwards-transformationprotected booleanprotected booleancompute(Access2D.Collectable<N, ? super TransformableRegion<N>> matrix, boolean valuesOnly, boolean fullSize) protected booleancomputeBidiagonal(Access2D.Collectable<N, ? super TransformableRegion<N>> matrix, boolean fullSize) booleancomputeValuesOnly(Access2D.Collectable<N, ? super TransformableRegion<N>> matrix) intcountSignificant(double threshold) booleandecompose(Access2D.Collectable<N, ? super TransformableRegion<N>> matrix) private static voiddoCase1(double[] s, double[] e, int p, int k, RotateRight q2RotR) private static voiddoCase2(double[] s, double[] e, int p, int k, RotateRight mtrxQ1) private static voiddoCase3(double[] s, double[] e, int p, int k, RotateRight q1RotR, RotateRight q2RotR) private static voiddoCase4(double[] s, int k, NegateColumn q2NegCol, ExchangeColumns q1XchgCols, ExchangeColumns q2XchgCols) protected booleandoCompute(Access2D.Collectable<N, ? super TransformableRegion<N>> matrix, boolean valuesOnly, boolean fullSize) voidftran(double[] arg) intdoubleThe condition number.getD()Deprecated.doubleSometimes also called the Schatten 2-norm or Hilbert-Schmidt norm.The output must be a "right inverse" and a "generalised inverse".getInverse(PhysicalStore<N> preallocated) Implementing this method is optional.private MatrixStore<N> getInverseOldVersion(DecompositionStore<N> preallocated) doublegetKyFanNorm(int k) Ky Fan k-norm.doubledoubleintgetS()getSolution(Access2D.Collectable<N, ? super PhysicalStore<N>> rhs, PhysicalStore<N> preallocated) Implementing this method is optional.doublegetU()If [A] is m-by-n and its rank is r, then: The first r columns of [U] span the column space, range or image of [A]. The last m-r columns of [U] span the left nullspace or cokernel of [A]. Calculating the QR decomposition of [A] is a faster alternative.getV()If [A] is m-by-n and its rank is r, then: The first r columns of [V] span the row space or coimage of [A]. The last n-r columns of [V] span the nullspace or kernel of [A]. Calculating the QR decomposition of [A]T is a faster alternative.The output must be a "right inverse" and a "generalised inverse".invert(Access2D<?> original, PhysicalStore<N> preallocated) Exactly how (if at all) a specific implementation makes use ofpreallocatedis not specified by this interface.booleanbooleanbooleanThis is a property of the algorithm/implementation, not the data.booleanPlease 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.protected booleanprotected MatrixStore<N> makeD()preallocate(int nbEquations, int nbVariables, int nbSolutions) voidreset()Delete computed results, and resets attributes to default values[A][X]=[B] or [body][return]=[rhs]solve(Access2D<?> body, Access2D<?> rhs, PhysicalStore<N> preallocated) Exactly how (if at all) a specific implementation makes use ofpreallocatedis not specified by this interface.(package private) static voidtoDiagonal(double[] s, double[] e, RotateRight q1RotR, RotateRight q2RotR, ExchangeColumns q1XchgCols, ExchangeColumns q2XchgCols, NegateColumn q2NegCol) Methods inherited from class AbstractDecomposition
aggregator, applyPivotOrder, applyReverseOrder, collect, computed, copyColumn, copyRow, function, getDimensionalEpsilon, isAspectRatioNormal, isComputed, makeArray, makeDiagonal, makeEye, makeHouseholder, makeIdentity, makeRotation, makeRotation, makeZero, makeZero, scalar, wrapMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface InverterTask
preallocateMethods inherited from interface MatrixDecomposition
isComputedMethods inherited from interface MatrixDecomposition.RankRevealing
getRankMethods inherited from interface MatrixDecomposition.Solver
compute, getSolution, invert, preallocate, solve, toInverseProvider, toSolutionProviderMethods inherited from interface SingularValue
ftran, getSingularValues, reconstruct, reconstructMethods inherited from interface SolverTask
preallocateMethods inherited from interface Structure2D
count, countColumns, countRows, firstInColumn, firstInRow, getMaxDim, getMinDim, isEmpty, isFat, isScalar, isSquare, isTall, isVector, limitOfColumn, limitOfRow, size
-
Field Details
-
TINY
private static final double TINY≈ 1.6E-291 -
e
private double[] e -
myBidiagonal
-
myFullSize
private final boolean myFullSize -
myInputStructure
-
myInverse
-
myS
-
mySingularValues
-
myTransposed
private boolean myTransposed -
myU
-
myV
-
myValuesOnly
private boolean myValuesOnly -
s
private double[] s
-
-
Constructor Details
-
DenseSingularValue
DenseSingularValue(PhysicalStore.Factory<N, ? extends DecompositionStore<N>> factory, DenseBidiagonal<N> bidiagonal, boolean fullSize)
-
-
Method Details
-
doCase1
-
doCase2
-
doCase3
private static void doCase3(double[] s, double[] e, int p, int k, RotateRight q1RotR, RotateRight q2RotR) -
doCase4
private static void doCase4(double[] s, int k, NegateColumn q2NegCol, ExchangeColumns q1XchgCols, ExchangeColumns q2XchgCols) -
toDiagonal
static void toDiagonal(double[] s, double[] e, RotateRight q1RotR, RotateRight q2RotR, ExchangeColumns q1XchgCols, ExchangeColumns q2XchgCols, NegateColumn q2NegCol) -
btran
public void btran(double[] arg) - Specified by:
btranin interfaceInvertibleFactor<N extends Comparable<N>>- 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<N extends Comparable<N>>- Parameters:
arg- [b] transformed into [x]
-
computeValuesOnly
- Specified by:
computeValuesOnlyin interfaceMatrixDecomposition.Values<N extends Comparable<N>>- Parameters:
matrix- The matrix to decompose- Returns:
- The same as
MatrixDecomposition.Solver.compute(Collectable)orMatrixDecomposition.decompose(Collectable)if the instance does not implementMatrixDecomposition.Solver.
-
countSignificant
public int countSignificant(double threshold) - Specified by:
countSignificantin interfaceMatrixDecomposition.RankRevealing<N extends Comparable<N>>- Parameters:
threshold- Significance limit- Returns:
- The number of elements in the diagonal matrix that are greater than the threshold
-
decompose
- Specified by:
decomposein interfaceMatrixDecomposition<N extends Comparable<N>>- Parameters:
matrix- A matrix to decompose- Returns:
- true if decomposition suceeded; false if not
-
ftran
public void ftran(double[] arg) - Specified by:
ftranin interfaceInvertibleFactor<N extends Comparable<N>>- See Also:
-
getColDim
public int getColDim()- Specified by:
getColDimin interfaceStructure2D- Returns:
- The number of columns
-
getCondition
public double getCondition()Description copied from interface:SingularValueThe condition number.- Specified by:
getConditionin interfaceProvider2D.Condition- Specified by:
getConditionin interfaceSingularValue<N extends Comparable<N>>- Returns:
- The largest singular value divided by the smallest singular value.
-
getCovariance
- Specified by:
getCovariancein interfaceSingularValue<N extends Comparable<N>>- Returns:
- [[A]T[A]]-1 Where [A] is the original matrix.
-
getD
Deprecated.UsegetS()instead- Specified by:
getDin interfaceSingularValue<N extends Comparable<N>>- Returns:
- The diagonal matrix of singular values.
-
getFrobeniusNorm
public double getFrobeniusNorm()Description copied from interface:SingularValueSometimes also called the Schatten 2-norm or Hilbert-Schmidt norm.- Specified by:
getFrobeniusNormin interfaceSingularValue<N extends Comparable<N>>- Returns:
- The square root of the sum of squares of the singular values.
-
getInverse
Description copied from interface:MatrixDecomposition.SolverThe output must be a "right inverse" and a "generalised inverse".- Specified by:
getInversein interfaceMatrixDecomposition.Solver<N extends Comparable<N>>
-
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<N extends Comparable<N>>- 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
-
getKyFanNorm
public double getKyFanNorm(int k) Description copied from interface:SingularValueKy Fan k-norm.
The first Ky Fan k-norm is the operator norm (the largest singular value), and the last is called the trace norm (the sum of all singular values).
- Specified by:
getKyFanNormin interfaceSingularValue<N extends Comparable<N>>- Parameters:
k- The number of singular values to add up.- Returns:
- The sum of the k largest singular values.
-
getOperatorNorm
public double getOperatorNorm()- Specified by:
getOperatorNormin interfaceSingularValue<N extends Comparable<N>>- Returns:
- 2-norm
-
getRankThreshold
public double getRankThreshold()- Specified by:
getRankThresholdin interfaceMatrixDecomposition.RankRevealing<N extends Comparable<N>>
-
getRowDim
public int getRowDim()- Specified by:
getRowDimin interfaceStructure2D- Returns:
- The number of rows
-
getS
- Specified by:
getSin interfaceSingularValue<N extends Comparable<N>>- Returns:
- The diagonal matrix of singular values.
-
getSingularValues
- Specified by:
getSingularValuesin interfaceSingularValue<N extends Comparable<N>>- Returns:
- The singular values ordered in descending order.
-
getSolution
public MatrixStore<N> getSolution(Access2D.Collectable<N, ? super PhysicalStore<N>> rhs, PhysicalStore<N> 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<N extends Comparable<N>>- 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
-
getTraceNorm
public double getTraceNorm()- Specified by:
getTraceNormin interfaceSingularValue<N extends Comparable<N>>
-
getU
Description copied from interface:SingularValueIf [A] is m-by-n and its rank is r, then:- The first r columns of [U] span the column space, range or image of [A].
- The last m-r columns of [U] span the left nullspace or cokernel of [A].
- Specified by:
getUin interfaceSingularValue<N extends Comparable<N>>
-
getV
Description copied from interface:SingularValueIf [A] is m-by-n and its rank is r, then:- The first r columns of [V] span the row space or coimage of [A].
- The last n-r columns of [V] span the nullspace or kernel of [A].
- Specified by:
getVin interfaceSingularValue<N extends Comparable<N>>
-
invert
Description copied from interface:InverterTaskThe output must be a "right inverse" and a "generalised inverse".- Specified by:
invertin interfaceInverterTask<N extends Comparable<N>>- Throws:
RecoverableCondition
-
invert
public MatrixStore<N> invert(Access2D<?> original, PhysicalStore<N> 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<N extends Comparable<N>>- 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
-
isFullRank
public boolean isFullRank()- Specified by:
isFullRankin interfaceMatrixDecomposition.RankRevealing<N extends Comparable<N>>- Returns:
- true if the rank is equal to the minimum of the row and column dimensions; false if not
-
isFullSize
public boolean isFullSize()- Specified by:
isFullSizein interfaceMatrixDecomposition.EconomySize<N extends Comparable<N>>- Returns:
- True if it will generate a full sized decomposition.
-
isOrdered
public boolean isOrdered()Description copied from interface:MatrixDecomposition.OrderedThis is a property of the algorithm/implementation, not the data. Typically relevant forSingularValue,Eigenvalueor anyMatrixDecomposition.RankRevealingdecomposition.- Specified by:
isOrderedin interfaceMatrixDecomposition.Ordered<N extends Comparable<N>>- Returns:
- true if the rows/columns of the returned matrix factors are guaranteed some specific order; false if there is no such guarantee.
-
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<N extends Comparable<N>>- Overrides:
isSolvablein classAbstractDecomposition<N extends Comparable<N>, DecompositionStore<N extends Comparable<N>>>- 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<N extends Comparable<N>>
-
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>>- Overrides:
resetin classAbstractDecomposition<N extends Comparable<N>, DecompositionStore<N extends Comparable<N>>>
-
solve
Description copied from interface:SolverTask[A][X]=[B] or [body][return]=[rhs]- Specified by:
solvein interfaceSolverTask<N extends Comparable<N>>- Throws:
RecoverableCondition
-
solve
public MatrixStore<N> solve(Access2D<?> body, Access2D<?> rhs, PhysicalStore<N> 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<N extends Comparable<N>>- 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
-
getInverseOldVersion
-
checkSolvability
protected boolean checkSolvability()- Overrides:
checkSolvabilityin classAbstractDecomposition<N extends Comparable<N>, DecompositionStore<N extends Comparable<N>>>
-
compute
protected boolean compute(Access2D.Collectable<N, ? super TransformableRegion<N>> matrix, boolean valuesOnly, boolean fullSize) -
computeBidiagonal
protected boolean computeBidiagonal(Access2D.Collectable<N, ? super TransformableRegion<N>> matrix, boolean fullSize) -
doCompute
protected boolean doCompute(Access2D.Collectable<N, ? super TransformableRegion<N>> matrix, boolean valuesOnly, boolean fullSize) -
isTransposed
protected boolean isTransposed() -
makeD
-
makeSingularValues
-
getS()instead