Skip to content

Commit

Permalink
Update Radials.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
Spinachboul authored Mar 28, 2024
1 parent 070749c commit 01a8e67
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Radials.jl
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,20 @@ function _approx_rbf(val, rad::RadialBasis)
n = length(rad.x)
approx = _make_approx(val, rad)

Threads.@threads for i in 1:n
# Define a function to compute tmp for a single index i
function compute_tmp(i)
tmp = zero(eltype(val))
@inbounds @simd ivdep for j in eachindex(val)
tmp += ((val[j] - rad.x[i][j]) / rad.scale_factor)^2
end
tmp = sqrt(tmp)
return sqrt(tmp)
end

# Use pmap to parallelize the computation of tmp
tmp_values = pmap(compute_tmp, 1:n)

# Update the approx using the computed tmp values
for (i, tmp) in enumerate(tmp_values)
_add_tmp_to_approx!(approx, i, tmp, rad)
end

Expand Down

0 comments on commit 01a8e67

Please sign in to comment.