Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use array views in spin functions #2

Merged
merged 1 commit into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "FastSphericalHarmonics"
uuid = "d335c211-7587-445e-a753-f0b1fb7e445f"
authors = ["Erik Schnetter <[email protected]>"]
version = "1.3.0"
version = "1.3.1"

[deps]
ComputedFieldTypes = "459fdd68-db75-56b8-8c15-d717a790f88e"
Expand Down
12 changes: 6 additions & 6 deletions src/spin.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ end
function coeff_complex2real(C::AbstractArray{Complex{Float64},2}, s::Int)
@assert s == 0
C′ = Array{Float64}(undef, size(C))
C′[:, 1] = real.(C[:, 1])
@views C′[:, 1] .= real.(C[:, 1])
for col in 2:2:size(C′, 2), row in 1:size(C′, 1)
avg = (C[row, col] + conj(C[row, col + 1])) / sqrt(2)
C′[row, col] = imag(avg)
Expand All @@ -42,7 +42,7 @@ end
function coeff_real2complex(C::AbstractArray{Float64,2}, s::Int)
@assert s == 0
C′ = Array{Complex{Float64}}(undef, size(C))
C′[:, 1] = C[:, 1]
@views C′[:, 1] = C[:, 1]
for col in 2:2:size(C, 2), row in 1:size(C, 1)
val = Complex{Float64}(C[row, col + 1], C[row, col]) / sqrt(2)
C′[row, col] = val
Expand Down Expand Up @@ -266,7 +266,7 @@ function spinsph_eth(C::AbstractArray{Float64,2}, s::Int)
for col in 1:size(ðC, 2)
m = col == 1 ? 0 : (col % 2 == 0 ? -1 : 1) * (col ÷ 2)
α = ifelse(m ≥ s, 1, -1)
ðC[:, col] .*= α
@views ðC[:, col] .*= α
end

return ðC
Expand All @@ -277,7 +277,7 @@ function spinsph_eth(C::AbstractArray{SVector{2,Float64},2}, s::Int)
for col in 1:size(C′, 2)
m = col == 1 ? 0 : (col % 2 == 0 ? -1 : 1) * (col ÷ 2)
α = ifelse(m > s + 1, 1, -1)
C′[:, col] .*= α
@views C′[:, col] .*= α
end

ðC′ = spinsph_eth(C′, s)
Expand Down Expand Up @@ -330,7 +330,7 @@ function spinsph_ethbar(C::AbstractArray{Float64,2}, s::Int)
for col in 1:size(ðC, 2)
m = col == 1 ? 0 : (col % 2 == 0 ? -1 : 1) * (col ÷ 2)
α = ifelse(m > s, 1, -1)
ðC[:, col] .*= α
@views ðC[:, col] .*= α
end

return ðC
Expand All @@ -341,7 +341,7 @@ function spinsph_ethbar(C::AbstractArray{SVector{2,Float64},2}, s::Int)
for col in 1:size(C′, 2)
m = col == 1 ? 0 : (col % 2 == 0 ? -1 : 1) * (col ÷ 2)
α = ifelse(m ≥ s - 1, 1, -1)
C′[:, col] .*= α
@views C′[:, col] .*= α
end

ðC′ = spinsph_ethbar(C′, s)
Expand Down