Skip to content

Commit 0da1e3e

Browse files
committed
code suggestions
1 parent 3411c4d commit 0da1e3e

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

src/common/matrixproperties.jl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -151,44 +151,44 @@ function strided_ishermitian_approx(
151151
blocksize = 32, atol::Real = default_hermitian_tol(A), rtol::Real = 0
152152
)
153153
n = size(A, 1)
154-
ϵ = abs2(zero(eltype(A)))
155-
ϵmax = oftype(ϵ, rtol > 0 ? max(atol, rtol * norm(A)) : atol)^2
154+
ϵ² = abs2(zero(eltype(A)))
155+
ϵ²max = oftype², rtol > 0 ? max(atol, rtol * norm(A)) : atol)^2
156156
for j in 1:blocksize:n
157157
jb = min(blocksize, n - j + 1)
158-
ϵ += _ishermitian_approx_diag(view(A, j:(j + jb - 1), j:(j + jb - 1)), anti)
159-
ϵ < ϵmax || return false
158+
ϵ² += _ishermitian_approx_diag(view(A, j:(j + jb - 1), j:(j + jb - 1)), anti)
159+
ϵ² < ϵ²max || return false
160160
for i in 1:blocksize:(j - 1)
161161
ib = blocksize
162-
ϵ += _ishermitian_approx_offdiag(
162+
ϵ² += _ishermitian_approx_offdiag(
163163
view(A, i:(i + ib - 1), j:(j + jb - 1)),
164164
view(A, j:(j + jb - 1), i:(i + ib - 1)),
165165
anti
166166
)
167-
ϵ < ϵmax || return false
167+
ϵ² < ϵ²max || return false
168168
end
169169
end
170170
return true
171171
end
172172

173173
function _ishermitian_approx_diag(A, ::Val{anti}) where {anti}
174174
n = size(A, 1)
175-
ϵ = abs2(zero(eltype(A)))
175+
ϵ² = abs2(zero(eltype(A)))
176176
@inbounds for j in 1:n
177177
@simd for i in 1:j
178178
val = anti ? (A[i, j] + adjoint(A[j, i])) : (A[i, j] - adjoint(A[j, i]))
179-
ϵ += abs2(val)
179+
ϵ² += abs2(val) * (1 + Int(i < j))
180180
end
181181
end
182-
return ϵ
182+
return ϵ²
183183
end
184184
function _ishermitian_approx_offdiag(Al, Au, ::Val{anti}) where {anti}
185185
m, n = size(Al) # == reverse(size(Al))
186-
ϵ = abs2(zero(eltype(Al)))
186+
ϵ² = abs2(zero(eltype(Al)))
187187
@inbounds for j in 1:n
188188
@simd for i in 1:m
189189
val = anti ? (Al[i, j] + adjoint(Au[j, i])) : (Al[i, j] - adjoint(Au[j, i]))
190-
ϵ += abs2(val)
190+
ϵ² += abs2(val)
191191
end
192192
end
193-
return ϵ
193+
return 2ϵ²
194194
end

0 commit comments

Comments
 (0)