Mercurial > repos > public > sbplib_julia
changeset 99:6b6d680f2e25 cell_based_test
Allow apply(::Laplace) to take Index types
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Wed, 06 Feb 2019 09:09:55 +0100 |
parents | 50273f745f05 |
children | 49796ca2dfa0 a274d6384e91 |
files | diffOp.jl |
diffstat | 1 files changed, 9 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/diffOp.jl Wed Feb 06 08:58:32 2019 +0100 +++ b/diffOp.jl Wed Feb 06 09:09:55 2019 +0100 @@ -69,16 +69,21 @@ using UnsafeArrays -# u = L*v -function apply(L::Laplace{2}, v::AbstractArray{T,2} where T, I::CartesianIndex{2}) +function apply(L::Laplace{2}, v::AbstractArray{T,2} where T, I::Tuple{Index{R1}, Index{R2}}) where {R1, R2} h = Grid.spacings(L.grid) # 2nd x-derivative - @inbounds vx = uview(v, :, I[2]) + @inbounds vx = uview(v, :, Int(I[2])) @inbounds uᵢ = apply(L.op, h[1], vx , I[1]) # 2nd y-derivative - @inbounds vy = uview(v, I[1], :) + @inbounds vy = uview(v, Int(I[1]), :) @inbounds uᵢ += apply(L.op, h[2], vy, I[2]) return uᵢ end + +# Slow but maybe convenient? +function apply(L::Laplace{2}, v::AbstractArray{T,2} where T, i::CartesianIndex{2}) + I = Index{Unknown}.(Tuple(i)) + apply(L, v, I) +end