Class Condition

java.lang.Object
org.flag4j.linalg.Condition

public final class Condition extends Object

Utility class for computing the condition number of a matrix.

The condition number of a matrix A is defined as the norm of A times the norm of A-1 (i.e. the norm of the inverse of A). That is, cond(A) = ||A|| * ||A-1|| where ||A|| may be any matrix norm (generally taken to be the L2-norm).

Conditions numbers are associated with a linear equation Ax = b and provides a bound on how inaccurate the solution x will be after approximation before round-off errors are taken into account. If the condition number is large, then a small error in b may result in large errors in x. Subsequently, if the condition number is small, then the error in x will not be much bigger than the error in b.

The condition number is more precisely defined to be the maximum ratio of the relative error in x to the relative error in b. Let e be the error in b and A be a nonsingular matrix. Then,

     cond(A) = maxe,b≠0{ (||b|| / ||A-1b||) * (||A-1e|| / ||e||) }
             = ||A|| * ||A-1|| as stated.

When the L2-norm is used to compute the condition number then,

     cond(A) = σmax(A) / σmin(A)
where σmax(A) and σmin(A) are the maximum and minimum singular values of the matrix A.

This class supports the computation of the condition number of a real or complex matrix using the following norms.

  • Method Details

    • cond

      public static double cond(Matrix src, double p)

      Computes the condition number of a matrix.

      This method computes the condition number using the matrix operator norm induced by the vector p-norm (MatrixNorms.inducedNorm(Matrix, double)). p must be one of the following:

      • p=1: Maximum absolute column sum of the matrix.
      • p=-1: Minimum absolute column sum of the matrix.
      • p=2: Spectral norm. Equivalent to the maximum singular value of the matrix.
      • p=-2: Equivalent to the minimum singular value of the matrix.
      • p=Double.POSITIVE_INFINITY: Maximum absolute row sum of the matrix.
      • p=Double.NEGATIVE_INFINITY: Minimum absolute row sum of the matrix.
      When p < 1, the "norm" is not a true mathematical norm but may still serve useful numerical purposes.

      To compute the condition number using other norms see one the below methods:

      Parameters:
      src - The matrix to compute the condition number of.
      p - The p-value to use in the induced norm during condition number computation. Must be one of the following: 1, -1, 2, -2, Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY.
      Returns:
      The condition number of src as computed using the matrix operator norm induced by vector p-norm.
    • cond

      public static double cond(CMatrix src, double p)

      Computes the condition number of a matrix.

      This method computes the condition number using the matrix operator norm induced by the vector p-norm (MatrixNorms.inducedNorm(CMatrix, double)). p must be one of the following:

      • p=1: Maximum absolute column sum of the matrix.
      • p=-1: Minimum absolute column sum of the matrix.
      • p=2: Spectral norm. Equivalent to the maximum singular value of the matrix.
      • p=-2: Equivalent to the minimum singular value of the matrix.
      • p=Double.POSITIVE_INFINITY: Maximum absolute row sum of the matrix.
      • p=Double.NEGATIVE_INFINITY: Minimum absolute row sum of the matrix.
      When p < 1, the "norm" is not a true mathematical norm but may still serve useful numerical purposes.

      To compute the condition number using other norms see one the below methods:

      Parameters:
      src - The matrix to compute the condition number of.
      p - The p-value to use in the induced norm during condition number computation. Must be one of the following: 1, -1, 2, -2, Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY.
      Returns:
      The condition number of src as computed using the matrix operator norm induced by vector p-norm.
    • condSchatten

      public static double condSchatten(Matrix src, double p)
      Computes the condition number of a matrix using the Schatten norm.
      Parameters:
      src - Matrix to compute the condition number of.
      p - The p value in the Schatten norm.
      Returns:
      The condition number of src.
    • condSchatten

      public static double condSchatten(CMatrix src, double p)
      Computes the condition number of a matrix using the Schatten norm.
      Parameters:
      src - Matrix to compute the condition number of.
      p - The p value in the Schatten norm.
      Returns:
      The condition number of src.
    • condFro

      public static double condFro(Matrix src)
      Computes the condition number of a matrix using the Frobenius norm.
      Parameters:
      src - Matrix to compute the condition number of.
      Returns:
      The condition number of src.
    • condFro

      public static double condFro(CMatrix src)
      Computes the condition number of a matrix using the Frobenius norm.
      Parameters:
      src - Matrix to compute the condition number of.
      Returns:
      The condition number of src.
    • condEntryWise

      public static double condEntryWise(Matrix src, double p)
      Computes the condition number of a matrix using an entry-wise norm.
      Parameters:
      src - Matrix to compute the condition number of.
      Returns:
      The condition number of src.
    • condEntryWise

      public static double condEntryWise(CMatrix src, double p)
      Computes the condition number of a matrix using an entry-wise norm.
      Parameters:
      src - Matrix to compute the condition number of.
      Returns:
      The condition number of src.