File tree 2 files changed +39
-2
lines changed
2 files changed +39
-2
lines changed Original file line number Diff line number Diff line change @@ -43,8 +43,25 @@ Pkg.add("Interpolations")
43
43
from the Julia REPL.
44
44
45
45
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
+ ```
48
65
49
66
## Performance shootout
50
67
Original file line number Diff line number Diff line change @@ -36,3 +36,23 @@ Pkg.add("Interpolations")
36
36
```
37
37
38
38
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
+ ```
You can’t perform that action at this time.
0 commit comments