Skip to content

Commit

Permalink
Use instances instead of types when specifying options
Browse files Browse the repository at this point in the history
This opens up for actually keeping data in the options, even if that
data is not of bits types (and thus not possible to include as a type
parameter), for example a boundar condition Tangent(k) with an interpolation
object that has eltype(itp) <: Array.
  • Loading branch information
tomasaschan committed Oct 5, 2015
1 parent 614f7db commit 4a72de0
Show file tree
Hide file tree
Showing 23 changed files with 129 additions and 119 deletions.
26 changes: 11 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,25 +99,25 @@ B-splines of quadratic or higher degree require solving an equation system to ob
Some examples:
```jl
# Nearest-neighbor interpolation
itp = interpolate(a, BSpline{Constant}, OnCell)
itp = interpolate(a, BSpline(Constant()), OnCell())
v = itp[5.4] # returns a[5]

# (Multi)linear interpolation
itp = interpolate(A, BSpline{Linear}, OnGrid)
itp = interpolate(A, BSpline(Linear()), OnGrid())
v = itp[3.2, 4.1] # returns 0.9*(0.8*A[3,4]+0.2*A[4,4]) + 0.1*(0.8*A[3,5]+0.2*A[4,5])

# Quadratic interpolation with reflecting boundary conditions
# Quadratic is the lowest order that has continuous gradient
itp = interpolate(A, BSpline{Quadratic{Reflect}}, OnCell)
itp = interpolate(A, BSpline(Quadratic(Reflect())), OnCell())

# Linear interpolation in the first dimension, and no interpolation (just lookup) in the second
itp = interpolate(A, Tuple{BSpline{Linear}, BSpline{NoInterp}}, OnGrid)
itp = interpolate(A, (BSpline(Linear()), NoInterp()), OnGrid())
v = itp[3.65, 5] # returns 0.35*A[3,5] + 0.65*A[4,5]
```
There are more options available, for example:
```jl
# In-place interpolation
itp = interpolate!(A, BSpline{Quadratic{InPlace}}, OnCell)
itp = interpolate!(A, BSpline(Quadratic(InPlace())), OnCell())
```
which destroys the input `A` but also does not need to allocate as much memory.

Expand All @@ -133,7 +133,7 @@ In 1D
A = rand(20)
A_x = collect(1.:40.)
knots = (a,)
itp = interpolate(knots,A, Gridded{Linear})
itp = interpolate(knots,A, Gridded(Linear()))
itp[2.0]
```

Expand All @@ -148,22 +148,22 @@ For example:
```jl
A = rand(8,20)
knots = ([x^2 for x = 1:8], [0.2y for y = 1:20])
itp = interpolate(knots, A, Gridded{Linear})
itp = interpolate(knots, A, Gridded(Linear()))
itp[4,1.2] # approximately A[2,6]
```
One may also mix modes, by specifying a mode vector in the form of an explicit tuple:
```jl
itp = interpolate(knots, A, Tuple{Gridded{Linear},Gridded{Constant}})
itp = interpolate(knots, A, (Gridded(Linear()),Gridded(Constant())))
```


Presently there are only three modes for gridded:
```jl
Gridded{Linear}
Gridded(Linear())
```
whereby a linear interpolation is applied between knots,
```jl
Gridded{Constant}
Gridded(Constant())
```
whereby nearest neighbor interpolation is used on the applied axis,
```jl
Expand All @@ -174,11 +174,7 @@ coordinates results in the throwing of an error.

## Extrapolation

The call to `extrapolate` defines what happens if you try to index into the interpolation object with coordinates outside of `[1, size(data,d)]` in any dimension `d`. The implemented boundary conditions are `Throw` and `Flat`, with more options planned.

## More examples

There's an [IJulia notebook](http://nbviewer.ipython.org/github/tlycken/Interpolations.jl/blob/master/doc/Interpolations.jl.ipynb) that shows off some of the current functionality, and outlines where we're headed. I try to keep it up to date when I make any significant improvements and/or breaking changes, but if it's not, do file a PR.
The call to `extrapolate` defines what happens if you try to index into the interpolation object with coordinates outside of `[1, size(data,d)]` in any dimension `d`. The implemented boundary conditions are `Throw`, `Flat`, `Linear`, `Periodic` and `Reflect`, with more options planned. `Periodic` and `Reflect` require that there is a method of `Base.mod` that can handle the indices used.

## Performance shootout

Expand Down
2 changes: 1 addition & 1 deletion doc/devdocs.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ First let's create an interpolation object:
0.134746
0.430876

julia> yitp = interpolate(A, BSpline{Linear}, OnGrid)
julia> yitp = interpolate(A, BSpline(Linear()), OnGrid())
5-element Interpolations.BSplineInterpolation{Float64,1,Float64,Interpolations.BSpline{Interpolations.Linear},Interpolations.OnGrid}:
0.74838
0.995383
Expand Down
18 changes: 9 additions & 9 deletions src/b-splines/b-splines.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ export
abstract Degree{N}

immutable BSpline{D<:Degree} <: InterpolationType end
BSpline{D<:Degree}(::Type{D}) = BSpline{D}
BSpline{D<:Degree}(::D) = BSpline{D}()

bsplinetype{D<:Degree}(::Type{BSpline{D}}) = D

immutable BSplineInterpolation{T,N,TCoefs,IT<:DimSpec{BSpline},GT<:DimSpec{GridType},pad} <: AbstractInterpolation{T,N,IT,GT}
coefs::Array{TCoefs,N}
end
function BSplineInterpolation{N,TCoefs,TWeights<:Real,IT<:DimSpec{BSpline},GT<:DimSpec{GridType},pad}(::Type{TWeights}, A::AbstractArray{TCoefs,N}, ::Type{IT}, ::Type{GT}, ::Val{pad})
function BSplineInterpolation{N,TCoefs,TWeights<:Real,IT<:DimSpec{BSpline},GT<:DimSpec{GridType},pad}(::Type{TWeights}, A::AbstractArray{TCoefs,N}, ::IT, ::GT, ::Val{pad})
isleaftype(IT) || error("The b-spline type must be a leaf type (was $IT)")
isleaftype(TCoefs) || warn("For performance reasons, consider using an array of a concrete type (eltype(A) == $(eltype(A)))")

Expand Down Expand Up @@ -49,12 +49,12 @@ count_interp_dims{T,N,TCoefs,IT<:DimSpec{InterpolationType},GT<:DimSpec{GridType
end
end

function interpolate{TWeights,TCoefs,IT<:DimSpec{BSpline},GT<:DimSpec{GridType}}(::Type{TWeights}, ::Type{TCoefs}, A, ::Type{IT}, ::Type{GT})
function interpolate{TWeights,TCoefs,IT<:DimSpec{BSpline},GT<:DimSpec{GridType}}(::Type{TWeights}, ::Type{TCoefs}, A, it::IT, gt::GT)
Apad, Pad = prefilter(TWeights, TCoefs, A, IT, GT)
BSplineInterpolation(TWeights, Apad, IT, GT, Pad)
BSplineInterpolation(TWeights, Apad, it, gt, Pad)
end
function interpolate{IT<:DimSpec{BSpline},GT<:DimSpec{GridType}}(A::AbstractArray, ::Type{IT}, ::Type{GT})
interpolate(tweight(A), tcoef(A), A, IT, GT)
function interpolate{IT<:DimSpec{BSpline},GT<:DimSpec{GridType}}(A::AbstractArray, it::IT, gt::GT)
interpolate(tweight(A), tcoef(A), A, it, gt)
end

# We can't just return a tuple-of-types due to julia #12500
Expand All @@ -68,9 +68,9 @@ tcoef(A::AbstractArray{Float32}) = Float32
tcoef(A::AbstractArray{Rational{Int}}) = Rational{Int}
tcoef{T<:Integer}(A::AbstractArray{T}) = typeof(float(zero(T)))

interpolate!{TWeights,IT<:DimSpec{BSpline},GT<:DimSpec{GridType}}(::Type{TWeights}, A, ::Type{IT}, ::Type{GT}) = BSplineInterpolation(TWeights, prefilter!(TWeights, A, IT, GT), IT, GT, Val{0}())
function interpolate!{IT<:DimSpec{BSpline},GT<:DimSpec{GridType}}(A::AbstractArray, ::Type{IT}, ::Type{GT})
interpolate!(tweight(A), A, IT, GT)
interpolate!{TWeights,IT<:DimSpec{BSpline},GT<:DimSpec{GridType}}(::Type{TWeights}, A, it::IT, gt::GT) = BSplineInterpolation(TWeights, prefilter!(TWeights, A, IT, GT), it, gt, Val{0}())
function interpolate!{IT<:DimSpec{BSpline},GT<:DimSpec{GridType}}(A::AbstractArray, it::IT, gt::GT)
interpolate!(tweight(A), A, it, gt)
end

include("constant.jl")
Expand Down
2 changes: 1 addition & 1 deletion src/b-splines/quadratic.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
immutable Quadratic{BC<:BoundaryCondition} <: Degree{2} end
Quadratic{BC<:BoundaryCondition}(::Type{BC}) = Quadratic{BC}
Quadratic{BC<:BoundaryCondition}(::BC) = Quadratic{BC}()

function define_indices_d{BC}(::Type{BSpline{Quadratic{BC}}}, d, pad)
symix, symixm, symixp = symbol("ix_",d), symbol("ixm_",d), symbol("ixp_",d)
Expand Down
17 changes: 9 additions & 8 deletions src/extrapolation/extrapolation.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
export Throw,
FilledExtrapolation # for direct control over typeof(fillvalue)
FillValue,
TypedFillValue # for direct control over typeof(fillvalue)

type Extrapolation{T,N,ITPT,IT,GT,ET} <: AbstractInterpolationWrapper{T,N,ITPT,IT,GT}
itp::ITPT
end
Extrapolation{T,ITPT,IT,GT,ET}(::Type{T}, N, itp::ITPT, ::Type{IT}, ::Type{GT}, ::Type{ET}) =
Extrapolation{T,ITPT,IT,GT,ET}(::Type{T}, N, itp::ITPT, ::Type{IT}, ::Type{GT}, et::ET) =
Extrapolation{T,N,ITPT,IT,GT,ET}(itp)

"""
Expand All @@ -15,15 +16,15 @@ The scheme can take any of these values:
* `Throw` - throws a BoundsError for out-of-bounds indices
* `Flat` - for constant extrapolation, taking the closest in-bounds value
* `Linear` - linear extrapolation (the wrapped interpolation object must support gradient)
* `Reflect` - reflecting extrapolation
* `Periodic` - periodic extrapolation
* `Reflect` - reflecting extrapolation (indices must support `mod`)
* `Periodic` - periodic extrapolation (indices must support `mod`)
You can also combine schemes in tuples. For example, the scheme `Tuple{Linear, Flat}` will use linear extrapolation in the first dimension, and constant in the second.
You can also combine schemes in tuples. For example, the scheme `(Linear(), Flat())` will use linear extrapolation in the first dimension, and constant in the second.
Finally, you can specify different extrapolation behavior in different direction. `Tuple{Tuple{Linear,Flat}, Flat}` will extrapolate linearly in the first dimension if the index is too small, but use constant etrapolation if it is too large, and always use constant extrapolation in the second dimension.
Finally, you can specify different extrapolation behavior in different direction. `((Linear(),Flat()), Flat())` will extrapolate linearly in the first dimension if the index is too small, but use constant etrapolation if it is too large, and always use constant extrapolation in the second dimension.
"""
extrapolate{T,N,IT,GT,ET}(itp::AbstractInterpolation{T,N,IT,GT}, ::Type{ET}) =
Extrapolation(T,N,itp,IT,GT,ET)
extrapolate{T,N,IT,GT}(itp::AbstractInterpolation{T,N,IT,GT}, et) =
Extrapolation(T,N,itp,IT,GT,et)

include("throw.jl")
include("flat.jl")
Expand Down
35 changes: 24 additions & 11 deletions src/extrapolation/filled.jl
Original file line number Diff line number Diff line change
@@ -1,23 +1,36 @@
nindexes(N::Int) = N == 1 ? "1 index" : "$N indexes"

abstract AbstractFillValue
immutable FillValue{T} <: AbstractFillValue
val::T
end
immutable TypedFillValue{T} <: AbstractFillValue
val::T
end
TypedFillValue{T}(::Type{T}, v) = TypedFillValue{T}(convert(T, v))

type FilledExtrapolation{T,N,ITP<:AbstractInterpolation,IT,GT,FT} <: AbstractExtrapolation{T,N,ITP,IT,GT}
type FilledExtrapolation{T,N,ITP<:AbstractInterpolation,IT,GT,FT<:AbstractFillValue} <: AbstractExtrapolation{T,N,ITP,IT,GT}
itp::ITP
fillvalue::FT
end
"""
`FilledExtrapolation(itp, fillvalue)` creates an extrapolation object that returns the `fillvalue` any time the indexes in `itp[x1,x2,...]` are out-of-bounds.
FilledExtrapolation{T,N,IT,GT,FT}(itp::AbstractInterpolation{T,N,IT,GT}, fv::FT) = FilledExtrapolation{T,N,typeof(itp),IT,GT,FT}(itp,fv)
# """
# `FilledExtrapolation(itp, fillvalue)` creates an extrapolation object that returns the `fillvalue` any time the indexes in `itp[x1,x2,...]` are out-of-bounds.

By comparison with `extrapolate`, this version lets you control the `fillvalue`'s type directly. It's important for the `fillvalue` to be of the same type as returned by `itp[x1,x2,...]` for in-bounds regions for the index types you are using; otherwise, indexing will be type-unstable (and slow).
"""
function FilledExtrapolation{T,N,IT,GT}(itp::AbstractInterpolation{T,N,IT,GT}, fillvalue)
FilledExtrapolation{T,N,typeof(itp),IT,GT,typeof(fillvalue)}(itp, fillvalue)
end
# By comparison with `extrapolate`, this version lets you control the `fillvalue`'s type directly. It's important for the `fillvalue` to be of the same type as returned by `itp[x1,x2,...]` for in-bounds regions for the index types you are using; otherwise, indexing will be type-unstable (and slow).
# """
# function FilledExtrapolation{T,N,IT,GT}(itp::AbstractInterpolation{T,N,IT,GT}, fillvalue::FillValue)
# FilledExtrapolation{T,N,typeof(itp),IT,GT,typeof(fillvalue)}(itp, fillvalue)
# end

"""
`extrapolate(itp, fillvalue)` creates an extrapolation object that returns the `fillvalue` any time the indexes in `itp[x1,x2,...]` are out-of-bounds.
`extrapolate(itp, fillvalue)` creates an extrapolation object that returns the `fillvalue` any time the indexes in `itp[x1,x2,...]` are out-of-bounds. The type of the fill value will be converted to the eltype of the interpolation object, so that indexing into the extrapolation object is type-stable.
"""
extrapolate{T,N,IT,GT}(itp::AbstractInterpolation{T,N,IT,GT}, fillvalue::FillValue) = FilledExtrapolation(itp, FillValue(convert(T, fillvalue.val)))
"""
`extrapolate(itp, fillvalue<:TypedFillValue)` creates an extrapolation object that returns the `fillvalue` any time the indexes in `itp[x1,x2,...]` are out-of-bounds. The type of the original fill value is not changed, so it is possible to do `extrapolate(itp, TypedFillValue("hello"))` - although indexing into that extrapolation object will now be type unstable.
"""
extrapolate{T,N,IT,GT}(itp::AbstractInterpolation{T,N,IT,GT}, fillvalue) = FilledExtrapolation(itp, convert(eltype(itp), fillvalue))
extrapolate{T,N,IT,GT}(itp::AbstractInterpolation{T,N,IT,GT}, fillvalue::TypedFillValue) = FilledExtrapolation(itp, fillvalue)

@generated function getindex{T,N}(fitp::FilledExtrapolation{T,N}, args::Number...)
n = length(args)
Expand All @@ -27,7 +40,7 @@ extrapolate{T,N,IT,GT}(itp::AbstractInterpolation{T,N,IT,GT}, fillvalue) = Fille
$meta
# Check to see if we're in the extrapolation region, i.e.,
# out-of-bounds in an index
@nexprs $N d->((args[d] < lbound(fitp,d) || args[d] > ubound(fitp, d)) && return fitp.fillvalue)
@nexprs $N d->((args[d] < lbound(fitp,d) || args[d] > ubound(fitp, d)) && return fitp.fillvalue.val)
# In the interpolation region
return getindex(fitp.itp,args...)
end
Expand Down
18 changes: 9 additions & 9 deletions src/gridded/gridded.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export Gridded

immutable Gridded{D<:Degree} <: InterpolationType end
Gridded{D<:Degree}(::Type{D}) = Gridded{D}
Gridded{D<:Degree}(::D) = Gridded{D}()

griddedtype{D<:Degree}(::Type{Gridded{D}}) = D

Expand All @@ -13,7 +13,7 @@ immutable GriddedInterpolation{T,N,TCoefs,IT<:DimSpec{Gridded},K<:Tuple{Vararg{V
knots::K
coefs::Array{TCoefs,N}
end
function GriddedInterpolation{N,TCoefs,TWeights<:Real,IT<:DimSpec{Gridded},pad}(::Type{TWeights}, knots::NTuple{N,GridIndex}, A::AbstractArray{TCoefs,N}, ::Type{IT}, ::Val{pad})
function GriddedInterpolation{N,TCoefs,TWeights<:Real,IT<:DimSpec{Gridded},pad}(::Type{TWeights}, knots::NTuple{N,GridIndex}, A::AbstractArray{TCoefs,N}, ::IT, ::Val{pad})
isleaftype(IT) || error("The b-spline type must be a leaf type (was $IT)")
isleaftype(TCoefs) || warn("For performance reasons, consider using an array of a concrete type (eltype(A) == $(eltype(A)))")

Expand Down Expand Up @@ -48,16 +48,16 @@ iextract{T<:GridType}(::Type{T}, d) = T
end
end

function interpolate{TWeights,TCoefs,Tel,N,IT<:DimSpec{Gridded}}(::Type{TWeights}, ::Type{TCoefs}, knots::NTuple{N,GridIndex}, A::AbstractArray{Tel,N}, ::Type{IT})
GriddedInterpolation(TWeights, knots, A, IT, Val{0}())
function interpolate{TWeights,TCoefs,Tel,N,IT<:DimSpec{Gridded}}(::Type{TWeights}, ::Type{TCoefs}, knots::NTuple{N,GridIndex}, A::AbstractArray{Tel,N}, it::IT)
GriddedInterpolation(TWeights, knots, A, it, Val{0}())
end
function interpolate{Tel,N,IT<:DimSpec{Gridded}}(knots::NTuple{N,GridIndex}, A::AbstractArray{Tel,N}, ::Type{IT})
interpolate(tweight(A), tcoef(A), knots, A, IT)
function interpolate{Tel,N,IT<:DimSpec{Gridded}}(knots::NTuple{N,GridIndex}, A::AbstractArray{Tel,N}, it::IT)
interpolate(tweight(A), tcoef(A), knots, A, it)
end

interpolate!{TWeights,Tel,N,IT<:DimSpec{Gridded}}(::Type{TWeights}, knots::NTuple{N,GridIndex}, A::AbstractArray{Tel,N}, ::Type{IT}) = GriddedInterpolation(TWeights, knots, A, IT, Val{0}())
function interpolate!{Tel,N,IT<:DimSpec{Gridded}}(knots::NTuple{N,GridIndex}, A::AbstractArray{Tel,N}, ::Type{IT})
interpolate!(tweight(A), tcoef(A), knots, A, IT)
interpolate!{TWeights,Tel,N,IT<:DimSpec{Gridded}}(::Type{TWeights}, knots::NTuple{N,GridIndex}, A::AbstractArray{Tel,N}, it::IT) = GriddedInterpolation(TWeights, knots, A, it, Val{0}())
function interpolate!{Tel,N,IT<:DimSpec{Gridded}}(knots::NTuple{N,GridIndex}, A::AbstractArray{Tel,N}, it::IT)
interpolate!(tweight(A), tcoef(A), knots, A, it)
end

include("constant.jl")
Expand Down
12 changes: 6 additions & 6 deletions test/b-splines/constant.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ A2 = rand(Float64, N1, N1) * 100
A3 = rand(Float64, N1, N1, N1) * 100

for (constructor, copier) in ((interpolate, x->x), (interpolate!, copy))
itp1c = @inferred(constructor(copier(A1), BSpline(Constant), OnCell))
itp1g = @inferred(constructor(copier(A1), BSpline(Constant), OnGrid))
itp2c = @inferred(constructor(copier(A2), BSpline(Constant), OnCell))
itp2g = @inferred(constructor(copier(A2), BSpline(Constant), OnGrid))
itp3c = @inferred(constructor(copier(A3), BSpline(Constant), OnCell))
itp3g = @inferred(constructor(copier(A3), BSpline(Constant), OnGrid))
itp1c = @inferred(constructor(copier(A1), BSpline(Constant()), OnCell()))
itp1g = @inferred(constructor(copier(A1), BSpline(Constant()), OnGrid()))
itp2c = @inferred(constructor(copier(A2), BSpline(Constant()), OnCell()))
itp2g = @inferred(constructor(copier(A2), BSpline(Constant()), OnGrid()))
itp3c = @inferred(constructor(copier(A3), BSpline(Constant()), OnCell()))
itp3g = @inferred(constructor(copier(A3), BSpline(Constant()), OnGrid()))

# Evaluation on provided data points
# 1D
Expand Down
6 changes: 3 additions & 3 deletions test/b-splines/linear.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ f(x) = g1(x)
A1 = Float64[f(x) for x in 1:xmax]

for (constructor, copier) in ((interpolate, x->x), (interpolate!, copy))
itp1c = @inferred(constructor(copier(A1), BSpline(Linear), OnCell))
itp1c = @inferred(constructor(copier(A1), BSpline(Linear()), OnCell()))

# Just interpolation
for x in 1:.2:xmax
Expand All @@ -20,7 +20,7 @@ for (constructor, copier) in ((interpolate, x->x), (interpolate!, copy))
# Rational element types
fr(x) = (x^2) // 40 + 2
A1R = Rational{Int}[fr(x) for x in 1:10]
itp1r = @inferred(constructor(copier(A1R), BSpline(Linear), OnGrid))
itp1r = @inferred(constructor(copier(A1R), BSpline(Linear()), OnGrid()))
@test @inferred(size(itp1r)) == size(A1R)
@test_approx_eq_eps itp1r[23//10] fr(23//10) abs(.1*fr(23//10))
@test typeof(itp1r[23//10]) == Rational{Int}
Expand All @@ -31,7 +31,7 @@ for (constructor, copier) in ((interpolate, x->x), (interpolate!, copy))
f(x,y) = g1(x)*g2(y)
ymax = 10
A2 = Float64[f(x,y) for x in 1:xmax, y in 1:ymax]
itp2 = @inferred(constructor(copier(A2), BSpline(Linear), OnGrid))
itp2 = @inferred(constructor(copier(A2), BSpline(Linear()), OnGrid()))
@test @inferred(size(itp2)) == size(A2)

for x in 2.1:.2:xmax-1, y in 1.9:.2:ymax-.9
Expand Down
4 changes: 2 additions & 2 deletions test/b-splines/mixed.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ N = 10
for (constructor, copier) in ((interpolate, x->x), (interpolate!, copy))
A2 = rand(Float64, N, N) * 100
for BC in (Flat,Line,Free,Periodic,Reflect,Natural), GT in (OnGrid, OnCell)
itp_a = @inferred(constructor(copier(A2), Tuple{BSpline(Linear), BSpline(Quadratic(BC))}, GT))
itp_b = @inferred(constructor(copier(A2), Tuple{BSpline(Quadratic(BC)), BSpline(Linear)}, GT))
itp_a = @inferred(constructor(copier(A2), (BSpline(Linear()), BSpline(Quadratic(BC()))), GT()))
itp_b = @inferred(constructor(copier(A2), (BSpline(Quadratic(BC())), BSpline(Linear())), GT()))
@test @inferred(size(itp_a)) == size(A2)
@test @inferred(size(itp_b)) == size(A2)

Expand Down
12 changes: 6 additions & 6 deletions test/b-splines/multivalued.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,20 @@ Base.promote_rule{T1,T2<:Number}(::Type{MyPair{T1}}, ::Type{T2}) = MyPair{promot

# 1d
A = reinterpret(MyPair{Float64}, rand(2, 10), (10,))
itp = interpolate(A, BSpline(Constant), OnGrid)
itp = interpolate(A, BSpline(Constant()), OnGrid())
itp[3.2]
itp = interpolate(A, BSpline(Linear), OnGrid)
itp = interpolate(A, BSpline(Linear()), OnGrid())
itp[3.2]
itp = interpolate(A, BSpline(Quadratic(Flat)), OnGrid)
itp = interpolate(A, BSpline(Quadratic(Flat())), OnGrid())
itp[3.2]

# 2d
A = reinterpret(MyPair{Float64}, rand(2, 10, 5), (10,5))
itp = interpolate(A, BSpline(Constant), OnGrid)
itp = interpolate(A, BSpline(Constant()), OnGrid())
itp[3.2,1.8]
itp = interpolate(A, BSpline(Linear), OnGrid)
itp = interpolate(A, BSpline(Linear()), OnGrid())
itp[3.2,1.8]
itp = interpolate(A, BSpline(Quadratic(Flat)), OnGrid)
itp = interpolate(A, BSpline(Quadratic(Flat())), OnGrid())
itp[3.2,1.8]

end
Loading

0 comments on commit 4a72de0

Please sign in to comment.