Class Condition
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.
- Induced (operator) norm:
cond(Matrix, double)andcond(CMatrix, double). - Schatten norm:
condSchatten(Matrix, double)andcondSchatten(CMatrix, double). - Frobenius norm:
condFro(Matrix)andcondFro(CMatrix). - Entry-wise norm:
condEntryWise(Matrix, double)andcondEntryWise(CMatrix, double)
-
Method Summary
Modifier and TypeMethodDescriptionstatic doubleComputes the condition number of a matrix.static doubleComputes the condition number of a matrix.static doublecondEntryWise(CMatrix src, double p) Computes the condition number of a matrix using anentry-wise norm.static doublecondEntryWise(Matrix src, double p) Computes the condition number of a matrix using anentry-wise norm.static doubleComputes the condition number of a matrix using the Frobenius norm.static doubleComputes the condition number of a matrix using the Frobenius norm.static doublecondSchatten(CMatrix src, double p) Computes the condition number of a matrix using theSchatten norm.static doublecondSchatten(Matrix src, double p) Computes the condition number of a matrix using theSchatten norm.
-
Method Details
-
cond
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)).pmust 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.
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:
- Schatten norm:
condSchatten(Matrix, double). - Frobenius norm:
condFro(Matrix) - Entry-wise norm:
condEntryWise(Matrix, double)
- 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_INFINITYorDouble.NEGATIVE_INFINITY.- Returns:
- The condition number of
srcas computed using the matrix operator norm induced by vector p-norm.
-
cond
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)).pmust 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.
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:
- Schatten norm:
condSchatten(CMatrix, double). - Frobenius norm:
condFro(CMatrix) - Entry-wise norm:
condEntryWise(CMatrix, double)
- 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_INFINITYorDouble.NEGATIVE_INFINITY.- Returns:
- The condition number of
srcas computed using the matrix operator norm induced by vector p-norm.
-
condSchatten
Computes the condition number of a matrix using theSchatten 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
Computes the condition number of a matrix using theSchatten 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
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
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
Computes the condition number of a matrix using anentry-wise norm.- Parameters:
src- Matrix to compute the condition number of.- Returns:
- The condition number of
src.
-
condEntryWise
Computes the condition number of a matrix using anentry-wise norm.- Parameters:
src- Matrix to compute the condition number of.- Returns:
- The condition number of
src.
-