From 0c27e951029ce0f3f73f03e61857d8d8d84d8568 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Mon, 25 Sep 2023 19:19:43 +0200 Subject: [PATCH] Fix format --- src/Certificate/Symmetry/block_diag.jl | 29 +++++++++++++++++--------- test/symmetry.jl | 23 ++++++++++---------- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/src/Certificate/Symmetry/block_diag.jl b/src/Certificate/Symmetry/block_diag.jl index 937fe77bd..b6f52c1ca 100644 --- a/src/Certificate/Symmetry/block_diag.jl +++ b/src/Certificate/Symmetry/block_diag.jl @@ -34,8 +34,8 @@ function _reorder!(F::LinearAlgebra.Schur{T}) where {T} next_i = i + 1 end if !isnothing(prev_i) && - (real(S[i, i]), imag(S[i, i])) < - (real(S[prev_i, prev_i]), imag(S[prev_i, prev_i])) + (real(S[i, i]), imag(S[i, i])) < + (real(S[prev_i, prev_i]), imag(S[prev_i, prev_i])) select = trues(n) select[prev_i:(i-1)] .= false select[next_i:end] .= false @@ -50,7 +50,11 @@ end # We can multiply by `Diagonal(d)` if `d[i] * conj(d[i]) = 1`. # So in the real case, `d = ±1` but in the complex case, we have more freedom. -function _sign_diag(A::AbstractMatrix{T}, B::AbstractMatrix{T}; tol = Base.rtoldefault(real(T))) where {T} +function _sign_diag( + A::AbstractMatrix{T}, + B::AbstractMatrix{T}; + tol = Base.rtoldefault(real(T)), +) where {T} n = LinearAlgebra.checksquare(A) d = ones(T, n) for j in 2:n @@ -111,7 +115,11 @@ complex conjugates. If `S` is a `Matrix{<:Complex}`, then `S` is upper triangular so there is nothing to do. """ -function _rotate_complex(A::AbstractMatrix{T}, B::AbstractMatrix{T}; tol = Base.rtoldefault(real(T))) where {T} +function _rotate_complex( + A::AbstractMatrix{T}, + B::AbstractMatrix{T}; + tol = Base.rtoldefault(real(T)), +) where {T} n = LinearAlgebra.checksquare(A) I = collect(1:n) J = copy(I) @@ -121,19 +129,20 @@ function _rotate_complex(A::AbstractMatrix{T}, B::AbstractMatrix{T}; tol = Base. if pair || i == n continue end - pair = abs(A[i + 1, i]) > tol + pair = abs(A[i+1, i]) > tol if pair - a = (A[i + 1, i], A[i, i + 1]) - b = (B[i + 1, i], B[i, i + 1]) + a = (A[i+1, i], A[i, i+1]) + b = (B[i+1, i], B[i, i+1]) c = a[2:-1:1] - if LinearAlgebra.norm(abs.(a) .- abs.(b)) > LinearAlgebra.norm(abs.(c) .- abs.(b)) + if LinearAlgebra.norm(abs.(a) .- abs.(b)) > + LinearAlgebra.norm(abs.(c) .- abs.(b)) a = c J[i] = i + 1 - J[i + 1] = i + J[i+1] = i end c = (-).(a) if LinearAlgebra.norm(a .- b) > LinearAlgebra.norm(c .- b) - V[i + 1] = -V[i] + V[i+1] = -V[i] end end end diff --git a/test/symmetry.jl b/test/symmetry.jl index 08ba21483..6fff85ecc 100644 --- a/test/symmetry.jl +++ b/test/symmetry.jl @@ -109,14 +109,14 @@ function _test_orthogonal_transformation_to(T::Type) ] _test_orthogonal_transformation_to(A1, A2) A1 = T[ - -1 0 1 - 1 1 0 - 0 1 -1 + -1 0 1 + 1 1 0 + 0 1 -1 ] A2 = T[ - -1 1 0 - 0 1 1 - 1 0 -1 + -1 1 0 + 0 1 1 + 1 0 -1 ] _test_orthogonal_transformation_to(A1, A2) return @@ -167,7 +167,6 @@ end TestSymmetry.runtests() - #A1 = [ # 1.0+0.0im 0.0+0.0im 0.0+0.0im # 0.0+0.0im 1.0+0.0im 0.0+0.0im @@ -260,13 +259,13 @@ TestSymmetry.runtests() #TestSymmetry._test_orthogonal_transformation_to(A1, A2) A1 = [ - -1 0 1 - 1 1 0 - 0 1 -1 + -1 0 1 + 1 1 0 + 0 1 -1 ] A2 = [ - -1 1 0 - 0 1 1 + -1 1 0 + 0 1 1 1 0 -1 ] TestSymmetry._test_orthogonal_transformation_to(A1, A2)