Skip to content

Commit 046e535

Browse files
authored
Merge pull request #164 from JuliaMath/teh/migrating_from_grid
README: include tips for migrating from Grid.
2 parents 0349718 + 6ab758a commit 046e535

File tree

1 file changed

+35
-3
lines changed

1 file changed

+35
-3
lines changed

README.md

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ itp = interpolate(A, options...)
4545
```
4646
where `options...` (discussed below) controls the type of
4747
interpolation you want to perform. This syntax assumes that the
48-
samples in `A` are equally-spaced.
48+
samples in `A` are equally-spaced.
4949

5050
To evaluate the interpolation at position `(x, y, ...)`, simply do
5151
```jl
@@ -135,7 +135,7 @@ itp = interpolate!(A, BSpline(Quadratic(InPlace())), OnCell())
135135
```
136136
which destroys the input `A` but also does not need to allocate as much memory.
137137

138-
### Scaled BSplines
138+
### Scaled BSplines
139139

140140
BSplines assume your data is uniformly spaced on the grid `1:N`, or its multidimensional equivalent. If you have data of the form `[f(x) for x in A]`, you need to tell Interpolations about the grid `A`. If `A` is not uniformly spaced, you must use gridded interpolation described below. However, if `A` is a collection of ranges or linspaces, you can use scaled BSplines. This is more efficient because the gridded algorithm does not exploit the uniform spacing. Scaled BSplines can also be used with any spline degree available for BSplines, while gridded interpolation does not currently support quadratic or cubic splines.
141141

@@ -173,7 +173,7 @@ A = rand(20)
173173
A_x = collect(1.0:2.0:40.0)
174174
knots = (A_x,)
175175
itp = interpolate(knots, A, Gridded(Linear()))
176-
itp[2.0]
176+
itp[2.0]
177177
```
178178

179179
The spacing between adjacent samples need not be constant, you can use the syntax
@@ -279,6 +279,38 @@ they ran more than 20 seconds (far longer than any other test). Both
279279
performed much better in 2d, interestingly. You can see that
280280
Interpolations wins in every case, sometimes by a very large margin.
281281

282+
## Transitioning from Grid.jl
283+
284+
Instead of using
285+
```julia
286+
yi = InterpGrid(y, BCreflect, InterpQuadratic)
287+
```
288+
you should use
289+
```julia
290+
yi = interpolate(y, BSpline(Quadratic(Reflect())), OnCell())
291+
```
292+
293+
In general, here are the closest mappings:
294+
295+
| Grid | Interpolations |
296+
|:-----------------:|:------------------------------------------:|
297+
| `InterpNearest` | `Constant` |
298+
| `InterpLinear` | `Linear` |
299+
| `InterpQuadratic` | `Quadratic` |
300+
| `InterpCubic` | `Cubic` |
301+
| | |
302+
| `BCnil` | `extrapolate(itp, Interpolations.Throw())` |
303+
| `BCnan` | `extrapolate(itp, NaN)` |
304+
| `BCna` | `extrapolate(itp, NaN)` |
305+
| `BCreflect` | `interpolate` with `Reflect()` |
306+
| `BCperiodic` | `interpolate` with `Periodic()` |
307+
| `BCnearest` | `interpolate` with `Flat()` |
308+
| `BCfill` | `extrapolate` with value |
309+
| | |
310+
| odd orders | `OnGrid()` |
311+
| even orders | `OnCell()` |
312+
313+
282314
## Contributing
283315

284316
Work is very much in progress, but and help is always welcome. If you want to help out but don't know where to start, take a look at issue [#5 - our feature wishlist](https://github.com/JuliaMath/Interpolations.jl/issues/5) =) There is also some [developer documentation](doc/devdocs.md) that may help you understand how things work internally.

0 commit comments

Comments
 (0)