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

BUG: Overflow in tan and tanh for large complex values #5510

Closed
wants to merge 2 commits into from

Commits on Jan 27, 2015

  1. BUG: Overflow in tan and tanh for large complex values

    np.tanh(1000+0j) gives nan+nan*j instead of 1.0+0j.
    np.tan(0+1000j) gives  nan+nan*j instead of 1j.
    
    I've imported the implementation for ctanh from FreeBSD's math library
    which handles large arguments correctly and fixes this bug and the
    equivalent bug in np.tan.
    
    The problem here is that importing the function into npy_math_complex.c
    and adding a config check causes us to use the implementation from glibc
    on Linux, which also has this bug. Although it seems to have been fixed
    in glibc last April
    (http://sourceware.org/bugzilla/show_bug.cgi?id=11521).
    
    I see several things that could be done here, the easiest is probably to
    use our version of ctanh unconditionally. Although there are a multitude
    of ways to go about that, for instance should I remove the
    implementation from npy_math_complex.c and just place it directly in
    umath/funcs.inc, where the buggy version was? Or should I just remove
    the config check and add a note about it somewhere?
    
    Closes numpy#2321.
    ewmoore authored and charris committed Jan 27, 2015
    Copy the full SHA
    5b58985 View commit details
    Browse the repository at this point in the history
  2. STY: C style cleanup.

    Omitted numpy/core/src/npymath/test_c99complex.c, which is a jungle
    of macro magic.
    charris committed Jan 27, 2015
    Copy the full SHA
    ff5a1c2 View commit details
    Browse the repository at this point in the history