Mercurial > repos > public > sbplib_julia
comparison sbpD2.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 | d485da6e3a77 |
children | b795ec7f9ca0 |
comparison
equal
deleted
inserted
replaced
70:e4fa13137d12 | 78:fbf7398f8154 |
---|---|
1 abstract type ConstantStencilOperator end | 1 abstract type ConstantStencilOperator end |
2 | 2 |
3 function apply(op::ConstantStencilOperator, h::Real, v::AbstractVector, i::Int) | 3 @inline function apply(op::ConstantStencilOperator, h::Real, v::AbstractVector, i::Int) |
4 cSize = closureSize(op) | 4 cSize = closureSize(op) |
5 N = length(v) | 5 N = length(v) |
6 | 6 |
7 if i ∈ range(1; length=cSize) | 7 if i ∈ range(1; length=cSize) |
8 uᵢ = apply(op.closureStencils[i], v, i)/h^2 | 8 uᵢ = @inbounds apply(op.closureStencils[i], v, i)/h^2 |
9 elseif i ∈ range(N - cSize+1, length=cSize) | 9 elseif i ∈ range(N - cSize+1, length=cSize) |
10 uᵢ = Int(op.parity)*apply(flip(op.closureStencils[N-i+1]), v, i)/h^2 | 10 uᵢ = @inbounds Int(op.parity)*apply(flip(op.closureStencils[N-i+1]), v, i)/h^2 |
11 else | 11 else |
12 uᵢ = apply(op.innerStencil, v, i)/h^2 | 12 uᵢ = @inbounds apply(op.innerStencil, v, i)/h^2 |
13 end | 13 end |
14 | 14 |
15 return uᵢ | 15 return uᵢ |
16 end | 16 end |
17 | 17 |