diff diffOp.jl @ 88:170e5447bc19 patch_based_test

Reduce allocations
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Fri, 25 Jan 2019 15:10:41 +0100
parents 38733e84ef1a
children c0729ade65da
line wrap: on
line diff
--- a/diffOp.jl	Fri Jan 25 13:40:15 2019 +0100
+++ b/diffOp.jl	Fri Jan 25 15:10:41 2019 +0100
@@ -50,7 +50,7 @@
 # u = L*v
 using UnsafeArrays
 @inline function apply!(L::Laplace{2}, u::AbstractVector, v::AbstractVector)
-    u .= 0*u # Fix this?
+    fill!(u,0)
     h = Grid.spacings(L.grid)
 
     li = LinearIndices(L.grid.numberOfPointsPerDim)
@@ -77,7 +77,9 @@
         end
     end
 
-    u .= L.a*u
+    for i ∈ eachindex(u)
+        @inbounds u[i] = L.a*u[i]
+    end
 
     return nothing
 end