Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement Lambert W function #84

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,35 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Portions of this code are derived from SciPy and are licensed under
the Scipy License:

> Copyright (c) 2001, 2002 Enthought, Inc.
> All rights reserved.

> Copyright (c) 2003-2012 SciPy Developers.
> All rights reserved.

> Redistribution and use in source and binary forms, with or without
> modification, are permitted provided that the following conditions are met:

> a. Redistributions of source code must retain the above copyright notice,
> this list of conditions and the following disclaimer.
> b. Redistributions in binary form must reproduce the above copyright
> notice, this list of conditions and the following disclaimer in the
> documentation and/or other materials provided with the distribution.
> c. Neither the name of Enthought nor the names of the SciPy Developers
> may be used to endorse or promote products derived from this software
> without specific prior written permission.
>
> THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
> AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
> IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
> ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
> BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
> OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
> SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
> INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
> CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
> ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
> THE POSSIBILITY OF SUCH DAMAGE.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SpecialFunctions.jl

Special mathematical functions in Julia, including Bessel, Hankel, Airy, error, Dawson, sine and cosine integrals,
eta, zeta, digamma, inverse digamma, trigamma, and polygamma functions.
eta, zeta, digamma, inverse digamma, trigamma, polygamma, and Lambert W functions.
Most of these functions were formerly part of Base.

Note: On Julia 0.7, this package downloads and/or builds
Expand Down
1 change: 1 addition & 0 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ libraries.
| [`besselix(nu,z)`](@ref SpecialFunctions.besselix) | scaled modified Bessel function of the first kind of order `nu` at `z` |
| [`besselk(nu,z)`](@ref SpecialFunctions.besselk) | modified [Bessel function](https://en.wikipedia.org/wiki/Bessel_function) of the second kind of order `nu` at `z` |
| [`besselkx(nu,z)`](@ref SpecialFunctions.besselkx) | scaled modified Bessel function of the second kind of order `nu` at `z` |
| [`lambertw(z,k)`](@ref SpecialFunctions.lambertw) | `k`th branch of the Lambert W function at `z` |

## Installation

Expand Down
3 changes: 3 additions & 0 deletions docs/src/special.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,7 @@ SpecialFunctions.besselk
SpecialFunctions.besselkx
SpecialFunctions.eta
SpecialFunctions.zeta
SpecialFunctions.lambertw
SpecialFunctions.lambertwbp
SpecialFunctions.omega
```
10 changes: 10 additions & 0 deletions src/SpecialFunctions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,20 @@ end
export sinint,
cosint

export lambertw, lambertwbp

const omega_const_bf_ = Ref{BigFloat}()
function __init__()
# allocate storage for this BigFloat constant each time this module is loaded
omega_const_bf_[] =
parse(BigFloat,"0.5671432904097838729999686622103555497538157871865125081351310792230457930866845666932194")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't big"0.56..." better than parse(...)?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you check, for instance with @less big"1.0", you see that the macro does more work.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. @code_llvm big"0.56..." gives a LOT more code.

Copy link
Member

@giordano giordano May 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, big"..." doesn't respect current set precision:

julia> setprecision(1024) do
           precision(big"1.0")
       end
256

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that intended behavior of big"..."? Or should one raise an issue?

end

include("bessel.jl")
include("erf.jl")
include("sincosint.jl")
include("gamma.jl")
include("lambertw.jl")
include("deprecated.jl")

end # module
Loading