Class HermitianEvD<N extends Comparable<N>>
- All Implemented Interfaces:
Eigenvalue<N>
,MatrixDecomposition<N>
,MatrixDecomposition.Determinant<N>
,MatrixDecomposition.Hermitian<N>
,MatrixDecomposition.Ordered<N>
,MatrixDecomposition.Solver<N>
,MatrixDecomposition.Values<N>
,Provider2D
,Provider2D.Determinant<N>
,Provider2D.Eigenpairs
,Provider2D.Inverse<Optional<MatrixStore<N>>>
,Provider2D.Solution<Optional<MatrixStore<N>>>
,DeterminantTask<N>
,InverterTask<N>
,MatrixTask<N>
,SolverTask<N>
,InvertibleFactor<N>
,Structure1D
,Structure2D
- Direct Known Subclasses:
HermitianEvD.C128
,HermitianEvD.H256
,HermitianEvD.Q128
,HermitianEvD.R064
,HermitianEvD.R128
If A is symmetric, then A = V*D*V' where the eigenvalue matrix D is diagonal and the eigenvector matrix V is orthogonal. I.e. A = V.times(D.times(V.transpose())) and V.times(V.transpose()) equals the identity matrix.
If A is not symmetric, then the eigenvalue matrix D is block diagonal with the real eigenvalues in 1-by-1 blocks and any complex eigenvalues, lambda + i*mu, in 2-by-2 blocks, [lambda, mu; -mu, lambda]. The columns of V represent the eigenvectors in the sense that A*V = V*D, i.e. A.times(V) equals V.times(D). The matrix V may be badly conditioned, or even singular, so the validity of the equation A = V*D*inverse(V) depends upon V.cond().
-
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 class
Nested classes/interfaces inherited from interface org.ojalgo.matrix.decomposition.Eigenvalue
Eigenvalue.Eigenpair, Eigenvalue.Factory<N extends Comparable<N>>, Eigenvalue.Generalisation, Eigenvalue.Generalised<N extends Comparable<N>>
Nested classes/interfaces inherited from interface org.ojalgo.matrix.task.InverterTask
InverterTask.Factory<N extends Comparable<N>>
Nested classes/interfaces inherited from interface org.ojalgo.matrix.transformation.InvertibleFactor
InvertibleFactor.IdentityFactor<N extends Comparable<N>>
Nested classes/interfaces inherited from interface org.ojalgo.matrix.decomposition.MatrixDecomposition
MatrixDecomposition.Determinant<N extends Comparable<N>>, MatrixDecomposition.EconomySize<N extends Comparable<N>>, MatrixDecomposition.Factory<D extends MatrixDecomposition<?>>, MatrixDecomposition.Hermitian<N extends Comparable<N>>, MatrixDecomposition.Ordered<N extends Comparable<N>>, MatrixDecomposition.Pivoting<N extends Comparable<N>>, MatrixDecomposition.RankRevealing<N extends Comparable<N>>, MatrixDecomposition.Solver<N extends Comparable<N>>, MatrixDecomposition.Values<N extends Comparable<N>>
Nested classes/interfaces inherited from interface org.ojalgo.matrix.Provider2D
Provider2D.Condition, Provider2D.Determinant<N extends Comparable<N>>, Provider2D.Eigenpairs, Provider2D.Hermitian, Provider2D.Inverse<M>, Provider2D.Rank, Provider2D.Solution<M>, Provider2D.Symmetric, Provider2D.Trace<N extends Comparable<N>>
Nested classes/interfaces inherited from interface org.ojalgo.matrix.task.SolverTask
SolverTask.Factory<N extends 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
FieldsModifier and TypeFieldDescriptionprivate double[]
private double[]
private MatrixStore
<N> private final TridiagonalDecomposition
<N> Fields inherited from interface org.ojalgo.matrix.decomposition.Eigenvalue
C128, DESCENDING_NORM, H256, Q128, R064, R128
Fields inherited from interface org.ojalgo.matrix.decomposition.MatrixDecomposition
TYPICAL
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
HermitianEvD
(PhysicalStore.Factory<N, ? extends DecompositionStore<N>> factory) protected
HermitianEvD
(PhysicalStore.Factory<N, ? extends DecompositionStore<N>> factory, TridiagonalDecomposition<N> tridiagonal) -
Method Summary
Modifier and TypeMethodDescriptionfinal void
btran
(PhysicalStore<N> arg) Backwards-transformationboolean
checkAndDecompose
(MatrixStore<N> matrix) Absolutely must check if the matrix is hermitian or not.protected boolean
protected boolean
doDecompose
(Access2D.Collectable<N, ? super PhysicalStore<N>> matrix, boolean valuesOnly) A matrix' determinant is the product of its eigenvalues.void
getEigenvalues
(double[] realParts, Optional<double[]> imaginaryParts) The output must be a "right inverse" and a "generalised inverse".getInverse
(PhysicalStore<N> preallocated) Implementing this method is optional.getSolution
(Access2D.Collectable<N, ? super PhysicalStore<N>> rhs) [A][X]=[B] or [this][return]=[rhs]getSolution
(Access2D.Collectable<N, ? super PhysicalStore<N>> rhs, PhysicalStore<N> preallocated) Implementing this method is optional.getTrace()
A matrix' trace is the sum of the diagonal elements.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 ofpreallocated
is not specified by this interface.boolean
If [A] is hermitian then [V][D][V]-1 becomes [Q][D][Q]H...boolean
The eigenvalues in D (and the eigenvectors in V) are not necessarily ordered.boolean
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.protected MatrixStore
<N> makeD()
protected Array1D
<ComplexNumber> protected MatrixStore
<N> makeV()
preallocate
(Structure2D template) Will create a PhysicalStore instance suitable for use withInverterTask.invert(Access2D, PhysicalStore)
.preallocate
(Structure2D templateBody, Structure2D templateRHS) Will create a PhysicalStore instance suitable for use withSolverTask.solve(Access2D, Access2D, PhysicalStore)
.void
reset()
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 ofpreallocated
is not specified by this interface.(package private) static void
tql2
(double[] d, double[] e, RotateRight mtrxV) Methods inherited from class org.ojalgo.matrix.decomposition.EigenvalueDecomposition
calculateDeterminant, computeValuesOnly, decompose, getColDim, getD, getEigenvalues, getMaxDim, getMinDim, getRowDim, getV, setD, setEigenvalues, setV, sort
Methods inherited from class org.ojalgo.matrix.decomposition.GenericDecomposition
aggregator, allocate, collect, copy, function, makeArray, makeDiagonal, makeEye, makeHouseholder, makeIdentity, makeRotation, makeRotation, makeZero, makeZero, scalar, wrap
Methods inherited from class org.ojalgo.matrix.decomposition.AbstractDecomposition
computed, countColumns, countRows, getDimensionalEpsilon, isAspectRatioNormal, isComputed
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.decomposition.Eigenvalue
getEigenpair, getEigenpairs, getEigenvectors, reconstruct
Methods inherited from interface org.ojalgo.matrix.task.InverterTask
preallocate
Methods inherited from interface org.ojalgo.matrix.transformation.InvertibleFactor
btran
Methods inherited from interface org.ojalgo.matrix.decomposition.MatrixDecomposition
decompose, isComputed
Methods inherited from interface org.ojalgo.matrix.decomposition.MatrixDecomposition.Determinant
toDeterminantProvider
Methods inherited from interface org.ojalgo.matrix.decomposition.MatrixDecomposition.Solver
compute, ftran, ftran, invert, solve, toInverseProvider, toSolutionProvider
Methods inherited from interface org.ojalgo.matrix.task.SolverTask
preallocate
Methods inherited from interface org.ojalgo.structure.Structure2D
count, countColumns, countRows, firstInColumn, firstInRow, getColDim, getMaxDim, getMinDim, getRowDim, isEmpty, isFat, isScalar, isSquare, isTall, isVector, limitOfColumn, limitOfRow, size
-
Field Details
-
d
private double[] d -
e
private double[] e -
myInverse
-
myTridiagonal
-
-
Constructor Details
-
HermitianEvD
-
HermitianEvD
protected HermitianEvD(PhysicalStore.Factory<N, ? extends DecompositionStore<N>> factory, TridiagonalDecomposition<N> tridiagonal)
-
-
Method Details
-
tql2
-
btran
Description copied from interface:InvertibleFactor
Backwards-transformationSolve [x]T[A] = [b]T (equivalent to [A]T[x] = [b]) by transforming [b] into [x] in-place.
- Specified by:
btran
in interfaceInvertibleFactor<N extends Comparable<N>>
- Parameters:
arg
- [b] transformed into [x]
-
checkAndDecompose
Description copied from interface:MatrixDecomposition.Hermitian
Absolutely must check if the matrix is hermitian or not. Then, depending on the result different paths can be chosen - compute or not / choose different algorithms...- Specified by:
checkAndDecompose
in interfaceMatrixDecomposition.Hermitian<N extends Comparable<N>>
- Parameters:
matrix
- A matrix to check and then (maybe) decompose- Returns:
- true if the hermitian check passed and decomposition succeeded; false if not
-
getDeterminant
Description copied from interface:MatrixDecomposition.Determinant
A matrix' determinant is the product of its eigenvalues.
- Specified by:
getDeterminant
in interfaceMatrixDecomposition.Determinant<N extends Comparable<N>>
- Specified by:
getDeterminant
in interfaceProvider2D.Determinant<N extends Comparable<N>>
- Returns:
- The matrix' determinant
-
getEigenvalues
- Specified by:
getEigenvalues
in interfaceEigenvalue<N extends Comparable<N>>
- Parameters:
realParts
- An array that will receive the real parts of the eigenvaluesimaginaryParts
- An optional array that, if present, will receive the imaginary parts of the eigenvalues
-
getInverse
Description copied from interface:MatrixDecomposition.Solver
The output must be a "right inverse" and a "generalised inverse".- Specified by:
getInverse
in interfaceMatrixDecomposition.Solver<N extends Comparable<N>>
-
getInverse
Description copied from interface:MatrixDecomposition.Solver
Implementing this method is optional.
Exactly how a specific implementation makes use of
preallocated
is not specified by this interface. It must be documented for each implementation.Should produce the same results as calling
MatrixDecomposition.Solver.getInverse()
.- Specified by:
getInverse
in 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. UseInverterTask.preallocate(int, int)
orInverterTask.preallocate(Structure2D)
to get a suitable instance.- Returns:
- The inverse, this is where you get the solution
-
getSolution
Description copied from interface:MatrixDecomposition.Solver
[A][X]=[B] or [this][return]=[rhs]- Specified by:
getSolution
in interfaceMatrixDecomposition.Solver<N extends Comparable<N>>
-
getSolution
public MatrixStore<N> getSolution(Access2D.Collectable<N, ? super PhysicalStore<N>> rhs, PhysicalStore<N> preallocated) Description copied from interface:MatrixDecomposition.Solver
Implementing this method is optional.
Exactly how a specific implementation makes use of
preallocated
is 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:
getSolution
in 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
-
getTrace
Description copied from interface:Eigenvalue
A matrix' trace is the sum of the diagonal elements. It is also the sum of the eigenvalues. This method should return the sum of the eigenvalues.- Specified by:
getTrace
in interfaceEigenvalue<N extends Comparable<N>>
- Returns:
- The matrix' trace
-
invert
Description copied from interface:InverterTask
The output must be a "right inverse" and a "generalised inverse".- Specified by:
invert
in interfaceInverterTask<N extends Comparable<N>>
- Throws:
RecoverableCondition
-
invert
public MatrixStore<N> invert(Access2D<?> original, PhysicalStore<N> preallocated) throws RecoverableCondition Description copied from interface:InverterTask
Exactly how (if at all) a specific implementation makes use of
preallocated
is 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:
invert
in 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/ /correct solution.- Returns:
- The inverse
- Throws:
RecoverableCondition
- TODO
-
isHermitian
public boolean isHermitian()Description copied from interface:Eigenvalue
If [A] is hermitian then [V][D][V]-1 becomes [Q][D][Q]H...- Specified by:
isHermitian
in interfaceEigenvalue<N extends Comparable<N>>
-
isOrdered
public boolean isOrdered()Description copied from interface:Eigenvalue
The eigenvalues in D (and the eigenvectors in V) are not necessarily ordered. This is a property of the algorithm/implementation, not the data.- Specified by:
isOrdered
in interfaceEigenvalue<N extends Comparable<N>>
- Specified by:
isOrdered
in interfaceMatrixDecomposition.Ordered<N extends Comparable<N>>
- Returns:
- true if they are ordered
-
isSolvable
public boolean isSolvable()Description copied from interface:MatrixDecomposition.Solver
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. It's that in combination with the specific decomposition algorithm's capabilities.- Specified by:
isSolvable
in interfaceMatrixDecomposition.Solver<N extends Comparable<N>>
- Overrides:
isSolvable
in classAbstractDecomposition<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
Description copied from interface:InverterTask
Will create a PhysicalStore instance suitable for use with
InverterTask.invert(Access2D, PhysicalStore)
.When inverting a matrix (mxn) the preallocated memory/matrix will typically be nxm (and of course most of the time A is square).
- Specified by:
preallocate
in interfaceInverterTask<N extends Comparable<N>>
-
preallocate
Description copied from interface:SolverTask
Will create a PhysicalStore instance suitable for use with
SolverTask.solve(Access2D, Access2D, PhysicalStore)
. The dimensions of the returned instance is not specified by this interface - it is specified by the behaviour/requirements of each implementation.When solving an equation system [A][X]=[B] ([mxn][nxb]=[mxb]) the preallocated memory/matrix will typically be either mxb or nxb.
- Specified by:
preallocate
in interfaceSolverTask<N extends Comparable<N>>
-
reset
public void reset()Description copied from interface:MatrixDecomposition
Delete computed results, and resets attributes to default values- Specified by:
reset
in interfaceMatrixDecomposition<N extends Comparable<N>>
- Overrides:
reset
in classEigenvalueDecomposition<N extends Comparable<N>>
-
solve
Description copied from interface:SolverTask
[A][X]=[B] or [body][return]=[rhs]- Specified by:
solve
in 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:SolverTask
Exactly how (if at all) a specific implementation makes use of
preallocated
is 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:
solve
in 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
-
checkSolvability
protected boolean checkSolvability()- Overrides:
checkSolvability
in classAbstractDecomposition<N extends Comparable<N>>
-
doDecompose
protected boolean doDecompose(Access2D.Collectable<N, ? super PhysicalStore<N>> matrix, boolean valuesOnly) - Specified by:
doDecompose
in classEigenvalueDecomposition<N extends Comparable<N>>
-
makeD
- Specified by:
makeD
in classEigenvalueDecomposition<N extends Comparable<N>>
-
makeEigenvalues
- Specified by:
makeEigenvalues
in classEigenvalueDecomposition<N extends Comparable<N>>
-
makeV
- Specified by:
makeV
in classEigenvalueDecomposition<N extends Comparable<N>>
-