diff diffOp.jl @ 78:fbf7398f8154 cell_based_test

Inline and inbounds everything
author Ylva Rydin <ylva.rydin@telia.com>
date Thu, 24 Jan 2019 14:38:14 +0100
parents e4fa13137d12
children b795ec7f9ca0
line wrap: on
line diff
--- a/diffOp.jl	Fri Jan 18 13:51:32 2019 +0100
+++ b/diffOp.jl	Thu Jan 24 14:38:14 2019 +0100
@@ -61,7 +61,7 @@
 end
 
 # u = L*v
-function apply(L::Laplace{2}, v::AbstractVector, i::Int)
+@inline function apply(L::Laplace{2}, v::AbstractVector, i::Int)
     h = Grid.spacings(L.grid)
 
     li = LinearIndices(L.grid.numberOfPointsPerDim)
@@ -69,10 +69,10 @@
     I = ci[i]
 
     # 2nd x-derivative
-    vx = view(v, view(li,:,I[2]))
+    vx = @inbounds view(v, view(li,:,I[2]))
     uᵢ  = apply(L.op, h[1], vx , I[1])
     # 2nd y-derivative
-    vy = view(v, view(li,I[1],:))
+    vy = @inbounds view(v, view(li,I[1],:))
     uᵢ += apply(L.op, h[2], vy, I[2])
 
     return uᵢ