Skip to content

Commit 2afc6ef

Browse files
committed
b-splines pass
1 parent 36665db commit 2afc6ef

File tree

4 files changed

+13
-12
lines changed

4 files changed

+13
-12
lines changed

src/Interpolations.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ export
3535
using Compat
3636
using WoodburyMatrices, Ratios, AxisAlgorithms
3737

38-
import Base: convert, size, getindex, gradient, scale, promote_rule, ndims, eltype
38+
import Base: convert, size, getindex, gradient, promote_rule, ndims, eltype
39+
if isdefined(:scaling) import Base.scaling end
3940

4041
abstract Flag
4142
abstract InterpolationType <: Flag

src/b-splines/b-splines.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ function interpolate!{IT<:DimSpec{BSpline},GT<:DimSpec{GridType}}(A::AbstractArr
7373
interpolate!(tweight(A), A, it, gt)
7474
end
7575

76+
offsetsym(off, d) = off == -1 ? Symbol("ixm_", d) :
77+
off == 0 ? Symbol("ix_", d) :
78+
off == 1 ? Symbol("ixp_", d) :
79+
off == 2 ? Symbol("ixpp_", d) : error("offset $off not recognized")
80+
7681
include("constant.jl")
7782
include("linear.jl")
7883
include("quadratic.jl")

src/b-splines/indexing.jl

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function gradient_impl{T,N,TCoefs,IT<:DimSpec{BSpline},GT<:DimSpec{GridType},Pad
5454
# For each component of the gradient, alternately calculate
5555
# coefficients and set component
5656
n = count_interp_dims(IT, N)
57-
exs = Array(Expr, 2n)
57+
exs = Array{Expr}(2n)
5858
cntr = 0
5959
for d = 1:N
6060
if count_interp_dims(iextract(IT, d), 1) > 0
@@ -104,7 +104,7 @@ for R in [:Real, :Any]
104104
n = count_interp_dims(itp, N)
105105
Tg = promote_type(T, [x <: AbstractArray ? eltype(x) : x for x in xs]...)
106106
xargs = [:(xs[$d]) for d in 1:length(xs)]
107-
:(gradient!(Array($Tg,$n), itp, $(xargs...)))
107+
:(gradient!(Array{$Tg}($n), itp, $(xargs...)))
108108
end
109109
end
110110

@@ -153,12 +153,7 @@ end
153153
n = count_interp_dims(itp,N)
154154
TH = promote_type(T, [x <: AbstractArray ? eltype(x) : x for x in xs]...)
155155
xargs = [:(xs[$d]) for d in 1:length(xs)]
156-
:(hessian!(Array($TH,$n,$n), itp, $(xargs...)))
156+
:(hessian!(Array{TH}($n,$n), itp, $(xargs...)))
157157
end
158158

159159
hessian1{T}(itp::AbstractInterpolation{T,1}, x) = hessian(itp, x)[1,1]
160-
161-
offsetsym(off, d) = off == -1 ? Symbol("ixm_", d) :
162-
off == 0 ? Symbol("ix_", d) :
163-
off == 1 ? Symbol("ixp_", d) :
164-
off == 2 ? Symbol("ixpp_", d) : error("offset $off not recognized")

src/b-splines/prefiltering.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ end
88

99
function padded_index{N,pad}(sz::NTuple{N,Int}, ::Val{pad})
1010
szpad = ntuple(i->sz[i]+2padextract(pad,i), N)::NTuple{N,Int}
11-
ind = Array(UnitRange{Int},N)
11+
ind = Array{UnitRange{Int}}(N)
1212
for i in 1:N
1313
p = padextract(pad,i)
1414
ind[i] = 1+p:szpad[i]-p
@@ -21,7 +21,7 @@ function copy_with_padding{TC,IT<:DimSpec{InterpolationType}}(::Type{TC}, A, ::T
2121
Pad = padding(IT)
2222
ind,sz = padded_index(size(A), Pad)
2323
if sz == size(A)
24-
coefs = copy!(Array(TC, size(A)), A)
24+
coefs = copy!(Array{TC}(size(A)), A)
2525
else
2626
coefs = zeros(TC, sz...)
2727
coefs[ind...] = A
@@ -30,7 +30,7 @@ function copy_with_padding{TC,IT<:DimSpec{InterpolationType}}(::Type{TC}, A, ::T
3030
end
3131

3232
prefilter!{TWeights, IT<:BSpline, GT<:GridType}(::Type{TWeights}, A, ::Type{IT}, ::Type{GT}) = A
33-
prefilter{TWeights, TC, IT<:BSpline, GT<:GridType}(::Type{TWeights}, ::Type{TC}, A, ::Type{IT}, ::Type{GT}) = prefilter!(TWeights, copy!(Array(TC, size(A)), A), IT, GT), Val{0}()
33+
prefilter{TWeights, TC, IT<:BSpline, GT<:GridType}(::Type{TWeights}, ::Type{TC}, A, ::Type{IT}, ::Type{GT}) = prefilter!(TWeights, copy!(Array{TC}(size(A)), A), IT, GT), Val{0}()
3434

3535
function prefilter{TWeights,TC,IT<:Union{Cubic,Quadratic},GT<:GridType}(
3636
::Type{TWeights}, ::Type{TC}, A::AbstractArray, ::Type{BSpline{IT}}, ::Type{GT}

0 commit comments

Comments
 (0)