|
10 | 10 | //! # Algorithm and Implementation |
11 | 11 | //! |
12 | 12 | //! The crate implements cubic smooting spline algorithm proposed by Carl de Boor in his book |
13 | | -//! ["A Practical Guide to Splines"](https://www.springer.com/gp/book/9780387953663) and inspired by |
| 13 | +//! ["A Practical Guide to Splines"](https://www.springer.com/gp/book/9780387953663) and has been inspired by |
14 | 14 | //! code from MATLAB [CSAPS](https://www.mathworks.com/help/curvefit/csaps.html) function and Fortran |
15 | 15 | //! routine SMOOTH from [PGS](http://pages.cs.wisc.edu/~deboor/pgs/) (originally written by Carl de Boor). |
16 | 16 | //! |
17 | | -//! The algorithm implementation based on [ndarray](https://docs.rs/ndarray) and [sprs](https://docs.rs/sprs) crates. |
| 17 | +//! The algorithm implementation is based on [ndarray](https://docs.rs/ndarray) and [sprs](https://docs.rs/sprs) crates. |
18 | 18 | //! |
19 | 19 | //! # Features |
20 | 20 | //! |
|
70 | 70 | //! println!("yi: {}", yi); |
71 | 71 | //! ``` |
72 | 72 | //! |
| 73 | +//! 2-d grid (surface) data smoothing |
| 74 | +//! |
| 75 | +//! ``` |
| 76 | +//! use ndarray::array; |
| 77 | +//! use csaps::GridCubicSmoothingSpline; |
| 78 | +//! |
| 79 | +//! let x0 = array![1.0, 2.0, 3.0, 4.0]; |
| 80 | +//! let x1 = array![1.0, 2.0, 3.0, 4.0]; |
| 81 | +//! let x = vec![x0.view(), x1.view()]; |
| 82 | +//! |
| 83 | +//! let xi0 = array![1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0]; |
| 84 | +//! let xi1 = array![1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0]; |
| 85 | +//! let xi = vec![xi0.view(), xi1.view()]; |
| 86 | +//! |
| 87 | +//! let y = array![ |
| 88 | +//! [0.5, 1.2, 3.4, 2.5], |
| 89 | +//! [1.5, 2.2, 4.4, 3.5], |
| 90 | +//! [2.5, 3.2, 5.4, 4.5], |
| 91 | +//! [3.5, 4.2, 6.4, 5.5], |
| 92 | +//! ]; |
| 93 | +//! |
| 94 | +//! let yi = GridCubicSmoothingSpline::new(&x, &y) |
| 95 | +//! .make().unwrap() |
| 96 | +//! .evaluate(&x).unwrap(); |
| 97 | +//! |
| 98 | +//! println!("xi: {:?}", xi); |
| 99 | +//! println!("yi: {}", yi); |
| 100 | +//! ``` |
| 101 | +//! |
73 | 102 | //! # Input and Output Data Types |
74 | 103 | //! |
75 | 104 | //! The input data sites and data values should be array-like containers with floating point items |
76 | 105 | //! (`f32` or `f64`). It can be `&ndarray::Array` or `ndarray::ArrayView`, or `&Vec<_>`, or `&[_]`. |
77 | 106 | //! |
78 | 107 | //! The output evaluated data is always `ndarray::Array`. |
79 | 108 | //! |
| 109 | +//! In n-dimensional grid data case the input `x` and `weights` data must be a slice of `ArrayView1`, |
| 110 | +//! but not a slice of `AsArray` array-like because `ndarray::Array` does not implement `AsRef` trait |
| 111 | +//! currently. In the future we might be able to support `AsArray` in n-dimensional grid data case. |
| 112 | +//! |
80 | 113 |
|
81 | 114 | mod errors; |
82 | 115 | mod ndarrayext; |
|
0 commit comments