File tree Expand file tree Collapse file tree 2 files changed +39
-2
lines changed
Expand file tree Collapse file tree 2 files changed +39
-2
lines changed Original file line number Diff line number Diff line change @@ -43,8 +43,25 @@ Pkg.add("Interpolations")
4343from 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
Original file line number Diff line number Diff line change @@ -36,3 +36,23 @@ Pkg.add("Interpolations")
3636```
3737
3838from 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