public abstract class HermitianEvD<N extends Number> extends Object implements MatrixDecomposition.Solver<N>
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().
MatrixDecomposition.Determinant<N extends Number>, MatrixDecomposition.EconomySize<N extends Number>, MatrixDecomposition.Factory<D extends MatrixDecomposition<?>>, MatrixDecomposition.Hermitian<N extends Number>, MatrixDecomposition.Ordered<N extends Number>, MatrixDecomposition.Pivoting<N extends Number>, MatrixDecomposition.RankRevealing<N extends Number>, MatrixDecomposition.Solver<N extends Number>, MatrixDecomposition.Values<N extends Number>
Structure2D.IntRowColumn, Structure2D.Logical<S extends Structure2D,B extends Structure2D.Logical<S,?>>, Structure2D.LongRowColumn, Structure2D.ReducibleTo1D<R extends Structure1D>, Structure2D.RowColumnCallback, Structure2D.RowColumnKey<R,C>, Structure2D.RowColumnMapper<R,C>
Structure1D.BasicMapper<T>, Structure1D.IndexCallback, Structure1D.IndexMapper<T>, Structure1D.IntIndex, Structure1D.LongIndex, Structure1D.LoopCallback
SolverTask.Factory<N extends Number>
InverterTask.Factory<N extends Number>
Eigenvalue.Eigenpair, Eigenvalue.Factory<N extends Number>
TYPICAL
COMPLEX, PRIMITIVE, QUATERNION, RATIONAL
COMPLEX, PRIMITIVE, QUATERNION, RATIONAL
COMPLEX, PRIMITIVE, QUATERNION, RATIONAL
Modifier | Constructor and Description |
---|---|
protected |
HermitianEvD(PhysicalStore.Factory<N,? extends DecompositionStore<N>> aFactory,
org.ojalgo.matrix.decomposition.TridiagonalDecomposition<N> tridiagonal) |
Modifier and Type | Method and Description |
---|---|
protected AggregatorSet<N> |
aggregator() |
protected DecompositionStore<N> |
allocate(long numberOfRows,
long numberOfColumns) |
N |
calculateDeterminant(Access2D<?> matrix) |
boolean |
checkAndDecompose(MatrixStore<N> matrix)
Absolutely must check if the matrix is hermitian or not.
|
protected boolean |
checkSolvability() |
protected MatrixStore<N> |
collect(Access2D.Collectable<N,? super DecompositionStore<N>> source) |
protected boolean |
computed(boolean computed) |
boolean |
computeValuesOnly(Access2D.Collectable<N,? super PhysicalStore<N>> matrix) |
protected DecompositionStore<N> |
copy(Access2D<?> source) |
long |
countColumns() |
long |
countRows() |
boolean |
decompose(Access2D.Collectable<N,? super PhysicalStore<N>> matrix) |
protected boolean |
doGeneral(Access2D.Collectable<N,? super PhysicalStore<N>> matrix,
boolean eigenvaluesOnly) |
protected boolean |
doHermitian(Access2D.Collectable<N,? super PhysicalStore<N>> matrix,
boolean valuesOnly) |
protected FunctionSet<N> |
function() |
protected int |
getColDim() |
MatrixStore<N> |
getD()
The only requirements on [D] are that it should contain the eigenvalues and that [A][V] = [V][D].
|
N |
getDeterminant()
A matrix' determinant is the product of its eigenvalues.
|
protected double |
getDimensionalEpsilon() |
Array1D<ComplexNumber> |
getEigenvalues()
Even for real matrices the eigenvalues (and eigenvectors) are potentially complex numbers.
|
void |
getEigenvalues(double[] realParts,
Optional<double[]> imaginaryParts) |
MatrixStore<N> |
getInverse()
The output must be a "right inverse" and a "generalised inverse".
|
MatrixStore<N> |
getInverse(PhysicalStore<N> preallocated)
Implementiong this method is optional.
|
protected int |
getMaxDim() |
protected int |
getMinDim() |
protected int |
getRowDim() |
MatrixStore<N> |
getSolution(Access2D.Collectable<N,? super PhysicalStore<N>> rhs)
[A][X]=[B] or [this][return]=[rhs]
|
MatrixStore<N> |
getSolution(Access2D.Collectable<N,? super PhysicalStore<N>> rhs,
PhysicalStore<N> preallocated)
Implementiong this method is optional.
|
ComplexNumber |
getTrace()
A matrix' trace is the sum of the diagonal elements.
|
MatrixStore<N> |
getV()
The columns of [V] represent the eigenvectors of [A] in the sense that [A][V] = [V][D].
|
MatrixStore<N> |
invert(Access2D<?> original)
The output must be a "right inverse" and a "generalised inverse".
|
MatrixStore<N> |
invert(Access2D<?> original,
PhysicalStore<N> preallocated)
Exactly how (if at all) a specific implementation makes use of
preallocated is not
specified by this interface. |
protected boolean |
isAspectRatioNormal() |
boolean |
isComputed() |
boolean |
isHermitian()
If [A] is hermitian then [V][D][V]-1 becomes [Q][D][Q]H...
|
boolean |
isOrdered()
The eigenvalues in D (and the eigenvectors in V) are not necessarily ordered.
|
boolean |
isSolvable() |
protected BasicArray<N> |
makeArray(int length) |
protected MatrixStore<N> |
makeD() |
protected Array1D<ComplexNumber> |
makeEigenvalues() |
protected DecompositionStore<N> |
makeEye(int numberOfRows,
int numberOfColumns) |
protected Householder<N> |
makeHouseholder(int dimension) |
protected MatrixStore.LogicalBuilder<N> |
makeIdentity(int dimension) |
protected Rotation<N> |
makeRotation(int low,
int high,
double cos,
double sin) |
protected Rotation<N> |
makeRotation(int low,
int high,
N cos,
N sin) |
protected MatrixStore<N> |
makeV() |
protected DecompositionStore<N> |
makeZero(int numberOfRows,
int numberOfColumns) |
PhysicalStore<N> |
preallocate(Structure2D template)
Will create a PhysicalStore instance suitable for use with
InverterTask.invert(Access2D, PhysicalStore) . |
PhysicalStore<N> |
preallocate(Structure2D templateBody,
Structure2D templateRHS)
Will create a PhysicalStore instance suitable for use with
SolverTask.solve(Access2D, Access2D, PhysicalStore) . |
void |
reset()
Delete computed results, and resets attributes to default values
|
protected Scalar.Factory<N> |
scalar() |
MatrixStore<N> |
solve(Access2D<?> body,
Access2D<?> rhs)
[A][X]=[B] or [body][return]=[rhs]
|
MatrixStore<N> |
solve(Access2D<?> body,
Access2D<?> rhs,
PhysicalStore<N> preallocated)
Exactly how (if at all) a specific implementation makes use of
preallocated is not
specified by this interface. |
protected MatrixStore.LogicalBuilder<N> |
wrap(Access2D<?> source) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
compute, isSolvable
decompose, isComputed, reconstruct
column, column, column, column, column, count, count, countColumns, countRows, index, index, isEmpty, isFat, isScalar, isSquare, isTall, isVector, loopAll, loopColumn, loopColumn, loopDiagonal, loopMatching, loopRow, loopRow, mapperOf, row, row, row, row, row
index, loopAll, loopMatching, loopRange, mapper, size
preallocate
preallocate
copyEigenvector, equals, getEigenpair, getEigenvectors, make, make, reconstruct, reconstruct
checkAndCompute
protected HermitianEvD(PhysicalStore.Factory<N,? extends DecompositionStore<N>> aFactory, org.ojalgo.matrix.decomposition.TridiagonalDecomposition<N> tridiagonal)
public final N getDeterminant()
MatrixDecomposition.Determinant
A matrix' determinant is the product of its eigenvalues.
getDeterminant
in interface MatrixDecomposition.Determinant<N extends Number>
public void getEigenvalues(double[] realParts, Optional<double[]> imaginaryParts)
getEigenvalues
in interface Eigenvalue<N extends Number>
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
eigenvaluespublic final MatrixStore<N> getInverse()
MatrixDecomposition.Solver
getInverse
in interface MatrixDecomposition.Solver<N extends Number>
public final MatrixStore<N> getInverse(PhysicalStore<N> preallocated)
MatrixDecomposition.Solver
Implementiong 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()
.
getInverse
in interface MatrixDecomposition.Solver<N extends Number>
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.public final MatrixStore<N> getSolution(Access2D.Collectable<N,? super PhysicalStore<N>> rhs)
MatrixDecomposition.Solver
getSolution
in interface MatrixDecomposition.Solver<N extends Number>
public final MatrixStore<N> getSolution(Access2D.Collectable<N,? super PhysicalStore<N>> rhs, PhysicalStore<N> preallocated)
MatrixDecomposition.Solver
Implementiong 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 #getSolution(Collectable)
.
getSolution
in interface MatrixDecomposition.Solver<N extends Number>
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.public final ComplexNumber getTrace()
Eigenvalue
getTrace
in interface Eigenvalue<N extends Number>
public final MatrixStore<N> invert(Access2D<?> original) throws RecoverableCondition
InverterTask
invert
in interface InverterTask<N extends Number>
RecoverableCondition
public final MatrixStore<N> invert(Access2D<?> original, PhysicalStore<N> preallocated) throws RecoverableCondition
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 suitbale preallocated
.
invert
in interface InverterTask<N extends Number>
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.RecoverableCondition
- TODOpublic final boolean isHermitian()
Eigenvalue
isHermitian
in interface Eigenvalue<N extends Number>
public boolean isOrdered()
Eigenvalue
isOrdered
in interface Eigenvalue<N extends Number>
isOrdered
in interface MatrixDecomposition.Ordered<N extends Number>
public PhysicalStore<N> preallocate(Structure2D template)
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).
preallocate
in interface InverterTask<N extends Number>
public PhysicalStore<N> preallocate(Structure2D templateBody, Structure2D templateRHS)
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.
preallocate
in interface SolverTask<N extends Number>
public void reset()
MatrixDecomposition
reset
in interface MatrixDecomposition<N extends Number>
public MatrixStore<N> solve(Access2D<?> body, Access2D<?> rhs) throws RecoverableCondition
SolverTask
solve
in interface SolverTask<N extends Number>
RecoverableCondition
public MatrixStore<N> solve(Access2D<?> body, Access2D<?> rhs, PhysicalStore<N> preallocated) throws RecoverableCondition
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 suitbale preallocated
.
solve
in interface SolverTask<N extends Number>
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.RecoverableCondition
protected boolean checkSolvability()
protected final boolean doGeneral(Access2D.Collectable<N,? super PhysicalStore<N>> matrix, boolean eigenvaluesOnly)
protected final boolean doHermitian(Access2D.Collectable<N,? super PhysicalStore<N>> matrix, boolean valuesOnly)
protected MatrixStore<N> makeD()
protected Array1D<ComplexNumber> makeEigenvalues()
protected MatrixStore<N> makeV()
public N calculateDeterminant(Access2D<?> matrix)
calculateDeterminant
in interface DeterminantTask<N extends Number>
public final boolean checkAndDecompose(MatrixStore<N> matrix)
MatrixDecomposition.Hermitian
checkAndDecompose
in interface MatrixDecomposition.Hermitian<N extends Number>
matrix
- A matrix to check and then (maybe) decomposepublic boolean computeValuesOnly(Access2D.Collectable<N,? super PhysicalStore<N>> matrix)
computeValuesOnly
in interface MatrixDecomposition.Values<N extends Number>
matrix
- The matrix to decomposeSolver#compute(Collectable)
or #decompose(Collectable)
if the
instance does not implement MatrixDecomposition.Solver
.public final boolean decompose(Access2D.Collectable<N,? super PhysicalStore<N>> matrix)
decompose
in interface MatrixDecomposition<N extends Number>
matrix
- A matrix to decomposepublic final MatrixStore<N> getD()
Eigenvalue
getD
in interface Eigenvalue<N extends Number>
public final Array1D<ComplexNumber> getEigenvalues()
Eigenvalue
Even for real matrices the eigenvalues (and eigenvectors) are potentially complex numbers. Typically they need to be expressed as complex numbers when [A] is not symmetric.
The values should be in the same order as the matrices "V" and "D", and if they is ordered or not is
indicated by the Eigenvalue.isOrdered()
method.
getEigenvalues
in interface Eigenvalue<N extends Number>
public final MatrixStore<N> getV()
Eigenvalue
getV
in interface Eigenvalue<N extends Number>
protected int getColDim()
protected int getMaxDim()
protected int getMinDim()
protected int getRowDim()
protected final AggregatorSet<N> aggregator()
protected final DecompositionStore<N> allocate(long numberOfRows, long numberOfColumns)
protected final MatrixStore<N> collect(Access2D.Collectable<N,? super DecompositionStore<N>> source)
protected final DecompositionStore<N> copy(Access2D<?> source)
protected final FunctionSet<N> function()
protected final BasicArray<N> makeArray(int length)
protected final DecompositionStore<N> makeEye(int numberOfRows, int numberOfColumns)
protected final Householder<N> makeHouseholder(int dimension)
protected final MatrixStore.LogicalBuilder<N> makeIdentity(int dimension)
protected final Rotation<N> makeRotation(int low, int high, double cos, double sin)
protected final Rotation<N> makeRotation(int low, int high, N cos, N sin)
protected final DecompositionStore<N> makeZero(int numberOfRows, int numberOfColumns)
protected final Scalar.Factory<N> scalar()
protected final MatrixStore.LogicalBuilder<N> wrap(Access2D<?> source)
public final long countColumns()
countColumns
in interface Structure2D
public final long countRows()
countRows
in interface Structure2D
public final boolean isComputed()
isComputed
in interface MatrixDecomposition<N extends Number>
MatrixDecomposition.decompose(Access2D.Collectable)
public final boolean isSolvable()
protected final boolean computed(boolean computed)
protected final double getDimensionalEpsilon()
protected final boolean isAspectRatioNormal()
Copyright © 2019 Optimatika. All rights reserved.