Top Description Inners Fields Constructors Methods
org.apache.commons.math3.linear

public Class FieldLUDecomposition<T extends FieldElement<T>>

extends Object
Class Inheritance
Type Parameters
<T>
the type of the field elements
Imports
org.apache.commons.math3.Field, .FieldElement, org.apache.commons.math3.exception.DimensionMismatchException, org.apache.commons.math3.util.MathArrays

Calculates the LUP-decomposition of a square matrix.

The LUP-decomposition of a matrix A consists of three matrices L, U and P that satisfy: PA = LU, L is lower triangular, and U is upper triangular and P is a permutation matrix. All matrices are m×m.

Since field elements do not provide an ordering operator, the permutation matrix is computed here only in order to avoid a zero pivot element, no attempt is done to get the largest pivot element.

This class is based on the class with similar name from the JAMA library.

Since
2.0 (changed to concrete class in 3.0)
See Also
MathWorld, Wikipedia

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
FieldLUDecomposition.Solver<
the type of the field elements
T extends FieldElement<T>
>

Specialized solver.

Field Summary

Modifier and TypeField and Description
private FieldMatrix<T>
cachedL

Cached value of L.

private FieldMatrix<T>
cachedP

Cached value of P.

private FieldMatrix<T>
cachedU

Cached value of U.

private boolean
even

Parity of the permutation associated with the LU decomposition.

private final Field<T>
field

Field to which the elements belong.

private T[][]
lu

Entries of LU decomposition.

private int[]
pivot

Pivot permutation associated with LU decomposition.

private boolean
singular

Singularity indicator.

Constructor Summary

AccessConstructor and Description
public
FieldLUDecomposition(FieldMatrix<T>
The matrix to decompose.
matrix
)

Calculates the LU-decomposition of the given matrix.

Method Summary

Modifier and TypeMethod and Description
public T

Returns:

determinant of the matrix
getDeterminant
()

Return the determinant of the matrix.

public FieldMatrix<T>

Returns:

the L matrix (or null if decomposed matrix is singular)
getL
()

Returns the matrix L of the decomposition.

public FieldMatrix<T>

Returns:

the P rows permutation matrix (or null if decomposed matrix is singular)
getP
()

Returns the P rows permutation matrix.

public int[]

Returns:

the pivot permutation vector
getPivot
()

Returns the pivot permutation vector.

public FieldDecompositionSolver<T>

Returns:

a solver
getSolver
()

Get a solver for finding the A × X = B solution in exact linear sense.

public FieldMatrix<T>

Returns:

the U matrix (or null if decomposed matrix is singular)
getU
()

Returns the matrix U of the decomposition.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cachedLback to summary
private FieldMatrix<T> cachedL

Cached value of L.

cachedPback to summary
private FieldMatrix<T> cachedP

Cached value of P.

cachedUback to summary
private FieldMatrix<T> cachedU

Cached value of U.

evenback to summary
private boolean even

Parity of the permutation associated with the LU decomposition.

fieldback to summary
private final Field<T> field

Field to which the elements belong.

luback to summary
private T[][] lu

Entries of LU decomposition.

pivotback to summary
private int[] pivot

Pivot permutation associated with LU decomposition.

singularback to summary
private boolean singular

Singularity indicator.

Constructor Detail

FieldLUDecompositionback to summary
public FieldLUDecomposition(FieldMatrix<T> matrix)

Calculates the LU-decomposition of the given matrix.

Parameters
matrix:FieldMatrix<T>

The matrix to decompose.

Exceptions
NonSquareMatrixException:
if matrix is not square

Method Detail

getDeterminantback to summary
public T getDeterminant()

Return the determinant of the matrix.

Returns:T

determinant of the matrix

getLback to summary
public FieldMatrix<T> getL()

Returns the matrix L of the decomposition.

L is a lower-triangular matrix

Returns:FieldMatrix<T>

the L matrix (or null if decomposed matrix is singular)

getPback to summary
public FieldMatrix<T> getP()

Returns the P rows permutation matrix.

P is a sparse matrix with exactly one element set to 1.0 in each row and each column, all other elements being set to 0.0.

The positions of the 1 elements are given by the pivot permutation vector.

Returns:FieldMatrix<T>

the P rows permutation matrix (or null if decomposed matrix is singular)

See Also
getPivot()
getPivotback to summary
public int[] getPivot()

Returns the pivot permutation vector.

Returns:int[]

the pivot permutation vector

See Also
getP()
getSolverback to summary
public FieldDecompositionSolver<T> getSolver()

Get a solver for finding the A × X = B solution in exact linear sense.

Returns:FieldDecompositionSolver<T>

a solver

getUback to summary
public FieldMatrix<T> getU()

Returns the matrix U of the decomposition.

U is an upper-triangular matrix

Returns:FieldMatrix<T>

the U matrix (or null if decomposed matrix is singular)

org.apache.commons.math3.linear back to summary

private Class FieldLUDecomposition.Solver<T extends FieldElement<T>>

extends Object
implements FieldDecompositionSolver<T extends FieldElement<T>>
Class Inheritance
All Implemented Interfaces
org.apache.commons.math3.linear.FieldDecompositionSolver
Type Parameters
<T>
the type of the field elements

Specialized solver.

Field Summary

Modifier and TypeField and Description
private final Field<T>
field

Field to which the elements belong.

private final T[][]
lu

Entries of LU decomposition.

private final int[]
pivot

Pivot permutation associated with LU decomposition.

private final boolean
singular

Singularity indicator.

Constructor Summary

AccessConstructor and Description
private
Solver(final Field<T>
field to which the matrix elements belong
field
,
final T[][]
entries of LU decomposition
lu
,
final int[]
pivot permutation associated with LU decomposition
pivot
,
final boolean
singularity indicator
singular
)

Build a solver from decomposed matrix.

Method Summary

Modifier and TypeMethod and Description
public FieldMatrix<T>
getInverse()

Implements org.apache.commons.math3.linear.FieldDecompositionSolver.getInverse.

Get the inverse (or pseudo-inverse) of the decomposed matrix.

public boolean
isNonSingular()

Implements org.apache.commons.math3.linear.FieldDecompositionSolver.isNonSingular.

Check if the decomposed matrix is non-singular.

public FieldVector<T>
solve(FieldVector<T>
right-hand side of the equation A × X = B
b
)

Implements org.apache.commons.math3.linear.FieldDecompositionSolver.solve.

Solve the linear equation A × X = B for matrices A.

public ArrayFieldVector<T>

Returns:

a vector X such that A × X = B
solve
(ArrayFieldVector<T>
right-hand side of the equation A × X = B
b
)

Solve the linear equation A × X = B.

public FieldMatrix<T>
solve(FieldMatrix<T>
right-hand side of the equation A × X = B
b
)

Implements org.apache.commons.math3.linear.FieldDecompositionSolver.solve.

Solve the linear equation A × X = B for matrices A.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

fieldback to summary
private final Field<T> field

Field to which the elements belong.

luback to summary
private final T[][] lu

Entries of LU decomposition.

pivotback to summary
private final int[] pivot

Pivot permutation associated with LU decomposition.

singularback to summary
private final boolean singular

Singularity indicator.

Constructor Detail

Solverback to summary
private Solver(final Field<T> field, final T[][] lu, final int[] pivot, final boolean singular)

Build a solver from decomposed matrix.

Parameters
field:Field<T>

field to which the matrix elements belong

lu:T[][]

entries of LU decomposition

pivot:int[]

pivot permutation associated with LU decomposition

singular:boolean

singularity indicator

Method Detail

getInverseback to summary
public FieldMatrix<T> getInverse()

Implements org.apache.commons.math3.linear.FieldDecompositionSolver.getInverse.

Doc from org.apache.commons.math3.linear.FieldDecompositionSolver.getInverse.

Get the inverse (or pseudo-inverse) of the decomposed matrix.

Returns:FieldMatrix<T>

inverse matrix

isNonSingularback to summary
public boolean isNonSingular()

Implements org.apache.commons.math3.linear.FieldDecompositionSolver.isNonSingular.

Doc from org.apache.commons.math3.linear.FieldDecompositionSolver.isNonSingular.

Check if the decomposed matrix is non-singular.

Returns:boolean

true if the decomposed matrix is non-singular

solveback to summary
public FieldVector<T> solve(FieldVector<T> b)

Implements org.apache.commons.math3.linear.FieldDecompositionSolver.solve.

Doc from org.apache.commons.math3.linear.FieldDecompositionSolver.solve.

Solve the linear equation A × X = B for matrices A.

The A matrix is implicit, it is provided by the underlying decomposition algorithm.

Parameters
b:FieldVector<T>

right-hand side of the equation A × X = B

Returns:FieldVector<T>

a vector X that minimizes the two norm of A × X - B

solveback to summary
public ArrayFieldVector<T> solve(ArrayFieldVector<T> b)

Solve the linear equation A × X = B.

The A matrix is implicit here. It is

Parameters
b:ArrayFieldVector<T>

right-hand side of the equation A × X = B

Returns:ArrayFieldVector<T>

a vector X such that A × X = B

Exceptions
DimensionMismatchException:
if the matrices dimensions do not match.
SingularMatrixException:
if the decomposed matrix is singular.
solveback to summary
public FieldMatrix<T> solve(FieldMatrix<T> b)

Implements org.apache.commons.math3.linear.FieldDecompositionSolver.solve.

Doc from org.apache.commons.math3.linear.FieldDecompositionSolver.solve.

Solve the linear equation A × X = B for matrices A.

The A matrix is implicit, it is provided by the underlying decomposition algorithm.

Parameters
b:FieldMatrix<T>

right-hand side of the equation A × X = B

Returns:FieldMatrix<T>

a matrix X that minimizes the two norm of A × X - B