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

add complex error functions (via http:https://ab-initio.mit.edu/Faddeeva) #1799

Merged
merged 6 commits into from
Dec 21, 2012

Conversation

stevengj
Copy link
Member

This patch adds support for error functions erf and erfc of arbitrary complex arguments, as well as the related functions erfi, erfcx, and dawson. (It requires the most recent version of openlibm with the Faddeeva package merged.)

Note that the ugliness with the libFaddeeva_wrapper library can go away once ccall supports C99 complex numbers (issue #85).

The code works, but a little tweak from a Julia expert would be useful. In

for f in (:erf, :erfc, :erfcx, :erfi, :Dawson)
    @eval begin
        global $f
        function ($f)(z::Complex128)
            local w::Array{Float64,1} = Array(Float64,2)
            ccall(($(string("wrapFaddeeva_",f)),:libFaddeeva_wrapper), Void, (Ptr{Complex128},Ptr{Complex128},Float64,), pointer(w), &z, zero(Float64))
            return complex128(w[1],w[2])
        end
 ...

I declared w as a local variable to hold the return value. I tried declaring

const w::Array{Float64,1} = Array(Float64,2)

in the surrounding let block instead, similar to how the Bessel and Airy functions are handled, but for some reason this led to Julia complaining that w was not defined inside the function. I'm guessing that it is some kind of macro hygiene problem, but using $(esc(w)) did not seem to work.

@ViralBShah
Copy link
Member

I just updated the openlibm submodule on master. Merge master into this branch and commit - that should fix the travis build.

Could you also add a couple of tests to test/math.jl?

@stevengj
Copy link
Member Author

Done. Pull from stevengj@ac7c520

(Not sure how to modify the existing pull request on github.)

@ViralBShah
Copy link
Member

Just keep committing to the same branch, and it will keep showing up in this pull request.

@ViralBShah
Copy link
Member

Your commits are showing up fine. I think you need to Faddeeva-wrapper to STAGE2_DEPS in deps/Makefile so that it is built and installed.

@stevengj
Copy link
Member Author

Done. (I could have sworn I already did that, but maybe I forgot to save...)

@ViralBShah
Copy link
Member

Same error. @staticfloat Are you able to tell why the Faddeeva wrapper is not getting installed in the right place?

@stevengj
Copy link
Member Author

Could you be more precise about the problem you are seeing? If I do 'make' and run ./julia the new functions work just fine for me. I also tried git cloning a fresh repo from mine and re-running make from scratch, and it still works.

@Keno
Copy link
Member

Keno commented Dec 21, 2012

I think @ViralBShah was referring to the failure in the CI test, here: https://travis-ci.org/JuliaLang/julia/jobs/3768385/#L1039

@ViralBShah
Copy link
Member

Ok, this looks like it works. The clang build failure was due to a failure setting up the build environment, but the gcc build went through fine.

ViralBShah pushed a commit that referenced this pull request Dec 21, 2012
@ViralBShah ViralBShah merged commit 8b466b1 into JuliaLang:master Dec 21, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants