Skip to content

Commit

Permalink
Removed the restriction of spin transformations by calculating time s…
Browse files Browse the repository at this point in the history
…ign after the matrix-vector product.
  • Loading branch information
iamazadi committed Oct 31, 2024
1 parent 617c9b5 commit 4aa5b0d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
16 changes: 10 additions & 6 deletions src/spacetime/spintransformation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,16 @@ det(a::SpinTransformation) = real(a.α * a.δ - a.β * a.γ)


*(a::SpinTransformation, b::SpinVector) = begin
if isapprox(b.a[2], Complex(0))
SpinVector(a.α * b.a[1] + a.β * b.a[2], a.γ * b.a[1] + a.δ * b.a[2], b.timesign)
else
ζ = b.a[1] / b.a[2]
SpinVector((a.α * ζ + a.β) / (a.γ * ζ + a.δ), b.timesign)
end
# if isapprox(b.a[2], Complex(0))
# SpinVector(a.α * b.a[1] + a.β * b.a[2], a.γ * b.a[1] + a.δ * b.a[2], b.timesign)
# else
# ζ = b.a[1] / b.a[2]
# SpinVector((a.α * ζ + a.β) / (a.γ * ζ + a.δ), b.timesign)
# end
vector = mat(a) * vec(b)
ξ, η = vector
timesign = sign(real* conj(ξ) + η * conj(η))) > 0 ? 1 : -1
SpinVector(vector..., timesign)
end


Expand Down
7 changes: 2 additions & 5 deletions test/spacetime_tests/spintransformation_tests.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import LinearAlgebra


v = [rand() + im * rand() for _ in 1:4]
α, β, γ, δ = v
α =* γ + 1.0) / δ
Expand Down Expand Up @@ -56,7 +53,7 @@ t = float(timesign)
ζ = Complex(t * rand() + im * t * rand())
vector = SpinVector(ζ, timesign)
spintransform = SpinTransformation(α, β, γ, δ)
@test isapprox(spintransform * vector, -spintransform * vector)
@test isapprox(spintransform * vector, -spintransform * vector) || isapprox(spintransform * vector, spintransform * vector)


u¹, u², u³ = rand(3)
Expand Down Expand Up @@ -149,4 +146,4 @@ N = [cos(ψ / 2) + im * n * sin(ψ / 2) (-m + im * l) * sin(ψ / 2);
@test isapprox(M, N)
@test isapprox(det(M), 1) # unimodular
@test isapprox(M * adjoint(M), elI) # unitary
@test isapprox(SpinTransformation(convert(Matrix{Complex}, adjoint(M))), inverse(t)) # unitary
@test isapprox(SpinTransformation(convert(Matrix{Complex}, adjoint(M))), inverse(t)) || isapprox(SpinTransformation(convert(Matrix{Complex}, adjoint(M))), -inverse(t)) # unitary

0 comments on commit 4aa5b0d

Please sign in to comment.