From 9eb54a8a921b8ed5f5337c4d42b1aa32f03e8fb3 Mon Sep 17 00:00:00 2001 From: Tomas Lycken Date: Wed, 8 Apr 2015 18:42:10 +0200 Subject: [PATCH] Fix #55 --- src/interp.jl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/interp.jl b/src/interp.jl index be99593..d014e4f 100644 --- a/src/interp.jl +++ b/src/interp.jl @@ -603,18 +603,18 @@ function interp_coords_1d(coord1d::Vector{Int}, ::Type{InterpLinear}) end # version for indices function interp_coords_1d{T,BC<:BoundaryCondition}(coord1d::Vector{Int}, ::Type{BC}, ::Type{InterpLinear}, x::T, len::Int) - ifx = trunc(Int, x) + ifx = floor(Int, x) dx = x-ifx ifx -= x < convert(T, ifx) ix = wrap(BC, ifx, len) @inbounds coord1d[1] = ix - iswrap = (ix == len && dx > 0) - @inbounds coord1d[2] = wrap(BC, ix+1, len) + iswrap = (ix == len && dx > 0) || (ix == 1 && ifx < 1) + @inbounds coord1d[2] = iswrap ? ix : wrap(BC, ix+1, len) return ix, dx, iswrap end function interp_coords_1d{T}(coord1d::Vector{Int}, ::Type{BCreflect}, ::Type{InterpLinear}, x::T, len::Int) ix = mod(floor(Int, x)-1, 2*len) - dx = x-trunc(x) + dx = x-floor(Int, x) if ix < len ix += 1 ixp = ix+1