Class LUDecomposition<F extends Field<F>>
This class represents the decomposition of a matrix
A
into a product of a lower
and upper
triangular matrices, L
and U
respectively, such as A = P·L·U
with
P
a
permutation
matrix.
This decomposition is typically used to resolve linear systems
of equations (Gaussian elimination) or to calculate the determinant
of a square Matrix
(O(m³)
).
Numerical stability is guaranteed through pivoting if the
Field
elements are numbers
For others elements types, numerical stability can be ensured by setting
the context-local
pivot
comparator (see setPivotComparator(java.util.Comparator<org.jscience.mathematics.structure.Field>)
).
Pivoting can be disabled by setting the pivot comparator
to null
(P
is then the matrix identity).
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Comparator<Field>
Holds the default comparator for pivoting. -
Method Summary
Modifier and TypeMethodDescriptionReturns the determinant of theMatrix
having this decomposition.Returns the lower matrix decomposition (L
) with diagonal elements equal to the multiplicative identity for F.getLU()
Returns the lower/upper decomposition in one single matrix.getPermutation
(F zero, F one) Returns the permutation matrix (P
).static Comparator<Field>
Returns thelocal
comparator used for pivoting ornull
if pivoting is not performed (defaultNUMERIC_COMPARATOR
).javolution.util.FastTable<javolution.util.Index>
Returns the pivots elements of this decomposition.Returns the upper matrix decomposition (U
).inverse()
Returns the solution X of the equation: A * X = Identity withthis = A.lu()
using back and forward substitutions.static void
Sets thelocal
comparator used for pivoting ornull
to disable pivoting.Returns the solution X of the equation: A * X = B withthis = A.lu()
using back and forward substitutions.static <F extends Field<F>>
LUDecomposition<F>Returns the lower/upper decomposition of the specified matrix.
-
Field Details
-
NUMERIC_COMPARATOR
Holds the default comparator for pivoting.
-
-
Method Details
-
valueOf
Returns the lower/upper decomposition of the specified matrix.- Parameters:
source
- the matrix for which the decomposition is calculated.- Returns:
- the lower/upper decomposition of the specified matrix.
- Throws:
DimensionException
- if the specified matrix is not square.
-
setPivotComparator
Sets thelocal
comparator used for pivoting ornull
to disable pivoting.- Parameters:
cmp
- the comparator for pivoting ornull
.
-
getPivotComparator
Returns thelocal
comparator used for pivoting ornull
if pivoting is not performed (defaultNUMERIC_COMPARATOR
).- Returns:
- the comparator for pivoting or
null
.
-
solve
Returns the solution X of the equation: A * X = B withthis = A.lu()
using back and forward substitutions.- Parameters:
B
- the input matrix.- Returns:
- the solution X = (1 / A) * B.
- Throws:
DimensionException
- if the dimensions do not match.
-
inverse
Returns the solution X of the equation: A * X = Identity withthis = A.lu()
using back and forward substitutions.- Returns:
this.solve(Identity)
-
determinant
Returns the determinant of theMatrix
having this decomposition.- Returns:
- the determinant of the matrix source.
-
getLower
Returns the lower matrix decomposition (L
) with diagonal elements equal to the multiplicative identity for F.- Parameters:
zero
- the additive identity for F.one
- the multiplicative identity for F.- Returns:
- the lower matrix.
-
getUpper
Returns the upper matrix decomposition (U
).- Parameters:
zero
- the additive identity for F.- Returns:
- the upper matrix.
-
getPermutation
Returns the permutation matrix (P
).- Parameters:
zero
- the additive identity for F.one
- the multiplicative identity for F.- Returns:
- the permutation matrix.
-
getLU
Returns the lower/upper decomposition in one single matrix.- Returns:
- the lower/upper matrix merged in a single matrix.
-
getPivots
public javolution.util.FastTable<javolution.util.Index> getPivots()Returns the pivots elements of this decomposition.- Returns:
- the row indices after permutation.
-