Commits

Alex Gaynor  committed f7ae881 Merge

merged default in

  • Participants
  • Parent commits 5a96403, cdd972e
  • Branches kill-someobject

Comments (0)

Files changed (27)

File lib_pypy/dbm.py

     libpath = ctypes.util.find_library('db')
     if not libpath:
         # XXX this is hopeless...
-        libpath = ctypes.util.find_library('db-4.5')
-        if not libpath:
+        for c in '56789':
+            libpath = ctypes.util.find_library('db-4.%s' % c)
+            if libpath:
+                break
+        else:
             raise ImportError("Cannot find dbm library")
     lib = CDLL(libpath) # Linux
     _platform = 'bdb'

File pypy/doc/whatsnew-head.rst

 .. branch: stdlib-2.7.3
 The stdlib was updated to version 2.7.3
 
+.. branch: numpypy-complex2
+Complex dtype support for numpy
+
+
 
 .. "uninteresting" branches that we should just ignore for the whatsnew:
 .. branch: slightly-shorter-c

File pypy/interpreter/astcompiler/test/test_compiler.py

File contents unchanged.

File pypy/module/cmath/constant.py

-import math
-from pypy.rlib.rfloat import isinf
-from pypy.rpython.tool import rffi_platform
-from pypy.translator.tool.cbuild import ExternalCompilationInfo
-
-
-class CConfig:
-    _compilation_info_ = ExternalCompilationInfo(includes=['float.h'])
-
-    DBL_MAX = rffi_platform.DefinedConstantDouble('DBL_MAX')
-    DBL_MIN = rffi_platform.DefinedConstantDouble('DBL_MIN')
-    DBL_MANT_DIG = rffi_platform.ConstantInteger('DBL_MANT_DIG')
-
-
-for k, v in rffi_platform.configure(CConfig).items():
-    assert v is not None, "no value found for %r" % k
-    globals()[k] = v
-
-
-assert 0.0 < DBL_MAX < (1e200*1e200)
-assert isinf(DBL_MAX * 1.0001)
-assert DBL_MIN > 0.0
-assert DBL_MIN * (2**-53) == 0.0
-
-
-# Constants.
-M_LN2 = 0.6931471805599453094   # natural log of 2
-M_LN10 = 2.302585092994045684   # natural log of 10
-
-
-# CM_LARGE_DOUBLE is used to avoid spurious overflow in the sqrt, log,
-# inverse trig and inverse hyperbolic trig functions.  Its log is used in the
-# evaluation of exp, cos, cosh, sin, sinh, tan, and tanh to avoid unecessary
-# overflow.
-CM_LARGE_DOUBLE = DBL_MAX/4.
-CM_SQRT_LARGE_DOUBLE = math.sqrt(CM_LARGE_DOUBLE)
-CM_LOG_LARGE_DOUBLE = math.log(CM_LARGE_DOUBLE)
-CM_SQRT_DBL_MIN = math.sqrt(DBL_MIN)
-
-# CM_SCALE_UP is an odd integer chosen such that multiplication by
-# 2**CM_SCALE_UP is sufficient to turn a subnormal into a normal.
-# CM_SCALE_DOWN is (-(CM_SCALE_UP+1)/2).  These scalings are used to compute
-# square roots accurately when the real and imaginary parts of the argument
-# are subnormal.
-CM_SCALE_UP = (2*(DBL_MANT_DIG/2) + 1)
-CM_SCALE_DOWN = -(CM_SCALE_UP+1)/2

File pypy/module/cmath/interp_cmath.py

 import math
-from math import fabs
 from pypy.rlib.objectmodel import specialize
-from pypy.rlib.rfloat import copysign, asinh, log1p, isinf, isnan
 from pypy.tool.sourcetools import func_with_new_name
 from pypy.interpreter.error import OperationError
 from pypy.interpreter.gateway import NoneNotWrapped
 from pypy.module.cmath import names_and_docstrings
-from pypy.module.cmath.constant import DBL_MIN, CM_SCALE_UP, CM_SCALE_DOWN
-from pypy.module.cmath.constant import CM_LARGE_DOUBLE, DBL_MANT_DIG
-from pypy.module.cmath.constant import M_LN2, M_LN10
-from pypy.module.cmath.constant import CM_SQRT_LARGE_DOUBLE, CM_SQRT_DBL_MIN
-from pypy.module.cmath.constant import CM_LOG_LARGE_DOUBLE
-from pypy.module.cmath.special_value import isfinite, special_type, INF, NAN
-from pypy.module.cmath.special_value import sqrt_special_values
-from pypy.module.cmath.special_value import acos_special_values
-from pypy.module.cmath.special_value import acosh_special_values
-from pypy.module.cmath.special_value import asinh_special_values
-from pypy.module.cmath.special_value import atanh_special_values
-from pypy.module.cmath.special_value import log_special_values
-from pypy.module.cmath.special_value import exp_special_values
-from pypy.module.cmath.special_value import cosh_special_values
-from pypy.module.cmath.special_value import sinh_special_values
-from pypy.module.cmath.special_value import tanh_special_values
-from pypy.module.cmath.special_value import rect_special_values
+from pypy.rlib import rcomplex
 
 pi = math.pi
 e  = math.e
 
 
 def c_neg(x, y):
-    return (-x, -y)
+    return rcomplex.c_neg(x,y)
 
 
 @unaryfn
 def c_sqrt(x, y):
-    # Method: use symmetries to reduce to the case when x = z.real and y
-    # = z.imag are nonnegative.  Then the real part of the result is
-    # given by
-    #
-    #   s = sqrt((x + hypot(x, y))/2)
-    #
-    # and the imaginary part is
-    #
-    #   d = (y/2)/s
-    #
-    # If either x or y is very large then there's a risk of overflow in
-    # computation of the expression x + hypot(x, y).  We can avoid this
-    # by rewriting the formula for s as:
-    #
-    #   s = 2*sqrt(x/8 + hypot(x/8, y/8))
-    #
-    # This costs us two extra multiplications/divisions, but avoids the
-    # overhead of checking for x and y large.
-    #
-    # If both x and y are subnormal then hypot(x, y) may also be
-    # subnormal, so will lack full precision.  We solve this by rescaling
-    # x and y by a sufficiently large power of 2 to ensure that x and y
-    # are normal.
-
-    if not isfinite(x) or not isfinite(y):
-        return sqrt_special_values[special_type(x)][special_type(y)]
-
-    if x == 0. and y == 0.:
-        return (0., y)
-
-    ax = fabs(x)
-    ay = fabs(y)
-
-    if ax < DBL_MIN and ay < DBL_MIN and (ax > 0. or ay > 0.):
-        # here we catch cases where hypot(ax, ay) is subnormal
-        ax = math.ldexp(ax, CM_SCALE_UP)
-        ay1= math.ldexp(ay, CM_SCALE_UP)
-        s = math.ldexp(math.sqrt(ax + math.hypot(ax, ay1)),
-                       CM_SCALE_DOWN)
-    else:
-        ax /= 8.
-        s = 2.*math.sqrt(ax + math.hypot(ax, ay/8.))
-
-    d = ay/(2.*s)
-
-    if x >= 0.:
-        return (s, copysign(d, y))
-    else:
-        return (d, copysign(s, y))
-
+    return rcomplex.c_sqrt(x,y)
 
 @unaryfn
 def c_acos(x, y):
-    if not isfinite(x) or not isfinite(y):
-        return acos_special_values[special_type(x)][special_type(y)]
-
-    if fabs(x) > CM_LARGE_DOUBLE or fabs(y) > CM_LARGE_DOUBLE:
-        # avoid unnecessary overflow for large arguments
-        real = math.atan2(fabs(y), x)
-        # split into cases to make sure that the branch cut has the
-        # correct continuity on systems with unsigned zeros
-        if x < 0.:
-            imag = -copysign(math.log(math.hypot(x/2., y/2.)) +
-                             M_LN2*2., y)
-        else:
-            imag = copysign(math.log(math.hypot(x/2., y/2.)) +
-                            M_LN2*2., -y)
-    else:
-        s1x, s1y = c_sqrt(1.-x, -y)
-        s2x, s2y = c_sqrt(1.+x, y)
-        real = 2.*math.atan2(s1x, s2x)
-        imag = asinh(s2x*s1y - s2y*s1x)
-    return (real, imag)
-
+    return rcomplex.c_acos(x,y)
 
 @unaryfn
 def c_acosh(x, y):
-    # XXX the following two lines seem unnecessary at least on Linux;
-    # the tests pass fine without them
-    if not isfinite(x) or not isfinite(y):
-        return acosh_special_values[special_type(x)][special_type(y)]
-
-    if fabs(x) > CM_LARGE_DOUBLE or fabs(y) > CM_LARGE_DOUBLE:
-        # avoid unnecessary overflow for large arguments
-        real = math.log(math.hypot(x/2., y/2.)) + M_LN2*2.
-        imag = math.atan2(y, x)
-    else:
-        s1x, s1y = c_sqrt(x - 1., y)
-        s2x, s2y = c_sqrt(x + 1., y)
-        real = asinh(s1x*s2x + s1y*s2y)
-        imag = 2.*math.atan2(s1y, s2x)
-    return (real, imag)
-
+    return rcomplex.c_acosh(x,y)
 
 @unaryfn
 def c_asin(x, y):
-    # asin(z) = -i asinh(iz)
-    sx, sy = c_asinh(-y, x)
-    return (sy, -sx)
-
+    return rcomplex.c_asin(x,y)
 
 @unaryfn
 def c_asinh(x, y):
-    if not isfinite(x) or not isfinite(y):
-        return asinh_special_values[special_type(x)][special_type(y)]
-
-    if fabs(x) > CM_LARGE_DOUBLE or fabs(y) > CM_LARGE_DOUBLE:
-        if y >= 0.:
-            real = copysign(math.log(math.hypot(x/2., y/2.)) +
-                            M_LN2*2., x)
-        else:
-            real = -copysign(math.log(math.hypot(x/2., y/2.)) +
-                             M_LN2*2., -x)
-        imag = math.atan2(y, fabs(x))
-    else:
-        s1x, s1y = c_sqrt(1.+y, -x)
-        s2x, s2y = c_sqrt(1.-y, x)
-        real = asinh(s1x*s2y - s2x*s1y)
-        imag = math.atan2(y, s1x*s2x - s1y*s2y)
-    return (real, imag)
-
+    return rcomplex.c_asinh(x,y)
 
 @unaryfn
 def c_atan(x, y):
-    # atan(z) = -i atanh(iz)
-    sx, sy = c_atanh(-y, x)
-    return (sy, -sx)
-
+    return rcomplex.c_atan(x,y)
 
 @unaryfn
 def c_atanh(x, y):
-    if not isfinite(x) or not isfinite(y):
-        return atanh_special_values[special_type(x)][special_type(y)]
-
-    # Reduce to case where x >= 0., using atanh(z) = -atanh(-z).
-    if x < 0.:
-        return c_neg(*c_atanh(*c_neg(x, y)))
-
-    ay = fabs(y)
-    if x > CM_SQRT_LARGE_DOUBLE or ay > CM_SQRT_LARGE_DOUBLE:
-        # if abs(z) is large then we use the approximation
-        # atanh(z) ~ 1/z +/- i*pi/2 (+/- depending on the sign
-        # of y
-        h = math.hypot(x/2., y/2.)   # safe from overflow
-        real = x/4./h/h
-        # the two negations in the next line cancel each other out
-        # except when working with unsigned zeros: they're there to
-        # ensure that the branch cut has the correct continuity on
-        # systems that don't support signed zeros
-        imag = -copysign(math.pi/2., -y)
-    elif x == 1. and ay < CM_SQRT_DBL_MIN:
-        # C99 standard says:  atanh(1+/-0.) should be inf +/- 0i
-        if ay == 0.:
-            raise ValueError("math domain error")
-            #real = INF
-            #imag = y
-        else:
-            real = -math.log(math.sqrt(ay)/math.sqrt(math.hypot(ay, 2.)))
-            imag = copysign(math.atan2(2., -ay) / 2, y)
-    else:
-        real = log1p(4.*x/((1-x)*(1-x) + ay*ay))/4.
-        imag = -math.atan2(-2.*y, (1-x)*(1+x) - ay*ay) / 2.
-    return (real, imag)
-
+    return rcomplex.c_atanh(x,y)
 
 @unaryfn
 def c_log(x, y):
-    # The usual formula for the real part is log(hypot(z.real, z.imag)).
-    # There are four situations where this formula is potentially
-    # problematic:
-    #
-    # (1) the absolute value of z is subnormal.  Then hypot is subnormal,
-    # so has fewer than the usual number of bits of accuracy, hence may
-    # have large relative error.  This then gives a large absolute error
-    # in the log.  This can be solved by rescaling z by a suitable power
-    # of 2.
-    #
-    # (2) the absolute value of z is greater than DBL_MAX (e.g. when both
-    # z.real and z.imag are within a factor of 1/sqrt(2) of DBL_MAX)
-    # Again, rescaling solves this.
-    #
-    # (3) the absolute value of z is close to 1.  In this case it's
-    # difficult to achieve good accuracy, at least in part because a
-    # change of 1ulp in the real or imaginary part of z can result in a
-    # change of billions of ulps in the correctly rounded answer.
-    #
-    # (4) z = 0.  The simplest thing to do here is to call the
-    # floating-point log with an argument of 0, and let its behaviour
-    # (returning -infinity, signaling a floating-point exception, setting
-    # errno, or whatever) determine that of c_log.  So the usual formula
-    # is fine here.
-
-    # XXX the following two lines seem unnecessary at least on Linux;
-    # the tests pass fine without them
-    if not isfinite(x) or not isfinite(y):
-        return log_special_values[special_type(x)][special_type(y)]
-
-    ax = fabs(x)
-    ay = fabs(y)
-
-    if ax > CM_LARGE_DOUBLE or ay > CM_LARGE_DOUBLE:
-        real = math.log(math.hypot(ax/2., ay/2.)) + M_LN2
-    elif ax < DBL_MIN and ay < DBL_MIN:
-        if ax > 0. or ay > 0.:
-            # catch cases where hypot(ax, ay) is subnormal
-            real = math.log(math.hypot(math.ldexp(ax, DBL_MANT_DIG),
-                                       math.ldexp(ay, DBL_MANT_DIG)))
-            real -= DBL_MANT_DIG*M_LN2
-        else:
-            # log(+/-0. +/- 0i)
-            raise ValueError("math domain error")
-            #real = -INF
-            #imag = atan2(y, x)
-    else:
-        h = math.hypot(ax, ay)
-        if 0.71 <= h and h <= 1.73:
-            am = max(ax, ay)
-            an = min(ax, ay)
-            real = log1p((am-1)*(am+1) + an*an) / 2.
-        else:
-            real = math.log(h)
-    imag = math.atan2(y, x)
-    return (real, imag)
-
+    return rcomplex.c_log(x,y)
 
 _inner_wrapped_log = wrapped_log
 
 
 @unaryfn
 def c_log10(x, y):
-    rx, ry = c_log(x, y)
-    return (rx / M_LN10, ry / M_LN10)
-
+    return rcomplex.c_log10(x,y)
 
 @unaryfn
 def c_exp(x, y):
-    if not isfinite(x) or not isfinite(y):
-        if isinf(x) and isfinite(y) and y != 0.:
-            if x > 0:
-                real = copysign(INF, math.cos(y))
-                imag = copysign(INF, math.sin(y))
-            else:
-                real = copysign(0., math.cos(y))
-                imag = copysign(0., math.sin(y))
-            r = (real, imag)
-        else:
-            r = exp_special_values[special_type(x)][special_type(y)]
-
-        # need to raise ValueError if y is +/- infinity and x is not
-        # a NaN and not -infinity
-        if isinf(y) and (isfinite(x) or (isinf(x) and x > 0)):
-            raise ValueError("math domain error")
-        return r
-
-    if x > CM_LOG_LARGE_DOUBLE:
-        l = math.exp(x-1.)
-        real = l * math.cos(y) * math.e
-        imag = l * math.sin(y) * math.e
-    else:
-        l = math.exp(x)
-        real = l * math.cos(y)
-        imag = l * math.sin(y)
-    if isinf(real) or isinf(imag):
-        raise OverflowError("math range error")
-    return real, imag
-
+    return rcomplex.c_exp(x,y)
 
 @unaryfn
 def c_cosh(x, y):
-    if not isfinite(x) or not isfinite(y):
-        if isinf(x) and isfinite(y) and y != 0.:
-            if x > 0:
-                real = copysign(INF, math.cos(y))
-                imag = copysign(INF, math.sin(y))
-            else:
-                real = copysign(INF, math.cos(y))
-                imag = -copysign(INF, math.sin(y))
-            r = (real, imag)
-        else:
-            r = cosh_special_values[special_type(x)][special_type(y)]
-
-        # need to raise ValueError if y is +/- infinity and x is not
-        # a NaN
-        if isinf(y) and not isnan(x):
-            raise ValueError("math domain error")
-        return r
-
-    if fabs(x) > CM_LOG_LARGE_DOUBLE:
-        # deal correctly with cases where cosh(x) overflows but
-        # cosh(z) does not.
-        x_minus_one = x - copysign(1., x)
-        real = math.cos(y) * math.cosh(x_minus_one) * math.e
-        imag = math.sin(y) * math.sinh(x_minus_one) * math.e
-    else:
-        real = math.cos(y) * math.cosh(x)
-        imag = math.sin(y) * math.sinh(x)
-    if isinf(real) or isinf(imag):
-        raise OverflowError("math range error")
-    return real, imag
-
+    return rcomplex.c_cosh(x,y)
 
 @unaryfn
 def c_sinh(x, y):
-    # special treatment for sinh(+/-inf + iy) if y is finite and nonzero
-    if not isfinite(x) or not isfinite(y):
-        if isinf(x) and isfinite(y) and y != 0.:
-            if x > 0:
-                real = copysign(INF, math.cos(y))
-                imag = copysign(INF, math.sin(y))
-            else:
-                real = -copysign(INF, math.cos(y))
-                imag = copysign(INF, math.sin(y))
-            r = (real, imag)
-        else:
-            r = sinh_special_values[special_type(x)][special_type(y)]
-
-        # need to raise ValueError if y is +/- infinity and x is not
-        # a NaN
-        if isinf(y) and not isnan(x):
-            raise ValueError("math domain error")
-        return r
-
-    if fabs(x) > CM_LOG_LARGE_DOUBLE:
-        x_minus_one = x - copysign(1., x)
-        real = math.cos(y) * math.sinh(x_minus_one) * math.e
-        imag = math.sin(y) * math.cosh(x_minus_one) * math.e
-    else:
-        real = math.cos(y) * math.sinh(x)
-        imag = math.sin(y) * math.cosh(x)
-    if isinf(real) or isinf(imag):
-        raise OverflowError("math range error")
-    return real, imag
-
+    return rcomplex.c_sinh(x,y)
 
 @unaryfn
 def c_tanh(x, y):
-    # Formula:
-    #
-    #   tanh(x+iy) = (tanh(x)(1+tan(y)^2) + i tan(y)(1-tanh(x))^2) /
-    #   (1+tan(y)^2 tanh(x)^2)
-    #
-    #   To avoid excessive roundoff error, 1-tanh(x)^2 is better computed
-    #   as 1/cosh(x)^2.  When abs(x) is large, we approximate 1-tanh(x)^2
-    #   by 4 exp(-2*x) instead, to avoid possible overflow in the
-    #   computation of cosh(x).
-
-    if not isfinite(x) or not isfinite(y):
-        if isinf(x) and isfinite(y) and y != 0.:
-            if x > 0:
-                real = 1.0        # vv XXX why is the 2. there?
-                imag = copysign(0., 2. * math.sin(y) * math.cos(y))
-            else:
-                real = -1.0
-                imag = copysign(0., 2. * math.sin(y) * math.cos(y))
-            r = (real, imag)
-        else:
-            r = tanh_special_values[special_type(x)][special_type(y)]
-
-        # need to raise ValueError if y is +/-infinity and x is finite
-        if isinf(y) and isfinite(x):
-            raise ValueError("math domain error")
-        return r
-
-    if fabs(x) > CM_LOG_LARGE_DOUBLE:
-        real = copysign(1., x)
-        imag = 4. * math.sin(y) * math.cos(y) * math.exp(-2.*fabs(x))
-    else:
-        tx = math.tanh(x)
-        ty = math.tan(y)
-        cx = 1. / math.cosh(x)
-        txty = tx * ty
-        denom = 1. + txty * txty
-        real = tx * (1. + ty*ty) / denom
-        imag = ((ty / denom) * cx) * cx
-    return real, imag
-
+    return rcomplex.c_tanh(x,y)
 
 @unaryfn
 def c_cos(x, y):
-    # cos(z) = cosh(iz)
-    return c_cosh(-y, x)
+    return rcomplex.c_cos(x,y)
 
 @unaryfn
 def c_sin(x, y):
-    # sin(z) = -i sinh(iz)
-    sx, sy = c_sinh(-y, x)
-    return sy, -sx
+    return rcomplex.c_sin(x,y)
 
 @unaryfn
 def c_tan(x, y):
-    # tan(z) = -i tanh(iz)
-    sx, sy = c_tanh(-y, x)
-    return sy, -sx
-
+    return rcomplex.c_tan(x,y)
 
 def c_rect(r, phi):
-    if not isfinite(r) or not isfinite(phi):
-        # if r is +/-infinity and phi is finite but nonzero then
-        # result is (+-INF +-INF i), but we need to compute cos(phi)
-        # and sin(phi) to figure out the signs.
-        if isinf(r) and isfinite(phi) and phi != 0.:
-            if r > 0:
-                real = copysign(INF, math.cos(phi))
-                imag = copysign(INF, math.sin(phi))
-            else:
-                real = -copysign(INF, math.cos(phi))
-                imag = -copysign(INF, math.sin(phi))
-            z = (real, imag)
-        else:
-            z = rect_special_values[special_type(r)][special_type(phi)]
-
-        # need to raise ValueError if r is a nonzero number and phi
-        # is infinite
-        if r != 0. and not isnan(r) and isinf(phi):
-            raise ValueError("math domain error")
-        return z
-
-    real = r * math.cos(phi)
-    imag = r * math.sin(phi)
-    return real, imag
+    return rcomplex.c_rect(r,phi)
 
 def wrapped_rect(space, w_x, w_y):
     x = space.float_w(w_x)
 
 
 def c_phase(x, y):
-    # Windows screws up atan2 for inf and nan, and alpha Tru64 5.1 doesn't
-    # follow C99 for atan2(0., 0.).
-    if isnan(x) or isnan(y):
-        return NAN
-    if isinf(y):
-        if isinf(x):
-            if copysign(1., x) == 1.:
-                # atan2(+-inf, +inf) == +-pi/4
-                return copysign(0.25 * math.pi, y)
-            else:
-                # atan2(+-inf, -inf) == +-pi*3/4
-                return copysign(0.75 * math.pi, y)
-        # atan2(+-inf, x) == +-pi/2 for finite x
-        return copysign(0.5 * math.pi, y)
-    if isinf(x) or y == 0.:
-        if copysign(1., x) == 1.:
-            # atan2(+-y, +inf) = atan2(+-0, +x) = +-0.
-            return copysign(0., y)
-        else:
-            # atan2(+-y, -inf) = atan2(+-0., -x) = +-pi.
-            return copysign(math.pi, y)
-    return math.atan2(y, x)
+    return rcomplex.c_phase(x,y)
 
 def wrapped_phase(space, w_z):
     x, y = space.unpackcomplex(w_z)
 
 
 def c_abs(x, y):
-    if not isfinite(x) or not isfinite(y):
-        # C99 rules: if either the real or the imaginary part is an
-        # infinity, return infinity, even if the other part is a NaN.
-        if isinf(x):
-            return INF
-        if isinf(y):
-            return INF
-
-        # either the real or imaginary part is a NaN,
-        # and neither is infinite. Result should be NaN.
-        return NAN
-
-    result = math.hypot(x, y)
-    if not isfinite(result):
-        raise OverflowError("math range error")
-    return result
-
+    return rcomplex.c_abs(x,y)
 
 def c_polar(x, y):
-    phi = c_phase(x, y)
-    r = c_abs(x, y)
-    return r, phi
+    return rcomplex.c_polar(x,y)
 
 def wrapped_polar(space, w_z):
     x, y = space.unpackcomplex(w_z)
 
 
 def c_isinf(x, y):
-    return isinf(x) or isinf(y)
+    return rcomplex.c_isinf(x,y)
 
 def wrapped_isinf(space, w_z):
     x, y = space.unpackcomplex(w_z)
 
 
 def c_isnan(x, y):
-    return isnan(x) or isnan(y)
+    return rcomplex.c_isnan(x,y)
 
 def wrapped_isnan(space, w_z):
     x, y = space.unpackcomplex(w_z)

File pypy/module/cmath/special_value.py

-import math
-from pypy.rlib.rfloat import isnan, isinf, copysign
-
-# code to deal with special values (infinities, NaNs, ...)
-#
-# The special types can be:
-ST_NINF    = 0         # negative infinity
-ST_NEG     = 1         # negative finite number (nonzero)
-ST_NZERO   = 2         # -0.
-ST_PZERO   = 3         # +0.
-ST_POS     = 4         # positive finite number (nonzero)
-ST_PINF    = 5         # positive infinity
-ST_NAN     = 6         # Not a Number
-
-def special_type(d):
-    if isnan(d):
-        return ST_NAN
-    elif isinf(d):
-        if d > 0.0:
-            return ST_PINF
-        else:
-            return ST_NINF
-    else:
-        if d != 0.0:
-            if d > 0.0:
-                return ST_POS
-            else:
-                return ST_NEG
-        else:
-            if copysign(1., d) == 1.:
-                return ST_PZERO
-            else:
-                return ST_NZERO
-
-def isfinite(d):
-    return not isinf(d) and not isnan(d)
-
-
-P   = math.pi
-P14 = 0.25 * math.pi
-P12 = 0.5 * math.pi
-P34 = 0.75 * math.pi
-INF = 1e200 * 1e200
-N   = INF / INF
-U   = -9.5426319407711027e33   # unlikely value, used as placeholder
-Z   = 0.0    # defined here instead of in the tuples below, because of a bug
-             # in pypy releases < 1.5
-NAN = N
-
-def build_table(lst):
-    table = []
-    assert len(lst) == 49
-    it = iter(lst)
-    for j in range(7):
-        row = []
-        for i in range(7):
-            (x, y) = it.next()
-            row.append((x, y))
-        table.append(row)
-    return table
-
-acos_special_values = build_table([
-    (P34,INF), (P,INF), (P,INF), (P,-INF), (P,-INF), (P34,-INF), (N,INF),
-    (P12,INF), (U,U),   (U,U),   (U,U),    (U,U),    (P12,-INF), (N,N),
-    (P12,INF), (U,U),   (P12,Z), (P12,-Z), (U,U),    (P12,-INF), (P12,N),
-    (P12,INF), (U,U),   (P12,Z), (P12,-Z), (U,U),    (P12,-INF), (P12,N),
-    (P12,INF), (U,U),   (U,U),   (U,U),    (U,U),    (P12,-INF), (N,N),
-    (P14,INF), (Z,INF), (Z,INF), (Z,-INF), (Z,-INF), (P14,-INF), (N,INF),
-    (N,INF),   (N,N),   (N,N),   (N,N),    (N,N),    (N,-INF),   (N,N),
-    ])
-
-acosh_special_values = build_table([
-    (INF,-P34), (INF,-P), (INF,-P), (INF,P), (INF,P), (INF,P34), (INF,N),
-    (INF,-P12), (U,U),    (U,U),    (U,U),   (U,U),   (INF,P12), (N,N),
-    (INF,-P12), (U,U),    (Z,-P12), (Z,P12), (U,U),   (INF,P12), (N,N),
-    (INF,-P12), (U,U),    (Z,-P12), (Z,P12), (U,U),   (INF,P12), (N,N),
-    (INF,-P12), (U,U),    (U,U),    (U,U),   (U,U),   (INF,P12), (N,N),
-    (INF,-P14), (INF,-Z), (INF,-Z), (INF,Z), (INF,Z), (INF,P14), (INF,N),
-    (INF,N),    (N,N),    (N,N),    (N,N),   (N,N),   (INF,N),   (N,N),
-    ])
-
-asinh_special_values = build_table([
-    (-INF,-P14), (-INF,-Z), (-INF,-Z),(-INF,Z), (-INF,Z), (-INF,P14), (-INF,N),
-    (-INF,-P12), (U,U),     (U,U),    (U,U),    (U,U),    (-INF,P12), (N,N),
-    (-INF,-P12), (U,U),     (-Z,-Z),  (-Z,Z),   (U,U),    (-INF,P12), (N,N),
-    (INF,-P12),  (U,U),     (Z,-Z),   (Z,Z),    (U,U),    (INF,P12),  (N,N),
-    (INF,-P12),  (U,U),     (U,U),    (U,U),    (U,U),    (INF,P12),  (N,N),
-    (INF,-P14),  (INF,-Z),  (INF,-Z), (INF,Z),  (INF,Z),  (INF,P14),  (INF,N),
-    (INF,N),     (N,N),     (N,-Z),   (N,Z),    (N,N),    (INF,N),    (N,N),
-    ])
-
-atanh_special_values = build_table([
-    (-Z,-P12), (-Z,-P12), (-Z,-P12), (-Z,P12), (-Z,P12), (-Z,P12), (-Z,N),
-    (-Z,-P12), (U,U),     (U,U),     (U,U),    (U,U),    (-Z,P12), (N,N),
-    (-Z,-P12), (U,U),     (-Z,-Z),   (-Z,Z),   (U,U),    (-Z,P12), (-Z,N),
-    (Z,-P12),  (U,U),     (Z,-Z),    (Z,Z),    (U,U),    (Z,P12),  (Z,N),
-    (Z,-P12),  (U,U),     (U,U),     (U,U),    (U,U),    (Z,P12),  (N,N),
-    (Z,-P12),  (Z,-P12),  (Z,-P12),  (Z,P12),  (Z,P12),  (Z,P12),  (Z,N),
-    (Z,-P12),  (N,N),     (N,N),     (N,N),    (N,N),    (Z,P12),  (N,N),
-    ])
-
-log_special_values = build_table([
-    (INF,-P34), (INF,-P), (INF,-P),  (INF,P),  (INF,P), (INF,P34), (INF,N),
-    (INF,-P12), (U,U),    (U,U),     (U,U),    (U,U),   (INF,P12), (N,N),
-    (INF,-P12), (U,U),    (-INF,-P), (-INF,P), (U,U),   (INF,P12), (N,N),
-    (INF,-P12), (U,U),    (-INF,-Z), (-INF,Z), (U,U),   (INF,P12), (N,N),
-    (INF,-P12), (U,U),    (U,U),     (U,U),    (U,U),   (INF,P12), (N,N),
-    (INF,-P14), (INF,-Z), (INF,-Z),  (INF,Z),  (INF,Z), (INF,P14), (INF,N),
-    (INF,N),    (N,N),    (N,N),     (N,N),    (N,N),   (INF,N),   (N,N),
-    ])
-
-sqrt_special_values = build_table([
-    (INF,-INF), (Z,-INF), (Z,-INF), (Z,INF), (Z,INF), (INF,INF), (N,INF),
-    (INF,-INF), (U,U),    (U,U),    (U,U),   (U,U),   (INF,INF), (N,N),
-    (INF,-INF), (U,U),    (Z,-Z),   (Z,Z),   (U,U),   (INF,INF), (N,N),
-    (INF,-INF), (U,U),    (Z,-Z),   (Z,Z),   (U,U),   (INF,INF), (N,N),
-    (INF,-INF), (U,U),    (U,U),    (U,U),   (U,U),   (INF,INF), (N,N),
-    (INF,-INF), (INF,-Z), (INF,-Z), (INF,Z), (INF,Z), (INF,INF), (INF,N),
-    (INF,-INF), (N,N),    (N,N),    (N,N),   (N,N),   (INF,INF), (N,N),
-    ])
-
-exp_special_values = build_table([
-    (Z,Z),   (U,U), (Z,-Z),   (Z,Z),   (U,U), (Z,Z),   (Z,Z),
-    (N,N),   (U,U), (U,U),    (U,U),   (U,U), (N,N),   (N,N),
-    (N,N),   (U,U), (1.,-Z),  (1.,Z),  (U,U), (N,N),   (N,N),
-    (N,N),   (U,U), (1.,-Z),  (1.,Z),  (U,U), (N,N),   (N,N),
-    (N,N),   (U,U), (U,U),    (U,U),   (U,U), (N,N),   (N,N),
-    (INF,N), (U,U), (INF,-Z), (INF,Z), (U,U), (INF,N), (INF,N),
-    (N,N),   (N,N), (N,-Z),   (N,Z),   (N,N), (N,N),   (N,N),
-    ])
-
-cosh_special_values = build_table([
-    (INF,N), (U,U), (INF,Z),  (INF,-Z), (U,U), (INF,N), (INF,N),
-    (N,N),   (U,U), (U,U),    (U,U),    (U,U), (N,N),   (N,N),
-    (N,Z),   (U,U), (1.,Z),   (1.,-Z),  (U,U), (N,Z),   (N,Z),
-    (N,Z),   (U,U), (1.,-Z),  (1.,Z),   (U,U), (N,Z),   (N,Z),
-    (N,N),   (U,U), (U,U),    (U,U),    (U,U), (N,N),   (N,N),
-    (INF,N), (U,U), (INF,-Z), (INF,Z),  (U,U), (INF,N), (INF,N),
-    (N,N),   (N,N), (N,Z),    (N,Z),    (N,N), (N,N),   (N,N),
-    ])
-
-sinh_special_values = build_table([
-    (INF,N), (U,U), (-INF,-Z), (-INF,Z), (U,U), (INF,N), (INF,N),
-    (N,N),   (U,U), (U,U),     (U,U),    (U,U), (N,N),   (N,N),
-    (Z,N),   (U,U), (-Z,-Z),   (-Z,Z),   (U,U), (Z,N),   (Z,N),
-    (Z,N),   (U,U), (Z,-Z),    (Z,Z),    (U,U), (Z,N),   (Z,N),
-    (N,N),   (U,U), (U,U),     (U,U),    (U,U), (N,N),   (N,N),
-    (INF,N), (U,U), (INF,-Z),  (INF,Z),  (U,U), (INF,N), (INF,N),
-    (N,N),   (N,N), (N,-Z),    (N,Z),    (N,N), (N,N),   (N,N),
-    ])
-
-tanh_special_values = build_table([
-    (-1.,Z), (U,U), (-1.,-Z), (-1.,Z), (U,U), (-1.,Z), (-1.,Z),
-    (N,N),   (U,U), (U,U),    (U,U),   (U,U), (N,N),   (N,N),
-    (N,N),   (U,U), (-Z,-Z),  (-Z,Z),  (U,U), (N,N),   (N,N),
-    (N,N),   (U,U), (Z,-Z),   (Z,Z),   (U,U), (N,N),   (N,N),
-    (N,N),   (U,U), (U,U),    (U,U),   (U,U), (N,N),   (N,N),
-    (1.,Z),  (U,U), (1.,-Z),  (1.,Z),  (U,U), (1.,Z),  (1.,Z),
-    (N,N),   (N,N), (N,-Z),   (N,Z),   (N,N), (N,N),   (N,N),
-    ])
-
-rect_special_values = build_table([
-    (INF,N), (U,U), (-INF,Z), (-INF,-Z), (U,U), (INF,N), (INF,N),
-    (N,N),   (U,U), (U,U),    (U,U),     (U,U), (N,N),   (N,N),
-    (Z,Z),   (U,U), (-Z,Z),   (-Z,-Z),   (U,U), (Z,Z),   (Z,Z),
-    (Z,Z),   (U,U), (Z,-Z),   (Z,Z),     (U,U), (Z,Z),   (Z,Z),
-    (N,N),   (U,U), (U,U),    (U,U),     (U,U), (N,N),   (N,N),
-    (INF,N), (U,U), (INF,-Z), (INF,Z),   (U,U), (INF,N), (INF,N),
-    (N,N),   (N,N), (N,Z),    (N,Z),     (N,N), (N,N),   (N,N),
-    ])
-
-assert copysign(1., acosh_special_values[5][2][1]) == -1.

File pypy/module/cmath/test/test_cmath.py

 
 
 def test_special_values():
-    from pypy.module.cmath.special_value import sqrt_special_values
+    from pypy.rlib.special_value import sqrt_special_values
     assert len(sqrt_special_values) == 7
     assert len(sqrt_special_values[4]) == 7
     assert isinstance(sqrt_special_values[5][1], tuple)
     Empty lines or lines starting with -- are ignored
     yields id, fn, arg_real, arg_imag, exp_real, exp_imag
     """
-    fname = os.path.join(os.path.dirname(__file__), fname)
     with open(fname) as fp:
         for line in fp:
             # skip comment lines and blank lines
 def test_specific_values():
     #if not float.__getformat__("double").startswith("IEEE"):
     #    return
-
-    for id, fn, ar, ai, er, ei, flags in parse_testfile('cmath_testcases.txt'):
+    
+    # too fragile...
+    fname = os.path.join(os.path.dirname(__file__), '../../../rlib/test', 'rcomplex_testcases.txt')
+    for id, fn, ar, ai, er, ei, flags in parse_testfile(fname):
         arg = (ar, ai)
         expected = (er, ei)
         function = getattr(interp_cmath, 'c_' + fn)

File pypy/module/micronumpy/__init__.py

         'str_': 'interp_boxes.W_StringBox',
         'unicode_': 'interp_boxes.W_UnicodeBox',
         'void': 'interp_boxes.W_VoidBox',
+        'complexfloating': 'interp_boxes.W_ComplexFloatingBox',
+        'complex_': 'interp_boxes.W_Complex128Box',
+        'complex128': 'interp_boxes.W_Complex128Box',
+        'complex64': 'interp_boxes.W_Complex64Box',
     }
 
     # ufuncs
         ("arccosh", "arccosh"),
         ("arcsinh", "arcsinh"),
         ("arctanh", "arctanh"),
+        ("conj", "conjugate"),
+        ("conjugate", "conjugate"),
         ("copysign", "copysign"),
         ("cos", "cos"),
         ("cosh", "cosh"),
         ('floor_divide', 'floor_divide'),
         ('logaddexp', 'logaddexp'),
         ('logaddexp2', 'logaddexp2'),
+        ('real', 'real'),
+        ('imag', 'imag'),
     ]:
         interpleveldefs[exposed] = "interp_ufuncs.get(space).%s" % impl
 

File pypy/module/micronumpy/compile.py

     w_slice = "slice"
     w_str = "str"
     w_unicode = "unicode"
-
+    w_complex = "complex"
+    
     def __init__(self):
         """NOT_RPYTHON"""
         self.fromcache = InternalSpaceCache(self).getorbuild

File pypy/module/micronumpy/interp_boxes.py

 from pypy.interpreter.baseobjspace import Wrappable
 from pypy.interpreter.error import operationerrfmt, OperationError
 from pypy.interpreter.gateway import interp2app, unwrap_spec
-from pypy.interpreter.typedef import TypeDef
+from pypy.interpreter.typedef import TypeDef, GetSetProperty
 from pypy.objspace.std.floattype import float_typedef
 from pypy.objspace.std.stringtype import str_typedef
 from pypy.objspace.std.unicodetype import unicode_typedef, unicode_from_object
 from pypy.objspace.std.inttype import int_typedef
+from pypy.objspace.std.complextype import complex_typedef
 from pypy.rlib.rarithmetic import LONG_BIT
 from pypy.tool.sourcetools import func_with_new_name
 from pypy.module.micronumpy.arrayimpl.voidbox import VoidBoxStorage
     def convert_to(self, dtype):
         return dtype.box(self.value)
 
+class ComplexBox(object):
+    _mixin_ = True
+
+    def __init__(self, real, imag=0.):
+        self.real = real
+        self.imag = imag
+
+    def convert_to(self, dtype):
+        from pypy.module.micronumpy.types import ComplexFloating
+        if not isinstance(dtype.itemtype, ComplexFloating):
+            raise TypeError('cannot convert %r to complex' % dtype)
+        return dtype.box_complex(self.real, self.imag)
+
+    def convert_real_to(self, dtype):
+        return dtype.box(self.real)
+
+    def convert_imag_to(self, dtype):
+        return dtype.box(self.imag)
+
 class W_GenericBox(Wrappable):
     _attrs_ = ()
 
         return space.wrap(box.value)
 
     def descr_float(self, space):
-        box = self.convert_to(W_Float64Box._get_dtype(space))
+        try:
+            box = self.convert_to(W_Float64Box._get_dtype(space))
+        except TypeError:
+            raise OperationError(space.w_TypeError,
+                                 space.wrap("Cannot convert %s to float" % self._get_dtype(space).name))
+
         assert isinstance(box, W_Float64Box)
         return space.wrap(box.value)
 
 def descr_index(space, self):
     return space.index(self.item(space))
 
+
 class W_VoidBox(W_FlexibleBox):
     @unwrap_spec(item=str)
     def descr_getitem(self, space, item):
         #    arr.storage[i] = arg[i]
         return W_UnicodeBox(arr, 0, arr.dtype)
 
+
+class W_ComplexFloatingBox(W_InexactBox):
+    _attrs_ = ()
+    def descr_get_real(self, space):
+        dtype = self._COMPONENTS_BOX._get_dtype(space)
+        box = self.convert_real_to(dtype)
+        assert isinstance(box, self._COMPONENTS_BOX)
+        return space.wrap(box)
+
+    def descr_get_imag(self, space):
+        dtype = self._COMPONENTS_BOX._get_dtype(space)
+        box = self.convert_imag_to(dtype)
+        assert isinstance(box, self._COMPONENTS_BOX)
+        return space.wrap(box)
+
+
+class W_Complex64Box(ComplexBox, W_ComplexFloatingBox):
+    descr__new__, _get_dtype = new_dtype_getter("complex64")
+    _COMPONENTS_BOX = W_Float32Box
+
+
+class W_Complex128Box(ComplexBox, W_ComplexFloatingBox):
+    descr__new__, _get_dtype = new_dtype_getter("complex128")
+    _COMPONENTS_BOX = W_Float64Box
+
+    
 W_GenericBox.typedef = TypeDef("generic",
     __module__ = "numpypy",
 
     __new__ = interp2app(W_UnicodeBox.descr__new__unicode_box.im_func),
 )
 
+W_ComplexFloatingBox.typedef = TypeDef("complexfloating", W_InexactBox.typedef,
+    __module__ = "numpypy",
+)
+
+
+W_Complex128Box.typedef = TypeDef("complex128", (W_ComplexFloatingBox.typedef, complex_typedef),
+    __module__ = "numpypy",
+    __new__ = interp2app(W_Complex128Box.descr__new__.im_func),
+    real = GetSetProperty(W_ComplexFloatingBox.descr_get_real),
+    imag = GetSetProperty(W_ComplexFloatingBox.descr_get_imag),
+)
+
+W_Complex64Box.typedef = TypeDef("complex64", (W_ComplexFloatingBox.typedef),
+    __module__ = "numpypy",
+    __new__ = interp2app(W_Complex64Box.descr__new__.im_func),
+    real = GetSetProperty(W_ComplexFloatingBox .descr_get_real),
+    imag = GetSetProperty(W_ComplexFloatingBox.descr_get_imag),
+)

File pypy/module/micronumpy/interp_dtype.py

     def box(self, value):
         return self.itemtype.box(value)
 
+    @specialize.argtype(1, 2)
+    def box_complex(self, real, imag):
+        return self.itemtype.box_complex(real, imag)
+
+
     def coerce(self, space, w_item):
         return self.itemtype.coerce(space, self, w_item)
 
     def is_signed(self):
         return self.kind == SIGNEDLTR
 
+    def is_complex_type(self):
+        return (self.num == 14 or self.num == 15)
+
     def is_bool_type(self):
         return self.kind == BOOLLTR
 
             alternate_constructors=[space.w_float],
             aliases=["float"],
         )
+        # self.w_float128dtype = W_Dtype(
+        #     types.Float128(),
+        #     num=13,
+        #     kind=FLOATINGLTR,
+        #     name="float128",
+        #     ...
+        # )
+        self.w_complex64dtype = W_Dtype(
+            types.Complex64(),
+            num=14,
+            kind=FLOATINGLTR,
+            name="complex64",
+            char="F",
+            w_box_type = space.gettypefor(interp_boxes.W_Complex64Box),
+        )
+        self.w_complex128dtype = W_Dtype(
+            types.Complex128(),
+            num=15,
+            kind=FLOATINGLTR,
+            name="complex128",
+            char="D",
+            w_box_type = space.gettypefor(interp_boxes.W_Complex128Box),
+            alternate_constructors=[space.w_complex],
+            aliases=["complex"],
+        )
         self.w_stringdtype = W_Dtype(
             types.StringType(1),
             num=18,
             self.w_int16dtype, self.w_uint16dtype, self.w_int32dtype,
             self.w_uint32dtype, self.w_longdtype, self.w_ulongdtype,
             self.w_int64dtype, self.w_uint64dtype,
-            self.w_float32dtype,
-            self.w_float64dtype, self.w_stringdtype, self.w_unicodedtype,
+            self.w_float32dtype, self.w_float64dtype, self.w_complex64dtype,
+            self.w_complex128dtype,
+            self.w_stringdtype, self.w_unicodedtype,
             self.w_voiddtype,
         ]
         self.float_dtypes_by_num_bytes = sorted(

File pypy/module/micronumpy/interp_numarray.py

     descr_neg = _unaryop_impl("negative")
     descr_abs = _unaryop_impl("absolute")
     descr_invert = _unaryop_impl("invert")
+    descr_get_real = _unaryop_impl("real")
+    descr_get_imag = _unaryop_impl("imag")
 
     def descr_nonzero(self, space):
         if self.get_size() > 1:
     swapaxes = interp2app(W_NDimArray.descr_swapaxes),
     flat = GetSetProperty(W_NDimArray.descr_get_flatiter),
     item = interp2app(W_NDimArray.descr_item),
+    real = GetSetProperty(W_NDimArray.descr_get_real),
+    imag = GetSetProperty(W_NDimArray.descr_get_imag),
 
     __array_interface__ = GetSetProperty(W_NDimArray.descr_array_iface),
 )
         for w_elem in elems_w:
             dtype = interp_ufuncs.find_dtype_for_scalar(space, w_elem,
                                                         dtype)
-            if dtype is interp_dtype.get_dtype_cache(space).w_float64dtype:
-                break
+            #if dtype is interp_dtype.get_dtype_cache(space).w_float64dtype:
+            #    break
+            
         if dtype is None:
             dtype = interp_dtype.get_dtype_cache(space).w_float64dtype
     if ndmin > len(shape):

File pypy/module/micronumpy/interp_ufuncs.py

     return not dtype.itemtype.bool(val)
 
 class W_Ufunc(Wrappable):
-    _attrs_ = ["name", "promote_to_float", "promote_bools", "identity"]
-    _immutable_fields_ = ["promote_to_float", "promote_bools", "name"]
+    _attrs_ = ["name", "promote_to_float", "promote_bools", "identity", "allow_complex"]
+    _immutable_fields_ = ["promote_to_float", "promote_bools", "name", "allow_complex"]
 
     def __init__(self, name, promote_to_float, promote_bools, identity,
-                 int_only):
+                 int_only, allow_complex):
         self.name = name
         self.promote_to_float = promote_to_float
         self.promote_bools = promote_bools
+        self.allow_complex = allow_complex
 
         self.identity = identity
         self.int_only = int_only
     _immutable_fields_ = ["func", "name"]
 
     def __init__(self, func, name, promote_to_float=False, promote_bools=False,
-        identity=None, bool_result=False, int_only=False):
+        identity=None, bool_result=False, int_only=False, allow_complex=True):
 
         W_Ufunc.__init__(self, name, promote_to_float, promote_bools, identity,
-                         int_only)
+                         int_only, allow_complex)
         self.func = func
         self.bool_result = bool_result
 
         calc_dtype = find_unaryop_result_dtype(space,
                                   w_obj.get_dtype(),
                                   promote_to_float=self.promote_to_float,
-                                  promote_bools=self.promote_bools)
+                                  promote_bools=self.promote_bools,
+                                  allow_complex=self.allow_complex)
         if out is not None:
             if not isinstance(out, W_NDimArray):
                 raise OperationError(space.w_TypeError, space.wrap(
     argcount = 2
 
     def __init__(self, func, name, promote_to_float=False, promote_bools=False,
-        identity=None, comparison_func=False, int_only=False):
+        identity=None, comparison_func=False, int_only=False, allow_complex=True):
 
         W_Ufunc.__init__(self, name, promote_to_float, promote_bools, identity,
-                         int_only)
+                         int_only, allow_complex)
         self.func = func
         self.comparison_func = comparison_func
         if name == 'logical_and':
             w_out = None
         w_lhs = convert_to_array(space, w_lhs)
         w_rhs = convert_to_array(space, w_rhs)
+        calc_dtype = find_binop_result_dtype(space,
+            w_lhs.get_dtype(), w_rhs.get_dtype(),
+            int_only=self.int_only,
+            promote_to_float=self.promote_to_float,
+            promote_bools=self.promote_bools,
+            allow_complex=self.allow_complex,
+            )
         if space.is_w(w_out, space.w_None) or w_out is None:
             out = None
-            calc_dtype = find_binop_result_dtype(space,
-                w_lhs.get_dtype(), w_rhs.get_dtype(),
-                int_only=self.int_only,
-                promote_to_float=self.promote_to_float,
-                promote_bools=self.promote_bools,
-            )
         elif not isinstance(w_out, W_NDimArray):
             raise OperationError(space.w_TypeError, space.wrap(
                     'output must be an array'))
 
 
 def find_binop_result_dtype(space, dt1, dt2, promote_to_float=False,
-    promote_bools=False, int_only=False):
+    promote_bools=False, int_only=False, allow_complex=True):
     # dt1.num should be <= dt2.num
     if dt1.num > dt2.num:
         dt1, dt2 = dt2, dt1
     if int_only and (not dt1.is_int_type() or not dt2.is_int_type()):
         raise OperationError(space.w_TypeError, space.wrap("Unsupported types"))
+    if not allow_complex and (dt1.is_complex_type() or dt2.is_complex_type()):
+        raise OperationError(space.w_TypeError, space.wrap("Unsupported types"))
     # Some operations promote op(bool, bool) to return int8, rather than bool
     if promote_bools and (dt1.kind == dt2.kind == interp_dtype.BOOLLTR):
         return interp_dtype.get_dtype_cache(space).w_int8dtype
+
+    # Everything promotes to complex
+    if dt2.num == 14 or dt2.num == 15 or dt1.num == 14 or dt2.num == 15:
+        if dt2.num == 15 or dt1.num == 15:
+            return interp_dtype.get_dtype_cache(space).w_complex128dtype
+        else:
+            return interp_dtype.get_dtype_cache(space).w_complex64dtype
+    
     if promote_to_float:
         return find_unaryop_result_dtype(space, dt2, promote_to_float=True)
     # If they're the same kind, choose the greater one.
 
 
 def find_unaryop_result_dtype(space, dt, promote_to_float=False,
-    promote_bools=False, promote_to_largest=False):
+    promote_bools=False, promote_to_largest=False, allow_complex=True):
     if promote_bools and (dt.kind == interp_dtype.BOOLLTR):
         return interp_dtype.get_dtype_cache(space).w_int8dtype
+    if not allow_complex and (dt.is_complex_type()):
+        raise OperationError(space.w_TypeError, space.wrap("Unsupported types"))
     if promote_to_float:
         if dt.kind == interp_dtype.FLOATINGLTR:
             return dt
     bool_dtype = interp_dtype.get_dtype_cache(space).w_booldtype
     long_dtype = interp_dtype.get_dtype_cache(space).w_longdtype
     int64_dtype = interp_dtype.get_dtype_cache(space).w_int64dtype
-
+    complex_type = interp_dtype.get_dtype_cache(space).w_complex128dtype
+    float_type = interp_dtype.get_dtype_cache(space).w_float64dtype
     if isinstance(w_obj, interp_boxes.W_GenericBox):
         dtype = w_obj.get_dtype(space)
         if current_guess is None:
             current_guess is long_dtype or current_guess is int64_dtype):
             return int64_dtype
         return current_guess
+    elif space.isinstance_w(w_obj, space.w_complex):
+        if (current_guess is None or current_guess is bool_dtype or
+            current_guess is long_dtype or current_guess is int64_dtype or
+            current_guess is complex_type or current_guess is float_type):
+            return complex_type
+        return current_guess
+    if current_guess is complex_type:
+        return complex_type
     return interp_dtype.get_dtype_cache(space).w_float64dtype
 
 
             ("floor_divide", "floordiv", 2, {"promote_bools": True}),
             ("divide", "div", 2, {"promote_bools": True}),
             ("true_divide", "div", 2, {"promote_to_float": True}),
-            ("mod", "mod", 2, {"promote_bools": True}),
+            ("mod", "mod", 2, {"promote_bools": True, 'allow_complex': False}),
             ("power", "pow", 2, {"promote_bools": True}),
             ("left_shift", "lshift", 2, {"int_only": True}),
             ("right_shift", "rshift", 2, {"int_only": True}),
             ("greater_equal", "ge", 2, {"comparison_func": True}),
             ("isnan", "isnan", 1, {"bool_result": True}),
             ("isinf", "isinf", 1, {"bool_result": True}),
-            ("isneginf", "isneginf", 1, {"bool_result": True}),
-            ("isposinf", "isposinf", 1, {"bool_result": True}),
+            ("isneginf", "isneginf", 1, {"bool_result": True,
+                                         "allow_complex": False}),
+            ("isposinf", "isposinf", 1, {"bool_result": True,
+                                         "allow_complex": False}),
             ("isfinite", "isfinite", 1, {"bool_result": True}),
 
             ('logical_and', 'logical_and', 2, {'comparison_func': True,
             ("maximum", "max", 2),
             ("minimum", "min", 2),
 
-            ("copysign", "copysign", 2, {"promote_to_float": True}),
+            ("copysign", "copysign", 2, {"promote_to_float": True,
+                                         "allow_complex": False}),
 
             ("positive", "pos", 1),
             ("negative", "neg", 1),
             ("absolute", "abs", 1),
             ("sign", "sign", 1, {"promote_bools": True}),
-            ("signbit", "signbit", 1, {"bool_result": True}),
+            ("signbit", "signbit", 1, {"bool_result": True, 
+                                       "allow_complex": False}),
             ("reciprocal", "reciprocal", 1),
+            ("conjugate", "conj", 1),
+            ("real", "real", 1),
+            ("imag", "imag", 1),
 
-            ("fabs", "fabs", 1, {"promote_to_float": True}),
+            ("fabs", "fabs", 1, {"promote_to_float": True,
+                                 "allow_complex": False}),
             ("fmax", "fmax", 2, {"promote_to_float": True}),
             ("fmin", "fmin", 2, {"promote_to_float": True}),
-            ("fmod", "fmod", 2, {"promote_to_float": True}),
-            ("floor", "floor", 1, {"promote_to_float": True}),
-            ("ceil", "ceil", 1, {"promote_to_float": True}),
-            ("trunc", "trunc", 1, {"promote_to_float": True}),
+            ("fmod", "fmod", 2, {"promote_to_float": True, 
+                                 'allow_complex': False}),
+            ("floor", "floor", 1, {"promote_to_float": True,
+                                   "allow_complex": False}),
+            ("ceil", "ceil", 1, {"promote_to_float": True,
+                                   "allow_complex": False}),
+            ("trunc", "trunc", 1, {"promote_to_float": True,
+                                   "allow_complex": False}),
             ("exp", "exp", 1, {"promote_to_float": True}),
             ("exp2", "exp2", 1, {"promote_to_float": True}),
             ("expm1", "expm1", 1, {"promote_to_float": True}),
             ("arcsin", "arcsin", 1, {"promote_to_float": True}),
             ("arccos", "arccos", 1, {"promote_to_float": True}),
             ("arctan", "arctan", 1, {"promote_to_float": True}),
-            ("arctan2", "arctan2", 2, {"promote_to_float": True}),
+            ("arctan2", "arctan2", 2, {"promote_to_float": True,
+                                       "allow_complex": False}),
             ("sinh", "sinh", 1, {"promote_to_float": True}),
             ("cosh", "cosh", 1, {"promote_to_float": True}),
             ("tanh", "tanh", 1, {"promote_to_float": True}),
             ("arccosh", "arccosh", 1, {"promote_to_float": True}),
             ("arctanh", "arctanh", 1, {"promote_to_float": True}),
 
-            ("radians", "radians", 1, {"promote_to_float": True}),
-            ("degrees", "degrees", 1, {"promote_to_float": True}),
+            ("radians", "radians", 1, {"promote_to_float": True,
+                                       "allow_complex": False}),
+            ("degrees", "degrees", 1, {"promote_to_float": True,
+                                       "allow_complex": False}),
 
             ("log", "log", 1, {"promote_to_float": True}),
             ("log2", "log2", 1, {"promote_to_float": True}),
             ("log10", "log10", 1, {"promote_to_float": True}),
             ("log1p", "log1p", 1, {"promote_to_float": True}),
-            ("logaddexp", "logaddexp", 2, {"promote_to_float": True}),
-            ("logaddexp2", "logaddexp2", 2, {"promote_to_float": True}),
+            ("logaddexp", "logaddexp", 2, {"promote_to_float": True,
+                                       "allow_complex": False}),
+            ("logaddexp2", "logaddexp2", 2, {"promote_to_float": True,
+                                       "allow_complex": False}),
         ]:
             self.add_ufunc(space, *ufunc_def)
 

File pypy/module/micronumpy/test/complex64_testcases.txt

+-- Testcases for functions in cmath.
+--
+-- Each line takes the form:
+--
+-- <testid> <function> <input_value> -> <output_value> <flags>
+--
+-- where:
+--
+--   <testid> is a short name identifying the test,
+--
+--   <function> is the function to be tested (exp, cos, asinh, ...),
+--
+--   <input_value> is a pair of floats separated by whitespace
+--     representing real and imaginary parts of a complex number, and
+--
+--   <output_value> is the expected (ideal) output value, again
+--     represented as a pair of floats.
+--
+--   <flags> is a list of the floating-point flags required by C99
+--
+-- The possible flags are:
+--
+--   divide-by-zero : raised when a finite input gives a
+--     mathematically infinite result.
+--
+--   overflow : raised when a finite input gives a finite result whose
+--     real or imaginary part is too large to fit in the usual range
+--     of an IEEE 754 double.
+--
+--   invalid : raised for invalid inputs.
+--
+--   ignore-real-sign : indicates that the sign of the real part of
+--     the result is unspecified; if the real part of the result is
+--     given as inf, then both -inf and inf should be accepted as
+--     correct.
+--
+--   ignore-imag-sign : indicates that the sign of the imaginary part
+--     of the result is unspecified.
+--
+-- Flags may appear in any order.
+--
+-- Lines beginning with '--' (like this one) start a comment, and are
+-- ignored.  Blank lines, or lines containing only whitespace, are also
+-- ignored.
+
+-- The majority of the values below were computed with the help of
+-- version 2.3 of the MPFR library for multiple-precision
+-- floating-point computations with correct rounding.  All output
+-- values in this file are (modulo yet-to-be-discovered bugs)
+-- correctly rounded, provided that each input and output decimal
+-- floating-point value below is interpreted as a representation of
+-- the corresponding nearest IEEE 754 double-precision value.  See the
+-- MPFR homepage at http://www.mpfr.org for more information about the
+-- MPFR project.
+
+-----------------------
+-- sqrt: Square root --
+-----------------------
+
+-- zeros
+sqrt0000 sqrt 0.0 0.0 -> 0.0 0.0
+sqrt0001 sqrt 0.0 -0.0 -> 0.0 -0.0
+sqrt0002 sqrt -0.0 0.0 -> 0.0 0.0
+sqrt0003 sqrt -0.0 -0.0 -> 0.0 -0.0
+sqrt0004 sqrt 1.0 -0.0 -> 1.0 -0.0
+
+-- values along both sides of real axis
+sqrt0010 sqrt -1.40129846432481707092372958329e-45  0.0 -> 0.0 3.743392130574644e-23
+sqrt0011 sqrt -1.40129846432481707092372958329e-45 -0.0 -> 0.0 -3.743392130574644e-23
+sqrt0012 sqrt -1e-35 0.0 -> 0.0 3.1622776601683795e-18
+sqrt0013 sqrt -1e-35 -0.0 -> 0.0 -3.1622776601683791e-18
+sqrt0014 sqrt -1e-20 0.0 -> 0.0 9.9999999999999996e-11
+sqrt0015 sqrt -1e-20 -0.0 -> 0.0 -9.9999999999999996e-11
+sqrt0016 sqrt -9.9999999999999998e-17 0.0 -> 0.0 1e-08
+sqrt0017 sqrt -9.9999999999999998e-17 -0.0 -> 0.0 -1e-08
+sqrt0018 sqrt -0.001 0.0 -> 0.0 0.031622776601683791
+sqrt0019 sqrt -0.001 -0.0 -> 0.0 -0.031622776601683791
+sqrt0020 sqrt -0.57899999999999996 0.0 -> 0.0 0.76092049518987193
+sqrt0021 sqrt -0.57899999999999996 -0.0 -> 0.0 -0.76092049518987193
+sqrt0022 sqrt -0.99999999999999989 0.0 -> 0.0 0.99999999999999989
+sqrt0023 sqrt -0.99999999999999989 -0.0 -> 0.0 -0.99999999999999989
+sqrt0024 sqrt -1.0000000000000002 0.0 -> 0.0 1.0
+sqrt0025 sqrt -1.0000000000000002 -0.0 -> 0.0 -1.0
+sqrt0026 sqrt -1.0009999999999999 0.0 -> 0.0 1.000499875062461
+sqrt0027 sqrt -1.0009999999999999 -0.0 -> 0.0 -1.000499875062461
+sqrt0028 sqrt -2.0 0.0 -> 0.0 1.4142135623730951
+sqrt0029 sqrt -2.0 -0.0 -> 0.0 -1.4142135623730951
+sqrt0030 sqrt -23.0 0.0 -> 0.0 4.7958315233127191
+sqrt0031 sqrt -23.0 -0.0 -> 0.0 -4.7958315233127191
+sqrt0032 sqrt -10000000000000000.0 0.0 -> 0.0 100000000.0
+sqrt0033 sqrt -10000000000000000.0 -0.0 -> 0.0 -100000000.0
+sqrt0034 sqrt -9.9999999999999998e+19 0.0 -> 0.0 9.9999999999999993e+9
+sqrt0035 sqrt -9.9999999999999998e+19 -0.0 -> 0.0 -9.9999999999999993e+9
+sqrt0036 sqrt -1.0000000000000001e+29 0.0 -> 0.0 3.1622776601683796e+14
+sqrt0037 sqrt -1.0000000000000001e+29 -0.0 -> 0.0 -3.1622776601683796e+14
+sqrt0038 sqrt 1.40129846432481707092372958329e-45 0.0 -> 3.743392130574644e-162 0.0
+sqrt0039 sqrt 9.8813129168249309e-324 -0.0 -> 3.1434555694052576e-162 -0.0
+sqrt0040 sqrt 1e-305 0.0 -> 3.1622776601683791e-153 0.0
+sqrt0041 sqrt 1e-305 -0.0 -> 3.1622776601683791e-153 -0.0
+sqrt0042 sqrt 1e-150 0.0 -> 9.9999999999999996e-76 0.0
+sqrt0043 sqrt 1e-150 -0.0 -> 9.9999999999999996e-76 -0.0
+sqrt0044 sqrt 9.9999999999999998e-17 0.0 -> 1e-08 0.0
+sqrt0045 sqrt 9.9999999999999998e-17 -0.0 -> 1e-08 -0.0
+sqrt0046 sqrt 0.001 0.0 -> 0.031622776601683791 0.0
+sqrt0047 sqrt 0.001 -0.0 -> 0.031622776601683791 -0.0
+sqrt0048 sqrt 0.57899999999999996 0.0 -> 0.76092049518987193 0.0
+sqrt0049 sqrt 0.57899999999999996 -0.0 -> 0.76092049518987193 -0.0
+sqrt0050 sqrt 0.99999999999999989 0.0 -> 0.99999999999999989 0.0
+sqrt0051 sqrt 0.99999999999999989 -0.0 -> 0.99999999999999989 -0.0
+sqrt0052 sqrt 1.0000000000000002 0.0 -> 1.0 0.0
+sqrt0053 sqrt 1.0000000000000002 -0.0 -> 1.0 -0.0
+sqrt0054 sqrt 1.0009999999999999 0.0 -> 1.000499875062461 0.0
+sqrt0055 sqrt 1.0009999999999999 -0.0 -> 1.000499875062461 -0.0
+sqrt0056 sqrt 2.0 0.0 -> 1.4142135623730951 0.0
+sqrt0057 sqrt 2.0 -0.0 -> 1.4142135623730951 -0.0
+sqrt0058 sqrt 23.0 0.0 -> 4.7958315233127191 0.0
+sqrt0059 sqrt 23.0 -0.0 -> 4.7958315233127191 -0.0
+sqrt0060 sqrt 10000000000000000.0 0.0 -> 100000000.0 0.0
+sqrt0061 sqrt 10000000000000000.0 -0.0 -> 100000000.0 -0.0
+sqrt0062 sqrt 9.9999999999999998e+149 0.0 -> 9.9999999999999993e+74 0.0
+sqrt0063 sqrt 9.9999999999999998e+149 -0.0 -> 9.9999999999999993e+74 -0.0
+sqrt0064 sqrt 1.0000000000000001e+299 0.0 -> 3.1622776601683796e+149 0.0
+sqrt0065 sqrt 1.0000000000000001e+299 -0.0 -> 3.1622776601683796e+149 -0.0
+
+-- random inputs
+sqrt0100 sqrt -0.34252542541549913 -223039880.15076211 -> 10560.300180587592 -10560.300196805192
+sqrt0101 sqrt -0.88790791393018909 -5.3307751730827402 -> 1.5027154613689004 -1.7737140896343291
+sqrt0102 sqrt -113916.89291310767 -0.018143374626153858 -> 2.6877817875351178e-05 -337.51576691038952
+sqrt0103 sqrt -0.63187172386197121 -0.26293913366617694 -> 0.16205707495266153 -0.81125471918761971
+sqrt0104 sqrt -0.058185169308906215 -2.3548312990430991 -> 1.0717660342420072 -1.0985752598086966
+sqrt0105 sqrt -1.0580584765935896 0.14400319259151736 -> 0.069837489270111242 1.030987755262468
+sqrt0106 sqrt -1.1667595947504932 0.11159711473953678 -> 0.051598531319315251 1.0813981705111229
+sqrt0107 sqrt -0.5123728411449906 0.026175433648339085 -> 0.018278026262418718 0.71603556293597614
+sqrt0108 sqrt -3.7453400060067228 1.0946500314809635 -> 0.27990088541692498 1.9554243814742367
+sqrt0109 sqrt -0.0027736121575097673 1.0367943000839817 -> 0.71903560338719175 0.72096172651250545
+sqrt0110 sqrt 1501.2559699453188 -1.1997325207283589 -> 38.746047664730959 -0.015481998720355024
+sqrt0111 sqrt 1.4830075326850578 -0.64100878436755349 -> 1.244712815741096 -0.25749264258434584
+sqrt0112 sqrt 0.095395618499734602 -0.48226565701639595 -> 0.54175904053472879 -0.44509239434231551
+sqrt0113 sqrt 0.50109185681863277 -0.54054037379892561 -> 0.7868179858332387 -0.34349772344520979
+sqrt0114 sqrt 0.98779807595367897 -0.00019848758437225191 -> 0.99388031770665153 -9.9854872279921968e-05
+sqrt0115 sqrt 11.845472380792259 0.0010051104581506761 -> 3.4417252072345397 0.00014601840612346451
+sqrt0116 sqrt 2.3558249686735975 0.25605157371744403 -> 1.5371278477386647 0.083288964575761404
+sqrt0117 sqrt 0.77584894123159098 1.0496420627016076 -> 1.0200744386390885 0.51449287568756552
+sqrt0118 sqrt 1.8961715669604893 0.34940793467158854 -> 1.3827991781411615 0.12634080935066902
+sqrt0119 sqrt 0.96025378316565801 0.69573224860140515 -> 1.0358710342209998 0.33581991658093457
+
+-- values near 0
+sqrt0120 sqrt 7.3577938365086866e-313 8.1181408465112743e-319 -> 8.5777583531543516e-157 4.732087634251168e-163
+sqrt0121 sqrt 1.2406883874892108e-310 -5.1210133324269776e-312 -> 1.1140990057468052e-155 -2.2982756945349973e-157
+sqrt0122 sqrt -7.1145453001139502e-322 2.9561379244703735e-314 -> 1.2157585807480286e-157 1.2157586100077242e-157
+sqrt0123 sqrt -4.9963244206801218e-314 -8.4718424423690227e-319 -> 1.8950582312540437e-162 -2.2352459419578971e-157
+sqrt0124 sqrt 0.0 7.699553609385195e-318 -> 1.9620848107797476e-159 1.9620848107797476e-159
+sqrt0125 sqrt -0.0 3.3900826606499415e-309 -> 4.1170879639922327e-155 4.1170879639922327e-155
+sqrt0126 sqrt 0.0 -9.8907989772250828e-319 -> 7.032353438652342e-160 -7.032353438652342e-160
+sqrt0127 sqrt -0.0 -1.3722939367590908e-315 -> 2.6194407196566702e-158 -2.6194407196566702e-158
+sqrt0128 sqrt 7.9050503334599447e-323 0.0 -> 8.8910349979403099e-162 0.0
+sqrt0129 sqrt 1.8623241768349486e-309 -0.0 -> 4.3154654173506579e-155 -0.0
+sqrt0130 sqrt -2.665971134499887e-308 0.0 -> 0.0 1.6327801856036491e-154
+sqrt0131 sqrt -1.5477066694467245e-310 -0.0 -> 0.0 -1.2440685951533077e-155
+
+-- inputs whose absolute value overflows
+sqrt0140 sqrt 1.6999999999999999e+308 -1.6999999999999999e+308 -> 1.4325088230154573e+154 -5.9336458271212207e+153
+sqrt0141 sqrt -1.797e+308 -9.9999999999999999e+306 -> 3.7284476432057307e+152 -1.3410406899802901e+154
+
+-- special values
+sqrt1000 sqrt 0.0 0.0 -> 0.0 0.0
+sqrt1001 sqrt -0.0 0.0 -> 0.0 0.0
+sqrt1002 sqrt 0.0 inf -> inf inf
+sqrt1003 sqrt 2.3 inf -> inf inf
+sqrt1004 sqrt inf inf -> inf inf
+sqrt1005 sqrt -0.0 inf -> inf inf
+sqrt1006 sqrt -2.3 inf -> inf inf
+sqrt1007 sqrt -inf inf -> inf inf
+sqrt1008 sqrt nan inf -> inf inf
+sqrt1009 sqrt 0.0 nan -> nan nan
+sqrt1010 sqrt 2.3 nan -> nan nan
+sqrt1011 sqrt -0.0 nan -> nan nan
+sqrt1012 sqrt -2.3 nan -> nan nan
+sqrt1013 sqrt -inf 0.0 -> 0.0 inf
+sqrt1014 sqrt -inf 2.3 -> 0.0 inf
+sqrt1015 sqrt inf 0.0 -> inf 0.0
+sqrt1016 sqrt inf 2.3 -> inf 0.0
+sqrt1017 sqrt -inf nan -> nan inf       ignore-imag-sign
+sqrt1018 sqrt inf nan -> inf nan
+sqrt1019 sqrt nan 0.0 -> nan nan
+sqrt1020 sqrt nan 2.3 -> nan nan
+sqrt1021 sqrt nan nan -> nan nan
+sqrt1022 sqrt 0.0 -0.0 -> 0.0 -0.0
+sqrt1023 sqrt -0.0 -0.0 -> 0.0 -0.0
+sqrt1024 sqrt 0.0 -inf -> inf -inf
+sqrt1025 sqrt 2.3 -inf -> inf -inf
+sqrt1026 sqrt inf -inf -> inf -inf
+sqrt1027 sqrt -0.0 -inf -> inf -inf
+sqrt1028 sqrt -2.3 -inf -> inf -inf
+sqrt1029 sqrt -inf -inf -> inf -inf
+sqrt1030 sqrt nan -inf -> inf -inf
+sqrt1031 sqrt -inf -0.0 -> 0.0 -inf
+sqrt1032 sqrt -inf -2.3 -> 0.0 -inf
+sqrt1033 sqrt inf -0.0 -> inf -0.0
+sqrt1034 sqrt inf -2.3 -> inf -0.0
+sqrt1035 sqrt nan -0.0 -> nan nan
+sqrt1036 sqrt nan -2.3 -> nan nan
+
+
+
+--------------------------
+-- acos: Inverse cosine --
+--------------------------
+
+-- zeros
+acos0000 acos 0.0 0.0 -> 1.5707963267948966 -0.0
+acos0001 acos 0.0 -0.0 -> 1.5707963267948966 0.0
+acos0002 acos -0.0 0.0 -> 1.5707963267948966 -0.0
+acos0003 acos -0.0 -0.0 -> 1.5707963267948966 0.0
+
+-- branch points: +/-1
+acos0010 acos 1.0 0.0 -> 0.0 -0.0
+acos0011 acos 1.0 -0.0 -> 0.0 0.0
+acos0012 acos -1.0 0.0 -> 3.1415926535897931 -0.0
+acos0013 acos -1.0 -0.0 -> 3.1415926535897931 0.0
+
+-- values along both sides of real axis
+acos0020 acos -9.8813129168249309e-324 0.0 -> 1.5707963267948966 -0.0
+acos0021 acos -9.8813129168249309e-324 -0.0 -> 1.5707963267948966 0.0
+acos0022 acos -1e-305 0.0 -> 1.5707963267948966 -0.0
+acos0023 acos -1e-305 -0.0 -> 1.5707963267948966 0.0
+acos0024 acos -1e-150 0.0 -> 1.5707963267948966 -0.0
+acos0025 acos -1e-150 -0.0 -> 1.5707963267948966 0.0
+acos0026 acos -9.9999999999999998e-17 0.0 -> 1.5707963267948968 -0.0
+acos0027 acos -9.9999999999999998e-17 -0.0 -> 1.5707963267948968 0.0
+acos0028 acos -0.001 0.0 -> 1.5717963269615634 -0.0
+acos0029 acos -0.001 -0.0 -> 1.5717963269615634 0.0
+acos0030 acos -0.57899999999999996 0.0 -> 2.1882979816120667 -0.0
+acos0031 acos -0.57899999999999996 -0.0 -> 2.1882979816120667 0.0
+acos0032 acos -0.99999999999999989 0.0 -> 3.1415926386886319 -0.0
+acos0033 acos -0.99999999999999989 -0.0 -> 3.1415926386886319 0.0
+acos0034 acos -1.0000000000000002 0.0 -> 3.1415926535897931 -2.1073424255447014e-08
+acos0035 acos -1.0000000000000002 -0.0 -> 3.1415926535897931 2.1073424255447014e-08
+acos0036 acos -1.0009999999999999 0.0 -> 3.1415926535897931 -0.044717633608306849
+acos0037 acos -1.0009999999999999 -0.0 -> 3.1415926535897931 0.044717633608306849
+acos0038 acos -2.0 0.0 -> 3.1415926535897931 -1.3169578969248168
+acos0039 acos -2.0 -0.0 -> 3.1415926535897931 1.3169578969248168
+acos0040 acos -23.0 0.0 -> 3.1415926535897931 -3.8281684713331012
+acos0041 acos -23.0 -0.0 -> 3.1415926535897931 3.8281684713331012
+acos0042 acos -10000000000000000.0 0.0 -> 3.1415926535897931 -37.534508668464674
+acos0043 acos -10000000000000000.0 -0.0 -> 3.1415926535897931 37.534508668464674
+acos0044 acos -9.9999999999999998e+149 0.0 -> 3.1415926535897931 -346.08091112966679
+acos0045 acos -9.9999999999999998e+149 -0.0 -> 3.1415926535897931 346.08091112966679
+acos0046 acos -1.0000000000000001e+299 0.0 -> 3.1415926535897931 -689.16608998577965
+acos0047 acos -1.0000000000000001e+299 -0.0 -> 3.1415926535897931 689.16608998577965
+acos0048 acos 9.8813129168249309e-324 0.0 -> 1.5707963267948966 -0.0
+acos0049 acos 9.8813129168249309e-324 -0.0 -> 1.5707963267948966 0.0
+acos0050 acos 1e-305 0.0 -> 1.5707963267948966 -0.0
+acos0051 acos 1e-305 -0.0 -> 1.5707963267948966 0.0
+acos0052 acos 1e-150 0.0 -> 1.5707963267948966 -0.0
+acos0053 acos 1e-150 -0.0 -> 1.5707963267948966 0.0
+acos0054 acos 9.9999999999999998e-17 0.0 -> 1.5707963267948966 -0.0
+acos0055 acos 9.9999999999999998e-17 -0.0 -> 1.5707963267948966 0.0
+acos0056 acos 0.001 0.0 -> 1.56979632662823 -0.0
+acos0057 acos 0.001 -0.0 -> 1.56979632662823 0.0
+acos0058 acos 0.57899999999999996 0.0 -> 0.95329467197772655 -0.0
+acos0059 acos 0.57899999999999996 -0.0 -> 0.95329467197772655 0.0
+acos0060 acos 0.99999999999999989 0.0 -> 1.4901161193847656e-08 -0.0
+acos0061 acos 0.99999999999999989 -0.0 -> 1.4901161193847656e-08 0.0
+acos0062 acos 1.0000000000000002 0.0 -> 0.0 -2.1073424255447014e-08
+acos0063 acos 1.0000000000000002 -0.0 -> 0.0 2.1073424255447014e-08
+acos0064 acos 1.0009999999999999 0.0 -> 0.0 -0.044717633608306849
+acos0065 acos 1.0009999999999999 -0.0 -> 0.0 0.044717633608306849
+acos0066 acos 2.0 0.0 -> 0.0 -1.3169578969248168
+acos0067 acos 2.0 -0.0 -> 0.0 1.3169578969248168
+acos0068 acos 23.0 0.0 -> 0.0 -3.8281684713331012
+acos0069 acos 23.0 -0.0 -> 0.0 3.8281684713331012
+acos0070 acos 10000000000000000.0 0.0 -> 0.0 -37.534508668464674
+acos0071 acos 10000000000000000.0 -0.0 -> 0.0 37.534508668464674
+acos0072 acos 9.9999999999999998e+149 0.0 -> 0.0 -346.08091112966679
+acos0073 acos 9.9999999999999998e+149 -0.0 -> 0.0 346.08091112966679
+acos0074 acos 1.0000000000000001e+299 0.0 -> 0.0 -689.16608998577965
+acos0075 acos 1.0000000000000001e+299 -0.0 -> 0.0 689.16608998577965
+
+-- random inputs
+acos0100 acos -3.3307113324596682 -10.732007530863266 -> 1.8706085694482339 3.113986806554613
+acos0101 acos -2863.952991743291 -2681013315.2571239 -> 1.5707973950301699 22.402607843274758
+acos0102 acos -0.33072639793220088 -0.85055464658253055 -> 1.8219426895922601 0.79250166729311966
+acos0103 acos -2.5722325842097802 -12.703940809821574 -> 1.7699942413107408 3.2565170156527325
+acos0104 acos -42.495233785459583 -0.54039320751337161 -> 3.1288732573153304 4.4424815519735601
+acos0105 acos -1.1363818625856401 9641.1325498630376 -> 1.5709141948820049 -9.8669410553254284
+acos0106 acos -2.4398426824157866e-11 0.33002051890266165 -> 1.570796326818066 -0.32430578041578667
+acos0107 acos -1.3521340428186552 2.9369737912076772 -> 1.9849059192339338 -1.8822893674117942
+acos0108 acos -1.827364706477915 1.0355459232147557 -> 2.5732246307960032 -1.4090688267854969
+acos0109 acos -0.25978373706403546 10.09712669185833 -> 1.5963940386378306 -3.0081673050196063
+acos0110 acos 0.33561778471072551 -4587350.6823999118 -> 1.5707962536333251 16.031960402579539
+acos0111 acos 0.49133444610998445 -0.8071422362990015 -> 1.1908761712801788 0.78573345813187867
+acos0112 acos 0.42196734507823974 -2.4812965431745115 -> 1.414091186100692 1.651707260988172
+acos0113 acos 2.961426210100655 -219.03295695248664 -> 1.5572768319822778 6.0824659885827304
+acos0114 acos 2.886209063652641 -20.38011207220606 -> 1.4302765252297889 3.718201853147642
+acos0115 acos 0.4180568075276509 1.4833433990823484 -> 1.3393834558303042 -1.2079847758301576
+acos0116 acos 52.376111405924718 0.013930429001941001 -> 0.00026601761804024188 -4.6515066691204714
+acos0117 acos 41637948387.625969 1.563418292894041 -> 3.7547918507883548e-11 -25.145424989809381
+acos0118 acos 0.061226659122249526 0.8447234394615154 -> 1.5240280306367315 -0.76791798971140812
+acos0119 acos 2.4480466420442959e+26 0.18002339201384662 -> 7.353756620564798e-28 -61.455650015996376
+
+-- values near infinity
+acos0200 acos 1.6206860518683021e+308 1.0308426226285283e+308 -> 0.56650826093826223 -710.54206874241561
+acos0201 acos 1.2067735875070062e+308 -1.3429173724390276e+308 -> 0.83874369390864889 710.48017794027498
+acos0202 acos -7.4130145132549047e+307 1.1759130543927645e+308 -> 2.1332729346478536 -710.21871115698752
+acos0203 acos -8.6329426442257249e+307 -1.2316282952184133e+308 -> 2.1821511032444838 710.29752145697148
+acos0204 acos 0.0 1.4289713855849746e+308 -> 1.5707963267948966 -710.24631069738996
+acos0205 acos -0.0 1.3153524545987432e+308 -> 1.5707963267948966 -710.1634604787539
+acos0206 acos 0.0 -9.6229037669269321e+307 -> 1.5707963267948966 709.85091679573691
+acos0207 acos -0.0 -4.9783616421107088e+307 -> 1.5707963267948966 709.19187157911233
+acos0208 acos 1.3937541925739389e+308 0.0 -> 0.0 -710.22135678707264
+acos0209 acos 9.1362388967371536e+307 -0.0 -> 0.0 709.79901953124613
+acos0210 acos -1.3457361220697436e+308 0.0 -> 3.1415926535897931 -710.18629698871848
+acos0211 acos -5.4699090056144284e+307 -0.0 -> 3.1415926535897931 709.28603271085649
+acos0212 acos 1.5880716932358901e+308 5.5638401252339929 -> 3.503519487773873e-308 -710.35187633140583
+acos0213 acos 1.2497211663463164e+308 -3.0456477717911024 -> 2.4370618453197486e-308 710.11227628223412
+acos0214 acos -9.9016224006029528e+307 4.9570427340789056 -> 3.1415926535897931 -709.87946935229468
+acos0215 acos -1.5854071066874139e+308 -4.4233577741497783 -> 3.1415926535897931 710.35019704672004
+acos0216 acos 9.3674623083647628 1.5209559051877979e+308 -> 1.5707963267948966 -710.30869484491086
+acos0217 acos 8.1773832021784383 -6.6093445795000056e+307 -> 1.5707963267948966 709.4752552227792
+acos0218 acos -3.1845935000665104 1.5768856396650893e+308 -> 1.5707963267948966 -710.34480761042687
+acos0219 acos -1.0577303880953903 -6.4574626815735613e+307 -> 1.5707963267948966 709.45200719662046
+
+-- values near 0
+acos0220 acos 1.8566986970714045e-320 3.1867234156760402e-321 -> 1.5707963267948966 -3.1867234156760402e-321
+acos0221 acos 7.9050503334599447e-323 -8.8931816251424378e-323 -> 1.5707963267948966 8.8931816251424378e-323
+acos0222 acos -4.4465908125712189e-323 2.4654065097222727e-311 -> 1.5707963267948966 -2.4654065097222727e-311
+acos0223 acos -6.1016916408192619e-311 -2.4703282292062327e-323 -> 1.5707963267948966 2.4703282292062327e-323
+acos0224 acos 0.0 3.4305783621842729e-311 -> 1.5707963267948966 -3.4305783621842729e-311
+acos0225 acos -0.0 1.6117409498633145e-319 -> 1.5707963267948966 -1.6117409498633145e-319
+acos0226 acos 0.0 -4.9900630229965901e-322 -> 1.5707963267948966 4.9900630229965901e-322
+acos0227 acos -0.0 -4.4889279210592818e-311 -> 1.5707963267948966 4.4889279210592818e-311
+acos0228 acos 5.3297678681477214e-312 0.0 -> 1.5707963267948966 -0.0
+acos0229 acos 6.2073425897211614e-313 -0.0 -> 1.5707963267948966 0.0
+acos0230 acos -4.9406564584124654e-324 0.0 -> 1.5707963267948966 -0.0
+acos0231 acos -1.7107517052899003e-318 -0.0 -> 1.5707963267948966 0.0
+
+-- special values
+acos1000 acos 0.0 0.0 -> 1.5707963267948966 -0.0
+acos1001 acos 0.0 -0.0 -> 1.5707963267948966 0.0
+acos1002 acos -0.0 0.0 -> 1.5707963267948966 -0.0
+acos1003 acos -0.0 -0.0 -> 1.5707963267948966 0.0
+acos1004 acos 0.0 nan -> 1.5707963267948966 nan
+acos1005 acos -0.0 nan -> 1.5707963267948966 nan
+acos1006 acos -2.3 inf -> 1.5707963267948966 -inf
+acos1007 acos -0.0 inf -> 1.5707963267948966 -inf
+acos1008 acos 0.0 inf -> 1.5707963267948966 -inf
+acos1009 acos 2.3 inf -> 1.5707963267948966 -inf
+acos1010 acos -2.3 nan -> nan nan
+acos1011 acos 2.3 nan -> nan nan
+acos1012 acos -inf 2.3 -> 3.1415926535897931 -inf
+acos1013 acos -inf 0.0 -> 3.1415926535897931 -inf
+acos1014 acos inf 2.3 -> 0.0 -inf
+acos1015 acos inf 0.0 -> 0.0 -inf
+acos1016 acos -inf inf -> 2.3561944901923448 -inf
+acos1017 acos inf inf -> 0.78539816339744828 -inf
+acos1018 acos inf nan -> nan inf                        ignore-imag-sign
+acos1019 acos -inf nan -> nan inf                       ignore-imag-sign
+acos1020 acos nan 0.0 -> nan nan
+acos1021 acos nan 2.3 -> nan nan
+acos1022 acos nan inf -> nan -inf
+acos1023 acos nan nan -> nan nan
+acos1024 acos -2.3 -inf -> 1.5707963267948966 inf
+acos1025 acos -0.0 -inf -> 1.5707963267948966 inf
+acos1026 acos 0.0 -inf -> 1.5707963267948966 inf
+acos1027 acos 2.3 -inf -> 1.5707963267948966 inf
+acos1028 acos -inf -2.3 -> 3.1415926535897931 inf
+acos1029 acos -inf -0.0 -> 3.1415926535897931 inf
+acos1030 acos inf -2.3 -> 0.0 inf
+acos1031 acos inf -0.0 -> 0.0 inf
+acos1032 acos -inf -inf -> 2.3561944901923448 inf
+acos1033 acos inf -inf -> 0.78539816339744828 inf
+acos1034 acos nan -0.0 -> nan nan
+acos1035 acos nan -2.3 -> nan nan
+acos1036 acos nan -inf -> nan inf
+
+
+--------------------------------------
+-- acosh: Inverse hyperbolic cosine --
+--------------------------------------
+
+-- zeros
+acosh0000 acosh 0.0 0.0 -> 0.0 1.5707963267948966
+acosh0001 acosh 0.0 -0.0 -> 0.0 -1.5707963267948966
+acosh0002 acosh -0.0 0.0 -> 0.0 1.5707963267948966
+acosh0003 acosh -0.0 -0.0 -> 0.0 -1.5707963267948966
+
+-- branch points: +/-1
+acosh0010 acosh 1.0 0.0 -> 0.0 0.0
+acosh0011 acosh 1.0 -0.0 -> 0.0 -0.0
+acosh0012 acosh -1.0 0.0 -> 0.0 3.1415926535897931
+acosh0013 acosh -1.0 -0.0 -> 0.0 -3.1415926535897931
+
+-- values along both sides of real axis
+acosh0020 acosh -9.8813129168249309e-324 0.0 -> 0.0 1.5707963267948966
+acosh0021 acosh -9.8813129168249309e-324 -0.0 -> 0.0 -1.5707963267948966
+acosh0022 acosh -1e-305 0.0 -> 0.0 1.5707963267948966
+acosh0023 acosh -1e-305 -0.0 -> 0.0 -1.5707963267948966
+acosh0024 acosh -1e-150 0.0 -> 0.0 1.5707963267948966
+acosh0025 acosh -1e-150 -0.0 -> 0.0 -1.5707963267948966
+acosh0026 acosh -9.9999999999999998e-17 0.0 -> 0.0 1.5707963267948968
+acosh0027 acosh -9.9999999999999998e-17 -0.0 -> 0.0 -1.5707963267948968
+acosh0028 acosh -0.001 0.0 -> 0.0 1.5717963269615634
+acosh0029 acosh -0.001 -0.0 -> 0.0 -1.5717963269615634
+acosh0030 acosh -0.57899999999999996 0.0 -> 0.0 2.1882979816120667
+acosh0031 acosh -0.57899999999999996 -0.0 -> 0.0 -2.1882979816120667
+acosh0032 acosh -0.99999999999999989 0.0 -> 0.0 3.1415926386886319
+acosh0033 acosh -0.99999999999999989 -0.0 -> 0.0 -3.1415926386886319
+acosh0034 acosh -1.0000000000000002 0.0 -> 2.1073424255447014e-08 3.1415926535897931
+acosh0035 acosh -1.0000000000000002 -0.0 -> 2.1073424255447014e-08 -3.1415926535897931
+acosh0036 acosh -1.0009999999999999 0.0 -> 0.044717633608306849 3.1415926535897931
+acosh0037 acosh -1.0009999999999999 -0.0 -> 0.044717633608306849 -3.1415926535897931
+acosh0038 acosh -2.0 0.0 -> 1.3169578969248168 3.1415926535897931
+acosh0039 acosh -2.0 -0.0 -> 1.3169578969248168 -3.1415926535897931
+acosh0040 acosh -23.0 0.0 -> 3.8281684713331012 3.1415926535897931
+acosh0041 acosh -23.0 -0.0 -> 3.8281684713331012 -3.1415926535897931
+acosh0042 acosh -10000000000000000.0 0.0 -> 37.534508668464674 3.1415926535897931
+acosh0043 acosh -10000000000000000.0 -0.0 -> 37.534508668464674 -3.1415926535897931
+acosh0044 acosh -9.9999999999999998e+149 0.0 -> 346.08091112966679 3.1415926535897931
+acosh0045 acosh -9.9999999999999998e+149 -0.0 -> 346.08091112966679 -3.1415926535897931
+acosh0046 acosh -1.0000000000000001e+299 0.0 -> 689.16608998577965 3.1415926535897931
+acosh0047 acosh -1.0000000000000001e+299 -0.0 -> 689.16608998577965 -3.1415926535897931
+acosh0048 acosh 9.8813129168249309e-324 0.0 -> 0.0 1.5707963267948966
+acosh0049 acosh 9.8813129168249309e-324 -0.0 -> 0.0 -1.5707963267948966
+acosh0050 acosh 1e-305 0.0 -> 0.0 1.5707963267948966
+acosh0051 acosh 1e-305 -0.0 -> 0.0 -1.5707963267948966
+acosh0052 acosh 1e-150 0.0 -> 0.0 1.5707963267948966
+acosh0053 acosh 1e-150 -0.0 -> 0.0 -1.5707963267948966
+acosh0054 acosh 9.9999999999999998e-17 0.0 -> 0.0 1.5707963267948966
+acosh0055 acosh 9.9999999999999998e-17 -0.0 -> 0.0 -1.5707963267948966
+acosh0056 acosh 0.001 0.0 -> 0.0 1.56979632662823
+acosh0057 acosh 0.001 -0.0 -> 0.0 -1.56979632662823
+acosh0058 acosh 0.57899999999999996 0.0 -> 0.0 0.95329467197772655
+acosh0059 acosh 0.57899999999999996 -0.0 -> 0.0 -0.95329467197772655
+acosh0060 acosh 0.99999999999999989 0.0 -> 0.0 1.4901161193847656e-08
+acosh0061 acosh 0.99999999999999989 -0.0 -> 0.0 -1.4901161193847656e-08
+acosh0062 acosh 1.0000000000000002 0.0 -> 2.1073424255447014e-08 0.0
+acosh0063 acosh 1.0000000000000002 -0.0 -> 2.1073424255447014e-08 -0.0
+acosh0064 acosh 1.0009999999999999 0.0 -> 0.044717633608306849 0.0
+acosh0065 acosh 1.0009999999999999 -0.0 -> 0.044717633608306849 -0.0
+acosh0066 acosh 2.0 0.0 -> 1.3169578969248168 0.0
+acosh0067 acosh 2.0 -0.0 -> 1.3169578969248168 -0.0
+acosh0068 acosh 23.0 0.0 -> 3.8281684713331012 0.0
+acosh0069 acosh 23.0 -0.0 -> 3.8281684713331012 -0.0
+acosh0070 acosh 10000000000000000.0 0.0 -> 37.534508668464674 0.0
+acosh0071 acosh 10000000000000000.0 -0.0 -> 37.534508668464674 -0.0
+acosh0072 acosh 9.9999999999999998e+149 0.0 -> 346.08091112966679 0.0
+acosh0073 acosh 9.9999999999999998e+149 -0.0 -> 346.08091112966679 -0.0
+acosh0074 acosh 1.0000000000000001e+299 0.0 -> 689.16608998577965 0.0
+acosh0075 acosh 1.0000000000000001e+299 -0.0 -> 689.16608998577965 -0.0
+
+-- random inputs
+acosh0100 acosh -1.4328589581250843 -1.8370347775558309 -> 1.5526962646549587 -2.190250168435786
+acosh0101 acosh -0.31075819156220957 -1.0772555786839297 -> 0.95139168286193709 -1.7812228089636479
+acosh0102 acosh -1.9044776578070453 -20.485370158932124 -> 3.7177411088932359 -1.6633888745861227
+acosh0103 acosh -0.075642506000858742 -21965976320.873051 -> 24.505907742881991 -1.5707963267983402
+acosh0104 acosh -1.6162271181056307 -3.0369343458696099 -> 1.9407057262861227 -2.0429549461750209
+acosh0105 acosh -0.3103780280298063 0.00018054880018078987 -> 0.00018992877058761416 1.886386995096728
+acosh0106 acosh -9159468751.5897655 5.8014747664273649 -> 23.631201197959193 3.1415926529564078
+acosh0107 acosh -0.037739157550933884 0.21841357493510705 -> 0.21685844960602488 1.6076735133449402
+acosh0108 acosh -8225991.0508394297 0.28318543008913644 -> 16.615956520420287 3.1415926191641019
+acosh0109 acosh -35.620070502302639 0.31303237005015 -> 4.2658980006943965 3.1328013255541873
+acosh0110 acosh 96.729939906820917 -0.029345228372365334 -> 5.2650434775863548 -0.00030338895866972843
+acosh0111 acosh 0.59656024007966491 -2.0412294654163978 -> 1.4923002024287835 -1.312568421900338
+acosh0112 acosh 109.29384112677828 -0.00015454863061533812 -> 5.3871662961545477 -1.4141245154061214e-06
+acosh0113 acosh 8.6705651969361597 -3.6723631649787465 -> 2.9336180958363545 -0.40267362031872861
+acosh0114 acosh 1.8101646445052686 -0.012345132721855478 -> 1.1997148566285769 -0.0081813912760150265
+acosh0115 acosh 52.56897195025288 0.001113916065985443 -> 4.6551827622264135 2.1193445872040307e-05
+acosh0116 acosh 0.28336786164214739 355643992457.40485 -> 27.290343226816528 1.5707963267940999
+acosh0117 acosh 0.73876621291911437 2.8828594541104322e-20 -> 4.2774820978159067e-20 0.73955845836827927
+acosh0118 acosh 0.025865471781718878 37125746064318.492 -> 31.938478989418012 1.5707963267948959
+acosh0119 acosh 2.2047353511780132 0.074712248143489271 -> 1.4286403248698021 0.037997904971626598
+
+-- values near infinity
+acosh0200 acosh 8.1548592876467785e+307 9.0943779335951128e+307 -> 710.08944620800605 0.83981165425478954
+acosh0201 acosh 1.4237229680972531e+308 -1.0336966617874858e+308 -> 710.4543331094759 -0.6279972876348755
+acosh0202 acosh -1.5014526899738939e+308 1.5670700378448792e+308 -> 710.66420706795464 2.3348137299106697
+acosh0203 acosh -1.0939040375213928e+308 -1.0416960351127978e+308 -> 710.30182863115886 -2.380636147787027
+acosh0204 acosh 0.0 1.476062433559588e+308 -> 710.27873384716929 1.5707963267948966
+acosh0205 acosh -0.0 6.2077210326221094e+307 -> 709.41256457484769 1.5707963267948966
+acosh0206 acosh 0.0 -1.5621899909968308e+308 -> 710.33544449990734 -1.5707963267948966
+acosh0207 acosh -0.0 -8.3556624833839122e+307 -> 709.70971018048317 -1.5707963267948966
+acosh0208 acosh 1.3067079752499342e+308 0.0 -> 710.15686680107228 0.0
+acosh0209 acosh 1.5653640340214026e+308 -0.0 -> 710.33747422926706 -0.0
+acosh0210 acosh -6.9011375992290636e+307 0.0 -> 709.51845699719922 3.1415926535897931
+acosh0211 acosh -9.9539576809926973e+307 -0.0 -> 709.88474095870185 -3.1415926535897931
+acosh0212 acosh 7.6449598518914925e+307 9.5706540768268358 -> 709.62081731754802 1.2518906916769345e-307
+acosh0213 acosh 5.4325410972602197e+307 -7.8064807816522706 -> 709.279177727925 -1.4369851312471974e-307
+acosh0214 acosh -1.1523626112360465e+308 7.0617510038869336 -> 710.03117010216909 3.1415926535897931
+acosh0215 acosh -1.1685027786862599e+308 -5.1568558357925625 -> 710.04507907571417 -3.1415926535897931
+acosh0216 acosh 3.0236370339788721 1.7503248720096417e+308 -> 710.44915723458064 1.5707963267948966
+acosh0217 acosh 6.6108007926031149 -9.1469968225806149e+307 -> 709.80019633903328 -1.5707963267948966
+acosh0218 acosh -5.1096262905623959 6.4484926785412395e+307 -> 709.45061713997973 1.5707963267948966
+acosh0219 acosh -2.8080920608735846 -1.7716118836519368e+308 -> 710.46124562363445 -1.5707963267948966
+
+-- values near 0
+acosh0220 acosh 4.5560530326699304e-317 7.3048989121436657e-318 -> 7.3048989121436657e-318 1.5707963267948966
+acosh0221 acosh 4.8754274133585331e-314 -9.8469794897684199e-315 -> 9.8469794897684199e-315 -1.5707963267948966
+acosh0222 acosh -4.6748876009960097e-312 9.7900342887557606e-318 -> 9.7900342887557606e-318 1.5707963267948966
+acosh0223 acosh -4.3136871538399236e-320 -4.9406564584124654e-323 -> 4.9406564584124654e-323 -1.5707963267948966
+acosh0224 acosh 0.0 4.3431013866496774e-314 -> 4.3431013866496774e-314 1.5707963267948966
+acosh0225 acosh -0.0 6.0147334335829184e-317 -> 6.0147334335829184e-317 1.5707963267948966
+acosh0226 acosh 0.0 -1.2880291387081297e-320 -> 1.2880291387081297e-320 -1.5707963267948966
+acosh0227 acosh -0.0 -1.4401563976534621e-317 -> 1.4401563976534621e-317 -1.5707963267948966
+acosh0228 acosh 1.3689680570863091e-313 0.0 -> 0.0 1.5707963267948966
+acosh0229 acosh 1.5304346893494371e-312 -0.0 -> 0.0 -1.5707963267948966
+acosh0230 acosh -3.7450175954766488e-320 0.0 -> 0.0 1.5707963267948966
+acosh0231 acosh -8.4250563080885801e-311 -0.0 -> 0.0 -1.5707963267948966
+
+-- special values
+acosh1000 acosh 0.0 0.0 -> 0.0 1.5707963267948966
+acosh1001 acosh -0.0 0.0 -> 0.0 1.5707963267948966
+acosh1002 acosh 0.0 inf -> inf 1.5707963267948966
+acosh1003 acosh 2.3 inf -> inf 1.5707963267948966
+acosh1004 acosh -0.0 inf -> inf 1.5707963267948966
+acosh1005 acosh -2.3 inf -> inf 1.5707963267948966
+acosh1006 acosh 0.0 nan -> nan nan
+acosh1007 acosh 2.3 nan -> nan nan
+acosh1008 acosh -0.0 nan -> nan nan
+acosh1009 acosh -2.3 nan -> nan nan
+acosh1010 acosh -inf 0.0 -> inf 3.1415926535897931
+acosh1011 acosh -inf 2.3 -> inf 3.1415926535897931
+acosh1012 acosh inf 0.0 -> inf 0.0
+acosh1013 acosh inf 2.3 -> inf 0.0
+acosh1014 acosh -inf inf -> inf 2.3561944901923448
+acosh1015 acosh inf inf -> inf 0.78539816339744828
+acosh1016 acosh inf nan -> inf nan
+acosh1017 acosh -inf nan -> inf nan
+acosh1018 acosh nan 0.0 -> nan nan
+acosh1019 acosh nan 2.3 -> nan nan
+acosh1020 acosh nan inf -> inf nan
+acosh1021 acosh nan nan -> nan nan
+acosh1022 acosh 0.0 -0.0 -> 0.0 -1.5707963267948966
+acosh1023 acosh -0.0 -0.0 -> 0.0 -1.5707963267948966
+acosh1024 acosh 0.0 -inf -> inf -1.5707963267948966
+acosh1025 acosh 2.3 -inf -> inf -1.5707963267948966
+acosh1026 acosh -0.0 -inf -> inf -1.5707963267948966
+acosh1027 acosh -2.3 -inf -> inf -1.5707963267948966
+acosh1028 acosh -inf -0.0 -> inf -3.1415926535897931
+acosh1029 acosh -inf -2.3 -> inf -3.1415926535897931
+acosh1030 acosh inf -0.0 -> inf -0.0
+acosh1031 acosh inf -2.3 -> inf -0.0
+acosh1032 acosh -inf -inf -> inf -2.3561944901923448
+acosh1033 acosh inf -inf -> inf -0.78539816339744828
+acosh1034 acosh nan -0.0 -> nan nan
+acosh1035 acosh nan -2.3 -> nan nan
+acosh1036 acosh nan -inf -> inf nan
+
+