Class VisualNumerics.math.DoubleLU
All Packages Class Hierarchy This Package Previous Next Index
Class VisualNumerics.math.DoubleLU
java.lang.Object
|
+----VisualNumerics.math.DoubleLU
- public class DoubleLU
- extends Object
LU factorization of a matrix of type double.
-
DoubleLU(double[][])
-
Create the LU factorization of a square matrix of type double.
-
condition()
-
Return an estimate of the reciprocal of the L1 condition number of the matrix used to construct
this instance.
-
determinant()
-
Return the determinant of the matrix used to construct this instance.
-
inverse()
-
Compute the inverse of a matrix of type double.
-
ipvt()
-
Return a vector containing the pivoting information from
the LU factorization.
-
solve(double[])
-
Return the solution x of the linear system Ax = b using the LU
factorization of A.
DoubleLU
public DoubleLU(double a[][]) throws IllegalArgumentException, MathException
- Create the LU factorization of a square matrix of type double.
- Parameters:
- a - Input square matrix of type double to be factored.
- Throws: IllegalArgumentException
- This exception is issued when the row lengths of
input matrix a are not equal (i.e. the matrix edges are "jagged".)
- Throws: MathException
- This exception is issued when the input matrix a is singular.
-
Algorithm:
-
The LU factorization is done using scaled partial pivoting. Scaled
partial pivoting differs from partial pivoting in that the pivoting
strategy is the same as if each row were scaled to have the same
infinity norm. The constructor is based on the LINPACK routine DGECO.
-
Example:
-
import VisualNumerics.math.DoubleLU;
import VisualNumerics.math.MathException;
import java.io.*;
class testDLU {
public static void main(String args[]) {
double ainv[][], x[];
double determ;
double a[][] = {{ 1.0, 3.0, 3.0},
{ 1.0, 3.0, 4.0},
{ 1.0, 4.0, 3.0}};
double b[] = {1.0, 4.0, -1.0};
try {
DoubleLU lu = new DoubleLU(a);
determ = lu.determinant();
x = lu.solve(b);
ainv = lu.inverse();
// ... print results ...
} catch (IOException ioe) {
System.err.println(ioe.toString());
} catch (IllegalArgumentException e) {
System.err.println(e.toString());
} catch (MathException e) {
System.err.println(e.toString());
}
}
}
solve
public double[] solve(double b[])
- Return the solution x of the linear system Ax = b using the LU
factorization of A.
- Parameters:
- b - Input vector of type double containing the right-hand side of the linear system.
- Returns:
- A vector of type double containing the solution to the linear system of
equations.
-
Algorithm:
-
The DoubleLU constructor computes an LU factorization of a matrix with elements of type double.
The solution to Ax = b is found by solving the simpler systems Ly = b
and Ux = y, where L and U are triangular matrices . The forward elimination step consists of solving the system
Ly = b by applying the same permutations and elimination operations to b
that were applied to the columns of A in the factorization. The backward
substitution step consists of solving the triangular system Ux = y for x.
This method is based on the LINPACK routine DGESL.
inverse
public double[][] inverse()
- Compute the inverse of a matrix of type double.
- Returns:
- The inverse of the matrix used to construct this object.
-
Algorithm:
-
The matrix inverse is constructed columnwise by invoking solve()
with successive columns of the identity matrix.
determinant
public double determinant()
- Return the determinant of the matrix used to construct this instance.
- Returns:
- A double scalar containing the determinant of the
matrix used to construct this instance.
-
Algorithm:
-
The DoubleLU constructor executes LU factorization of the
matrix. The product of the diagonal elements of the LU
factorization is then obtained. The determinant is this product with the sign
adjusted based on the number of pivoting interchanges that have
occurred in the LU factorization. This method is based on LINPACK routine DGEDI.
condition
public double condition()
- Return an estimate of the reciprocal of the L1 condition number of the matrix used to construct
this instance.
- Returns:
- An estimate of the reciprocal of the L
1 condition number of the matrix used to construct this instance.
-
Algorithm:
-
The DoubleLU constructor computes an LU factorization of the matrix.
This factorization is then used by this method in determining the condition
number. The L
1 condition number of a matrix A is defined to be the 1-norm
of A times the 1-norm of A inverse. Since it is expensive to compute the
1-norm of A inverse, the condition number is only estimated. The estimation
algorithm is the same as the algorithm used by the LINPACK routine DGECO. A condition
number less than approximately 2.22e-16 indicates that very small
changes in A can cause very large changes in the solution x of a linear
system involving A.
ipvt
public int[] ipvt()
- Return a vector containing the pivoting information from
the LU factorization.
- Returns:
- A vector with integer elements containing the pivoting
information from the LU factorization.
All Packages Class Hierarchy This Package Previous Next Index