Skip to content

Commit

Permalink
Fix format
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat committed Sep 25, 2023
1 parent 6731515 commit 0c27e95
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 22 deletions.
29 changes: 19 additions & 10 deletions src/Certificate/Symmetry/block_diag.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down
23 changes: 11 additions & 12 deletions test/symmetry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)

0 comments on commit 0c27e95

Please sign in to comment.