about summary refs log tree commit diff
path: root/math
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1997-12-01 17:16:22 +0000
committerUlrich Drepper <drepper@redhat.com>1997-12-01 17:16:22 +0000
commit04be94a87d0a74c022490db7f4f926253f0d69d3 (patch)
treeaed47130338b81c2af8e92849ed1429596adeca3 /math
parentf4017d205738b913f1002433cde5d4b4e93fbd81 (diff)
downloadglibc-04be94a87d0a74c022490db7f4f926253f0d69d3.tar.gz
glibc-04be94a87d0a74c022490db7f4f926253f0d69d3.tar.xz
glibc-04be94a87d0a74c022490db7f4f926253f0d69d3.zip
1997-12-01 17:27  Ulrich Drepper  <drepper@cygnus.com>

	* Makefile (subdirs): Add iconvdata and localedata.

	* iconv/gconv.h: Define UNKNOWN_10646_CHAR as error value.

	* iconv/gconv_conf.c (read_conf_file): Little optimization.

	* iconvdata/8bit-gap.c: New file.
	* iconvdata/8bit-generic.c: Renamed from ...
	* iconvdata/iso8859-generic.c: ...this.
	* iconvdata/configure: Removed.
	* iconvdata/Makefile: Add new modules and better rules.
	* iconvdata/iso6937.c: Minor bug fixes.
	* iconvdata/iso8859-1.c: Likewise.
	* iconvdata/t61.c: Likewise.
	* iconvdata/iso8859-2.c: Change to use 8bit-generic.c.
	Minor bug fixes.
	* iconvdata/iso8859-3.c: Likewise.
	* iconvdata/iso8859-4.c: Likewise.
	* iconvdata/iso8859-5.c: Likewise.
	* iconvdata/iso8859-6.c: Likewise.
	* iconvdata/iso8859-7.c: Likewise.
	* iconvdata/iso8859-8.c: Likewise.
	* iconvdata/iso8859-9.c: Likewise.
	* iconvdata/iso8859-10.c: Likewise.
	* iconvdata/ebcdic-at-de-a.c: New file.
	* iconvdata/ebcdic-at-de.c: New file.
	* iconvdata/ebcdic-ca-fr.c: New file.
	* iconvdata/hp-roman8.c: New file.
	* iconvdata/koi-8.c: New file.
	* iconvdata/koi8-r.c: New file.
	* iconvdata/koi8-h.c: New file.
	* iconvdata/latin-greek-1.c: New file.
	* iconvdata/latin-greek-1.h: New file.
	* iconvdata/latin-greek.c: New file.
	* iconvdata/latin-greek.h: New file.
	* iconvdata/jis0201.c: New file.
	* iconvdata/jis0201.h: New file.
	* iconvdata/jis0208.c: New file.
	* iconvdata/jis0208.h: New file.
	* iconvdata/jis0212.c: New file.
	* iconvdata/jis0212.h: New file.
	* iconvdata/sjis.c: New file.
	* iconvdata/gap.pl: New file.  Script to generate table header.
	* iconvdata/gaptab.pl: New file.
	* iconvdata/gconv-modules: Add info about new modules.

	* locale/programs/charmap.c: Also examine alias names given in charmap
	files.

	* localedata/*: Add to here from add-on.  We need the information
	to generate tables for iconv.

	Update from db-2.3.14.
	* db2/Makefile: Updated.
	* db2/config.h: Likewise.
	* db2/db.h: Likewise.
	* db2/db_int.h: Likewise.
	* db2/btree/bt_cursor.c: Likewise.
	* db2/btree/bt_delete.c: Likewise.
	* db2/btree/bt_put.c: Likewise.
	* db2/btree/bt_search.c: Likewise.
	* db2/btree/bt_split.c: Likewise.
	* db2/btree/btree_auto.c: Likewise.
	* db2/common/db_appinit.c: Likewise.
	* db2/common/db_apprec.c: Likewise.
	* db2/common/db_err.c: Likewise.
	* db2/common/db_region.c: Likewise.
	* db2/db/db_auto.c: Likewise.
	* db2/db/db_dispatch.c: Likewise.
	* db2/db/db_ret.c: Likewise.
	* db2/dbm/dbm.c: Likewise.
	* db2/hash/hash_auto.c: Likewise.
	* db2/include/btree_ext.h: Likewise.
	* db2/include/common_ext.h: Likewise.
	* db2/include/db.h.src: Likewise.
	* db2/include/db_cxx.h: Likewise.
	* db2/include/db_ext.h: Likewise.
	* db2/include/db_int.h.src: Likewise.
	* db2/include/lock.h: Likewise.
	* db2/include/log.h: Likewise.
	* db2/include/mp.h: Likewise.
	* db2/include/mp_ext.h: Likewise.
	* db2/include/os_ext.h: Likewise.
	* db2/include/os_func.h: Likewise.
	* db2/lock/lock.c: Likewise.
	* db2/lock/lock_deadlock.c: Likewise.
	* db2/log/log.c: Likewise.
	* db2/log/log_archive.c: Likewise.
	* db2/log/log_auto.c: Likewise.
	* db2/log/log_get.c: Likewise.
	* db2/log/log_put.c: Likewise.
	* db2/mp/mp_bh.c: Likewise.
	* db2/mp/mp_fget.c: Likewise.
	* db2/mp/mp_fopen.c: Likewise.
	* db2/mp/mp_fput.c: Likewise.
	* db2/mp/mp_fset.c: Likewise.
	* db2/mp/mp_open.c: Likewise.
	* db2/mp/mp_pr.c: Likewise.
	* db2/mp/mp_region.c: Likewise.
	* db2/mp/mp_sync.c: Likewise.
	* db2/mutex/README: Likewise.
	* db2/mutex/mutex.c: Likewise.
	* db2/os/os_open.c: Likewise.
	* db2/os/os_func.c: Removed.
	* db2/os/os_config.c: New file.
	* db2/os/os_spin.c: New file.
	* db2/txn/txn.c: Likewise.
	* db2/txn/txn_auto.c: Likewise.

1997-11-30 06:01  Ulrich Drepper  <drepper@cygnus.com>

	* posix/sys/wait.h (__WAIT_INT): Don't use complex version with
	__typeof for C++ since this fails for class members.
	Reported by Neal Becker <neal@ctd.comsat.com>.

1997-11-28 11:21  Zack Weinberg  <zack@rabi.phys.columbia.edu>

	* configure.in: Check for a working makeinfo (3.11 or better).
	* config.make.in: Add MAKEINFO to be substituted.
	* manual/Makefile: Don't update info if makeinfo is too old.

1997-11-30 05:21  Ulrich Drepper  <drepper@cygnus.com>

	* sysdeps/alpha/setjmp.S: Define _ASM and _SETJMP_H to get definitions.
	* sysdeps/alpha/__longjmp.S: Likewise.
	* sysdeps/unix/sysv/linux/alpha/kernel_termios.h: Include <termios.h>
	not <bits/termios.h>.

	* sysdeps/unix/sysv/linux/alpha/syscalls.list: Define syscall as
	__llseek and make llseek and lseek64 weak aliases.
	* sysdeps/unix/sysv/linux/sparc/sparc64/syscalls.list: Likewise.
	Patches by a sun <asun@zoology.washington.edu>.

1997-11-29 19:19  Zack Weinberg  <zack@rabi.phys.columbia.edu>

	* misc/sys/syslog.h: Delete KERNEL preprocessor conditional.
	* sysdeps/unix/sysv/linux/powerpc/bits/termios.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/bits/termios.h: Likewise.
	* misc/sys/syslog.h: Clean up BSD header.

1997-11-29  Andreas Jaeger  <aj@arthur.rhein-neckar.de>

	* sysdeps/unix/sysv/linux/bits/in.h: Add changes from Linux 2.1.67.

	* sysdeps/libm-ieee754/s_ctan.c (__ctan): Raise invalid exception
	for ctan(+-inf,x).
	* sysdeps/libm-ieee754/s_ctanl.c (__ctanl): Likewise.
	* sysdeps/libm-ieee754/s_ctanf.c (__ctanf): Likewise.

	* math/libm-test.c (csqrt_test): Add tests for cabs, carg, ctan,
	csqrt (-1), ctanh(i*pi/4).

1997-11-26  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>

	* sysdeps/generic/bits/confname.h: Fix comma in enumerator.

1997-11-28 13:28  Philip Blundell  <Philip.Blundell@pobox.com>

	* sysdeps/unix/sysv/linux/net/if_arp.h: Add more ARPHRD_ constants.

1997-11-26  Andreas Jaeger  <aj@arthur.rhein-neckar.de>

	* wcsmbs/wcrtomb.c (__wcrtomb): Remove unused variable fake.

1997-11-26 21:28  Ulrich Drepper  <drepper@cygnus.com>

	* sysdeps/posix/getcwd.c (GETCWD_STORYGE_CLASS): Remove definition
	and use.  Define GETCWD_RETURN_TYPE instead and use it.
	* sysdeps/unix/sysv/linux/getcwd.c: Define GETCWD_RETURN_TYPE instead
	of GETCWD_STORYGE_CLASS and put the return type and the
	`internal_function' in the right order for gcc 2.7.2.

1997-11-26  Andreas Jaeger  <aj@arthur.rhein-neckar.de>

	* sysdeps/unix/sysv/linux/sys/module.h: Remove file.  It's
	incompatible with Linux 2.1.x.  Packages using modules
	(e.g. modutils) should/do provide their own version.  Suggested by
	Richard Henderson.

	* sysdeps/unix/sysv/linux/Dist: Remove sys/module.h.

	* sysdeps/unix/sysv/linux/Makefile (sysdep_headers)
	[$(subdir)=socket]: Remove sys/module.h.

	* libio/stdio.h: Correct comment of sys_nerr/sys_errlist.
Diffstat (limited to 'math')
-rw-r--r--math/libm-test.c286
1 files changed, 283 insertions, 3 deletions
diff --git a/math/libm-test.c b/math/libm-test.c
index b7f265c038..a4b31a6929 100644
--- a/math/libm-test.c
+++ b/math/libm-test.c
@@ -53,11 +53,11 @@
    scalb, scalbn, signbit, sin, sincos, sinh, sqrt, tan, tanh, trunc
 
    and for the following complex math functions:
-   cacos, cacosh, casin, casinh, catan, catanh,
-   ccos, ccosh, cexp, clog, cpow, csin, csinh, csqrt, ctanh.
+   cabs, cacos, cacosh, carg, casin, casinh, catan, catanh,
+   ccos, ccosh, cexp, clog, cpow, csin, csinh, csqrt, ctan, ctanh.
 
    At the moment the following functions aren't tested:
-   cabs, carg, conj, cproj, cimag, creal, ctan, drem,
+   conj, cproj, cimag, creal, drem,
    j0, j1, jn, y0, y1, yn,
    significand,
    nan, comparison macros (isless,isgreater,...).
@@ -4044,6 +4044,145 @@ catanh_test (void)
 
 
 static void
+ctan_test (void)
+{
+  __complex__ MATHTYPE result;
+
+  result = FUNC(ctan) (BUILD_COMPLEX (0, 0));
+  check ("real(ctan(0 + i0)) = 0", __real__ result, 0);
+  check ("imag(ctan(0 + i0)) = 0", __imag__ result, 0);
+  result = FUNC(ctan) (BUILD_COMPLEX (0, minus_zero));
+  check ("real(ctan(0 - i0)) = 0", __real__ result, 0);
+  check ("imag(ctan(0 - i0)) = -0", __imag__ result, minus_zero);
+  result = FUNC(ctan) (BUILD_COMPLEX (minus_zero, 0));
+  check ("real(ctan(-0 + i0)) = -0", __real__ result, minus_zero);
+  check ("imag(ctan(-0 + i0)) = 0", __imag__ result, 0);
+  result = FUNC(ctan) (BUILD_COMPLEX (minus_zero, minus_zero));
+  check ("real(ctan(-0 - i0)) = -0", __real__ result, minus_zero);
+  check ("imag(ctan(-0 - i0)) = -0", __imag__ result, minus_zero);
+
+
+  result = FUNC(ctan) (BUILD_COMPLEX (0, plus_infty));
+  check ("real(ctan(0 + i Inf)) = 0", __real__ result, 0);
+  check ("imag(ctan(0 + i Inf)) = 1", __imag__ result, 1);
+  result = FUNC(ctan) (BUILD_COMPLEX (1, plus_infty));
+  check ("real(ctan(1 + i Inf)) = 0", __real__ result, 0);
+  check ("imag(ctan(1 + i Inf)) = 1", __imag__ result, 1);
+  result = FUNC(ctan) (BUILD_COMPLEX (minus_zero, plus_infty));
+  check ("real(ctan(-0 + i Inf)) = -0", __real__ result, minus_zero);
+  check ("imag(ctan(-0 + i Inf)) = 1", __imag__ result, 1);
+  result = FUNC(ctan) (BUILD_COMPLEX (-1, plus_infty));
+  check ("real(ctan(-1 + i Inf)) = -0", __real__ result, minus_zero);
+  check ("imag(ctan(-1 + i Inf)) = 1", __imag__ result, 1);
+
+  result = FUNC(ctan) (BUILD_COMPLEX (0, minus_infty));
+  check ("real(ctan(0 - i Inf)) = 0", __real__ result, 0);
+  check ("imag(ctan(0 - i Inf)) = -1", __imag__ result, -1);
+  result = FUNC(ctan) (BUILD_COMPLEX (1, minus_infty));
+  check ("real(ctan(1 - i Inf)) = 0", __real__ result, 0);
+  check ("imag(ctan(1 - i Inf)) = -1", __imag__ result, -1);
+  result = FUNC(ctan) (BUILD_COMPLEX (minus_zero, minus_infty));
+  check ("real(ctan(-0 - i Inf)) = -0", __real__ result, minus_zero);
+  check ("imag(ctan(-0 - i Inf)) = -1", __imag__ result, -1);
+  result = FUNC(ctan) (BUILD_COMPLEX (-1, minus_infty));
+  check ("real(ctan(-1 - i Inf)) = -0", __real__ result, minus_zero);
+  check ("imag(ctan(-1 - i Inf)) = -1", __imag__ result, -1);
+
+  result = FUNC(ctan) (BUILD_COMPLEX (plus_infty, 0));
+  check_isnan_exc ("real(ctan(Inf + i 0)) = NaN plus invalid exception",
+		   __real__ result, INVALID_EXCEPTION);
+  check_isnan ("imag(ctan(Inf + i 0)) = NaN plus invalid exception",
+	       __imag__ result);
+  result = FUNC(ctan) (BUILD_COMPLEX (plus_infty, 2));
+  check_isnan_exc ("real(ctan(Inf + i 2)) = NaN plus invalid exception",
+		   __real__ result, INVALID_EXCEPTION);
+  check_isnan ("imag(ctan(Inf + i 2)) = NaN plus invalid exception",
+	       __imag__ result);
+  result = FUNC(ctan) (BUILD_COMPLEX (minus_infty, 0));
+  check_isnan_exc ("real(ctan(-Inf + i 0)) = NaN plus invalid exception",
+		   __real__ result, INVALID_EXCEPTION);
+  check_isnan ("imag(ctan(-Inf + i 0)) = NaN plus invalid exception",
+	       __imag__ result);
+  result = FUNC(ctan) (BUILD_COMPLEX (minus_infty, 2));
+  check_isnan_exc ("real(ctan(- Inf + i 2)) = NaN plus invalid exception",
+		   __real__ result, INVALID_EXCEPTION);
+  check_isnan ("imag(ctan(- Inf + i 2)) = NaN plus invalid exception",
+	       __imag__ result);
+  result = FUNC(ctan) (BUILD_COMPLEX (plus_infty, minus_zero));
+  check_isnan_exc ("real(ctan(Inf - i 0)) = NaN plus invalid exception",
+		   __real__ result, INVALID_EXCEPTION);
+  check_isnan ("imag(ctan(Inf - i 0)) = NaN plus invalid exception",
+	       __imag__ result);
+  result = FUNC(ctan) (BUILD_COMPLEX (plus_infty, -2));
+  check_isnan_exc ("real(ctan(Inf - i 2)) = NaN plus invalid exception",
+		   __real__ result, INVALID_EXCEPTION);
+  check_isnan ("imag(ctan(Inf - i 2)) = NaN plus invalid exception",
+	       __imag__ result);
+  result = FUNC(ctan) (BUILD_COMPLEX (minus_infty, minus_zero));
+  check_isnan_exc ("real(ctan(-Inf - i 0)) = NaN plus invalid exception",
+		   __real__ result, INVALID_EXCEPTION);
+  check_isnan ("imag(ctan(-Inf - i 0)) = NaN plus invalid exception",
+	       __imag__ result);
+  result = FUNC(ctan) (BUILD_COMPLEX (minus_infty, -2));
+  check_isnan_exc ("real(ctan(-Inf - i 2)) = NaN plus invalid exception",
+		   __real__ result, INVALID_EXCEPTION);
+  check_isnan ("imag(ctan(-Inf - i 2)) = NaN plus invalid exception",
+	       __imag__ result);
+
+  result = FUNC(ctan) (BUILD_COMPLEX (nan_value, plus_infty));
+  check ("real(ctan(NaN + i Inf)) = +-0", FUNC(fabs) (__real__ result), 0);
+  check ("imag(ctan(NaN + i Inf)) = 1", __imag__ result, 1);
+  result = FUNC(ctan) (BUILD_COMPLEX (nan_value, minus_infty));
+  check ("real(ctan(NaN - i Inf)) = +-0", FUNC(fabs) (__real__ result), 0);
+  check ("imag(ctan(NaN - i Inf)) = -1", __imag__ result, -1);
+
+  result = FUNC(ctan) (BUILD_COMPLEX (0, nan_value));
+  check ("real(ctan(0 + i NaN)) = 0", __real__ result, 0);
+  check_isnan ("imag(ctan(0 + i NaN)) = NaN", __imag__ result);
+  result = FUNC(ctan) (BUILD_COMPLEX (minus_zero, nan_value));
+  check ("real(ctan(-0 + i NaN)) = -0", __real__ result, minus_zero);
+  check_isnan ("imag(ctan(-0 + i NaN)) = NaN", __imag__ result);
+
+  result = FUNC(ctan) (BUILD_COMPLEX (0.5, nan_value));
+  check_isnan_maybe_exc ("real(ctan(0.5 + i NaN)) = NaN plus maybe invalid exception",
+			 __real__ result, INVALID_EXCEPTION);
+  check_isnan ("imag(ctan(0.5 + i NaN)) = NaN plus maybe invalid exception",
+	       __imag__ result);
+  result = FUNC(ctan) (BUILD_COMPLEX (-4.5, nan_value));
+  check_isnan_maybe_exc ("real(ctan(-4.5 + i NaN)) = NaN plus maybe invalid exception",
+			 __real__ result, INVALID_EXCEPTION);
+  check_isnan ("imag(ctan(-4.5 + i NaN)) = NaN plus maybe invalid exception",
+	       __imag__ result);
+
+  result = FUNC(ctan) (BUILD_COMPLEX (nan_value, 0));
+  check_isnan_maybe_exc ("real(ctan(NaN + i 0)) = NaN plus maybe invalid exception",
+			 __real__ result, INVALID_EXCEPTION);
+  check_isnan ("imag(ctan(NaN + i 0)) = NaN plus maybe invalid exception",
+	       __imag__ result);
+  result = FUNC(ctan) (BUILD_COMPLEX (nan_value, 5));
+  check_isnan_maybe_exc ("real(ctan(NaN + i 5)) = NaN plus maybe invalid exception",
+			 __real__ result, INVALID_EXCEPTION);
+  check_isnan ("imag(ctan(NaN + i 5)) = NaN plus maybe invalid exception",
+	       __imag__ result);
+  result = FUNC(ctan) (BUILD_COMPLEX (nan_value, minus_zero));
+  check_isnan_maybe_exc ("real(ctan(NaN - i 0)) = NaN plus maybe invalid exception",
+			 __real__ result, INVALID_EXCEPTION);
+  check_isnan ("imag(ctan(NaN - i 0)) = NaN plus maybe invalid exception",
+	       __imag__ result);
+  result = FUNC(ctan) (BUILD_COMPLEX (nan_value, -0.25));
+  check_isnan_maybe_exc ("real(ctan(NaN -i 0.25)) = NaN plus maybe invalid exception",
+			 __real__ result, INVALID_EXCEPTION);
+  check_isnan ("imag(ctanh(NaN -i 0.25)) = NaN plus maybe invalid exception",
+	       __imag__ result);
+
+  result = FUNC(ctan) (BUILD_COMPLEX (nan_value, nan_value));
+  check_isnan ("real(ctan(NaN + i NaN)) = NaN", __real__ result);
+  check_isnan ("imag(ctan(NaN + i NaN)) = NaN", __imag__ result);
+
+}
+
+
+static void
 ctanh_test (void)
 {
   __complex__ MATHTYPE result;
@@ -4176,6 +4315,11 @@ ctanh_test (void)
   result = FUNC(ctanh) (BUILD_COMPLEX (nan_value, nan_value));
   check_isnan ("real(ctanh(NaN + i NaN)) = NaN", __real__ result);
   check_isnan ("imag(ctanh(NaN + i NaN)) = NaN", __imag__ result);
+
+  result = FUNC(ctanh) (BUILD_COMPLEX (0, M_PI_4));
+  check ("real(ctanh (0 + i pi/4)) == 0", __real__ result, 0);
+  check_eps ("imag(ctanh (0 + i pi/4)) == 1", __imag__ result, 1,
+	     CHOOSE (0, 0, 2e-7));
 }
 
 
@@ -4622,6 +4766,10 @@ csqrt_test (void)
   result = FUNC(csqrt) (BUILD_COMPLEX (nan_value, nan_value));
   check_isnan ("real(csqrt(NaN + i NaN)) = NaN", __real__ result);
   check_isnan ("imag(csqrt(NaN + i NaN)) = NaN", __imag__ result);
+
+  result = FUNC(csqrt) (BUILD_COMPLEX (-1, 0));
+  check ("real(csqrt(1 + i0) = 0", __real__ result, 0);
+  check ("imag(csqrt(1 + i0) = 1", __imag__ result, 1);
 }
 
 
@@ -4643,6 +4791,133 @@ cpow_test (void)
 
 
 static void
+cabs_test (void)
+{
+  /* cabs (x + iy) is specified as hypot (x,y) */
+  MATHTYPE a;
+  a = random_greater (0);
+  check_isinfp_ext ("cabs (+inf + i x) == +inf",
+		    FUNC(cabs) (BUILD_COMPLEX (plus_infty, a)), a);
+  check_isinfp_ext ("cabs (-inf + i x) == +inf",
+		    FUNC(cabs) (BUILD_COMPLEX (minus_infty, a)), a);
+
+  check_isinfp ("cabs (+inf+ iNaN) == +inf",
+		FUNC(cabs) (BUILD_COMPLEX(minus_infty, nan_value)));
+  check_isinfp ("cabs (-inf+ iNaN) == +inf",
+		FUNC(cabs) (BUILD_COMPLEX(minus_infty, nan_value)));
+
+  check_isnan ("cabs (NaN+ iNaN) == NaN",
+	       FUNC(cabs) (BUILD_COMPLEX(nan_value, nan_value)));
+
+  a = FUNC(cabs) (BUILD_COMPLEX (12.4L, 0.7L));
+  check ("cabs (x,y) == cabs (y,x)",
+	 FUNC(cabs) (BUILD_COMPLEX(0.7L, 12.4L)), a);
+  check ("cabs (x,y) == cabs (-x,y)",
+	 FUNC(cabs) (BUILD_COMPLEX(-12.4L, 0.7L)), a);
+  check ("cabs (x,y) == cabs (-y,x)",
+	 FUNC(cabs) (BUILD_COMPLEX(-0.7L, 12.4L)), a);
+  check ("cabs (x,y) == cabs (-x,-y)",
+	 FUNC(cabs) (BUILD_COMPLEX(-12.4L, -0.7L)), a);
+  check ("cabs (x,y) == cabs (-y,-x)",
+	 FUNC(cabs) (BUILD_COMPLEX(-0.7L, -12.4L)), a);
+  check ("cabs (x,0) == fabs (x)", FUNC(cabs) (BUILD_COMPLEX(-0.7L, 0)), 0.7L);
+  check ("cabs (x,0) == fabs (x)", FUNC(cabs) (BUILD_COMPLEX(0.7L, 0)), 0.7L);
+  check ("cabs (x,0) == fabs (x)", FUNC(cabs) (BUILD_COMPLEX(-1.0L, 0)), 1.0L);
+  check ("cabs (x,0) == fabs (x)", FUNC(cabs) (BUILD_COMPLEX(1.0L, 0)), 1.0L);
+  check ("cabs (x,0) == fabs (x)", FUNC(cabs) (BUILD_COMPLEX(-5.7e7L, 0)),
+	 5.7e7L);
+  check ("cabs (x,0) == fabs (x)", FUNC(cabs) (BUILD_COMPLEX(5.7e7L, 0)),
+	 5.7e7L);
+
+}
+
+
+static void
+carg_test (void)
+{
+  /* carg (x + iy) is specified as atan2 (y, x) */
+  MATHTYPE x;
+
+  x = random_greater (0);
+  check ("carg (x + i 0) == 0 for x > 0",
+	 FUNC(carg) (BUILD_COMPLEX(x, 0)), 0);
+  x = random_greater (0);
+  check ("carg (x - i 0) == -0 for x > 0",
+	 FUNC(carg) (BUILD_COMPLEX(x, minus_zero)), minus_zero);
+
+  check ("carg (+0 + i 0) == +0", FUNC(carg) (BUILD_COMPLEX(0, 0)), 0);
+  check ("carg (+0 - i 0) == -0", FUNC(carg) (BUILD_COMPLEX(0, minus_zero)),
+	 minus_zero);
+
+  x = -random_greater (0);
+  check ("carg (x + i 0) == +pi for x < 0", FUNC(carg) (BUILD_COMPLEX(x, 0)),
+	 M_PI);
+
+  x = -random_greater (0);
+  check ("carg (x - i 0) == -pi for x < 0",
+	 FUNC(carg) (BUILD_COMPLEX(x, minus_zero)), -M_PI);
+
+  check ("carg (-0 + i 0) == +pi", FUNC(carg) (BUILD_COMPLEX(minus_zero, 0)),
+	 M_PI);
+  check ("carg (-0 - i 0) == -pi",
+	 FUNC(carg) (BUILD_COMPLEX(minus_zero, minus_zero)), -M_PI);
+
+  x = random_greater (0);
+  check ("carg (+0 + i y) == pi/2 for y > 0", FUNC(carg) (BUILD_COMPLEX(0, x)),
+	 M_PI_2);
+
+  x = random_greater (0);
+  check ("carg (-0 + i y) == pi/2 for y > 0",
+	 FUNC(carg) (BUILD_COMPLEX(minus_zero, x)), M_PI_2);
+
+  x = random_less (0);
+  check ("carg (+0 + i y) == -pi/2 for y < 0", FUNC(carg) (BUILD_COMPLEX(0, x)),
+	 -M_PI_2);
+
+  x = random_less (0);
+  check ("carg (-0 + i y) == -pi/2 for y < 0",
+	 FUNC(carg) (BUILD_COMPLEX(minus_zero, x)), -M_PI_2);
+
+  x = random_greater (0);
+  check ("carg (inf + i y) == +0 for finite y > 0",
+	 FUNC(carg) (BUILD_COMPLEX(plus_infty, x)), 0);
+
+  x = -random_greater (0);
+  check ("carg (inf + i y) == -0 for finite y < 0",
+	 FUNC(carg) (BUILD_COMPLEX(plus_infty, x)), minus_zero);
+
+  x = random_value (-1e4, 1e4);
+  check ("carg(x + i inf) == pi/2 for finite x",
+         FUNC(carg) (BUILD_COMPLEX(x, plus_infty)), M_PI_2);
+
+  x = random_value (-1e4, 1e4);
+  check ("carg(x - i inf) == -pi/2 for finite x",
+         FUNC(carg) (BUILD_COMPLEX(x, minus_infty)), -M_PI_2);
+
+  x = random_greater (0);
+  check ("carg (-inf + i y) == +pi for finite y > 0",
+	 FUNC(carg) (BUILD_COMPLEX(minus_infty, x)), M_PI);
+
+  x = -random_greater (0);
+  check ("carg (-inf + i y) == -pi for finite y < 0",
+	 FUNC(carg) (BUILD_COMPLEX(minus_infty, x)), -M_PI);
+
+  check ("carg (+inf + i inf) == +pi/4",
+	 FUNC(carg) (BUILD_COMPLEX(plus_infty, plus_infty)), M_PI_4);
+
+  check ("carg (+inf -i inf) == -pi/4",
+	 FUNC(carg) (BUILD_COMPLEX(plus_infty, minus_infty)), -M_PI_4);
+
+  check ("carg (-inf +i inf) == +3*pi/4",
+	 FUNC(carg) (BUILD_COMPLEX(minus_infty, plus_infty)), 3 * M_PI_4);
+
+  check ("carg (-inf -i inf) == -3*pi/4",
+	 FUNC(carg) (BUILD_COMPLEX(minus_infty, minus_infty)), -3 * M_PI_4);
+
+}
+
+
+static void
 nearbyint_test (void)
 {
   check ("nearbyint(+0) = 0", FUNC(nearbyint) (0.0), 0.0);
@@ -5266,6 +5541,8 @@ main (int argc, char *argv[])
   fmax_test ();
 
   /* complex functions */
+  cabs_test ();
+  carg_test ();
   cexp_test ();
   csin_test ();
   csinh_test ();
@@ -5279,9 +5556,12 @@ main (int argc, char *argv[])
   casinh_test ();
   catan_test ();
   catanh_test ();
+  ctan_test ();
   ctanh_test ();
   csqrt_test ();
   cpow_test ();
+
+  /* multiply and add */
   fma_test ();
 
   /* special tests */