Skip to content

Commit

Permalink
add parallel computing
Browse files Browse the repository at this point in the history
  • Loading branch information
EigenSolver committed Apr 4, 2024
1 parent a9d71bb commit f98c441
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/SpinShuttling.jl
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ function sampling(samplingfunction::Function, M::Int)::Union{Tuple{Real,Real},Tu
N = length(samplingfunction(1))
A = N > 1 ? zeros(N) : 0
Q = copy(A)
for k in 1:M
Threads.@threads for k in 1:M
x = samplingfunction(k)::Union{Real,Vector{<:Real}}
Q = Q +(k-1)/k*(x-A).^ 2
A = A + (x-A)/k
Expand Down
5 changes: 3 additions & 2 deletions src/stochastics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ function covariancematrix(P₁::Matrix{<:Real}, P₂::Matrix{<:Real}, process::G
N = size(P₁, 1)
P₁ = P₁'; P₂ = P₂';
A = Matrix{Real}(undef, N, N)
for i in 1:N
Threads.@threads for i in 1:N
for j in 1:N
A[i, j] = covariance(P₁[:, i], P₂[:, j], process)
end
Expand All @@ -150,7 +150,7 @@ function covariancematrix(P::Matrix{<:Real}, process::GaussianRandomField)::Symm
N = size(P, 1)
P = P'
A = Matrix{Real}(undef, N, N)
for i in 1:N
Threads.@threads for i in 1:N
for j in i:N
A[i, j] = covariance(P[:, i], P[:, j], process)
end
Expand All @@ -164,6 +164,7 @@ numerical quadrature of the covariance matrix.
Using Simpson's rule by default.
"""
function characteristicfunction(R::RandomFunction)::Tuple{Vector{<:Real},Vector{<:Number}}
# need further optimization
dt=R.P[2,1]-R.P[1,1]
N=size(R.Σ,1)
@assert N%2==1
Expand Down

0 comments on commit f98c441

Please sign in to comment.