Skip to content

Commit 57c6786

Browse files
saschatimmeandreasnoack
authored andcommitted
Fix condskeel definition (#34512)
* Fix condskeel definition Skeel's condition number is a relative condition number, however the definition of `condskeel(A,x)` missed to divide by the norm of `x`. The definition is for example in Higham "Accuracy and stability of numerical algorithms" eq. (7.13) (p. 123). * Test condskeel definition fix
1 parent c4a0c83 commit 57c6786

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

stdlib/LinearAlgebra/src/generic.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,7 +1125,7 @@ condskeel(A::AbstractMatrix, p::Real=Inf) = opnorm(abs.(inv(A))*abs.(A), p)
11251125
11261126
```math
11271127
\\kappa_S(M, p) = \\left\\Vert \\left\\vert M \\right\\vert \\left\\vert M^{-1} \\right\\vert \\right\\Vert_p \\\\
1128-
\\kappa_S(M, x, p) = \\left\\Vert \\left\\vert M \\right\\vert \\left\\vert M^{-1} \\right\\vert \\left\\vert x \\right\\vert \\right\\Vert_p
1128+
\\kappa_S(M, x, p) = \\frac{\\left\\Vert \\left\\vert M \\right\\vert \\left\\vert M^{-1} \\right\\vert \\left\\vert x \\right\\vert \\right\\Vert_p}{\\left \\Vert x \\right \\Vert_p}
11291129
```
11301130
11311131
Skeel condition number ``\\kappa_S`` of the matrix `M`, optionally with respect to the
@@ -1137,7 +1137,9 @@ Valid values for `p` are `1`, `2` and `Inf` (default).
11371137
This quantity is also known in the literature as the Bauer condition number, relative
11381138
condition number, or componentwise relative condition number.
11391139
"""
1140-
condskeel(A::AbstractMatrix, x::AbstractVector, p::Real=Inf) = norm(abs.(inv(A))*(abs.(A)*abs.(x)), p)
1140+
function condskeel(A::AbstractMatrix, x::AbstractVector, p::Real=Inf)
1141+
norm(abs.(inv(A))*(abs.(A)*abs.(x)), p) / norm(x, p)
1142+
end
11411143

11421144
issymmetric(A::AbstractMatrix{<:Real}) = ishermitian(A)
11431145

stdlib/LinearAlgebra/test/generic.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,4 +462,9 @@ end
462462
end
463463
end
464464

465+
@testset "condskeel #34512" begin
466+
A = rand(3, 3)
467+
@test condskeel(A) condskeel(A, [8,8,8])
468+
end
469+
465470
end # module TestGeneric

0 commit comments

Comments
 (0)