Skip to content

Commit 1ca330c

Browse files
authored
Merge branch 'master' into AD_interop
2 parents 8a82a9d + 9375e3b commit 1ca330c

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed

README.md

+19-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,25 @@ Pkg.add("Interpolations")
4343
from the Julia REPL.
4444

4545

46-
47-
46+
## Example Usage
47+
Create a grid `xs` and an array `A` of values to be interpolated
48+
```
49+
xs = 1:0.2:5
50+
f(x) = log(x)
51+
A = [f(x) for x in xs]
52+
```
53+
Create linear interpolation object without extrapolation
54+
```
55+
interp_linear = LinearInterpolation(xs, A)
56+
interp_linear(3) # exactly log(3)
57+
interp_linear(3.1) # approximately log(3.1)
58+
interp_linear(0.9) # outside grid: error
59+
```
60+
Create linear interpolation object with extrapolation
61+
```
62+
interp_linear_extrap = LinearInterpolation(xs, A,extrapolation_bc=Line())
63+
interp_linear_extrap(0.9) # outside grid: linear extrapolation
64+
```
4865

4966
## Performance shootout
5067

docs/src/index.md

+20
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,23 @@ Pkg.add("Interpolations")
3636
```
3737

3838
from the Julia REPL.
39+
40+
## Example Usage
41+
Create a grid `xs` and an array `A` of values to be interpolated
42+
```
43+
xs = 1:0.2:5
44+
f(x) = log(x)
45+
A = [f(x) for x in xs]
46+
```
47+
Create linear interpolation object without extrapolation
48+
```
49+
interp_linear = LinearInterpolation(xs, A)
50+
interp_linear(3) # exactly log(3)
51+
interp_linear(3.1) # approximately log(3.1)
52+
interp_linear(0.9) # outside grid: error
53+
```
54+
Create linear interpolation object with extrapolation
55+
```
56+
interp_linear_extrap = LinearInterpolation(xs, A,extrapolation_bc=Line())
57+
interp_linear_extrap(0.9) # outside grid: linear extrapolation
58+
```

0 commit comments

Comments
 (0)