Skip to content

Commit

Permalink
small improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
PBrdng committed May 14, 2024
1 parent b2f7e8d commit 269b4f0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/linear_algebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ end
Compute optimal scaling factors `d` for the matrix `A` following Skeel [^S79]
if `c` is approximately of the order of the solution of the linear system
of interest.
The scaling factors are rounded to powers `e` of the base radix 2. Row scaling is only applied to rows with `e - m ≥ scaling_threshold` to prevent zero rows from being scaled, where `2^m` is approximately the maximum norm of a row of `A`.
The scaling factors are rounded to powers `e` of the base radix 2. Row scaling is only applied to rows with `e - m ≥ scaling_threshold` (this is an inequality of norms at log-scale) to prevent zero rows from being scaled, where `2^m` is approximately the maximum norm of a row of `A`.
[^S79]: Skeel, Robert D. "Scaling for numerical stability in Gaussian elimination." Journal of the ACM (JACM) 26.3 (1979): 494-526.
"""
Expand All @@ -444,9 +444,10 @@ function skeel_row_scaling!(
end

m = maximum(d)
s = scaling_threshold + m
@inbounds for i = 1:n
e = last(frexp(d[i]))
if e - m < scaling_threshold
if e < s
d[i] = 1.0
else
d[i] = exp2(-e)
Expand Down

0 comments on commit 269b4f0

Please sign in to comment.