comparison 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
comparison
equal deleted inserted replaced
87:38733e84ef1a 88:170e5447bc19
48 end 48 end
49 49
50 # u = L*v 50 # u = L*v
51 using UnsafeArrays 51 using UnsafeArrays
52 @inline function apply!(L::Laplace{2}, u::AbstractVector, v::AbstractVector) 52 @inline function apply!(L::Laplace{2}, u::AbstractVector, v::AbstractVector)
53 u .= 0*u # Fix this? 53 fill!(u,0)
54 h = Grid.spacings(L.grid) 54 h = Grid.spacings(L.grid)
55 55
56 li = LinearIndices(L.grid.numberOfPointsPerDim) 56 li = LinearIndices(L.grid.numberOfPointsPerDim)
57 n_x, n_y = L.grid.numberOfPointsPerDim 57 n_x, n_y = L.grid.numberOfPointsPerDim
58 58
75 for i ∈ eachindex(indices) 75 for i ∈ eachindex(indices)
76 @inbounds u[indices[i]] += temp[i] 76 @inbounds u[indices[i]] += temp[i]
77 end 77 end
78 end 78 end
79 79
80 u .= L.a*u 80 for i ∈ eachindex(u)
81 @inbounds u[i] = L.a*u[i]
82 end
81 83
82 return nothing 84 return nothing
83 end 85 end