Class RawEigenvalue
- java.lang.Object
-
- org.ojalgo.matrix.decomposition.AbstractDecomposition<java.lang.Double>
-
- org.ojalgo.matrix.decomposition.RawDecomposition
-
- org.ojalgo.matrix.decomposition.RawEigenvalue
-
- All Implemented Interfaces:
Eigenvalue<java.lang.Double>
,MatrixDecomposition<java.lang.Double>
,MatrixDecomposition.Determinant<java.lang.Double>
,MatrixDecomposition.Hermitian<java.lang.Double>
,MatrixDecomposition.Ordered<java.lang.Double>
,MatrixDecomposition.Values<java.lang.Double>
,Provider2D
,Provider2D.Determinant<java.lang.Double>
,Provider2D.Eigenpairs
,DeterminantTask<java.lang.Double>
,MatrixTask<java.lang.Double>
,Structure1D
,Structure2D
- Direct Known Subclasses:
RawEigenvalue.Dynamic
,RawEigenvalue.General
,RawEigenvalue.Symmetric
abstract class RawEigenvalue extends RawDecomposition implements Eigenvalue<java.lang.Double>
Eigenvalues and eigenvectors of a real matrix.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 Classes Modifier and Type Class Description (package private) static class
RawEigenvalue.Dynamic
(package private) static class
RawEigenvalue.General
(package private) static class
RawEigenvalue.Symmetric
-
Nested classes/interfaces inherited from interface org.ojalgo.matrix.decomposition.Eigenvalue
Eigenvalue.Eigenpair, Eigenvalue.Factory<N extends java.lang.Comparable<N>>, Eigenvalue.Generalisation, Eigenvalue.Generalised<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.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.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 double[]
d
Arrays for internal storage of eigenvalues.private double[]
e
Arrays for internal storage of eigenvalues.private MatrixStore<java.lang.Double>
myInverse
private double[][]
myTransposedV
Array for internal storage of eigenvectors.-
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
Constructors Modifier Constructor Description protected
RawEigenvalue()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.lang.Double
calculateDeterminant(Access2D<?> matrix)
protected boolean
checkSolvability()
boolean
computeValuesOnly(Access2D.Collectable<java.lang.Double,? super PhysicalStore<java.lang.Double>> matrix)
boolean
decompose(Access2D.Collectable<java.lang.Double,? super PhysicalStore<java.lang.Double>> matrix)
protected abstract boolean
doDecompose(double[][] data, boolean valuesOnly)
(package private) void
doGeneral(double[][] data, boolean valuesOnly)
(package private) void
doSymmetric(double[][] data, boolean valuesOnly)
MatrixStore<java.lang.Double>
getD()
Return the block diagonal eigenvalue matrixjava.lang.Double
getDeterminant()
A matrix' determinant is the product of its eigenvalues.Array1D<ComplexNumber>
getEigenvalues()
Even for real matrices the eigenvalues (and eigenvectors) are potentially complex numbers.void
getEigenvalues(double[] realParts, java.util.Optional<double[]> imaginaryParts)
(package private) double[]
getImaginaryParts()
Return the imaginary parts of the eigenvaluesMatrixStore<java.lang.Double>
getInverse()
MatrixStore<java.lang.Double>
getInverse(PhysicalStore<java.lang.Double> preallocated)
(package private) double[]
getRealParts()
Return the real parts of the eigenvaluesMatrixStore<java.lang.Double>
getSolution(Access2D.Collectable<java.lang.Double,? super PhysicalStore<java.lang.Double>> rhs, PhysicalStore<java.lang.Double> preallocated)
ComplexNumber
getTrace()
A matrix' trace is the sum of the diagonal elements.MatrixStore<java.lang.Double>
getV()
Return the eigenvector matrixMatrixStore<java.lang.Double>
invert(Access2D<?> original, PhysicalStore<java.lang.Double> preallocated)
protected MatrixStore<java.lang.Double>
makeD(double[] d, double[] e)
void
reset()
Delete computed results, and resets attributes to default valuesMatrixStore<java.lang.Double>
solve(MatrixStore<java.lang.Double> rhs, DecompositionStore<java.lang.Double> preallocated)
MatrixStore<java.lang.Double>
solve(Access2D<?> body, Access2D<?> rhs, PhysicalStore<java.lang.Double> preallocated)
-
Methods inherited from class org.ojalgo.matrix.decomposition.RawDecomposition
allocate, checkSymmetry, collect, function, getColDim, getInternalData, getInternalStore, getRowDim, make, makeDiagonal, newRawStore, reset, scalar, wrap, wrap
-
Methods inherited from class org.ojalgo.matrix.decomposition.AbstractDecomposition
computed, countColumns, countRows, getDimensionalEpsilon, isAspectRatioNormal, isComputed, isSolvable
-
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, isHermitian, isOrdered, reconstruct
-
Methods inherited from interface org.ojalgo.matrix.decomposition.MatrixDecomposition
isComputed
-
Methods inherited from interface org.ojalgo.matrix.decomposition.MatrixDecomposition.Determinant
toDeterminantProvider
-
Methods inherited from interface org.ojalgo.matrix.decomposition.MatrixDecomposition.Hermitian
checkAndDecompose
-
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 Detail
-
d
private double[] d
Arrays for internal storage of eigenvalues.
-
e
private double[] e
Arrays for internal storage of eigenvalues.
-
myInverse
private transient MatrixStore<java.lang.Double> myInverse
-
myTransposedV
private double[][] myTransposedV
Array for internal storage of eigenvectors.
-
-
Method Detail
-
calculateDeterminant
public java.lang.Double calculateDeterminant(Access2D<?> matrix)
- Specified by:
calculateDeterminant
in interfaceDeterminantTask<java.lang.Double>
-
computeValuesOnly
public boolean computeValuesOnly(Access2D.Collectable<java.lang.Double,? super PhysicalStore<java.lang.Double>> matrix)
- Specified by:
computeValuesOnly
in interfaceMatrixDecomposition.Values<java.lang.Double>
- Parameters:
matrix
- The matrix to decompose- Returns:
- The same as
MatrixDecomposition.Solver.compute(Collectable)
orMatrixDecomposition.decompose(Collectable)
if the instance does not implementMatrixDecomposition.Solver
.
-
decompose
public boolean decompose(Access2D.Collectable<java.lang.Double,? super PhysicalStore<java.lang.Double>> matrix)
- Specified by:
decompose
in interfaceMatrixDecomposition<java.lang.Double>
- Parameters:
matrix
- A matrix to decompose- Returns:
- true if decomposition suceeded; false if not
-
getD
public MatrixStore<java.lang.Double> getD()
Return the block diagonal eigenvalue matrix- Specified by:
getD
in interfaceEigenvalue<java.lang.Double>
- Returns:
- D
-
getDeterminant
public java.lang.Double getDeterminant()
Description copied from interface:MatrixDecomposition.Determinant
A matrix' determinant is the product of its eigenvalues.
- Specified by:
getDeterminant
in interfaceMatrixDecomposition.Determinant<java.lang.Double>
- Specified by:
getDeterminant
in interfaceProvider2D.Determinant<java.lang.Double>
- Returns:
- The matrix' determinant
-
getEigenvalues
public Array1D<ComplexNumber> getEigenvalues()
Description copied from interface: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.- Specified by:
getEigenvalues
in interfaceEigenvalue<java.lang.Double>
- Returns:
- The eigenvalues.
-
getEigenvalues
public void getEigenvalues(double[] realParts, java.util.Optional<double[]> imaginaryParts)
- Specified by:
getEigenvalues
in interfaceEigenvalue<java.lang.Double>
- 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
public MatrixStore<java.lang.Double> getInverse()
-
getInverse
public MatrixStore<java.lang.Double> getInverse(PhysicalStore<java.lang.Double> preallocated)
-
getSolution
public MatrixStore<java.lang.Double> getSolution(Access2D.Collectable<java.lang.Double,? super PhysicalStore<java.lang.Double>> rhs, PhysicalStore<java.lang.Double> preallocated)
-
getTrace
public ComplexNumber 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<java.lang.Double>
- Returns:
- The matrix' trace
-
getV
public MatrixStore<java.lang.Double> getV()
Return the eigenvector matrix- Specified by:
getV
in interfaceEigenvalue<java.lang.Double>
- Returns:
- V
-
invert
public MatrixStore<java.lang.Double> invert(Access2D<?> original, PhysicalStore<java.lang.Double> preallocated) throws RecoverableCondition
- Throws:
RecoverableCondition
-
reset
public void reset()
Description copied from interface:MatrixDecomposition
Delete computed results, and resets attributes to default values- Specified by:
reset
in interfaceMatrixDecomposition<java.lang.Double>
- Overrides:
reset
in classAbstractDecomposition<java.lang.Double>
-
solve
public MatrixStore<java.lang.Double> solve(Access2D<?> body, Access2D<?> rhs, PhysicalStore<java.lang.Double> preallocated) throws RecoverableCondition
- Throws:
RecoverableCondition
-
solve
public MatrixStore<java.lang.Double> solve(MatrixStore<java.lang.Double> rhs, DecompositionStore<java.lang.Double> preallocated)
-
checkSolvability
protected boolean checkSolvability()
- Overrides:
checkSolvability
in classAbstractDecomposition<java.lang.Double>
-
doDecompose
protected abstract boolean doDecompose(double[][] data, boolean valuesOnly)
-
makeD
protected MatrixStore<java.lang.Double> makeD(double[] d, double[] e)
-
doGeneral
void doGeneral(double[][] data, boolean valuesOnly)
-
doSymmetric
void doSymmetric(double[][] data, boolean valuesOnly)
-
getImaginaryParts
double[] getImaginaryParts()
Return the imaginary parts of the eigenvalues- Returns:
- imag(diag(D))
-
getRealParts
double[] getRealParts()
Return the real parts of the eigenvalues- Returns:
- real(diag(D))
-
-