From ac748f0775f4dd2a11284a29214241baf6f9e70c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johanna=20S=C3=B6rng=C3=A5rd?= Date: Sun, 28 Jul 2024 21:46:00 +0200 Subject: [PATCH] Add example of when the functions are `None` Bump version number, add changes to log --- CHANGELOG.md | 4 ++++ Cargo.lock | 2 +- Cargo.toml | 2 +- src/accurate/mod.rs | 17 +++++++++++++++-- src/fast/mod.rs | 17 +++++++++++++++-- 5 files changed, 36 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f8f0fb7..8a8de4b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 0.2.3 + + - Documentation improvements. + # 0.2.2 - Minor documentation improvements. diff --git a/Cargo.lock b/Cargo.lock index bd1b4de..a5a11a1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,7 +19,7 @@ checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "lambert_w" -version = "0.2.2" +version = "0.2.3" dependencies = [ "approx", ] diff --git a/Cargo.toml b/Cargo.toml index b40ad90..df6a977 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "lambert_w" -version = "0.2.2" +version = "0.2.3" edition = "2021" authors = ["Johanna Sörngård "] categories = ["mathematics"] diff --git a/src/accurate/mod.rs b/src/accurate/mod.rs index 127af03..a4ae864 100644 --- a/src/accurate/mod.rs +++ b/src/accurate/mod.rs @@ -12,8 +12,9 @@ use super::Z0; /// /// Uses the piecewise minimax rational function approximation method of Toshio Fukushima. /// -/// # Example +/// # Examples /// +/// Basic usage: /// ``` /// use lambert_w::accurate::lambert_w_0; /// @@ -24,6 +25,11 @@ use super::Z0; /// /// assert_abs_diff_eq!(w, 1.0736581947961492); /// ``` +/// Too small arguments result in `None`: +/// ``` +/// # use lambert_w::accurate::lambert_w_0; +/// assert_eq!(lambert_w_0(-1.0), None); +/// ``` pub fn lambert_w_0(z: f64) -> Option { dw0c(z - Z0) } @@ -32,8 +38,9 @@ pub fn lambert_w_0(z: f64) -> Option { /// /// Uses the piecewise minimax rational function approximation method of Toshio Fukushima. /// -/// # Example +/// # Examples /// +/// Basic usage: /// ``` /// use lambert_w::accurate::lambert_w_m1; /// @@ -44,6 +51,12 @@ pub fn lambert_w_0(z: f64) -> Option { /// /// assert_abs_diff_eq!(w, -1.6385284199703634); /// ``` +/// Too small or positive arguments result in `None`: +/// ``` +/// # use lambert_w::accurate::lambert_w_m1; +/// assert_eq!(lambert_w_m1(-1.0), None); +/// assert_eq!(lambert_w_m1(1.0), None); +/// ``` pub fn lambert_w_m1(z: f64) -> Option { dwm1c(z, z - Z0) } diff --git a/src/fast/mod.rs b/src/fast/mod.rs index 8451f51..76cd0ce 100644 --- a/src/fast/mod.rs +++ b/src/fast/mod.rs @@ -10,8 +10,9 @@ use swm1::swm1; /// /// Uses the piecewise minimax rational function approximation method of Toshio Fukushima. /// -/// # Example +/// # Examples /// +/// Basic usage: /// ``` /// use lambert_w::fast::lambert_w_0; /// @@ -22,6 +23,11 @@ use swm1::swm1; /// /// assert_abs_diff_eq!(w, 1.0736581947961492, epsilon = 1e-7); /// ``` +/// Too small arguments result in `None`: +/// ``` +/// # use lambert_w::fast::lambert_w_0; +/// assert_eq!(lambert_w_0(-1.0), None); +/// ``` pub fn lambert_w_0(z: f64) -> Option { sw0(z) } @@ -30,8 +36,9 @@ pub fn lambert_w_0(z: f64) -> Option { /// /// Uses the piecewise minimax rational function approximation method of Toshio Fukushima. /// -/// # Example +/// # Examples /// +/// Basic usage: /// ``` /// use lambert_w::fast::lambert_w_m1; /// @@ -42,6 +49,12 @@ pub fn lambert_w_0(z: f64) -> Option { /// /// assert_abs_diff_eq!(w, -1.6385284199703634, epsilon = 1e-7); /// ``` +/// Too small or positive arguments result in `None`: +/// ``` +/// # use lambert_w::fast::lambert_w_m1; +/// assert_eq!(lambert_w_m1(-1.0), None); +/// assert_eq!(lambert_w_m1(1.0), None); +/// ``` pub fn lambert_w_m1(z: f64) -> Option { swm1(z) }