Skip to content

Commit 17049d8

Browse files
committed
grammar
1 parent c124fb4 commit 17049d8

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed

src/lib.rs

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
//! # Algorithm and Implementation
1111
//!
1212
//! 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
1414
//! code from MATLAB [CSAPS](https://www.mathworks.com/help/curvefit/csaps.html) function and Fortran
1515
//! routine SMOOTH from [PGS](http://pages.cs.wisc.edu/~deboor/pgs/) (originally written by Carl de Boor).
1616
//!
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.
1818
//!
1919
//! # Features
2020
//!
@@ -70,13 +70,46 @@
7070
//! println!("yi: {}", yi);
7171
//! ```
7272
//!
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+
//!
73102
//! # Input and Output Data Types
74103
//!
75104
//! The input data sites and data values should be array-like containers with floating point items
76105
//! (`f32` or `f64`). It can be `&ndarray::Array` or `ndarray::ArrayView`, or `&Vec<_>`, or `&[_]`.
77106
//!
78107
//! The output evaluated data is always `ndarray::Array`.
79108
//!
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+
//!
80113
81114
mod errors;
82115
mod ndarrayext;

0 commit comments

Comments
 (0)