From 25fc83ecaf37c24d8d8bb27b678a2bc889895057 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johanna=20S=C3=B6rng=C3=A5rd?= Date: Sat, 28 Mar 2026 17:47:30 +0100 Subject: [PATCH 1/4] Update the `lambert_w` dependency to version 2 --- Cargo.lock | 14 ++++++++++++-- Cargo.toml | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 653a285..3699361 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -130,6 +130,16 @@ dependencies = [ "num-traits", ] +[[package]] +name = "lambert_w" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1809c947da7b51d3b401028c81f6c58c1815c481786a3224a16c84e85a337dd4" +dependencies = [ + "num-complex", + "num-traits", +] + [[package]] name = "libc" version = "0.2.180" @@ -300,7 +310,7 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d0893368b28f4d37983703c75b345967d4c7184ae3306a6c048c0b711573ae3b" dependencies = [ - "lambert_w", + "lambert_w 1.2.34", "num-complex", ] @@ -309,7 +319,7 @@ name = "puruspe" version = "0.4.4" dependencies = [ "approx", - "lambert_w", + "lambert_w 2.0.1", "num-complex", "peroxide", "proptest", diff --git a/Cargo.toml b/Cargo.toml index 73c047e..5ad5bd4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ readme = "README.md" rustdoc-args = ["--html-in-header", "katex-header.html", "--cfg", "docsrs"] [dependencies] -lambert_w = { version = "1.2.34", default-features = false, features = ["std"] } +lambert_w = { version = "2.0.1", default-features = false, features = ["std"] } num-complex = { version = "0.4.6" } [dev-dependencies] From 757090e1e7fba8068b19f0ab6678365cc8b5f1a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johanna=20S=C3=B6rng=C3=A5rd?= Date: Sat, 28 Mar 2026 18:08:47 +0100 Subject: [PATCH 2/4] Re-export the complex function from version 2 with an API that matches our previous one --- src/lib.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 3685db6..b33ae2b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,7 +2,22 @@ // Import from other crates // ============================================================================= // Lambert W functions -pub use lambert_w::{lambert_w, lambert_w0, lambert_wm1, sp_lambert_w0, sp_lambert_wm1}; +pub use lambert_w::{lambert_w0, lambert_wm1, sp_lambert_w0, sp_lambert_wm1}; +use lambert_w::lambert_w as complex_lambert_w; + +// Re-export the complex Lambert W function as the version of `lambert_w` from version 2 of the crate takes an error tolerance, +// which we set to floating point epsilon to match the API and performance of version 1. +/// Branch k of the complex valued Lambert W function computed on 64-bit floats with Halley's method. +/// The return value is a tuple where the first element is the real part and the second element is the imaginary part. +/// +/// The function iterates until the current and previous iterations are within floating point epsilon, or it has iterated a maximum number of times +/// +/// This function may be slightly less accurate close to the branch cut at -1/e, as well as close to zero on branches other than k=0. +/// +/// If you know you want the principal or secondary branches where they are real-valued, take a look at the [`lambert_w0`] or [`lambert_wm1`] functions instead. They can be up to two orders of magnitude faster. +pub fn lambert_w(k: i32, z_re: f64, z_im: f64) -> (f64, f64) { + complex_lambert_w(k, z_re, z_im, f64::EPSILON) +} // ============================================================================= // Export funcionts From 85f2f9a926b8d4b3aed8e9547e61b93d3078fcd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johanna=20S=C3=B6rng=C3=A5rd?= Date: Sat, 28 Mar 2026 18:11:37 +0100 Subject: [PATCH 3/4] End sentence with period --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index b33ae2b..e3e882c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,7 +10,7 @@ use lambert_w::lambert_w as complex_lambert_w; /// Branch k of the complex valued Lambert W function computed on 64-bit floats with Halley's method. /// The return value is a tuple where the first element is the real part and the second element is the imaginary part. /// -/// The function iterates until the current and previous iterations are within floating point epsilon, or it has iterated a maximum number of times +/// The function iterates until the current and previous iterations are within floating point epsilon, or it has iterated a maximum number of times. /// /// This function may be slightly less accurate close to the branch cut at -1/e, as well as close to zero on branches other than k=0. /// From 20cb888f567de10db54e2c2934969da36b5269c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johanna=20S=C3=B6rng=C3=A5rd?= Date: Sat, 28 Mar 2026 18:15:07 +0100 Subject: [PATCH 4/4] Inline wrapper --- src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index e3e882c..f41539a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -15,6 +15,8 @@ use lambert_w::lambert_w as complex_lambert_w; /// This function may be slightly less accurate close to the branch cut at -1/e, as well as close to zero on branches other than k=0. /// /// If you know you want the principal or secondary branches where they are real-valued, take a look at the [`lambert_w0`] or [`lambert_wm1`] functions instead. They can be up to two orders of magnitude faster. +// We inline this function since it's just a trivial wrapper. +#[inline] pub fn lambert_w(k: i32, z_re: f64, z_im: f64) -> (f64, f64) { complex_lambert_w(k, z_re, z_im, f64::EPSILON) }