You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use instances instead of types when specifying options
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.
which destroys the input `A` but also does not need to allocate as much memory.
123
123
@@ -133,7 +133,7 @@ In 1D
133
133
A =rand(20)
134
134
A_x =collect(1.:40.)
135
135
knots = (a,)
136
-
itp =interpolate(knots,A, Gridded{Linear})
136
+
itp =interpolate(knots,A, Gridded(Linear()))
137
137
itp[2.0]
138
138
```
139
139
@@ -148,22 +148,22 @@ For example:
148
148
```jl
149
149
A =rand(8,20)
150
150
knots = ([x^2for x =1:8], [0.2y for y =1:20])
151
-
itp =interpolate(knots, A, Gridded{Linear})
151
+
itp =interpolate(knots, A, Gridded(Linear()))
152
152
itp[4,1.2] # approximately A[2,6]
153
153
```
154
154
One may also mix modes, by specifying a mode vector in the form of an explicit tuple:
155
155
```jl
156
-
itp =interpolate(knots, A, Tuple{Gridded{Linear},Gridded{Constant}})
156
+
itp =interpolate(knots, A, (Gridded(Linear()),Gridded(Constant())))
157
157
```
158
158
159
159
160
160
Presently there are only three modes for gridded:
161
161
```jl
162
-
Gridded{Linear}
162
+
Gridded(Linear())
163
163
```
164
164
whereby a linear interpolation is applied between knots,
165
165
```jl
166
-
Gridded{Constant}
166
+
Gridded(Constant())
167
167
```
168
168
whereby nearest neighbor interpolation is used on the applied axis,
169
169
```jl
@@ -174,11 +174,7 @@ coordinates results in the throwing of an error.
174
174
175
175
## Extrapolation
176
176
177
-
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.
178
-
179
-
## More examples
180
-
181
-
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.
177
+
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.
Copy file name to clipboardExpand all lines: src/extrapolation/extrapolation.jl
+7-7Lines changed: 7 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ export Throw
3
3
type Extrapolation{T,N,ITPT,IT,GT,ET} <:AbstractInterpolationWrapper{T,N,ITPT,IT,GT}
4
4
itp::ITPT
5
5
end
6
-
Extrapolation{T,ITPT,IT,GT,ET}(::Type{T}, N, itp::ITPT, ::Type{IT}, ::Type{GT}, ::Type{ET}) =
6
+
Extrapolation{T,ITPT,IT,GT,ET}(::Type{T}, N, itp::ITPT, ::Type{IT}, ::Type{GT}, et::ET) =
7
7
Extrapolation{T,N,ITPT,IT,GT,ET}(itp)
8
8
9
9
"""
@@ -14,15 +14,15 @@ The scheme can take any of these values:
14
14
* `Throw` - throws a BoundsError for out-of-bounds indices
15
15
* `Flat` - for constant extrapolation, taking the closest in-bounds value
16
16
* `Linear` - linear extrapolation (the wrapped interpolation object must support gradient)
17
-
* `Reflect` - reflecting extrapolation
18
-
* `Periodic` - periodic extrapolation
17
+
* `Reflect` - reflecting extrapolation (indices must support `mod`)
18
+
* `Periodic` - periodic extrapolation (indices must support `mod`)
19
19
20
-
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.
20
+
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.
21
21
22
-
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.
22
+
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.
0 commit comments