1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
//! A re-write of [`GSL's Interpolation`] in Rust.
//!
//! ## Notes
//!
//! 1. `rsl-interpolation` requires LAPACK FFI, so you must use **just one** of the corresponding
//! [`ndarray_linalg features`]:
//!
//! ```text
//! [dependencies]
//! rsl-interpolation = { version = "0.1.19", features = ["ndarray-linalg/openblas-system"]}
//! ```
//!
//! 2. In 2d Interpolation, the `za` array must be defined in **column-major (Fortran)** style.
//! This is done to comply with GSL's interface.
//!
//!
//! # 1D Interpolation Types
//!
//! + [`LinearInterpolator`]
//! + [`CubicInterpolator`]
//! + [`CubicPeriodicInterpolator`]
//! + [`AkimaInterpolator`]
//! + [`AkimaPeriodicInterpolator`]
//! + [`SteffenInterpolator`]
//!
//! # 2D Interpolation Types
//!
//! + [`BilinearInterpolator`]
//! + [`BicubicInterpolator`]
//!
//! # Lower level interface
//!
//! + Interpolation type must be known at compilation time.
//! + The [`Interpolation`]/[`Interpolation2d`] objects do not store the arrays they were
//! constructed with; they must be passed as arguments at each evaluation.
//!
//! ## 1D Interpolation
//!
//! ```
//! # use rsl_interpolation::*;
//! # fn main() -> Result<(), InterpolationError>{
//! let xa = [0.0, 1.0, 2.0, 3.0, 4.0, 5.0];
//! let ya = [0.0, 2.0, 4.0, 6.0, 8.0, 10.0];
//! let interp = CubicInterpolator::build(&xa, &ya)?;
//!
//! let x = 3.9;
//! let acc = &mut Accelerator::new();
//! let y = interp.eval(&xa, &ya, x, acc)?;
//! let dy = interp.eval_deriv(&xa, &ya, x, acc)?;
//! let dy2 = interp.eval_deriv2(&xa, &ya, x, acc)?;
//! let int = interp.eval_integ(&xa, &ya, 0.4, 3.1, acc)?;
//! # Ok(())
//! # }
//! ```
//!
//! ## 2D Interpolation
//!
//! ```
//! # use rsl_interpolation::*;
//! # fn main() -> Result<(), InterpolationError>{
//! let xa = [0.0, 1.0, 2.0, 3.0];
//! let ya = [0.0, 2.0, 4.0, 6.0];
//! // z = x + y, in column-major order
//! let za = [
//! 0.0, 1.0, 2.0, 3.0,
//! 2.0, 3.0, 4.0, 5.0,
//! 4.0, 5.0, 6.0, 7.0,
//! 6.0, 7.0, 8.0, 9.0,
//! ];
//! let interp = BicubicInterpolator::build(&xa, &ya, &za)?;
//!
//! let (x, y) = (1.2, 2.8);
//! let acc = &mut Accelerator2d::new();
//! let z = interp.eval(&xa, &ya, &za, x, y, acc)?;
//! let dzdx = interp.eval_deriv_x(&xa, &ya, &za, x, y, acc)?;
//! let dzdy = interp.eval_deriv_y(&xa, &ya, &za, x, y, acc)?;
//! let dzdxx = interp.eval_deriv_xx(&xa, &ya, &za, x, y, acc)?;
//! let dzdyy = interp.eval_deriv_yy(&xa, &ya, &za, x, y, acc)?;
//! let dzdxy = interp.eval_deriv_xy(&xa, &ya, &za, x, y, acc)?;
//! # Ok(())
//! # }
//! ```
//!
//! # Higher level interface
//!
//! + Interpolation type can be determined at runtime.
//! + The [`Spline`]/[`Spline2d`] objects own the data they was constructed with, and provide
//! the same evaluation methods as the lower-level [`Interpolation`]/[`Interpolation2d`] object,
//! without needing to provide the data arrays in every call.
//!
//! ## 1D Interpolation
//!
//! ```
//! # use rsl_interpolation::*;
//! # fn main() -> Result<(), InterpolationError>{
//! let xa = [0.0, 1.0, 2.0, 3.0, 4.0, 5.0];
//! let ya = [0.0, 2.0, 4.0, 6.0, 8.0, 10.0];
//! let spline = Spline::build::<CubicInterpolator>(&xa, &ya)?;
//!
//! let x = 3.9;
//! let acc = &mut Accelerator::new();
//! let y = spline.eval(x, acc)?;
//! let dy = spline.eval_deriv(x, acc)?;
//! let dy2 = spline.eval_deriv2(x, acc)?;
//! let int = spline.eval_integ(0.4, 3.1, acc)?;
//! # Ok(())
//! # }
//! ```
//!
//! ## 2D Interpolation
//!
//! ```
//! # use rsl_interpolation::*;
//! # fn main() -> Result<(), InterpolationError>{
//! let xa = [0.0, 1.0, 2.0, 3.0];
//! let ya = [0.0, 2.0, 4.0, 6.0];
//! // z = x + y, in column-major order
//! let za = [
//! 0.0, 1.0, 2.0, 3.0,
//! 2.0, 3.0, 4.0, 5.0,
//! 4.0, 5.0, 6.0, 7.0,
//! 6.0, 7.0, 8.0, 9.0,
//! ];
//! let spline = Spline2d::build::<BicubicInterpolator>(&xa, &ya, &za)?;
//!
//! let (x, y) = (1.2, 2.8);
//! let acc = &mut Accelerator2d::new();
//! let z = spline.eval(x, y, acc)?;
//! let dzdx = spline.eval_deriv_x(x, y, acc)?;
//! let dzdy = spline.eval_deriv_y(x, y, acc)?;
//! let dzdxx = spline.eval_deriv_xx(x, y, acc)?;
//! let dzdyy = spline.eval_deriv_yy(x, y, acc)?;
//! let dzdxy = spline.eval_deriv_xy(x, y, acc)?;
//! # Ok(())
//! # }
//! ```
//!
//!
//! # Extra features
//!
//! + [`Accelerator2d`]: 2D Index Look-up accelerator. The generalization of the [`Accelerator`]
//! object for two dimensional interpolation.
//!
//! [`GSL's Interpolation`]: https://www.gnu.org/software/gsl/doc/html/interp.html
//! [`ndarray_linalg features`]: https://github.com/rust-ndarray/ndarray-linalg?tab=readme-ov-file#backend-features
pub use ;
// Public API
pub use Accelerator;
pub use Accelerator2d;
pub use *;
pub use ;
pub use ;
pub use Spline;
pub use Spline2d;
pub use ;