GithubHelp home page GithubHelp logo

Comments (2)

stevengj avatar stevengj commented on July 19, 2024 2

The actual source code is in https://github.com/JuliaLang/openspecfun ... the functions indeed have the option of returning a sequence of Bessel functions (see the N argument of zbesj, for example. It seems like it would be straightforward to add support for this for the case where the nu argument is a range with step(nu) == 1.

from specialfunctions.jl.

bblankrot avatar bblankrot commented on July 19, 2024 2

This change can be implemented by, for example, changing the following lines in bessel.jl:

ccall((:zbesh_,openspecfun), Cvoid,
           (Ref{Float64}, Ref{Float64}, Ref{Float64}, Ref{Int32}, Ref{Int32}, Ref{Int},
            Ref{Float64}, Ref{Float64}, Ref{Int32}, Ref{Int32}),
            real(z), imag(z), nu, kode, k, 1,
            ai1, ai2, ae1, ae2)

to

ccall((:zbesh_,openspecfun), Cvoid,
           (Ref{Float64}, Ref{Float64}, Ref{Float64}, Ref{Int32}, Ref{Int32}, Ref{Int},
            Ptr{Float64}, Ptr{Float64}, Ref{Int32}, Ref{Int32}),
            real(z), imag(z), nu, kode, k, N,
            ai1, ai2, ae1, ae2)

where ai1,ai2 are arrays instead of references. Limited testing shows a drastic cut in time and allocated memory:

julia> @btime besselh.(0:5, 1, 1.1+0.1im)
  5.658 μs (61 allocations: 1.11 KiB)
6-element Array{Complex{Float64},1}:
   0.651368+0.11899im
   0.393305-0.665955im
 -0.0513027-1.38437im
   -1.03222-4.31003im
   -7.65254-21.4245im
   -68.2153-145.21im
julia> @btime besselhseq(0, 5, 1, 1.1+0.1im)
  1.460 μs (11 allocations: 560 bytes)
6-element Array{Complex{Float64},1}:
   0.651368+0.11899im
   0.393305-0.665955im
 -0.0513027-1.38437im
   -1.03222-4.31003im
   -7.65254-21.4245im
   -68.2153-145.21im

However, I'm unsure what would be the best way to wrap these functions. If using the existing signatures, one would have to handle the case where some Bessel orders are negative, since zbesh only works for nu >= 0.

from specialfunctions.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.