Mercurial > repos > public > sbplib_julia
diff diffOp.jl @ 129:1aaeb46ba5f4 cell_based_test
Improve efficiency of apply by the following:
- Remove divisions in interior loop by storing and multiplying by the reciprocal of grid spacing instead.
- Add @inline to apply(::Laplace
- Remove initialization of w = 0 in apply(::Stencil) by manually unrolling first iteration of the loop.
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Thu, 14 Feb 2019 16:25:22 +0100 |
parents | 631eb9b35d72 |
children | bb1cc9c7877c c6aaf061c0a9 |
line wrap: on
line diff
--- a/diffOp.jl Thu Feb 14 12:46:58 2019 +0100 +++ b/diffOp.jl Thu Feb 14 16:25:22 2019 +0100 @@ -113,13 +113,13 @@ return uᵢ end -function apply(L::Laplace{2}, v::AbstractArray{T,2} where T, I::Tuple{Index{R1}, Index{R2}}) where {R1, R2} +@inline function apply(L::Laplace{2}, v::AbstractArray{T,2} where T, I::Tuple{Index{R1}, Index{R2}}) where {R1, R2} # 2nd x-derivative @inbounds vx = view(v, :, Int(I[2])) - @inbounds uᵢ = L.a*apply(L.op, L.grid.spacing[1], vx , I[1]) + @inbounds uᵢ = L.a*apply(L.op, L.grid.inverse_spacing[1], vx , I[1]) # 2nd y-derivative @inbounds vy = view(v, Int(I[1]), :) - @inbounds uᵢ += L.a*apply(L.op, L.grid.spacing[2], vy, I[2]) + @inbounds uᵢ += L.a*apply(L.op, L.grid.inverse_spacing[2], vy, I[2]) return uᵢ end