Skip to content

Commit

Permalink
Update for strain package
Browse files Browse the repository at this point in the history
  • Loading branch information
jmeziere committed Jul 29, 2024
1 parent 6a0b4d3 commit 9813ab1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
2 changes: 1 addition & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ include("DummyDocs.jl")
using .DummyDocs

makedocs(
sitename="BcdiCore.jl",
sitename="BcdiTrad.jl",
format = Documenter.HTML(
prettyurls = get(ENV, "CI", nothing) == "true"
),
Expand Down
28 changes: 13 additions & 15 deletions src/State.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ indicating trusted intensities need to be passed in.
"""
struct State{T}
realSpace::CuArray{ComplexF64, 3, CUDA.Mem.DeviceBuffer}
shift::Vector{Int64}
shift::Tuple{Int64,Int64,Int64}
support::CuArray{Bool, 3, CUDA.Mem.DeviceBuffer}
core::T

Expand All @@ -18,26 +18,24 @@ struct State{T}

function State(intens, recSupport, support)
s = size(intens)
shift = [0.,0,0]
for i in 1:s[1]
for j in 1:s[2]
for k in 1:s[3]
shift[1] += i*sqrt(intens[i,j,k])
shift[2] += j*sqrt(intens[i,j,k])
shift[3] += k*sqrt(intens[i,j,k])
end
end
end
shift .= [1,1,1] .- round.(Int64, shift ./ mapreduce(sqrt, +, intens))
intens = CuArray{Float64, 3, CUDA.Mem.DeviceBuffer}(circshift(intens,shift))
recSupport = CuArray{Float64, 3, CUDA.Mem.DeviceBuffer}(circshift(recSupport,shift))
shift .*= -1
intens, recSupport, shift = BcdiCore.centerPeak(intens, recSupport, "corner")

realSpace = CUDA.zeros(ComplexF64, s)
core = BcdiCore.TradState("L2", false, realSpace, intens, recSupport)
realSpace .= CUFFT.ifft(sqrt.(intens) .* recSupport)

new{typeof(core)}(realSpace, shift, support, core)
end

function State(intens, recSupport, support, core)
s = size(intens)
intens, recSupport, shift = BcdiCore.centerPeak(intens, recSupport, "corner")

newCore = BcdiCore.TradState(
core.losstype, core.scale, intens, core.plan,
core.realSpace, recSupport, core.working, core.deriv
)
new{typeof(newCore)}(core.realSpace, shift, support, newCore)
end
end

0 comments on commit 9813ab1

Please sign in to comment.