Mercurial > repos > public > sbplib_julia
comparison diffOp.jl @ 90:2882e1318cc3 patch_based_test
Add TODO:s on how to remove allocations in apply! for Laplace2d
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Fri, 25 Jan 2019 16:49:09 +0100 |
parents | c0729ade65da |
children |
comparison
equal
deleted
inserted
replaced
89:c0729ade65da | 90:2882e1318cc3 |
---|---|
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 |
59 | 59 |
60 # For each x | 60 # For each x |
61 #TODO: Can remove temporary if we pass u and indices to apply! | |
61 temp = zeros(eltype(u), n_y) | 62 temp = zeros(eltype(u), n_y) |
62 for i ∈ 1:n_x | 63 for i ∈ 1:n_x |
63 @inbounds indices = uview(li,i,:) | 64 @inbounds indices = uview(li,i,:) |
64 @inbounds apply!(L.op, temp, uview(v, indices), h[2]) | 65 @inbounds apply!(L.op, temp, uview(v, indices), h[2]) |
65 for i ∈ eachindex(indices) | 66 for i ∈ eachindex(indices) |
66 @inbounds u[indices[i]] = temp[i] | 67 @inbounds u[indices[i]] = temp[i] |
67 end | 68 end |
68 end | 69 end |
69 | 70 |
70 # For each y | 71 # For each y |
72 #TODO: Can remove temporary if we pass u and indices to apply! | |
71 temp = zeros(eltype(u), n_x) | 73 temp = zeros(eltype(u), n_x) |
72 for i ∈ 1:n_y | 74 for i ∈ 1:n_y |
73 @inbounds indices = uview(li,:,i) | 75 @inbounds indices = uview(li,:,i) |
74 @inbounds apply!(L.op, temp, uview(v, indices), h[1]) | 76 @inbounds apply!(L.op, temp, uview(v, indices), h[1]) |
75 for i ∈ eachindex(indices) | 77 for i ∈ eachindex(indices) |