Skip to content

Commit 743730d

Browse files
committed
Fix log_quasitriu for internal scaling s=0 (#56311)
1 parent a5b3ce0 commit 743730d

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

stdlib/LinearAlgebra/src/triangular.jl

+5
Original file line numberDiff line numberDiff line change
@@ -1865,6 +1865,11 @@ end
18651865
# SIAM J. Sci. Comput., 34(4), (2012) C153–C169. doi: 10.1137/110852553
18661866
# Algorithm 5.1
18671867
Base.@propagate_inbounds function _sqrt_pow_diag_block_2x2!(A, A0, s)
1868+
if iszero(s)
1869+
A[1,1] -= 1
1870+
A[2,2] -= 1
1871+
return A
1872+
end
18681873
_sqrt_real_2x2!(A, A0)
18691874
if isone(s)
18701875
A[1,1] -= 1

stdlib/LinearAlgebra/test/triangular.jl

+10
Original file line numberDiff line numberDiff line change
@@ -885,4 +885,14 @@ end
885885
@test V == Diagonal([1, 1])
886886
end
887887

888+
@testset "log_quasitriu with internal scaling s=0 (issue #54833)" begin
889+
M = [0.9949357359852791 -0.015567763143324862 -0.09091193493947397 -0.03994428739762443 0.07338356301650806;
890+
0.011813655598647289 0.9968988574699793 -0.06204555000202496 0.04694097614450692 0.09028834462782365;
891+
0.092737943594701 0.059546719185135925 0.9935850721633324 0.025348893985651405 -0.018530261590167685;
892+
0.0369187299165628 -0.04903571106913449 -0.025962938675946543 0.9977767446862031 0.12901494726320517;
893+
0.0 0.0 0.0 0.0 1.0]
894+
895+
@test exp(log(M)) M
896+
end
897+
888898
end # module TestTriangular

0 commit comments

Comments
 (0)