juliamath / specialfunctions.jl Goto Github PK
View Code? Open in Web Editor NEWSpecial mathematical functions in Julia
Home Page: https://specialfunctions.juliamath.org/stable/
License: Other
Special mathematical functions in Julia
Home Page: https://specialfunctions.juliamath.org/stable/
License: Other
On v0.6.2:
julia> using SpecialFunctions
julia> besselj0([1.0])
ERROR: besselj0([1.0],) has been moved to the package SpecialFunctions.jl.
Run Pkg.add("SpecialFunctions") to install SpecialFunctions on Julia v0.6 and later,
and then run `using SpecialFunctions`.
Stacktrace:
[1] besselj0(::Array{Float64,1}) at ./deprecated.jl:1303
I believe this is happening because the old Base.besselj0
had "broadcasted" methods besselj0(::Array{T,N})
attached to it. All of these methods got deprecated at some point, but SpecialFunctions only supplies the methods SpecialFunctions.besselj0(::T)
for a few values of T
.
Anyway, this error message is pretty obscure, and I'm not sure how to improve it.
Thanks. :)
I have found that bessely() with very large argument returns various results. For example,
julia> using SpecialFunctions
julia> bessely(1000.5, 7.745186719805684e8)
-1.65447992609e-312
julia> x = bessely(1000.5, 7.745186719805684e8)
1.3586779285536575e24
The assignment to x
enhances the effect, though different answers are returned without assignment as well.
I am using julia-v0.6.1
on x86_64 archlinux. The effect is less severe, but also present, on my macosx machine, which is running 0.6.1-pre3. Finally, on archlinux, I've also seen it with v0.6.2-pre.2
, commit 247087d94c.
Based on @tkelman's comment on JuliaMath/openspecfun#44, it sounds like @nolta was in the midst of porting the Fortran functions to pure Julia, after which I assume they'd be removed entirely from SpecialFunctions. Is that true?
It seems to me that this project could be made much simpler by using BinDeps with openspecfun as a binary dependency, thereby excluding the Fortran code from the repo and instead relying on openspecfun, which appears to be well maintained. That also avoids having to reinvent the wheel in terms of porting everything to Julia, unless that was a central goal.
Edit: Using openspecfun would also give us the Faddeeva functions as well as amos.
erfcx(big(1.0))
erfcx(1.000000000000000000000000000000000000000000000000000000000000000000000000000000,) has been moved to the package SpecialFunctions.jl.
Run Pkg.add("SpecialFunctions") to install SpecialFunctions on Julia v0.6 and later,
and then runusing SpecialFunctions
.Stacktrace:
[1] erfcx(::BigFloat) at ./deprecated.jl:1303
[2] include_string(::String, ::String) at ./loading.jl:522
I'm trying to update some code that currently uses my own implementation of the inverse Laplace transform to use InverseLaplace.jl instead. My code makes a call like SpecialFunctions.besselk(0, x)
. My implementation of the inverse Laplace transform results in x
having type Float64
, but InverseLaplace.jl wants x
to be a BigFloat
. This creates a problem
julia> SpecialFunctions.besselk(0, 1.0)
0.42102443824070834
julia> SpecialFunctions.besselk(0, BigFloat(1.0))
ERROR: MethodError: no method matching besselk(::BigFloat, ::Complex{BigFloat})
Closest candidates are:
besselk(::T<:AbstractFloat, ::Complex{T<:AbstractFloat}) where T<:AbstractFloat at /homedir/.julia/v0.6/SpecialFunctions/src/bessel.jl:502
besselk(::Real, ::Complex) at /homedir/.julia/v0.6/SpecialFunctions/src/bessel.jl:499
besselk(::Any...; kwargs...) at deprecated.jl:1303
...
Stacktrace:
[1] besselk(::Float64, ::Complex{BigFloat}) at /homedir/.julia/v0.6/SpecialFunctions/src/bessel.jl:500
[2] besselk(::Int64, ::BigFloat) at /homedir/.julia/v0.6/SpecialFunctions/src/bessel.jl:450
It seems like that first candidate fits the bill, but julia disagrees.
Using SpecialFunctions
println(erfcinv(1)) # all is OK
println(erfcinv(BigFloat(1))) # wrong error message -- erfcinv was moved to SpecialFunctions
The problem is that error message is confusing -- erfcinv can't handle BigFloat right now, but error message says that it is a problem of the package.
takes about half an hour of waiting with no feedback or progress indication to fail with the following output.
_
_ _ _(_)_ | A fresh approach to technical computing
(_) | (_) (_) | Documentation: https://docs.julialang.org
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 0.7.0-rc1.4 (2018-08-01 00:52 UTC)
_/ |\__'_|_|_|\__'_| | Commit 0ef8826 (0 days old master)
|__/ | x86_64-linux-gnu
(v0.7) pkg> add SpecialFunctions
Updating registry at `~/.julia/registries/General`
Updating git-repo `https://github.com/JuliaRegistries/General.git`
Resolving package versions...
Installed SpecialFunctions ─ v0.6.0
Updating `~/.julia/environments/v0.7/Project.toml`
[276daf66] + SpecialFunctions v0.6.0
Updating `~/.julia/environments/v0.7/Manifest.toml`
[276daf66] + SpecialFunctions v0.6.0
Building SpecialFunctions → `~/.julia/packages/SpecialFunctions/kvjJe/deps/build.log`
┌ Error: Error building `SpecialFunctions`:
│ WARNING: Base.UVError is deprecated, use IOError instead.
│ likely near /home/csto/.julia/packages/SpecialFunctions/kvjJe/deps/build.jl:2
│ WARNING: Base.UVError is deprecated, use IOError instead.
│ likely near /home/csto/.julia/packages/SpecialFunctions/kvjJe/deps/build.jl:2
│ in safe_isfile at /home/csto/.julia/packages/BinaryProvider/mWARv/src/Prefix.jl
│ [ Info: Downloading https://github.com/JuliaMath/OpenspecfunBuilder/releases/download/v0.5.3-1/libopenspecfun.x86_64-linux-gnu.tar.gz to /home/csto/.julia/p
ackages/SpecialFunctions/kvjJe/deps/usr/downloads/libopenspecfun.x86_64-linux-gnu.tar.gz...
│ ┌ Warning: `wait(t::Task)` is deprecated, use `fetch(t)` instead.
│ │ caller = macro expansion at OutputCollector.jl:62 [inlined]
│ └ @ Core ~/.julia/packages/BinaryProvider/mWARv/src/OutputCollector.jl:62
│ ┌ Warning: `wait(t::Task)` is deprecated, use `fetch(t)` instead.
│ │ caller = wait(::OutputCollector) at OutputCollector.jl:160
│ └ @ BinaryProvider ~/.julia/packages/BinaryProvider/mWARv/src/OutputCollector.jl:160
│ ┌ Warning: `wait(t::Task)` is deprecated, use `fetch(t)` instead.
│ │ caller = wait(::OutputCollector) at OutputCollector.jl:161
│ └ @ BinaryProvider ~/.julia/packages/BinaryProvider/mWARv/src/OutputCollector.jl:161
│ ┌ Warning: `wait(t::Task)` is deprecated, use `fetch(t)` instead.
│ │ caller = wait(::OutputCollector) at OutputCollector.jl:165
│ └ @ BinaryProvider ~/.julia/packages/BinaryProvider/mWARv/src/OutputCollector.jl:165
│ ┌ Warning: `search(s::AbstractString, c::Char)` is deprecated, use `something(findfirst(isequal(c), s), 0)` instead.
│ │ caller = (::getfield(BinaryProvider, Symbol("#url_ext#96")))(::String) at PlatformEngines.jl:641
│ └ @ BinaryProvider ~/.julia/packages/BinaryProvider/mWARv/src/PlatformEngines.jl:641
│ ┌ Warning: `rsearch(s::AbstractString, c::Char)` is deprecated, use `something(findlast(isequal(c), s), 0)` instead.
│ │ caller = (::getfield(BinaryProvider, Symbol("#url_ext#96")))(::String) at PlatformEngines.jl:647
│ └ @ BinaryProvider ~/.julia/packages/BinaryProvider/mWARv/src/PlatformEngines.jl:647
│ [ Info: Downloading https://github.com/JuliaLang/openlibm/archive/v0.5.4.tar.gz to /tmp/juliaNxGhtg-download.gz...
│ [ Info: No hash cache found
│ [ Info: Calculated hash 9a8ae1d17825a4a6a4c013d36a7f4348b27c47eedb6549c521ecc9c79d021c13 for file /tmp/juliaNxGhtg-download.gz
│ [ Info: Unpacking /tmp/juliaNxGhtg-download.gz into /home/csto/.julia/packages/SpecialFunctions/kvjJe/deps/src...
│ ┌ Warning: The `remove_destination` keyword argument is deprecated; use `force` instead
│ │ caller = ip:0x0
│ └ @ Core :-1
│ ┌ Warning: `is_apple` is deprecated, use `Sys.isapple` instead.
│ │ caller = top-level scope at none:0
│ └ @ Core none:0
│ ┌ Warning: The start/next/done iteration protocol is deprecated. Use `iterate` instead.
│ │ caller = iterate(::Symbol) at essentials.jl:853
│ └ @ Base ./essentials.jl:853
│ ERROR: LoadError: LoadError: StackOverflowError:
│ Stacktrace:
│ ... (the last 2 lines are repeated 39984 more times)
│ [79976] _methods_by_ftype at ./reflection.jl:717 [inlined]
│ [79976] _methods_by_ftype(::Any, ::Int64, ::UInt64) at ./reflection.jl:714
│ [79976] _methods at ./reflection.jl:710 [inlined]
│ [79976] has_non_default_iterate(::Type) at ./essentials.jl:868
│ [79976] start(::Symbol) at ./essentials.jl:878
│ [79976] iterate(::Symbol) at ./essentials.jl:853
│ [79976] start(::Symbol) at ./essentials.jl:880
│ [79976] iterate(::Symbol) at ./essentials.jl:853
│ in expression starting at /home/csto/.julia/packages/SpecialFunctions/kvjJe/deps/scratch.jl:87
│ in expression starting at /home/csto/.julia/packages/SpecialFunctions/kvjJe/deps/build.jl:2
[11:29:38] ######################################################################## 100.0%
[11:29:41] ######################################################################## 100.0%
└ @ Pkg.Operations ~/Applications/julia-0.7/usr/share/julia/stdlib/v0.7/Pkg/src/Operations.jl:1061
I am also trying on OSX but that one is still "running" after 30 min or so. I'd like to try and fix this but I don't quite know where to start
Despite the check of the julia version on the export
statement in SpecialFunctions.jl, the vectorization deprecation warnings still export some functions.
Example: on julia 0.5:
julia-0.5> using SpecialFunctions
julia-0.5> erf
WARNING: both SpecialFunctions and Base export "erf"; uses of it in module Main must be qualified
ERROR: UndefVarError: erf not defined
Of course, this breaks compatibility in code that is supposed to work on julia 0.5 and later.
hi Julia could please help me with these problems?
I tried to use this in c++: factorial (numero)+factorial(numero-1);
I need to print this factorial serie by using functions: 2, 3, 8, 30, 144,, I tried but it does not work.
numero means the termin or place wich will be realized the operation, for example if numero=4
so 4! + (4-1)! = 30 and 30 is the 4 place of the serie.
#include
//Exercise 130.print this factorial serie by using functions in c++: 2, 3, 8, 30, 144,etc.
using std::cin;
using std::cout;
using std::endl;
unsigned long factorial(unsigned long);
int main(int argc, char** argv) {
for(int i=0; i<=10; i ++)/
cout<<i<<"!="<<factorial(i)<<endl;
return 0;
}
unsigned long factorial(unsigned long numero)
{
if(numero<=1)
return 1;
else
return factorial (numero)+factorial(numero-1);
}
We have the same problem here as we do with Primes.jl: The functions are defined both here and in Base Julia but will eventually be removed from the latter. Should we remove the export
for now and perhaps switch it to a conditional export (as is currently done with Primes) once the functions are removed from Base?
While attempting to do a fresh install of SpecialFunctions in Julia v. 0.6.0 on Fedora 26 Linux (x86_64), the package fails to compile. Following error is reported:
julia> Pkg.add("SpecialFunctions")
INFO: Cloning cache of SpecialFunctions from https://github.com/JuliaMath/SpecialFunctions.jl.git
INFO: Installing SpecialFunctions v0.3.2
INFO: Building SpecialFunctions
INFO: No precompiled binaries found for your system. Building from scratch...
========================================================[ ERROR: SpecialFunctions ]=========================================================
LoadError: LoadError: ArgumentError: 'src' and 'dst' refer to the same file/dir.This is not supported.
`src` refers to: /usr/lib64/libopenlibm.so.2
`dst` refers to: /usr/lib64/libopenlibm.so.2
while loading /home/<my-user-name>/.julia/v0.6/SpecialFunctions/deps/scratch.jl, in expression starting on line 8
while loading /home/<my-user-name>/.julia/v0.6/SpecialFunctions/deps/build.jl, in expression starting on line 40
============================================================================================================================================
==============================================================[ BUILD ERRORS ]==============================================================
WARNING: SpecialFunctions had build errors.
- packages with build errors remain installed in /home/<my-user-name>/.julia/v0.6
- build the package(s) and all dependencies with `Pkg.build("SpecialFunctions")`
- build a single package by running its `deps/build.jl` script
============================================================================================================================================
I removed the package through
julia> Pkg.rm("SpecialFunctions")
then I quit the Julia REPL, deleted the package from Julia's cache in my home directory, restarted the Julia REPL and tried reinstalling , with the same result.
I found in my system two different versions of libopenlibm.so
:
/usr/lib64/libopenlibm.so.2
/usr/lib64/libopenlibm.so.2.3
but I don't know whether this has anything to do with the build problems at all.
julia> versioninfo()
Julia Version 0.6.0
Commit 903644385b* (2017-06-19 13:05 UTC)
Platform Info:
OS: Linux (x86_64-redhat-linux)
CPU: AMD FX(tm)-6300 Six-Core Processor
WORD_SIZE: 64
BLAS: libopenblas (DYNAMIC_ARCH Piledriver)
LAPACK: libopenblasp.so.0
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, bdver1)
The original readme for AMOS, part of Netlib, was:
A Portable Package for Bessel Functions of a Complex Argument
and Nonnegative OrderThis algorithm is a package of subroutines for computing Bessel
functions and Airy functions. The routines are updated
versions of those routines found in TOMS algorithm 644.
As far as I understand these are semi-automated fortran-julia translations, and the Wiki statement "The code base of Netlib was written at a time when computer software was not yet considered a merchandise. Therefore, no license terms or terms of use are stated for many programs." applies. Does anybody have the link to the translation script? Also: "This algorithm is a package of subroutines"... Hm? ;-)
Subtitle:
Julia implementations of Bessel and Airy functions
Summary:
Port of the Netlib package AMOS. AMOS, "A portable package for Bessel Functions of a Complex Argument and Nonnegative Order" contains subroutines for computing Bessel functions and Airy functions in Fortran. The code was translated to Julia using a semi-automated process.
The package description currently reads:
"Julia implementations of Bessel and Airy functions"
But actually there is more than that here now.
as given in first sentence of readme:
Special mathematical functions in Julia, including Bessel, Hankel, Airy, error, Dawson, sine and cosine integrals, eta, zeta, digamma, inverse digamma, trigamma, and polygamma functions.
@MikaelSlevinsky Has an implementation of Gauss Hypergeometric function ₂F₁ currently living in SingularIntegralEquations.jl:
It would be nice to move this out so that others can use it. Is this the right home for this? If so, I can make a PR.
Something to consider is the level of reliability of special functions. One can either take the Mathematica approach of "it's better to give the wrong answer than no answer at all" or a more restrictive "it's better to give no answer at all than the right answer if unsure". The latter seems safer, but in the case of Hypergeometric functions the number of parameters makes this burdensome.
It might make sense to have two packages, this one and an UntestedSpecialFunctions.jl.
I'd like to propose that we bump the Julia version requirement from the current 0.4- to 0.5-, and in doing so also remove the @vectorize_*
calls in favor of .
broadcasts. These will likely be deprecated in Base soon anyway, given the move away from implicit vectorization.
Since this package isn't registered I figured this wouldn't be too controversial, though I could certainly be wrong. Thoughts?
SpecialFunctions.jl fails to build on v0.7 because it cannot download libpopenspecfun-0.5.3. I fixed this myself by manually download it from github link. I'm not sure why this happens.
julia> Pkg.installed("SpecialFunctions")
v"0.3.8"
here is my versioninfo:
Julia Version 0.7.0-DEV.4719
Commit 34a8068 (2018-03-29 02:45 UTC)
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: Intel(R) Core(TM) i5-4200M CPU @ 2.50GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, haswell)
Environment:
Verctorized erfinv
seems to be missing, Julia 0.6,
julia> using SpecialFunctions
julia> erf(zeros(2))
WARNING: erf{T <: Number}(x::AbstractArray{T}) is deprecated, use ($(Expr(:globalref, Compat, Symbol("@compat"))))(erf.(x)) instead.
2-element Array{Float64,1}:
0.0
0.0
julia> erfinv(zeros(2))
ERROR: erfinv([0.0, 0.0],) has been moved to the package SpecialFunctions.jl.
Run Pkg.add("SpecialFunctions") to install SpecialFunctions on Julia v0.6 and later,
and then run `using SpecialFunctions`.
On Julia 0.6 commit commit b70b52b4f4685ca9859d6b3e4bd1a377406ad1cc (tag: v0.1.0)
I'm experiencing the following behaviour:
besselj(-55, Complex128(1.0e-4, 0.0))
will throw AmosException(2)
Since besselj(-55, 1.0e-4)
does not throw an error, I assume that there is a bug for the Complex case?
I am having a problem with using digamma
on 0.6.2.
Say I have this code saved in reproducible.jl
:
module ReproducibleError
using SpecialFunctions
function make_error()
return digamma(rand(10))
end
end #module
When I try to call make_error
I get the following:
julia> VERSION
v"0.6.2"
julia> include("/projects/juliadev/misc/reproducible.jl")
ReproducibleError
julia> ReproducibleError.make_error()
ERROR: digamma([0.00682959, 0.856906, 0.855035, 0.524282, 0.89706, 0.874412, 0.948103, 0.815427, 0.339152, 0.530628],) has been moved to the package SpecialFunctions.jl.
Run Pkg.add("SpecialFunctions") to install SpecialFunctions on Julia v0.6 and later,
and then run `using SpecialFunctions`.
Stacktrace:
[1] make_error() at /projects/juliadev/misc/reproducible.jl:7
However, if I type using SpecialFunctions
directly into the REPL I can use digamma
just fine... in the REPL. Can't figure why the module isn't importing properly into another.
I get the following error on 0.3.3 which is not present if I use 0.3.1 instead:
julia> Pkg.build("SpecialFunctions")
INFO: Building SpecialFunctions
INFO: Attempting to Create directory /wrk/mmillea/.julia/v0.6/SpecialFunctions/deps/downloads
INFO: Directory /wrk/mmillea/.julia/v0.6/SpecialFunctions/deps/downloads already created
INFO: Downloading file https://github.com/ararslan/openspecfun-builder/releases/download/v0.5.3/libopenspecfun-0.5.3-linux-x86_64.tar.gz
INFO: Done downloading file https://github.com/ararslan/openspecfun-builder/releases/download/v0.5.3/libopenspecfun-0.5.3-linux-x86_64.tar.gz
INFO: Attempting to Create directory /wrk/mmillea/.julia/v0.6/SpecialFunctions
INFO: Directory /wrk/mmillea/.julia/v0.6/SpecialFunctions already created
INFO: Path /wrk/mmillea/.julia/v0.6/SpecialFunctions/deps/usr/lib already created
====================================================[ ERROR: SpecialFunctions ]=====================================================
LoadError: Provider BinDeps.Binaries failed to satisfy dependency libopenspecfun
while loading /wrk/mmillea/.julia/v0.6/SpecialFunctions/deps/build.jl, in expression starting on line 43
====================================================================================================================================
==========================================================[ BUILD ERRORS ]==========================================================
WARNING: SpecialFunctions had build errors.
- packages with build errors remain installed in /wrk/mmillea/.julia/v0.6
- build the package(s) and all dependencies with `Pkg.build("SpecialFunctions")`
- build a single package by running its `deps/build.jl` script
====================================================================================================================================
>using SpecialFunctions
>erf([1,1])
erf([1, 1],) has been moved to the package SpecialFunctions.jl.
Run Pkg.add("SpecialFunctions") to install SpecialFunctions on Julia v0.6 and later,
and then run `using SpecialFunctions`.
The extra comma in the error message looks fishy to me, otherwise I'm stumped.
Calling besseli(nu, 0)
with nu < 0 raises an exception: SpecialFunctions.AmosException(1)
. This is correct for non-integer nu, but besseli(nu, 0)
should return 0 for integer nu (except nu=0). The problem is caused by the call to besselk(nu, 0)
which is divergent. Can the term 2_besselk(-nu,z,Int32(1))*sinpi(nu)/pi
be set to 0 for integer nu to avoid this exception? Cheers!
Hello. My understanding is that some of the special functions previously defined in Base have been moved to SpecialFunctions.jl. However, when I look at erf
for example, all of the three executions:
erf(1.0)
Base.erf(1.0)
SpecialFunctions.erf(1.0)
work (I'm using julia v0.6.1). Is erf
defined both on Base and Specialfunctions.jl now, but will soon be only available in SpecialFunctions.jl? And which one is called if I simply execute erf(1.0)
? Or all of the above three lines call the same function so that I don't have to worry about? I would greatly appreciate it if you could explain what is the current status on some of the special functions.
Happy Thanksgiving!
BVPs
PS: Of course, I know the following note (from the SpecialFunctions.jl document):
Prior to Julia 0.6, most of these functions were available in Julia's Base module.
Because of this, the symbols from this package are not exported on Julia 0.5 to avoid name conflicts.
In this case, the symbols will need to be explicitly imported or called with the prefix SpecialFunctions.
This is not necessary for Julia versions 0.6 and later.
Maybe it's there and I'm not seeing it, but is there a way straightforward way to evaluate the incomplete gamma function?
For integer n, we should have besselj(-n,0.0) = 0.0 + 0.0im
instead we get:
besselj(-1,0.0)
Base.Math.AmosException(1)
in _bessely(::Float64, ::Complex{Float64}, ::Int32) at ./special/bessel.jl:231
in besselj(::Float64, ::Complex{Float64}) at ./special/bessel.jl:294
in besselj(::Int64, ::Complex{Float64}) at ./special/bessel.jl:458
I believe this is a bug.
If n is not an integer than besselj(-n,0.0)
leads to a complex infinity, and so should probably throw an AmosException(1)
It world be nice to have Spherilcal Bessel and Hankel functions available
https://dlmf.nist.gov/10.47
This morning Pkg.update()
tries to downgrade SpecialFunctions
but then fails to build.
julia> versioninfo()
Julia Version 0.7.0-DEV.2771
Commit 7925161770 (2017-12-06 07:43 UTC)
Platform Info:
OS: Linux (x86_64-suse-linux)
CPU: Intel(R) Core(TM) i5-4460 CPU @ 3.20GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, haswell)
Environment:
with error:
julia> Pkg.build("SpecialFunctions")
INFO: Building SpecialFunctions
==========================[ ERROR: SpecialFunctions ]===========================
LoadError: LoadError: MethodError: Cannot `convert` an object of type Char to an object of type Symbol
This may have arisen from a call to the constructor Symbol(...),
since type constructors fall back to convert methods.
in expression starting at /home/colin/.julia/v0.7/SpecialFunctions/deps/binaries.jl:37
in expression starting at /home/colin/.julia/v0.7/SpecialFunctions/deps/build.jl:6
JuliaLang/julia#18584, would be nice to preserve @oxinabox's authorship as well
There is a builder at https://github.com/JuliaMath/OpenspecfunBuilder and there is a PR to update it. However, it looks like BinaryBuilder currently doesn't support Fortran for FreeBSD builds (see JuliaPackaging/BinaryBuilder.jl#277) so, hopefully, there will be some progress on the cross compiler soon. Please contribute there if you care about FreeBSD support otherwise we might need to drop support for FreeBSD.
julia> using SpecialFunctions
julia> gamma(big(0))
signal (11): Segmentation fault: 11
in expression starting at no file:0
mpfr_lgamma at /Users/solver/Projects/julia7/usr/lib/libmpfr.6.dylib (unknown line)
gamma at /Users/solver/.julia/packages/SpecialFunctions/49Wj/src/gamma.jl:717
gamma at /Users/solver/.julia/packages/SpecialFunctions/49Wj/src/gamma.jl:557
jl_fptr_trampoline at /Users/solver/Projects/julia7/src/gf.c:1813
do_call at /Users/solver/Projects/julia7/src/interpreter.c:324
eval_stmt_value at /Users/solver/Projects/julia7/src/interpreter.c:363 [inlined]
eval_body at /Users/solver/Projects/julia7/src/interpreter.c:671
jl_interpret_toplevel_thunk_callback at /Users/solver/Projects/julia7/src/interpreter.c:788
unknown function (ip: 0xfffffffffffffffe)
unknown function (ip: 0x115a5b66f)
unknown function (ip: 0x0)
jl_interpret_toplevel_thunk at /Users/solver/Projects/julia7/src/interpreter.c:797
jl_toplevel_eval_flex at /Users/solver/Projects/julia7/src/toplevel.c:814
jl_toplevel_eval_in at /Users/solver/Projects/julia7/src/builtins.c:631
eval at ./boot.jl:319
eval_user_input at /Users/solver/Projects/julia7/usr/share/julia/stdlib/v0.7/REPL/src/REPL.jl:85
macro expansion at /Users/solver/Projects/julia7/usr/share/julia/stdlib/v0.7/REPL/src/REPL.jl:116 [inlined]
#28 at ./task.jl:257
jl_fptr_trampoline at /Users/solver/Projects/julia7/src/gf.c:1813
jl_apply at /Users/solver/Projects/julia7/src/./julia.h:1533 [inlined]
start_task at /Users/solver/Projects/julia7/src/task.c:268
Allocations: 3659197 (Pool: 3658607; Big: 590); GC: 7
Segmentation fault: 11
In JuliaLang/julia#17130 (comment), @tkelman mentioned that everything in base/special would be moved into this package. I wanted to clarify a few things and figured that here would be a better place to do that than on Katharine's PR.
Currently this project is only including the Fortran functions defined in AMOS, whereas base/special also includes things from Faddeeva (e.g. erf
) and OpenLibm (e.g. gamma
). So this project will inherit Faddeeva and OpenLibm stuff as well? The OpenLibm dependency is a nonissue since it's included with Julia anyway, but Faddeeva is more Fortran and I assume that once base/special is migrated out of Base, Faddeeva will no longer be included with Julia. That means we either have to do the Fortran -> Julia translation thing, rewrite the functions in pure Julia, or introduce a Fortran binary dependency. Right?
I'm very new to julia, so not sure I managed to find the actual source code being used for those bessel(jhy) functions. There's a related thread suggesting that the chosen algorithm for integer arguments is different.
Nonetheless, for the general case, the Amos implementation returns a sequence of bessel functions, nu+I-1, I=1,...,N, and it would be very nice if the julia wrapper could return the whole sequence. Currently, I believe julia implements vectorisation over nu as a for loop and just takes the one value from the Amos sequence (or openlibm's).
Since it is not uncommon to need a sequence of values (Bessel functions tend to be used in recurrence relations), it is a bit wasteful to iterate over nu when it was already done at the Fortran level.
_
_ _ _(_)_ | A fresh approach to technical computing
(_) | (_) (_) | Documentation: https://docs.julialang.org
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 0.7.0-beta.105 (2018-07-01 09:04 UTC)
_/ |\__'_|_|_|\__'_| | Commit 656d58782c* (0 days old master)
|__/ | x86_64-apple-darwin17.6.0
julia> using SpecialFunctions
julia> factorial(5.0)
ERROR: factorial(x::Number) has been moved to the package SpecialFunctions.jl.
Run `Pkg.add("SpecialFunctions")` to install it, restart Julia,
and then run `using SpecialFunctions` to load it.
Stacktrace:
[1] error at ./error.jl:33 [inlined]
[2] factorial(::Float64) at ./deprecated.jl:1701
[3] top-level scope at none:0
julia> SpecialFunctions.factorial(5.0)
120.0
julia> factorial(5)
120
Is this expected (using [276daf66] SpecialFunctions v0.5.0
):
julia> gamma(big(1.0))
signal (11): Segmentation fault: 11
in expression starting at no file:0
mpfr_lgamma at /Applications/Julia-0.7.app/Contents/Resources/julia/lib/julia/libmpfr.6.dylib (unknown line)
gamma at /Users/verzani/.julia/packages/SpecialFunctions/49Wj/src/gamma.jl:717
jl_fptr_trampoline at /Users/osx/buildbot/slave/package_osx64/build/src/gf.c:1813
do_call at /Users/osx/buildbot/slave/package_osx64/build/src/interpreter.c:324
eval_stmt_value at /Users/osx/buildbot/slave/package_osx64/build/src/interpreter.c:363 [inlined]
eval_body at /Users/osx/buildbot/slave/package_osx64/build/src/interpreter.c:690
jl_interpret_toplevel_thunk_callback at /Users/osx/buildbot/slave/package_osx64/build/src/interpreter.c:788
unknown function (ip: 0xfffffffffffffffe)
unknown function (ip: 0x11dfaf84f)
unknown function (ip: 0x0)
jl_interpret_toplevel_thunk at /Users/osx/buildbot/slave/package_osx64/build/src/interpreter.c:797
jl_toplevel_eval_flex at /Users/osx/buildbot/slave/package_osx64/build/src/toplevel.c:814
jl_toplevel_eval_in at /Users/osx/buildbot/slave/package_osx64/build/src/builtins.c:631
eval at ./boot.jl:319
eval_user_input at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v0.7/REPL/src/REPL.jl:85
macro expansion at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v0.7/REPL/src/REPL.jl:116 [inlined]
#28 at ./task.jl:257
jl_fptr_trampoline at /Users/osx/buildbot/slave/package_osx64/build/src/gf.c:1813
jl_apply at /Users/osx/buildbot/slave/package_osx64/build/src/./julia.h:1533 [inlined]
start_task at /Users/osx/buildbot/slave/package_osx64/build/src/task.c:268
Allocations: 5394358 (Pool: 5393337; Big: 1021); GC: 11
Segmentation fault: 11
The list of functions at http://juliamath.github.io/SpecialFunctions.jl/latest/ doesn't cover all the implemented functions. For example, polygamma
is not documented although it is available. Also the ordering of functions in the table seems incomprehensible.
The list at http://juliamath.github.io/SpecialFunctions.jl/latest/special.html has all the functions as it seems autogenerated from the source code. How about just removing the hand-maintained table? Following the DRY principle, the autogenerated list is much better in terms of maintenance cost.
Matlab has an airyaizero function, Julia doesn't. It should. The desired function computes zeros of the airy functions.
Pkg.build("SpecialFunctions")
[ Info: Building SpecialFunctions
┌ Warning: `info()` is deprecated, use `@info` instead.
│ caller = top-level scope at <missing>:10
└ @ Core <missing>:10
INFO: Building openspecfun from source by request
ERROR: LoadError: LoadError: UndefVarError: Libdl not defined
Stacktrace:
[1] top-level scope
[2] include at ./boot.jl:292 [inlined]
[3] include_relative(::Module, ::String) at ./loading.jl:521
[4] include at ./sysimg.jl:26 [inlined]
[5] include(::String) at /home/chris/.julia/v0.7/BinDeps/src/BinDeps.jl:3
[6] top-level scope
[7] include at ./boot.jl:292 [inlined]
[8] include_relative(::Module, ::String) at ./loading.jl:521
[9] include(::Module, ::String) at ./sysimg.jl:26
[10] top-level scope
[11] eval at ./boot.jl:295 [inlined]
[12] top-level scope at ./<missing>:2
in expression starting at /home/chris/.julia/v0.7/BinDeps/src/dependencies.jl:636
in expression starting at /home/chris/.julia/v0.7/BinDeps/src/BinDeps.jl:583
┌ Error: ------------------------------------------------------------
│ # Build failed for SpecialFunctions
│ exception =
│ LoadError: LoadError: Failed to precompile BinDeps to /home/chris/.julia/lib/v0.7/BinDeps.ji.
│ Stacktrace:
│ [1] error at ./error.jl:33 [inlined]
│ [2] compilecache(::String) at ./loading.jl:648
│ [3] compilecache at ./loading.jl:605 [inlined]
│ [4] _require(::Symbol) at ./loading.jl:440
│ [5] require(::Symbol) at ./loading.jl:333
│ [6] include at ./boot.jl:292 [inlined]
│ [7] include_relative(::Module, ::String) at ./loading.jl:521
│ [8] include at ./sysimg.jl:26 [inlined]
│ [9] include at ./loading.jl:555 [inlined]
│ [10] top-level scope at ./<missing>:11
│ [11] include at ./boot.jl:292 [inlined]
│ [12] include_relative(::Module, ::String) at ./loading.jl:521
│ [13] include at ./sysimg.jl:26 [inlined]
│ [14] include(::String) at ./loading.jl:555
│ [15] top-level scope
│ [16] eval at ./boot.jl:295 [inlined]
│ [17] eval at ./sysimg.jl:71 [inlined]
│ [18] evalfile(::String, ::Array{String,1}) at ./loading.jl:550 (repeats 2 times)
│ [19] #2 at ./none:12 [inlined]
│ [20] cd(::getfield(, Symbol("##2#5")){String}, ::String) at ./file.jl:70
│ [21] (::getfield(, Symbol("##1#3")))(::IOStream) at ./none:11
│ [22] open(::getfield(, Symbol("##1#3")), ::String, ::String) at ./iostream.jl:310
│ [23] top-level scope
│ [24] eval at ./boot.jl:295 [inlined]
│ [25] eval(::Module, ::Expr) at ./sysimg.jl:71
│ [26] process_options(::Base.JLOptions) at ./client.jl:301
│ [27] _start() at ./client.jl:375
│ in expression starting at /home/chris/.julia/v0.7/SpecialFunctions/deps/scratch.jl:3
│ in expression starting at /home/chris/.julia/v0.7/SpecialFunctions/deps/build.jl:6
└ @ Main none:15
┌ Warning: ------------------------------------------------------------
│ # Build error summary
│
│ SpecialFunctions had build errors.
│
│ - packages with build errors remain installed in /home/chris/.julia/v0.7
│ - build the package(s) and all dependencies with `Pkg.build("SpecialFunctions")`
│ - build a single package by running its `deps/build.jl` script
└ @ Base.Pkg.Entry entry.jl:656
julia> libc_ptr = ccall(:jl_dlopen, Ptr{Cvoid}, (Ptr{Cvoid}, UInt32), C_NULL, 0)
Ptr{Nothing} @0x00007f7f62f68150
julia> glibc_ptr = Libdl.dlsym_e(libc_ptr, :gnu_get_libc_version)
ERROR: UndefVarError: Libdl not defined
julia> using Libdl
julia> glibc_ptr = Libdl.dlsym_e(libc_ptr, :gnu_get_libc_version)
Ptr{Nothing} @0x00007f7f61bf52d0
julia> versioninfo()
Julia Version 0.7.0-DEV.3393
Commit c5cd13ebe3* (2018-01-13 05:40 UTC)
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: Intel(R) Core(TM) i3-4010U CPU @ 1.70GHz
WORD_SIZE: 64
BLAS: libmkl_rt
LAPACK: libmkl_rt
LIBM: libimf
LLVM: libLLVM-3.9.1 (ORCJIT, haswell)
Environment:
Edit:
Adding using Libdl
to SpecialFunctions/deps/build.jl
alone is not enough to fix the problem. I also had to add it to BinDeps, but then I got LoadError: LoadError: UndefVarError: pushfront! not defined
.
Because I couldn't find anything about a Julia function called pushfront!
, and the error occurred in deps/binaries.jl
, I set ENV["JULIA_SPECIALFUNCTIONS_BUILD_SOURCE"] = true
and SpecialFunctions built just fine.
Builds just fine, but it wont precompile.
Then the problem was:
julia> @checked_lib openspecfun "/home/chris/.julia/v0.7/SpecialFunctions/deps/usr/lib/libopenspecfun.so"
ERROR: LoadError: UndefVarError: Libdl not defined
Stacktrace:
[1] @checked_lib(::LineNumberNode, ::Module, ::Any, ::Any) at /home/chris/.julia/v0.7/SpecialFunctions/deps/deps.jl:8
in expression starting at REPL[6]:1
So I edited `/deps/deps.jl' from:
macro checked_lib(libname, path)
((VERSION >= v"0.4.0-dev+3844" ? Base.Libdl.dlopen_e : Base.dlopen_e)(path) == C_NULL) && error("Unable to l$
quote const $(esc(libname)) = $path end
end
# Load dependencies
@checked_lib openspecfun "/home/chris/.julia/v0.7/SpecialFunctions/deps/usr/lib/libopenspecfun.so"
to:
using Libdl
macro checked_lib(libname, path)
((VERSION >= v"0.4.0-dev+3844" ? Libdl.dlopen_e : Base.dlopen_e)(path) == C_NULL) && error("Unable to l$
quote const $(esc(libname)) = $path end
end
# Load dependencies
@checked_lib openspecfun "/home/chris/.julia/v0.7/SpecialFunctions/deps/usr/lib/libopenspecfun.so"
Now everything works on my computer.
This is still an issue instead of a pull request, because there is probably a much cleaner way to fix the problem. (Short term when Compat updates?)
Eg, the file deps/deps.jl seems to have been created by the install process, so I would have to look into that.
Here is code to compute zeros of the besselj function. Are you interested in a PR ?
It could be more efficient, maybe cache some of first zeros. But, it works. The asymptotic formula happens to land in the basin of the correct zero, even for the first zero. It then uses root finding.
There are many special functions which use the Pochhammer function, and I believe this package could use and efficient version via the @horner
macro.
Is that within the scope for a PR?
It is also worth considering including the Stirling numbers of the first and second kind (though they are already defined in Combinatorics.jl) so as to make implmentations of many other special functions easier -- for example, the Bell polynomials.
Maybe these functions could be moved to SpecialFunctions.jl.
This is a common special function that it would be nice to include. It already is supplied by MPFR, which gives us a BigFloat
version. (Issue copied/moved from JuliaLang/julia#7089.)
See also the julia-users discussion on exponential integrals.
Some potentially useful references:
Of course, the usual copyright caveats apply: don't even look at the source code of any of these, just the equations. Especially for the ACM TOMS journal, the most evil journal in numerical analysis.
I assigned the problem of implementing E₁
to double-precision accuracy in the right-half complex plain (real(z) ≥ 0
) in problem set 3 of our course 18.S096 this January. In the solutions, I showed how to implement it using a combination of Taylor series and continued fractions, with some custom macros to do inlining, and got performance 5–6 times faster than the Fortran code used in SciPy.
This should be helpful as a starting point for more full-featured implementations. (The macros to simplify and inline continued-fraction expansions may also be useful in other special functions.)
There are two packages for the Lambert W function:
LambertW.jl, and
Surely the Lambert W function is special enough for the special club.
julia> Pkg.build("SpecialFunctions")
INFO: Building SpecialFunctions
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 126 0 126 0 0 126 0 --:--:-- --:--:-- --:--:-- 510
100 344k 100 344k 0 0 344k 0 0:00:01 --:--:-- 0:00:01 939k
WARNING: is_windows is deprecated, use Sys.iswindows instead.
Stacktrace:
[1] depwarn at ./deprecated.jl:68 [inlined]
[2] is_windows() at ./deprecated.jl:31
[3] download_cmd(::String, ::String) at /home/alex/.julia/v0.7/BinDeps/src/BinDeps.jl:49
[4] lower(::BinDeps.FileDownloader, ::BinDeps.SynchronousStepCollection) at /home/alex/.julia/v0.7/BinDeps/src/BinDeps.jl:268
[5] macro expansion at /home/alex/.julia/v0.7/BinDeps/src/BinDeps.jl:268 [inlined]
[6] generate_steps(::BinDeps.LibraryDependency, ::BinDeps.NetworkSource, ::Dict{Symbol,Any}) at /home/alex/.julia/v0.7/BinDeps/src/dependencies.jl:483
[7] lower(::BinDeps.GetSources, ::BinDeps.SynchronousStepCollection) at /home/alex/.julia/v0.7/BinDeps/src/dependencies.jl:321
[8] top-level scope at /home/alex/.julia/v0.7/BinDeps/src/BinDeps.jl:268
[9] include_relative(::Module, ::String) at ./loading.jl:509
[10] include at ./sysimg.jl:15 [inlined]
[11] include(::String) at ./loading.jl:543
[12] top-level scope at ./<missing>:17
[13] include_relative(::Module, ::String) at ./loading.jl:509
[14] include at ./sysimg.jl:15 [inlined]
[15] include(::String) at ./loading.jl:543
[16] top-level scope
[17] evalfile(::String, ::Array{String,1}) at ./loading.jl:538
[18] cd(::getfield(, Symbol("##2#4")){String}, ::String) at ./file.jl:70
[19] (::getfield(, Symbol("##1#3")))(::IOStream) at ./none:11
[20] open(::getfield(, Symbol("##1#3")), ::String, ::String) at ./iostream.jl:194
[21] top-level scope
[22] eval(::Module, ::Expr) at ./sysimg.jl:60
[23] process_options(::Base.JLOptions) at ./client.jl:322
[24] _start() at ./client.jl:406
in expression starting at /usr/home/alex/.julia/v0.7/SpecialFunctions/deps/scratch.jl:268
WARNING: is_windows is deprecated, use Sys.iswindows instead.
Stacktrace:
[1] depwarn at ./deprecated.jl:68 [inlined]
[2] is_windows() at ./deprecated.jl:31
[3] #_find_library#46(::Type, ::Function, ::BinDeps.LibraryDependency) at /home/alex/.julia/v0.7/BinDeps/src/dependencies.jl:646
[4] satisfy!(::BinDeps.LibraryDependency, ::Array{DataType,1}) at /home/alex/.julia/v0.7/BinDeps/src/dependencies.jl:895 (repeats 2 times)
[5] macro expansion at /home/alex/.julia/v0.7/BinDeps/src/dependencies.jl:950 [inlined]
[6] top-level scope at ./<missing>:126
[7] include_relative(::Module, ::String) at ./loading.jl:509
[8] include at ./sysimg.jl:15 [inlined]
[9] include(::String) at ./loading.jl:543
[10] top-level scope at ./<missing>:17
[11] include_relative(::Module, ::String) at ./loading.jl:509
[12] include at ./sysimg.jl:15 [inlined]
[13] include(::String) at ./loading.jl:543
[14] top-level scope
[15] evalfile(::String, ::Array{String,1}) at ./loading.jl:538
[16] cd(::getfield(, Symbol("##2#4")){String}, ::String) at ./file.jl:70
[17] (::getfield(, Symbol("##1#3")))(::IOStream) at ./none:11
[18] open(::getfield(, Symbol("##1#3")), ::String, ::String) at ./iostream.jl:194
[19] top-level scope
[20] eval(::Module, ::Expr) at ./sysimg.jl:60
[21] process_options(::Base.JLOptions) at ./client.jl:322
[22] _start() at ./client.jl:406
in expression starting at /usr/home/alex/.julia/v0.7/SpecialFunctions/deps/scratch.jl:125
INFO: Attempting to Create directory /usr/home/alex/.julia/v0.7/SpecialFunctions/deps/downloads
INFO: Directory /usr/home/alex/.julia/v0.7/SpecialFunctions/deps/downloads already created
INFO: Downloading file https://github.com/JuliaLang/openspecfun/archive/v0.5.3.tar.gz
INFO: Done downloading file https://github.com/JuliaLang/openspecfun/archive/v0.5.3.tar.gz
INFO: Attempting to Create directory /usr/home/alex/.julia/v0.7/SpecialFunctions/deps/src
INFO: Directory /usr/home/alex/.julia/v0.7/SpecialFunctions/deps/src already created
INFO: Attempting to Create directory /usr/home/alex/.julia/v0.7/SpecialFunctions/deps
INFO: Directory /usr/home/alex/.julia/v0.7/SpecialFunctions/deps already created
======================================================[ ERROR: SpecialFunctions ]======================================================
LoadError: LoadError: Path /usr/home/alex/.julia/v0.7/SpecialFunctions/deps/src/v0.5.3 was not created successfully (Tried to run pipeline(`/bin/mkdir -p /usr/home/alex/.julia/v0.7/SpecialFunctions/deps/src`, stdout=`/usr/bin/tar -xf /usr/home/alex/.julia/v0.7/SpecialFunctions/deps/downloads/v0.5.3.tar.gz -C /usr/home/alex/.julia/v0.7/SpecialFunctions/deps/src --no-same-owner --no-same-permissions`) )
in expression starting at /usr/home/alex/.julia/v0.7/SpecialFunctions/deps/scratch.jl:125
in expression starting at /usr/home/alex/.julia/v0.7/SpecialFunctions/deps/build.jl:6
=======================================================================================================================================
===========================================================[ BUILD ERRORS ]============================================================
WARNING: SpecialFunctions had build errors.
- packages with build errors remain installed in /usr/home/alex/.julia/v0.7
- build the package(s) and all dependencies with `Pkg.build("SpecialFunctions")`
- build a single package by running its `deps/build.jl` script
=======================================================================================================================================
julia> versioninfo()
Julia Version 0.7.0-DEV.2672
Commit a445cb67b5* (2017-11-27 19:06 UTC)
Platform Info:
OS: FreeBSD (x86_64-unknown-freebsd11.1)
CPU: Intel(R) Core(TM) i5-2520M CPU @ 2.50GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Sandybridge)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, sandybridge)
This is what Pkg.build("SpecialFunctions")
returns:
julia> Pkg.build("SpecialFunctions")
[ Info: Building SpecialFunctions @ Main none:10
WARNING: importing deprecated binding Base.Associative into BinDeps.
WARNING: Base.Associative is deprecated, use AbstractDict instead.
likely near /home/juliohm/.julia/v0.7/SpecialFunctions/deps/binaries.jl:44
in @install at /home/juliohm/.julia/v0.7/BinDeps/src/dependencies.jl
┌ Error: ------------------------------------------------------------
│ # Build failed for SpecialFunctions
│ exception =
│ LoadError: LoadError: UndefVarError: pushfront! not defined
│ Stacktrace:
│ [1] #_find_library#48(::Type, ::Function, ::BinDeps.LibraryDependency) at /home/juliohm/.julia/v0.7/BinDeps/src/dependencies.jl:652
│ [2] _find_library at /home/juliohm/.julia/v0.7/BinDeps/src/dependencies.jl:641 [inlined]
│ [3] satisfy!(::BinDeps.LibraryDependency, ::Array{DataType,1}) at /home/juliohm/.julia/v0.7/BinDeps/src/dependencies.jl:920 (repeats 2 times)
│ [4] top-level scope at /home/juliohm/.julia/v0.7/BinDeps/src/dependencies.jl:975
│ [5] include at ./boot.jl:292 [inlined]
│ [6] include_relative(::Module, ::String) at ./loading.jl:521
│ [7] include at ./sysimg.jl:26 [inlined]
│ [8] include at ./loading.jl:555 [inlined]
│ [9] top-level scope at ./<missing>:31
│ [10] include at ./boot.jl:292 [inlined]
│ [11] include_relative(::Module, ::String) at ./loading.jl:521
│ [12] include at ./sysimg.jl:26 [inlined]
│ [13] include(::String) at ./loading.jl:555
│ [14] top-level scope
│ [15] eval at ./boot.jl:295 [inlined]
│ [16] eval at ./sysimg.jl:71 [inlined]
│ [17] evalfile(::String, ::Array{String,1}) at ./loading.jl:550 (repeats 2 times)
│ [18] #2 at ./none:12 [inlined]
│ [19] cd(::getfield(, Symbol("##2#5")){String}, ::String) at ./file.jl:70
│ [20] (::getfield(, Symbol("##1#3")))(::IOStream) at ./none:11
│ [21] open(::getfield(, Symbol("##1#3")), ::String, ::String) at ./iostream.jl:310
│ [22] top-level scope
│ [23] eval at ./boot.jl:295 [inlined]
│ [24] eval(::Module, ::Expr) at ./sysimg.jl:71
│ [25] process_options(::Base.JLOptions) at ./client.jl:301
│ [26] _start() at ./client.jl:375
│ in expression starting at /home/juliohm/.julia/v0.7/SpecialFunctions/deps/binaries.jl:975
│ in expression starting at /home/juliohm/.julia/v0.7/SpecialFunctions/deps/build.jl:6
└ @ Main none:15
┌ Warning: ------------------------------------------------------------
│ # Build error summary
│
│ SpecialFunctions had build errors.
│
│ - packages with build errors remain installed in /home/juliohm/.julia/v0.7
│ - build the package(s) and all dependencies with `Pkg.build("SpecialFunctions")`
│ - build a single package by running its `deps/build.jl` script
└ @ Base.Pkg.Entry entry.jl:656
I get the following error while using SpecialFunctions
:
ERROR: LoadError: LoadError: TypeError: in @deprecate, in typeassert, expected Symbol, got Expr
Stacktrace:
[1] macro expansion at /Users/solver/.julia/v0.7/SpecialFunctions/src/deprecated.jl:8 [inlined]
[2] anonymous at ./<missing>:?
[3] include_relative(::Module, ::String) at ./loading.jl:464
[4] include at ./sysimg.jl:14 [inlined]
[5] include(::String) at /Users/solver/.julia/v0.7/SpecialFunctions/src/SpecialFunctions.jl:3
[6] include_relative(::Module, ::String) at ./loading.jl:464
[7] include(::Module, ::String) at ./sysimg.jl:14
[8] anonymous at ./<missing>:2
while loading /Users/solver/.julia/v0.7/SpecialFunctions/src/deprecated.jl, in expression starting on line 6
while loading /Users/solver/.julia/v0.7/SpecialFunctions/src/SpecialFunctions.jl, in expression starting on line 75
ERROR: LoadError: Failed to precompile SpecialFunctions to /Users/solver/.julia/lib/v0.7/SpecialFunctions.ji.
Stacktrace:
[1] compilecache(::String) at ./loading.jl:598
[2] _require(::Symbol) at ./loading.jl:407
[3] require(::Symbol) at ./loading.jl:318
[4] include_relative(::Module, ::String) at ./loading.jl:464
[5] include(::Module, ::String) at ./sysimg.jl:14
[6] process_options(::Base.JLOptions) at ./client.jl:315
[7] _start() at ./client.jl:383
while loading /Users/solver/.julia/v0.7/SpecialFunctions/test/runtests.jl, in expression starting on line 3
Here's my versioninfo:
julia> versioninfo()
Julia Version 0.7.0-DEV.1234
Commit 09f059a2d7 (2017-08-04 04:15 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin16.7.0)
CPU: Intel(R) Core(TM) i5-7600K CPU @ 3.80GHz
WORD_SIZE: 64
BLAS: libgfortblas
LAPACK: liblapack
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, broadwell)
Environment:
In Julia 0.7:
julia> Base.Test.@inferred digamma(3.0)
ERROR: return type Float64 does not match inferred return type Any
Stacktrace:
[1] error(::String) at ./error.jl:28
julia> Base.Test.@inferred digamma(complex(3.0))
0.9227843350984687 + 0.0im
julia> @code_warntype digamma(3.0)
Variables:
#self#::SpecialFunctions.#digamma
z@_2::Float64
x@_3::Float64
n::Int64
t::Float64
ψ::Any
x@_7::Any
y::Any
r::Any
s::Any
a6::Any
a5::Any
a4::Any
a3::Any
a2::Any
a1::Any
a0::Any
tt::Float64
#temp#@_19::Int64
ν::Int64
z@_21::Float64
#temp#@_22::Any
fy@_23::Float64
#temp#@_24::Float64
fy@_25::Float64
#temp#@_26::Bool
#temp#@_27::Int64
#temp#@_28::Float64
Body:
begin
z@_21::Float64 = z@_2::Float64
NewvarNode(:(n::Int64))
NewvarNode(:(t::Float64))
NewvarNode(:(ψ::Any))
x@_3::Float64 = z@_21::Float64
#= line 26 =#
$(Expr(:inbounds, false))
# meta: location float.jl <= 497
fy@_23::Float64 = (Base.sitofp)(Float64, 0)::Float64
# meta: pop location
$(Expr(:inbounds, :pop))
unless (Base.or_int)((Base.lt_float)(x@_3::Float64, fy@_23::Float64)::Bool, (Base.and_int)((Base.and_int)((Base.eq_float)(x@_3::Float64, fy@_23::Float64)::Bool, (Base.lt_float)(fy@_23::Float64, 9.223372036854776e18)::Bool)::Bool, (Base.sle_int)((Base.fptosi)(Int64, fy@_23::Float64)::Int64, 0)::Bool)::Bool)::Bool goto 35
#= line 27 =#
$(Expr(:inbounds, false))
# meta: location special/trig.jl cot 324
# meta: location math.jl tan 442
SSAValue(8) = $(Expr(:foreigncall, ("tan", "libopenlibm"), Float64, svec(Float64), :(:ccall), 1, :((Base.mul_float)(3.141592653589793, z@_21)::Float64)))
# meta: location math.jl nan_dom_err 323
unless (Base.and_int)((Base.ne_float)(SSAValue(8), SSAValue(8))::Bool, (Base.not_int)((Base.ne_float)((Base.mul_float)(3.141592653589793, z@_21::Float64)::Float64, (Base.mul_float)(3.141592653589793, z@_21::Float64)::Float64)::Bool)::Bool)::Bool goto 22
#temp#@_24::Float64 = (Base.Math.throw)($(Expr(:invoke, MethodInstance for DomainError(::Any, ::Any), :(Base.Math.DomainError), :((Base.mul_float)(3.141592653589793, z@_21)::Float64), "NaN result for non-NaN input."))::DomainError)::Union{}
goto 24
22:
#temp#@_24::Float64 = SSAValue(8)
24:
# meta: pop location
# meta: pop location
# meta: pop location
$(Expr(:inbounds, :pop))
ψ::Any = (Base.mul_float)((Base.neg_float)(3.141592653589793)::Float64, (Base.div_float)((Base.sitofp)(Float64, 1)::Float64, #temp#@_24::Float64)::Float64)::Float64
#= line 28 =#
z@_21::Float64 = (Base.sub_float)((Base.sitofp)(Float64, 1)::Float64, z@_21::Float64)::Float64
#= line 29 =#
x@_3::Float64 = z@_21::Float64
goto 38
35:
#= line 31 =#
ψ::Any = (Base.sitofp)(Float64, 0)::Float64
38:
#= line 33 =#
$(Expr(:inbounds, false))
# meta: location float.jl < 493
fy@_25::Float64 = (Base.sitofp)(Float64, 7)::Float64
# meta: pop location
$(Expr(:inbounds, :pop))
unless (Base.or_int)((Base.lt_float)(x@_3::Float64, fy@_25::Float64)::Bool, (Base.and_int)((Base.and_int)((Base.eq_float)(x@_3::Float64, fy@_25::Float64)::Bool, (Base.lt_float)(fy@_25::Float64, 9.223372036854776e18)::Bool)::Bool, (Base.slt_int)((Base.fptosi)(Int64, fy@_25::Float64)::Int64, 7)::Bool)::Bool)::Bool goto 90
#= line 35 =#
$(Expr(:inbounds, false))
# meta: location float.jl floor 334
# meta: location float.jl trunc 671
unless (Base.le_float)(-9.223372036854776e18, (Base.floor_llvm)(x@_3::Float64)::Float64)::Bool goto 53
#temp#@_26::Bool = (Base.lt_float)((Base.floor_llvm)(x@_3::Float64)::Float64, 9.223372036854776e18)::Bool
goto 55
53:
#temp#@_26::Bool = false
55:
unless #temp#@_26::Bool goto 60
#= line 672 =#
#temp#@_27::Int64 = (Base.fptosi)(Int64, (Base.floor_llvm)(x@_3::Float64)::Float64)::Int64
goto 63
60:
#= line 674 =#
#temp#@_27::Int64 = (Base.throw)($(Expr(:invoke, MethodInstance for InexactError(::Symbol, ::Any, ::Any), :(Base.InexactError), :(:trunc), Int64, :((Base.floor_llvm)(x@_3)::Float64)))::InexactError)::Union{}
63:
# meta: pop location
# meta: pop location
$(Expr(:inbounds, :pop))
n::Int64 = (Base.sub_int)(7, #temp#@_27::Int64)::Int64
#= line 36 =#
$(Expr(:inbounds, false))
# meta: location range.jl colon 5
# meta: pop location
$(Expr(:inbounds, :pop))
SSAValue(11) = (Base.select_value)((Base.sle_int)(1, (Base.sub_int)(n::Int64, 1)::Int64)::Bool, (Base.sub_int)(n::Int64, 1)::Int64, (Base.sub_int)(1, 1)::Int64)::Int64
#temp#@_19::Int64 = 1
75:
unless (Base.not_int)((#temp#@_19::Int64 === (Base.add_int)(SSAValue(11), 1)::Int64)::Bool)::Bool goto 85
SSAValue(12) = #temp#@_19::Int64
SSAValue(13) = (Base.add_int)(#temp#@_19::Int64, 1)::Int64
ν::Int64 = SSAValue(12)
#temp#@_19::Int64 = SSAValue(13)
#= line 37 =#
ψ::Any = (Base.sub_float)(ψ::Float64, (Base.div_float)((Base.sitofp)(Float64, 1)::Float64, (Base.add_float)(z@_21::Float64, (Base.sitofp)(Float64, ν::Int64)::Float64)::Float64)::Float64)::Float64
83:
goto 75
85:
#= line 39 =#
ψ::Any = (Base.sub_float)(ψ::Float64, (Base.div_float)((Base.sitofp)(Float64, 1)::Float64, z@_21::Float64)::Float64)::Float64
#= line 40 =#
z@_21::Float64 = (Base.add_float)(z@_21::Float64, (Base.sitofp)(Float64, n::Int64)::Float64)::Float64
90:
#= line 42 =#
t::Float64 = (Base.div_float)((Base.sitofp)(Float64, 1)::Float64, z@_21::Float64)::Float64
#= line 43 =#
$(Expr(:inbounds, false))
# meta: location math.jl log 442
SSAValue(10) = $(Expr(:foreigncall, ("log", "libopenlibm"), Float64, svec(Float64), :(:ccall), 1, :(z@_21)))
# meta: location math.jl nan_dom_err 323
unless (Base.and_int)((Base.ne_float)(SSAValue(10), SSAValue(10))::Bool, (Base.not_int)((Base.ne_float)(z@_21::Float64, z@_21::Float64)::Bool)::Bool)::Bool goto 101
#temp#@_28::Float64 = (Base.Math.throw)($(Expr(:invoke, MethodInstance for DomainError(::Any, ::Any), :(Base.Math.DomainError), :(z@_21), "NaN result for non-NaN input."))::DomainError)::Union{}
goto 103
101:
#temp#@_28::Float64 = SSAValue(10)
103:
# meta: pop location
# meta: pop location
$(Expr(:inbounds, :pop))
ψ::Any = (Base.add_float)(ψ::Float64, (Base.sub_float)(#temp#@_28::Float64, (Base.mul_float)(0.5, t::Float64)::Float64)::Float64)::Float64
#= line 44 =#
t::Float64 = (Base.mul_float)(t::Float64, t::Float64)::Float64
#= line 46 =#
SSAValue(2) = ψ::Float64
SSAValue(3) = t::Float64
tt::Float64 = t::Float64
# meta: location math.jl
#= line 139 =#
goto 117
117:
Base.Math.t = tt::Float64
#temp#@_22::Any = (Base.Math.muladd)(Base.Math.t, (Base.Math.muladd)(Base.Math.t, (Base.Math.muladd)(Base.Math.t, (Base.Math.muladd)(Base.Math.t, (Base.Math.muladd)(Base.Math.t, (Base.Math.muladd)(Base.Math.t, (Base.Math.muladd)(Base.Math.t, -0.4432598039215686, 0.08333333333333333)::Any, -0.021092796092796094)::Any, 0.007575757575757576)::Any, -0.004166666666666667)::Any, 0.003968253968253968)::Any, -0.008333333333333333)::Any, 0.08333333333333333)::Any
120:
# meta: pop location
SSAValue(5) = (SSAValue(3) * #temp#@_22::Any)::Any
SSAValue(6) = (SSAValue(2) - SSAValue(5))::Any
ψ::Any = SSAValue(6)
return SSAValue(6)
end::Any
The same function is type-stable in Julia 0.6, so it has probably to do with some change in Julia base code.
Moved from JuliaLang/julia#18698
According to the resolution of Issue #6564,
hankelh1(1, 0.0::Real)
should return something along the lines 0.0-1im*Inf
.
Instead, an AmosException is thrown:
julia> hankelh1(1,0.0)
ERROR: Base.Math.AmosException(1)
in _besselh at ./special/bessel.jl:128
in besselh at ./special/bessel.jl:195
Is this the intended behavior of the function?
Thank you for your time.
(I'm using julia-0.4.)
The error :
LoadError: LoadError: MethodError: Cannot `convert` an object of type Int64 to an object of type
Symbol
This may have arisen from a call to the constructor Symbol(...),
since type constructors fall back to convert methods.
Files in question: binaries.jl:37
and build.jl:6
.
Specific version : 0.7.0-DEV.2092
While attempting to update an existing SpecialFunctions
in v 0.7 I hit a symlink error; v 0.6 also updates SpecialFunctions
this morning but it builds without error.
So I removed the installation, checked that no cached version existed for SpecialFunctions
in .julia/v0.7/
and tried to reinstall. This leads to:
julia> Pkg.add("SpecialFunctions")
INFO: Installing SpecialFunctions v0.3.2
INFO: Building SpecialFunctions
INFO: No precompiled binaries found for your system. Building from scratch...
==========================[ ERROR: SpecialFunctions ]===========================
LoadError: LoadError: symlink: file already exists (EEXIST)
while loading /home/colin/.julia/v0.7/SpecialFunctions/deps/scratch.jl, in expression starting on line 8
while loading /home/colin/.julia/v0.7/SpecialFunctions/deps/build.jl, in expression starting on line 40
================================================================================
================================[ BUILD ERRORS ]================================
WARNING: SpecialFunctions had build errors.
- packages with build errors remain installed in /home/colin/.julia/v0.7
- build the package(s) and all dependencies with `Pkg.build("SpecialFunctions")`
Running Pkg.build just repeats the error.
It looks as though the install is looking for libopenlibm.so
; at first this did not exist on my system, so I installed a version from my openSUSE repo and it now exists as /usr/lib64/libopenlibm.so
but still the error persists.
julia> versioninfo()
Julia Version 0.7.0-DEV.1743
Commit 7e143bb333 (2017-09-09 20:19 UTC)
Platform Info:
OS: Linux (x86_64-suse-linux)
CPU: Intel(R) Core(TM) i5-4460 CPU @ 3.20GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, haswell)
Environment:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.