public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
* Long double complex methods
@ 2017-06-28 20:35 Aditya Upadhyay
  2017-06-28 21:36 ` Dionna Amalie Glaze via newlib
  2017-06-29  6:39 ` Corinna Vinschen
  0 siblings, 2 replies; 21+ messages in thread
From: Aditya Upadhyay @ 2017-06-28 20:35 UTC (permalink / raw)
  To: newlib

[-- Attachment #1: Type: text/plain, Size: 250 bytes --]

Hello Developers,

I have ported all long double complex methods with suffix "l" from
NetBSD. I am attaching the patches for all the methods. I am
requesting you to please review these patches and point me any
modification needed.

Thanks & Regards,

[-- Attachment #2: 0001-Importing-cacoshl.c-from-NetBSD.patch --]
[-- Type: text/x-patch, Size: 3084 bytes --]

From 388e5c5c7baead983de6fab7d2b72f9a408e31d1 Mon Sep 17 00:00:00 2001
From: Aditya Upadhyay <aadit0402@gmail.com>
Date: Thu, 29 Jun 2017 01:25:21 +0530
Subject: [PATCH 01/18] Importing cacoshl.c from NetBSD.

---
 newlib/libm/complex/Makefile.am |  2 +-
 newlib/libm/complex/cacoshl.c   | 45 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 46 insertions(+), 1 deletion(-)
 create mode 100755 newlib/libm/complex/cacoshl.c

diff --git a/newlib/libm/complex/Makefile.am b/newlib/libm/complex/Makefile.am
index 402053f..f747934 100644
--- a/newlib/libm/complex/Makefile.am
+++ b/newlib/libm/complex/Makefile.am
@@ -10,7 +10,7 @@ src = cabs.c cacos.c cacosh.c carg.c casin.c casinh.c \
       cpow.c cproj.c  creal.c  \
       csin.c csinh.c csqrt.c ctan.c ctanh.c
 
-lsrc = cabsl.c creall.c cimagl.c ccoshl.c
+lsrc = cabsl.c creall.c cimagl.c ccoshl.c cacoshl.c \
 
 fsrc =	cabsf.c casinf.c ccosf.c cimagf.c cprojf.c  \
         csqrtf.c cacosf.c casinhf.c ccoshf.c clogf.c clog10f.c \
diff --git a/newlib/libm/complex/cacoshl.c b/newlib/libm/complex/cacoshl.c
new file mode 100755
index 0000000..4e4e006
--- /dev/null
+++ b/newlib/libm/complex/cacoshl.c
@@ -0,0 +1,45 @@
+/* $NetBSD: cacoshl.c,v 1.1 2014/10/10 00:48:18 christos Exp $ */
+
+/*-
+ * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software written by Stephen L. Moshier.
+ * It is redistributed by the NetBSD Foundation by permission of the author.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <complex.h>
+
+long double complex
+cacoshl(long double complex z)
+{
+	long double complex w;
+
+#if 0 /* does not give the principal value */
+	w = I * cacosl(z);
+#else
+	w = clogl(z + csqrtl(z + 1) * csqrtl(z - 1));
+#endif
+	return w;
+}
-- 
2.7.4


[-- Attachment #3: 0002-Importing-clogl.c-from-NetBSD.patch --]
[-- Type: text/x-patch, Size: 2990 bytes --]

From d3e911206859c2703d2ff2ef3b4557db004d4dbe Mon Sep 17 00:00:00 2001
From: Aditya Upadhyay <aadit0402@gmail.com>
Date: Thu, 29 Jun 2017 01:27:48 +0530
Subject: [PATCH 02/18] Importing clogl.c from NetBSD.

---
 newlib/libm/complex/Makefile.am |  1 +
 newlib/libm/complex/clogl.c     | 46 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+)
 create mode 100755 newlib/libm/complex/clogl.c

diff --git a/newlib/libm/complex/Makefile.am b/newlib/libm/complex/Makefile.am
index f747934..ad5d9a9 100644
--- a/newlib/libm/complex/Makefile.am
+++ b/newlib/libm/complex/Makefile.am
@@ -11,6 +11,7 @@ src = cabs.c cacos.c cacosh.c carg.c casin.c casinh.c \
       csin.c csinh.c csqrt.c ctan.c ctanh.c
 
 lsrc = cabsl.c creall.c cimagl.c ccoshl.c cacoshl.c \
+       clogl.c
 
 fsrc =	cabsf.c casinf.c ccosf.c cimagf.c cprojf.c  \
         csqrtf.c cacosf.c casinhf.c ccoshf.c clogf.c clog10f.c \
diff --git a/newlib/libm/complex/clogl.c b/newlib/libm/complex/clogl.c
new file mode 100755
index 0000000..3644a44
--- /dev/null
+++ b/newlib/libm/complex/clogl.c
@@ -0,0 +1,46 @@
+/* $NetBSD: clogl.c,v 1.1 2014/10/10 00:48:18 christos Exp $ */
+
+/*-
+ * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software written by Stephen L. Moshier.
+ * It is redistributed by the NetBSD Foundation by permission of the author.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <complex.h>
+#include <math.h>
+
+long double complex
+clogl(long double complex z)
+{
+	long double complex w;
+	long double p, rr;
+
+	rr = cabsl(z);
+	p = logl(rr);
+	rr = atan2l(cimagl(z), creall(z));
+	w = p + rr * I;
+	return w;
+}
-- 
2.7.4


[-- Attachment #4: 0003-Importing-csqrtl.c-from-NetBSD.patch --]
[-- Type: text/x-patch, Size: 4774 bytes --]

From a7992ffa625e2d829a16218b34539b2a1aecb839 Mon Sep 17 00:00:00 2001
From: Aditya Upadhyay <aadit0402@gmail.com>
Date: Thu, 29 Jun 2017 01:28:51 +0530
Subject: [PATCH 03/18] Importing csqrtl.c from NetBSD.

---
 newlib/libm/complex/Makefile.am |   2 +-
 newlib/libm/complex/csqrtl.c    | 112 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 113 insertions(+), 1 deletion(-)
 create mode 100755 newlib/libm/complex/csqrtl.c

diff --git a/newlib/libm/complex/Makefile.am b/newlib/libm/complex/Makefile.am
index ad5d9a9..c70726e 100644
--- a/newlib/libm/complex/Makefile.am
+++ b/newlib/libm/complex/Makefile.am
@@ -11,7 +11,7 @@ src = cabs.c cacos.c cacosh.c carg.c casin.c casinh.c \
       csin.c csinh.c csqrt.c ctan.c ctanh.c
 
 lsrc = cabsl.c creall.c cimagl.c ccoshl.c cacoshl.c \
-       clogl.c
+       clogl.c csqrtl.c
 
 fsrc =	cabsf.c casinf.c ccosf.c cimagf.c cprojf.c  \
         csqrtf.c cacosf.c casinhf.c ccoshf.c clogf.c clog10f.c \
diff --git a/newlib/libm/complex/csqrtl.c b/newlib/libm/complex/csqrtl.c
new file mode 100755
index 0000000..c10a126
--- /dev/null
+++ b/newlib/libm/complex/csqrtl.c
@@ -0,0 +1,112 @@
+/*-
+ * Copyright (c) 2007-2008 David Schultz <das@FreeBSD.ORG>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#if 0
+__FBSDID("$FreeBSD: head/lib/msun/src/s_csqrtl.c 181402 2008-08-08 00:15:16Z das $");
+#else
+__RCSID("$NetBSD: csqrtl.c,v 1.2 2014/10/11 00:43:51 christos Exp $");
+#endif
+
+#include <complex.h>
+#include <float.h>
+#include <math.h>
+#include <stdbool.h>
+/*
+ * gcc doesn't implement complex multiplication or division correctly,
+ * so we need to handle infinities specially. We turn on this pragma to
+ * notify conforming c99 compilers that the fast-but-incorrect code that
+ * gcc generates is acceptable, since the special cases have already been
+ * handled.
+ */
+// #pragma	STDC CX_LIMITED_RANGE	ON
+
+/* We risk spurious overflow for components >= LDBL_MAX / (1 + sqrt(2)). */
+#define	THRESH	(LDBL_MAX / 2.414213562373095048801688724209698L)
+
+#define cpackl(r, i) ((r) + (i) * I)
+
+long double complex
+csqrtl(long double complex z)
+{
+	long double complex result;
+	long double a, b;
+	long double t;
+	bool scale;
+
+	a = creall(z);
+	b = cimagl(z);
+
+	/* Handle special cases. */
+	if (z == 0.0L)
+		return (cpackl(0.0L, b));
+	if (isinf(b))
+		return (cpackl(INFINITY, b));
+	if (isnan(a)) {
+		t = (b - b) / (b - b);	/* raise invalid if b is not a NaN */
+		return (cpackl(a, t));	/* return NaN + NaN i */
+	}
+	if (isinf(a)) {
+		/*
+		 * csqrt(inf + NaN i)  = inf +  NaN i
+		 * csqrt(inf + y i)    = inf +  0 i
+		 * csqrt(-inf + NaN i) = NaN +- inf i
+		 * csqrt(-inf + y i)   = 0   +  inf i
+		 */
+		if (signbit(a))
+			return (cpackl(fabsl(b - b), copysignl(a, b)));
+		else
+			return (cpackl(a, copysignl(b - b, b)));
+	}
+	/*
+	 * The remaining special case (b is NaN) is handled just fine by
+	 * the normal code path below.
+	 */
+
+	/* Scale to avoid overflow. */
+	if (fabsl(a) >= THRESH || fabsl(b) >= THRESH) {
+		a *= 0.25L;
+		b *= 0.25L;
+		scale = true;
+	} else {
+		scale = false;
+	}
+
+	/* Algorithm 312, CACM vol 10, Oct 1967. */
+	if (a >= 0L) {
+		t = sqrtl((a + hypotl(a, b)) * 0.5L);
+		result = cpackl(t, b / (2.0L * t));
+	} else {
+		t = sqrtl((-a + hypotl(a, b)) * 0.5L);
+		result = cpackl(fabsl(b) / (2.0L * t), copysignl(t, b));
+	}
+
+	/* Rescale. */
+	if (scale)
+		return (result * 2.0L);
+	else
+		return (result);
+}
-- 
2.7.4


[-- Attachment #5: 0004-Importing-cargl.c-from-NetBSD.patch --]
[-- Type: text/x-patch, Size: 1465 bytes --]

From 0f754d0339ad356f43e5caafdb899ae4cf456fe1 Mon Sep 17 00:00:00 2001
From: Aditya Upadhyay <aadit0402@gmail.com>
Date: Thu, 29 Jun 2017 01:30:47 +0530
Subject: [PATCH 04/18] Importing cargl.c from NetBSD.

---
 newlib/libm/complex/Makefile.am |  2 +-
 newlib/libm/complex/cargl.c     | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)
 create mode 100755 newlib/libm/complex/cargl.c

diff --git a/newlib/libm/complex/Makefile.am b/newlib/libm/complex/Makefile.am
index c70726e..48b6d92 100644
--- a/newlib/libm/complex/Makefile.am
+++ b/newlib/libm/complex/Makefile.am
@@ -11,7 +11,7 @@ src = cabs.c cacos.c cacosh.c carg.c casin.c casinh.c \
       csin.c csinh.c csqrt.c ctan.c ctanh.c
 
 lsrc = cabsl.c creall.c cimagl.c ccoshl.c cacoshl.c \
-       clogl.c csqrtl.c
+       clogl.c csqrtl.c cargl.c
 
 fsrc =	cabsf.c casinf.c ccosf.c cimagf.c cprojf.c  \
         csqrtf.c cacosf.c casinhf.c ccoshf.c clogf.c clog10f.c \
diff --git a/newlib/libm/complex/cargl.c b/newlib/libm/complex/cargl.c
new file mode 100755
index 0000000..d2885a4
--- /dev/null
+++ b/newlib/libm/complex/cargl.c
@@ -0,0 +1,18 @@
+/* $NetBSD: cargl.c,v 1.1 2014/10/10 00:48:18 christos Exp $ */
+
+/*
+ * Public domain.
+ */
+
+#include <complex.h>
+#include <math.h>
+
+long double
+cargl(long double complex z)
+{     
+       #ifdef _LDBL_EQ_DBL
+         return carg (z);
+       #else
+         return atan2l (imag (z), real (z));
+       #endif
+}
-- 
2.7.4


[-- Attachment #6: 0005-Importing-cprojl.c-from-NetBSD.patch --]
[-- Type: text/x-patch, Size: 3593 bytes --]

From 988137c3c30fbccd275f2cb4d1b5e6c56644e0a5 Mon Sep 17 00:00:00 2001
From: Aditya Upadhyay <aadit0402@gmail.com>
Date: Thu, 29 Jun 2017 01:31:22 +0530
Subject: [PATCH 05/18] Importing cprojl.c from NetBSD.

---
 newlib/libm/complex/Makefile.am |  2 +-
 newlib/libm/complex/cprojl.c    | 64 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 65 insertions(+), 1 deletion(-)
 create mode 100755 newlib/libm/complex/cprojl.c

diff --git a/newlib/libm/complex/Makefile.am b/newlib/libm/complex/Makefile.am
index 48b6d92..1f86709 100644
--- a/newlib/libm/complex/Makefile.am
+++ b/newlib/libm/complex/Makefile.am
@@ -11,7 +11,7 @@ src = cabs.c cacos.c cacosh.c carg.c casin.c casinh.c \
       csin.c csinh.c csqrt.c ctan.c ctanh.c
 
 lsrc = cabsl.c creall.c cimagl.c ccoshl.c cacoshl.c \
-       clogl.c csqrtl.c cargl.c
+       clogl.c csqrtl.c cargl.c cprojl.c
 
 fsrc =	cabsf.c casinf.c ccosf.c cimagf.c cprojf.c  \
         csqrtf.c cacosf.c casinhf.c ccoshf.c clogf.c clog10f.c \
diff --git a/newlib/libm/complex/cprojl.c b/newlib/libm/complex/cprojl.c
new file mode 100755
index 0000000..e71c773
--- /dev/null
+++ b/newlib/libm/complex/cprojl.c
@@ -0,0 +1,64 @@
+/*	$NetBSD: cprojl.c,v 1.7 2014/10/10 00:48:18 christos Exp $	*/
+
+/*-
+ * Copyright (c) 2010 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: cprojl.c,v 1.7 2014/10/10 00:48:18 christos Exp $");
+
+#include <complex.h>
+#include <math.h>
+
+#include "../common/fdlibm.h"
+
+/*
+ * cprojl(long double complex z)
+ *
+ * These functions return the value of the projection (not stereographic!)
+ * onto the Riemann sphere.
+ *
+ * z projects to z, except that all complex infinities (even those with one
+ * infinite part and one NaN part) project to positive infinity on the real axis.
+ * If z has an infinite part, then cproj(z) shall be equivalent to:
+ *
+ * INFINITY + I * copysign(0.0, cimag(z))
+ */
+long double complex
+cprojl(long double complex z)
+{
+	long_double_complex w = { .z = z };
+
+	/*CONSTCOND*/
+	if (isinf(creall(z)) || isinf(cimagl(z))) {
+#ifdef __INFINITY
+		REAL_PART(w) = HUGE_VAL;
+#else
+		REAL_PART(w) = INFINITY;
+#endif
+		IMAG_PART(w) = copysignl(0.0L, cimagl(z));
+	}
+
+	return (w.z);
+}
-- 
2.7.4


[-- Attachment #7: 0006-Importing-cexpl.c-from-NetBSD.patch --]
[-- Type: text/x-patch, Size: 3082 bytes --]

From d287a9d05a834bbf5d35b764fad32a234eb8f6f2 Mon Sep 17 00:00:00 2001
From: Aditya Upadhyay <aadit0402@gmail.com>
Date: Thu, 29 Jun 2017 01:32:00 +0530
Subject: [PATCH 06/18] Importing cexpl.c from NetBSD.

---
 newlib/libm/complex/Makefile.am |  2 +-
 newlib/libm/complex/cexpl.c     | 46 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+), 1 deletion(-)
 create mode 100755 newlib/libm/complex/cexpl.c

diff --git a/newlib/libm/complex/Makefile.am b/newlib/libm/complex/Makefile.am
index 1f86709..6eaa685 100644
--- a/newlib/libm/complex/Makefile.am
+++ b/newlib/libm/complex/Makefile.am
@@ -11,7 +11,7 @@ src = cabs.c cacos.c cacosh.c carg.c casin.c casinh.c \
       csin.c csinh.c csqrt.c ctan.c ctanh.c
 
 lsrc = cabsl.c creall.c cimagl.c ccoshl.c cacoshl.c \
-       clogl.c csqrtl.c cargl.c cprojl.c
+       clogl.c csqrtl.c cargl.c cprojl.c cexpl.c
 
 fsrc =	cabsf.c casinf.c ccosf.c cimagf.c cprojf.c  \
         csqrtf.c cacosf.c casinhf.c ccoshf.c clogf.c clog10f.c \
diff --git a/newlib/libm/complex/cexpl.c b/newlib/libm/complex/cexpl.c
new file mode 100755
index 0000000..8b56634
--- /dev/null
+++ b/newlib/libm/complex/cexpl.c
@@ -0,0 +1,46 @@
+/* $NetBSD: cexpl.c,v 1.1 2014/10/10 00:48:18 christos Exp $ */
+
+/*-
+ * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software written by Stephen L. Moshier.
+ * It is redistributed by the NetBSD Foundation by permission of the author.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <complex.h>
+#include <math.h>
+
+long double complex
+cexpl(long double complex z)
+{
+	long double complex w;
+	long double r, x, y;
+
+	x = creall(z);
+	y = cimagl(z);
+	r = expl(x);
+	w = r * cosl(y) + r * sinl(y) * I;
+	return w;
+}
-- 
2.7.4


[-- Attachment #8: 0007-Adding-cephes_subrl.h-and-cephes_subrl.c-from-NetBSD.patch --]
[-- Type: text/x-patch, Size: 5562 bytes --]

From a829ba6fb13522d8f361c28e65962b1e06073cf6 Mon Sep 17 00:00:00 2001
From: Aditya Upadhyay <aadit0402@gmail.com>
Date: Thu, 29 Jun 2017 01:34:23 +0530
Subject: [PATCH 07/18] Adding cephes_subrl.h and cephes_subrl.c from NetBSD.

---
 newlib/libm/complex/Makefile.am    |   5 +-
 newlib/libm/complex/cephes_subrl.c | 128 +++++++++++++++++++++++++++++++++++++
 newlib/libm/complex/cephes_subrl.h |   9 +++
 3 files changed, 140 insertions(+), 2 deletions(-)
 create mode 100755 newlib/libm/complex/cephes_subrl.c
 create mode 100755 newlib/libm/complex/cephes_subrl.h

diff --git a/newlib/libm/complex/Makefile.am b/newlib/libm/complex/Makefile.am
index 6eaa685..06706ea 100644
--- a/newlib/libm/complex/Makefile.am
+++ b/newlib/libm/complex/Makefile.am
@@ -11,7 +11,8 @@ src = cabs.c cacos.c cacosh.c carg.c casin.c casinh.c \
       csin.c csinh.c csqrt.c ctan.c ctanh.c
 
 lsrc = cabsl.c creall.c cimagl.c ccoshl.c cacoshl.c \
-       clogl.c csqrtl.c cargl.c cprojl.c cexpl.c
+       clogl.c csqrtl.c cargl.c cprojl.c cexpl.c \
+       cephes_subrl.c 
 
 fsrc =	cabsf.c casinf.c ccosf.c cimagf.c cprojf.c  \
         csqrtf.c cacosf.c casinhf.c ccoshf.c clogf.c clog10f.c \
@@ -44,4 +45,4 @@ CHAPTERS = complex.tex
 
 # A partial dependency list.
 
-$(lib_a_OBJECTS): $(srcdir)/../../libc/include/complex.h $(srcdir)/cephes_subr.h $(srcdir)/cephes_subrf.h
+$(lib_a_OBJECTS): $(srcdir)/../../libc/include/complex.h $(srcdir)/cephes_subr.h $(srcdir)/cephes_subrf.h  $(srcdir)/cephes_subrl.h
diff --git a/newlib/libm/complex/cephes_subrl.c b/newlib/libm/complex/cephes_subrl.c
new file mode 100755
index 0000000..8af11df
--- /dev/null
+++ b/newlib/libm/complex/cephes_subrl.c
@@ -0,0 +1,128 @@
+/* $NetBSD: cephes_subrl.c,v 1.2 2014/10/10 14:06:40 christos Exp $ */
+
+/*-
+ * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software written by Stephen L. Moshier.
+ * It is redistributed by the NetBSD Foundation by permission of the author.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <complex.h>
+#include <math.h>
+#include "cephes_subrl.h"
+
+/* calculate cosh and sinh */
+
+void
+_cchshl(long double x, long double *c, long double *s)
+{
+	long double e, ei;
+
+	if (fabsl(x) <= 0.5L) {
+		*c = coshl(x);
+		*s = sinhl(x);
+	} else {
+		e = expl(x);
+		ei = 0.5L / e;
+		e = 0.5L * e;
+		*s = e - ei;
+		*c = e + ei;
+	}
+}
+
+/* Program to subtract nearest integer multiple of PI */
+
+/* extended precision value of PI: */
+static const long double DP1 = 3.14159265358979323829596852490908531763125L;
+static const long double DP2 = 1.6667485837041756656403424829301998703007e-19L;
+#ifndef __vax__
+static const long double DP3 = 1.8830410776607851167459095484560349402753e-39L;
+#define MACHEPL 1.1e-38L
+#else
+static const long double DP3 = 0L;
+#define MACHEPL 1.1e-19L
+#endif
+
+long double
+_redupil(long double x)
+{
+	long double t;
+	long long i;
+
+	t = x / M_PIL;
+	if (t >= 0.0L)
+		t += 0.5L;
+	else
+		t -= 0.5L;
+
+	i = t;	/* the multiple */
+	t = i;
+	t = ((x - t * DP1) - t * DP2) - t * DP3;
+	return t;
+}
+
+/* Taylor series expansion for cosh(2y) - cos(2x) */
+
+long double
+_ctansl(long double complex z)
+{
+	long double f, x, x2, y, y2, rn, t;
+	long double d;
+
+	x = fabsl(2.0L * creall(z));
+	y = fabsl(2.0L * cimagl(z));
+
+	x = _redupil(x);
+
+	x = x * x;
+	y = y * y;
+	x2 = 1.0;
+	y2 = 1.0;
+	f = 1.0;
+	rn = 0.0;
+	d = 0.0;
+	do {
+		rn += 1.0L;
+		f *= rn;
+		rn += 1.0L;
+		f *= rn;
+		x2 *= x;
+		y2 *= y;
+		t = y2 + x2;
+		t /= f;
+		d += t;
+
+		rn += 1.0L;
+		f *= rn;
+		rn += 1.0L;
+		f *= rn;
+		x2 *= x;
+		y2 *= y;
+		t = y2 - x2;
+		t /= f;
+		d += t;
+	} while (fabsl(t/d) > MACHEPL);
+	return d;
+}
diff --git a/newlib/libm/complex/cephes_subrl.h b/newlib/libm/complex/cephes_subrl.h
new file mode 100755
index 0000000..6354b23
--- /dev/null
+++ b/newlib/libm/complex/cephes_subrl.h
@@ -0,0 +1,9 @@
+/* $NetBSD: cephes_subrl.h,v 1.1 2014/10/10 00:48:18 christos Exp $ */
+
+void _cchshl(long double, long double *, long double *);
+long double _redupil(long double);
+long double _ctansl(long double complex);
+
+#define	M_PIL	3.14159265358979323846264338327950280e+00L
+#define	M_PI_2L	1.57079632679489661923132169163975140e+00L
+
-- 
2.7.4


[-- Attachment #9: 0008-Importing-cacosl.c-from-NetBSD.patch --]
[-- Type: text/x-patch, Size: 3042 bytes --]

From cbf08ab8236883182822806423f7611bb53a9847 Mon Sep 17 00:00:00 2001
From: Aditya Upadhyay <aadit0402@gmail.com>
Date: Thu, 29 Jun 2017 01:35:44 +0530
Subject: [PATCH 08/18] Importing cacosl.c from NetBSD.

---
 newlib/libm/complex/Makefile.am |  2 +-
 newlib/libm/complex/cacosl.c    | 45 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 46 insertions(+), 1 deletion(-)
 create mode 100755 newlib/libm/complex/cacosl.c

diff --git a/newlib/libm/complex/Makefile.am b/newlib/libm/complex/Makefile.am
index 06706ea..8f21ea7 100644
--- a/newlib/libm/complex/Makefile.am
+++ b/newlib/libm/complex/Makefile.am
@@ -12,7 +12,7 @@ src = cabs.c cacos.c cacosh.c carg.c casin.c casinh.c \
 
 lsrc = cabsl.c creall.c cimagl.c ccoshl.c cacoshl.c \
        clogl.c csqrtl.c cargl.c cprojl.c cexpl.c \
-       cephes_subrl.c 
+       cephes_subrl.c cacosl.c
 
 fsrc =	cabsf.c casinf.c ccosf.c cimagf.c cprojf.c  \
         csqrtf.c cacosf.c casinhf.c ccoshf.c clogf.c clog10f.c \
diff --git a/newlib/libm/complex/cacosl.c b/newlib/libm/complex/cacosl.c
new file mode 100755
index 0000000..6a05c8c
--- /dev/null
+++ b/newlib/libm/complex/cacosl.c
@@ -0,0 +1,45 @@
+/* $NetBSD: cacosl.c,v 1.1 2014/10/10 00:48:18 christos Exp $ */
+
+/*-
+ * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software written by Stephen L. Moshier.
+ * It is redistributed by the NetBSD Foundation by permission of the author.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <complex.h>
+#include <math.h>
+#include "cephes_subrl.h"
+
+long double complex
+cacosl(long double complex z)
+{
+	long double complex w;
+
+	w = casinl(z);
+	w = (M_PI_2L - creall(w)) - cimagl(w) * I;
+	return w;
+}
+
-- 
2.7.4


[-- Attachment #10: 0009-Importing-ccosl.c-from-NetBSD.patch --]
[-- Type: text/x-patch, Size: 3098 bytes --]

From f4cbe221ef00535e36eb8f2905863898d72d9def Mon Sep 17 00:00:00 2001
From: Aditya Upadhyay <aadit0402@gmail.com>
Date: Thu, 29 Jun 2017 01:36:47 +0530
Subject: [PATCH 09/18] Importing ccosl.c from NetBSD.

---
 newlib/libm/complex/Makefile.am |  2 +-
 newlib/libm/complex/ccosl.c     | 45 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 46 insertions(+), 1 deletion(-)
 create mode 100755 newlib/libm/complex/ccosl.c

diff --git a/newlib/libm/complex/Makefile.am b/newlib/libm/complex/Makefile.am
index 8f21ea7..ff651eb 100644
--- a/newlib/libm/complex/Makefile.am
+++ b/newlib/libm/complex/Makefile.am
@@ -12,7 +12,7 @@ src = cabs.c cacos.c cacosh.c carg.c casin.c casinh.c \
 
 lsrc = cabsl.c creall.c cimagl.c ccoshl.c cacoshl.c \
        clogl.c csqrtl.c cargl.c cprojl.c cexpl.c \
-       cephes_subrl.c cacosl.c
+       cephes_subrl.c cacosl.c ccosl.c
 
 fsrc =	cabsf.c casinf.c ccosf.c cimagf.c cprojf.c  \
         csqrtf.c cacosf.c casinhf.c ccoshf.c clogf.c clog10f.c \
diff --git a/newlib/libm/complex/ccosl.c b/newlib/libm/complex/ccosl.c
new file mode 100755
index 0000000..c310f40
--- /dev/null
+++ b/newlib/libm/complex/ccosl.c
@@ -0,0 +1,45 @@
+/* $NetBSD: ccosl.c,v 1.1 2014/10/10 00:48:18 christos Exp $ */
+
+/*-
+ * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software written by Stephen L. Moshier.
+ * It is redistributed by the NetBSD Foundation by permission of the author.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <complex.h>
+#include <math.h>
+#include "cephes_subrl.h"
+
+long double complex
+ccosl(long double complex z)
+{
+	long double complex w;
+	long double ch, sh;
+
+	_cchshl(cimagl(z), &ch, &sh);
+	w = cosl(creall(z)) * ch - (sinl(creall(z)) * sh) * I;
+	return w;
+}
-- 
2.7.4


[-- Attachment #11: 0010-Importing-casinl.c-from-NetBSD.patch --]
[-- Type: text/x-patch, Size: 4241 bytes --]

From d60181366fe5889f9cae9ee0d66bb889a749b531 Mon Sep 17 00:00:00 2001
From: Aditya Upadhyay <aadit0402@gmail.com>
Date: Thu, 29 Jun 2017 01:38:01 +0530
Subject: [PATCH 10/18] Importing casinl.c from NetBSD.

---
 newlib/libm/complex/Makefile.am |   2 +-
 newlib/libm/complex/casinl.c    | 120 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 121 insertions(+), 1 deletion(-)
 create mode 100755 newlib/libm/complex/casinl.c

diff --git a/newlib/libm/complex/Makefile.am b/newlib/libm/complex/Makefile.am
index ff651eb..3af9f65 100644
--- a/newlib/libm/complex/Makefile.am
+++ b/newlib/libm/complex/Makefile.am
@@ -12,7 +12,7 @@ src = cabs.c cacos.c cacosh.c carg.c casin.c casinh.c \
 
 lsrc = cabsl.c creall.c cimagl.c ccoshl.c cacoshl.c \
        clogl.c csqrtl.c cargl.c cprojl.c cexpl.c \
-       cephes_subrl.c cacosl.c ccosl.c
+       cephes_subrl.c cacosl.c ccosl.c casinl.c
 
 fsrc =	cabsf.c casinf.c ccosf.c cimagf.c cprojf.c  \
         csqrtf.c cacosf.c casinhf.c ccoshf.c clogf.c clog10f.c \
diff --git a/newlib/libm/complex/casinl.c b/newlib/libm/complex/casinl.c
new file mode 100755
index 0000000..4884889
--- /dev/null
+++ b/newlib/libm/complex/casinl.c
@@ -0,0 +1,120 @@
+/* $NetBSD: casinl.c,v 1.1 2014/10/10 00:48:18 christos Exp $ */
+
+/*-
+ * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software written by Stephen L. Moshier.
+ * It is redistributed by the NetBSD Foundation by permission of the author.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <complex.h>
+#include <math.h>
+
+#ifdef __weak_alias
+__weak_alias(casinl, _casinl)
+#endif
+
+long double complex
+casinl(long double complex z)
+{
+	long double complex w;
+	long double complex ca, ct, zz, z2;
+	long double x, y;
+
+	x = creall(z);
+	y = cimagl(z);
+
+#if 0 /* MD: test is incorrect, casin(>1) is defined */
+	if (y == 0.0L) {
+		if (fabsl(x) > 1.0L) {
+			w = M_PI_2L + 0.0L * I;
+#if 0
+			mtherr ("casinl", DOMAIN);
+#endif
+		} else {
+			w = asinl(x) + 0.0L * I;
+		}
+		return w;
+	}
+#endif
+
+/* Power series expansion */
+/*
+b = cabsl(z);
+if( b < 0.125L )
+{
+z2.r = (x - y) * (x + y);
+z2.i = 2.0L * x * y;
+
+cn = 1.0L;
+n = 1.0L;
+ca.r = x;
+ca.i = y;
+sum.r = x;
+sum.i = y;
+do
+	{
+	ct.r = z2.r * ca.r  -  z2.i * ca.i;
+	ct.i = z2.r * ca.i  +  z2.i * ca.r;
+	ca.r = ct.r;
+	ca.i = ct.i;
+
+	cn *= n;
+	n += 1.0;
+	cn /= n;
+	n += 1.0;
+	b = cn/n;
+
+	ct.r *= b;
+	ct.i *= b;
+	sum.r += ct.r;
+	sum.i += ct.i;
+	b = fabsl(ct.r) + fabsl(ct.i);
+	}
+while( b > MACHEPL );
+w->r = sum.r;
+w->i = sum.i;
+return;
+}
+*/
+
+
+	ca = x + y * I;
+	ct = ca * I;
+	/* sqrtl( 1 - z*z) */
+	/* cmull( &ca, &ca, &zz ) */
+	/*x * x  -  y * y */
+	zz = (x - y) * (x + y) + (2.0L * x * y) * I;
+
+	zz = 1.0L - creall(zz) - cimagl(zz) * I;
+	z2 = csqrtl(zz);
+
+	zz = ct + z2;
+	zz = clogl(zz);
+	/* multiply by 1/i = -i */
+	w = zz * (-1.0L * I);
+	return w;
+}
+
-- 
2.7.4


[-- Attachment #12: 0011-Importing-catanhl.c-from-NetBSD.patch --]
[-- Type: text/x-patch, Size: 3035 bytes --]

From 86fb75be2f4c1bd24aa2abeb649a1d8719c72e8d Mon Sep 17 00:00:00 2001
From: Aditya Upadhyay <aadit0402@gmail.com>
Date: Thu, 29 Jun 2017 01:38:54 +0530
Subject: [PATCH 11/18] Importing catanhl.c from NetBSD.

---
 newlib/libm/complex/Makefile.am |  3 ++-
 newlib/libm/complex/catanhl.c   | 41 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100755 newlib/libm/complex/catanhl.c

diff --git a/newlib/libm/complex/Makefile.am b/newlib/libm/complex/Makefile.am
index 3af9f65..cbbed57 100644
--- a/newlib/libm/complex/Makefile.am
+++ b/newlib/libm/complex/Makefile.am
@@ -12,7 +12,8 @@ src = cabs.c cacos.c cacosh.c carg.c casin.c casinh.c \
 
 lsrc = cabsl.c creall.c cimagl.c ccoshl.c cacoshl.c \
        clogl.c csqrtl.c cargl.c cprojl.c cexpl.c \
-       cephes_subrl.c cacosl.c ccosl.c casinl.c
+       cephes_subrl.c cacosl.c ccosl.c casinl.c \
+       catanhl.c
 
 fsrc =	cabsf.c casinf.c ccosf.c cimagf.c cprojf.c  \
         csqrtf.c cacosf.c casinhf.c ccoshf.c clogf.c clog10f.c \
diff --git a/newlib/libm/complex/catanhl.c b/newlib/libm/complex/catanhl.c
new file mode 100755
index 0000000..8975fe8
--- /dev/null
+++ b/newlib/libm/complex/catanhl.c
@@ -0,0 +1,41 @@
+/* $NetBSD: catanhl.c,v 1.3 2014/10/10 12:43:15 christos Exp $ */
+
+/*-
+ * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software written by Stephen L. Moshier.
+ * It is redistributed by the NetBSD Foundation by permission of the author.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <complex.h>
+
+long double complex
+catanhl(long double complex z)
+{
+	long double complex w;
+
+	w = -1.0L * I * catanl(z * I);
+	return w;
+}
-- 
2.7.4


[-- Attachment #13: 0012-Importing-conjl.c-from-NetBSD.patch --]
[-- Type: text/x-patch, Size: 3103 bytes --]

From 9ed0dff1e785b0da7991c7e2896a722f0c6069ce Mon Sep 17 00:00:00 2001
From: Aditya Upadhyay <aadit0402@gmail.com>
Date: Thu, 29 Jun 2017 01:39:48 +0530
Subject: [PATCH 12/18] Importing conjl.c from NetBSD.

---
 newlib/libm/complex/Makefile.am |  2 +-
 newlib/libm/complex/conjl.c     | 46 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+), 1 deletion(-)
 create mode 100755 newlib/libm/complex/conjl.c

diff --git a/newlib/libm/complex/Makefile.am b/newlib/libm/complex/Makefile.am
index cbbed57..736a9e0 100644
--- a/newlib/libm/complex/Makefile.am
+++ b/newlib/libm/complex/Makefile.am
@@ -13,7 +13,7 @@ src = cabs.c cacos.c cacosh.c carg.c casin.c casinh.c \
 lsrc = cabsl.c creall.c cimagl.c ccoshl.c cacoshl.c \
        clogl.c csqrtl.c cargl.c cprojl.c cexpl.c \
        cephes_subrl.c cacosl.c ccosl.c casinl.c \
-       catanhl.c
+       catanhl.c conjl.c
 
 fsrc =	cabsf.c casinf.c ccosf.c cimagf.c cprojf.c  \
         csqrtf.c cacosf.c casinhf.c ccoshf.c clogf.c clog10f.c \
diff --git a/newlib/libm/complex/conjl.c b/newlib/libm/complex/conjl.c
new file mode 100755
index 0000000..35094ce
--- /dev/null
+++ b/newlib/libm/complex/conjl.c
@@ -0,0 +1,46 @@
+/*	$NetBSD: conjl.c,v 1.4 2010/09/20 16:55:20 christos Exp $	*/
+
+/*-
+ * Copyright (c) 2010 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: conjl.c,v 1.4 2010/09/20 16:55:20 christos Exp $");
+
+#include <complex.h>
+#include "../common/fdlibm.h"
+
+/*
+ * conjl(long double complex z)
+ * This function returns the complex conjugate value of its argument, z.
+ */
+long double complex
+conjl(long double complex z)
+{
+	long_double_complex w = { .z = z };
+
+	IMAG_PART(w) = -IMAG_PART(w);
+
+	return (w.z);
+}
-- 
2.7.4


[-- Attachment #14: 0013-Importing-cpowl.c-from-NetBSD.patch --]
[-- Type: text/x-patch, Size: 3363 bytes --]

From b3eed382dff7d4703f29a5de4d9d52728faa1de6 Mon Sep 17 00:00:00 2001
From: Aditya Upadhyay <aadit0402@gmail.com>
Date: Thu, 29 Jun 2017 01:40:31 +0530
Subject: [PATCH 13/18] Importing cpowl.c from NetBSD.

---
 newlib/libm/complex/Makefile.am |  2 +-
 newlib/libm/complex/cpowl.c     | 56 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 57 insertions(+), 1 deletion(-)
 create mode 100755 newlib/libm/complex/cpowl.c

diff --git a/newlib/libm/complex/Makefile.am b/newlib/libm/complex/Makefile.am
index 736a9e0..a9db385 100644
--- a/newlib/libm/complex/Makefile.am
+++ b/newlib/libm/complex/Makefile.am
@@ -13,7 +13,7 @@ src = cabs.c cacos.c cacosh.c carg.c casin.c casinh.c \
 lsrc = cabsl.c creall.c cimagl.c ccoshl.c cacoshl.c \
        clogl.c csqrtl.c cargl.c cprojl.c cexpl.c \
        cephes_subrl.c cacosl.c ccosl.c casinl.c \
-       catanhl.c conjl.c
+       catanhl.c conjl.c cpowl.c
 
 fsrc =	cabsf.c casinf.c ccosf.c cimagf.c cprojf.c  \
         csqrtf.c cacosf.c casinhf.c ccoshf.c clogf.c clog10f.c \
diff --git a/newlib/libm/complex/cpowl.c b/newlib/libm/complex/cpowl.c
new file mode 100755
index 0000000..85c2c20
--- /dev/null
+++ b/newlib/libm/complex/cpowl.c
@@ -0,0 +1,56 @@
+/* $NetBSD: cpowl.c,v 1.1 2014/10/10 00:48:18 christos Exp $ */
+
+/*-
+ * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software written by Stephen L. Moshier.
+ * It is redistributed by the NetBSD Foundation by permission of the author.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <complex.h>
+#include <math.h>
+
+long double complex
+cpowl(long double complex a, long double complex z)
+{
+	long double complex w;
+	long double x, y, r, theta, absa, arga;
+
+	x = creall(z);
+	y = cimagl(z);
+	absa = cabsl(a);
+	if (absa == 0.0L) {
+		return (0.0L + 0.0L * I);
+	}
+	arga = cargl(a);
+	r = powl(absa, x);
+	theta = x * arga;
+	if (y != 0.0L) {
+		r = r * expl(-y * arga);
+		theta = theta + y * logl(absa);
+	}
+	w = r * cosl(theta) + (r * sinl(theta)) * I;
+	return w;
+}
-- 
2.7.4


[-- Attachment #15: 0014-Importing-ctanhl.c-from-NetBSD.patch --]
[-- Type: text/x-patch, Size: 3176 bytes --]

From 16dd28c6ba167bcdd8a01cae54a905064f67989d Mon Sep 17 00:00:00 2001
From: Aditya Upadhyay <aadit0402@gmail.com>
Date: Thu, 29 Jun 2017 01:41:21 +0530
Subject: [PATCH 14/18] Importing ctanhl.c from NetBSD.

---
 newlib/libm/complex/Makefile.am |  2 +-
 newlib/libm/complex/ctanhl.c    | 47 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 48 insertions(+), 1 deletion(-)
 create mode 100755 newlib/libm/complex/ctanhl.c

diff --git a/newlib/libm/complex/Makefile.am b/newlib/libm/complex/Makefile.am
index a9db385..95066db 100644
--- a/newlib/libm/complex/Makefile.am
+++ b/newlib/libm/complex/Makefile.am
@@ -13,7 +13,7 @@ src = cabs.c cacos.c cacosh.c carg.c casin.c casinh.c \
 lsrc = cabsl.c creall.c cimagl.c ccoshl.c cacoshl.c \
        clogl.c csqrtl.c cargl.c cprojl.c cexpl.c \
        cephes_subrl.c cacosl.c ccosl.c casinl.c \
-       catanhl.c conjl.c cpowl.c
+       catanhl.c conjl.c cpowl.c ctanhl.c
 
 fsrc =	cabsf.c casinf.c ccosf.c cimagf.c cprojf.c  \
         csqrtf.c cacosf.c casinhf.c ccoshf.c clogf.c clog10f.c \
diff --git a/newlib/libm/complex/ctanhl.c b/newlib/libm/complex/ctanhl.c
new file mode 100755
index 0000000..1db886f
--- /dev/null
+++ b/newlib/libm/complex/ctanhl.c
@@ -0,0 +1,47 @@
+/* $NetBSD: ctanhl.c,v 1.1 2014/10/10 00:48:18 christos Exp $ */
+
+/*-
+ * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software written by Stephen L. Moshier.
+ * It is redistributed by the NetBSD Foundation by permission of the author.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <complex.h>
+#include <math.h>
+
+long double complex
+ctanhl(long double complex z)
+{
+	long double complex w;
+	long double x, y, d;
+
+	x = creall(z);
+	y = cimagl(z);
+	d = coshl(2.0L * x) + cosl(2.0L * y);
+	w = sinhl(2.0L * x) / d  +  (sinl(2.0L * y) / d) * I;
+
+	return w;
+}
-- 
2.7.4


[-- Attachment #16: 0015-Importing-ctanl.c-from-NetBSD.patch --]
[-- Type: text/x-patch, Size: 3358 bytes --]

From 70143a2a956c18b909b6555b76e8512253150e62 Mon Sep 17 00:00:00 2001
From: Aditya Upadhyay <aadit0402@gmail.com>
Date: Thu, 29 Jun 2017 01:42:07 +0530
Subject: [PATCH 15/18] Importing ctanl.c from NetBSD.

---
 newlib/libm/complex/Makefile.am |  2 +-
 newlib/libm/complex/ctanl.c     | 56 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 57 insertions(+), 1 deletion(-)
 create mode 100755 newlib/libm/complex/ctanl.c

diff --git a/newlib/libm/complex/Makefile.am b/newlib/libm/complex/Makefile.am
index 95066db..f8e493b 100644
--- a/newlib/libm/complex/Makefile.am
+++ b/newlib/libm/complex/Makefile.am
@@ -13,7 +13,7 @@ src = cabs.c cacos.c cacosh.c carg.c casin.c casinh.c \
 lsrc = cabsl.c creall.c cimagl.c ccoshl.c cacoshl.c \
        clogl.c csqrtl.c cargl.c cprojl.c cexpl.c \
        cephes_subrl.c cacosl.c ccosl.c casinl.c \
-       catanhl.c conjl.c cpowl.c ctanhl.c
+       catanhl.c conjl.c cpowl.c ctanhl.c ctanl.c
 
 fsrc =	cabsf.c casinf.c ccosf.c cimagf.c cprojf.c  \
         csqrtf.c cacosf.c casinhf.c ccoshf.c clogf.c clog10f.c \
diff --git a/newlib/libm/complex/ctanl.c b/newlib/libm/complex/ctanl.c
new file mode 100755
index 0000000..9255bdb
--- /dev/null
+++ b/newlib/libm/complex/ctanl.c
@@ -0,0 +1,56 @@
+/* $NetBSD: ctanl.c,v 1.1 2014/10/10 00:48:18 christos Exp $ */
+
+/*-
+ * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software written by Stephen L. Moshier.
+ * It is redistributed by the NetBSD Foundation by permission of the author.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include <complex.h>
+#include <math.h>
+#include "cephes_subrl.h"
+
+long double complex
+ctanl(long double complex z)
+{
+	long double complex w;
+	long double d;
+
+	d = cosl(2.0L * creall(z)) + coshl(2.0L * cimagl(z));
+
+	if (fabsl(d) < 0.25L)
+		d = _ctansl(z);
+
+	if (d == 0.0L) {
+		/* mtherr ("ctan", OVERFLOW); */
+		w = HUGE_VALF + HUGE_VALF * I;
+		return w;
+	}
+
+	w = sinl(2.0L * creall(z)) / d + (sinhl(2.0L * cimagl(z)) / d) * I;
+	return w;
+}
-- 
2.7.4


[-- Attachment #17: 0016-Importing-casinhl.c-from-NetBSD.patch --]
[-- Type: text/x-patch, Size: 3088 bytes --]

From f39b91e82bde1ff5370749a939cdaf3f44784c72 Mon Sep 17 00:00:00 2001
From: Aditya Upadhyay <aadit0402@gmail.com>
Date: Thu, 29 Jun 2017 01:53:34 +0530
Subject: [PATCH 16/18] Importing casinhl.c from NetBSD.

---
 newlib/libm/complex/Makefile.am |  3 ++-
 newlib/libm/complex/casinhl.c   | 41 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 newlib/libm/complex/casinhl.c

diff --git a/newlib/libm/complex/Makefile.am b/newlib/libm/complex/Makefile.am
index f8e493b..c640ffb 100644
--- a/newlib/libm/complex/Makefile.am
+++ b/newlib/libm/complex/Makefile.am
@@ -13,7 +13,8 @@ src = cabs.c cacos.c cacosh.c carg.c casin.c casinh.c \
 lsrc = cabsl.c creall.c cimagl.c ccoshl.c cacoshl.c \
        clogl.c csqrtl.c cargl.c cprojl.c cexpl.c \
        cephes_subrl.c cacosl.c ccosl.c casinl.c \
-       catanhl.c conjl.c cpowl.c ctanhl.c ctanl.c
+       catanhl.c conjl.c cpowl.c ctanhl.c ctanl.c \
+       casinhl.c
 
 fsrc =	cabsf.c casinf.c ccosf.c cimagf.c cprojf.c  \
         csqrtf.c cacosf.c casinhf.c ccoshf.c clogf.c clog10f.c \
diff --git a/newlib/libm/complex/casinhl.c b/newlib/libm/complex/casinhl.c
new file mode 100644
index 0000000..2864791
--- /dev/null
+++ b/newlib/libm/complex/casinhl.c
@@ -0,0 +1,41 @@
+/* $NetBSD: casinhl.c,v 1.1 2014/10/10 00:48:18 christos Exp $ */
+
+/*-
+ * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software written by Stephen L. Moshier.
+ * It is redistributed by the NetBSD Foundation by permission of the author.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <complex.h>
+
+long double complex
+casinhl(long double complex z)
+{
+	long double complex w;
+
+	w = -1.0L * I * casinl(z * I);
+	return w;
+}
-- 
2.7.4


[-- Attachment #18: 0017-Importing-csinhl.c-from-NetBSD.patch --]
[-- Type: text/x-patch, Size: 3092 bytes --]

From 60caf83af71ebef20dac9ef12d53636662c8850d Mon Sep 17 00:00:00 2001
From: Aditya Upadhyay <aadit0402@gmail.com>
Date: Thu, 29 Jun 2017 01:54:09 +0530
Subject: [PATCH 17/18] Importing csinhl.c from NetBSD.

---
 newlib/libm/complex/Makefile.am |  2 +-
 newlib/libm/complex/csinhl.c    | 45 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 46 insertions(+), 1 deletion(-)
 create mode 100644 newlib/libm/complex/csinhl.c

diff --git a/newlib/libm/complex/Makefile.am b/newlib/libm/complex/Makefile.am
index c640ffb..9f733e5 100644
--- a/newlib/libm/complex/Makefile.am
+++ b/newlib/libm/complex/Makefile.am
@@ -14,7 +14,7 @@ lsrc = cabsl.c creall.c cimagl.c ccoshl.c cacoshl.c \
        clogl.c csqrtl.c cargl.c cprojl.c cexpl.c \
        cephes_subrl.c cacosl.c ccosl.c casinl.c \
        catanhl.c conjl.c cpowl.c ctanhl.c ctanl.c \
-       casinhl.c
+       casinhl.c csinhl.c
 
 fsrc =	cabsf.c casinf.c ccosf.c cimagf.c cprojf.c  \
         csqrtf.c cacosf.c casinhf.c ccoshf.c clogf.c clog10f.c \
diff --git a/newlib/libm/complex/csinhl.c b/newlib/libm/complex/csinhl.c
new file mode 100644
index 0000000..44ed050
--- /dev/null
+++ b/newlib/libm/complex/csinhl.c
@@ -0,0 +1,45 @@
+/* $NetBSD: csinhl.c,v 1.1 2014/10/10 00:48:18 christos Exp $ */
+
+/*-
+ * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software written by Stephen L. Moshier.
+ * It is redistributed by the NetBSD Foundation by permission of the author.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <complex.h>
+#include <math.h>
+
+long double complex
+csinhl(long double complex z)
+{
+	long double complex w;
+	long double x, y;
+
+	x = creall(z);
+	y = cimagl(z);
+	w = sinhl(x) * cosl(y) + (coshl(x) * sinl(y)) * I;
+	return w;
+}
-- 
2.7.4


[-- Attachment #19: 0018-Importing-csinl.c-from-NetBSD.patch --]
[-- Type: text/x-patch, Size: 2479 bytes --]

From b748bd150f0a8070f50de86b248eb63d1aad1f93 Mon Sep 17 00:00:00 2001
From: Aditya Upadhyay <aadit0402@gmail.com>
Date: Thu, 29 Jun 2017 01:54:32 +0530
Subject: [PATCH 18/18] Importing csinl.c from NetBSD.

---
 newlib/libm/complex/csinl.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)
 create mode 100644 newlib/libm/complex/csinl.c

diff --git a/newlib/libm/complex/csinl.c b/newlib/libm/complex/csinl.c
new file mode 100644
index 0000000..2b96c72
--- /dev/null
+++ b/newlib/libm/complex/csinl.c
@@ -0,0 +1,45 @@
+/* $NetBSD: csinl.c,v 1.1 2014/10/10 00:48:18 christos Exp $ */
+
+/*-
+ * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software written by Stephen L. Moshier.
+ * It is redistributed by the NetBSD Foundation by permission of the author.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <complex.h>
+#include <math.h>
+#include "cephes_subrl.h"
+
+long double complex
+csinl(long double complex z)
+{
+	long double complex w;
+	long double ch, sh;
+
+	_cchshl(cimagl(z), &ch, &sh);
+	w = sinl(creall(z)) * ch + (cosl(creall(z)) * sh) * I;
+	return w;
+}
-- 
2.7.4


^ permalink raw reply	[flat|nested] 21+ messages in thread
* Long double complex methods
@ 2017-06-28 13:53 Aditya Upadhyay
  0 siblings, 0 replies; 21+ messages in thread
From: Aditya Upadhyay @ 2017-06-28 13:53 UTC (permalink / raw)
  To: newlib

[-- Attachment #1: Type: text/plain, Size: 176 bytes --]

Hello Developers,

This is the patch for conjl.c and ctanl.c ported from NetBSD. Please
review the same and suggest me needed modification.


Thanks & Regards,
Aditya Upadhyay

[-- Attachment #2: 0011-Importing-conjl.c-from-NetBSD.patch --]
[-- Type: text/x-patch, Size: 3099 bytes --]

From 35fea5cb4912073b8027b0622dd9143b8bd61803 Mon Sep 17 00:00:00 2001
From: Aditya Upadhyay <aadit0402@gmail.com>
Date: Wed, 28 Jun 2017 18:50:52 +0530
Subject: [PATCH 11/12] Importing conjl.c from NetBSD.

---
 newlib/libm/complex/Makefile.am |  2 +-
 newlib/libm/complex/conjl.c     | 46 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+), 1 deletion(-)
 create mode 100644 newlib/libm/complex/conjl.c

diff --git a/newlib/libm/complex/Makefile.am b/newlib/libm/complex/Makefile.am
index e121ac5..979a9a9 100644
--- a/newlib/libm/complex/Makefile.am
+++ b/newlib/libm/complex/Makefile.am
@@ -12,7 +12,7 @@ src = cabs.c cacos.c cacosh.c carg.c casin.c casinh.c \
 
 lsrc = cabsl.c creall.c cimagl.c ccoshl.c cacoshl.c \ 
        clogl.c csqrtl.c cargl.c cprojl.c cexpl.c cephes_subrl.c\
-       cacosl.c ccosl.c cpowl.c
+       cacosl.c ccosl.c cpowl.c conjl.c
 
 fsrc =	cabsf.c casinf.c ccosf.c cimagf.c cprojf.c  \
         csqrtf.c cacosf.c casinhf.c ccoshf.c clogf.c clog10f.c \
diff --git a/newlib/libm/complex/conjl.c b/newlib/libm/complex/conjl.c
new file mode 100644
index 0000000..35094ce
--- /dev/null
+++ b/newlib/libm/complex/conjl.c
@@ -0,0 +1,46 @@
+/*	$NetBSD: conjl.c,v 1.4 2010/09/20 16:55:20 christos Exp $	*/
+
+/*-
+ * Copyright (c) 2010 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: conjl.c,v 1.4 2010/09/20 16:55:20 christos Exp $");
+
+#include <complex.h>
+#include "../common/fdlibm.h"
+
+/*
+ * conjl(long double complex z)
+ * This function returns the complex conjugate value of its argument, z.
+ */
+long double complex
+conjl(long double complex z)
+{
+	long_double_complex w = { .z = z };
+
+	IMAG_PART(w) = -IMAG_PART(w);
+
+	return (w.z);
+}
-- 
2.7.4


[-- Attachment #3: 0012-Porting-ctanl.c-from-NetBSD.patch --]
[-- Type: text/x-patch, Size: 3329 bytes --]

From b0f90b446b21c0ee16aef03614580ade8d0ac43b Mon Sep 17 00:00:00 2001
From: Aditya Upadhyay <aadit0402@gmail.com>
Date: Wed, 28 Jun 2017 19:06:03 +0530
Subject: [PATCH 12/12] Porting ctanl.c from NetBSD.

---
 newlib/libm/complex/Makefile.am |  3 ++-
 newlib/libm/complex/ctanl.c     | 56 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 58 insertions(+), 1 deletion(-)
 create mode 100644 newlib/libm/complex/ctanl.c

diff --git a/newlib/libm/complex/Makefile.am b/newlib/libm/complex/Makefile.am
index 979a9a9..02cab35 100644
--- a/newlib/libm/complex/Makefile.am
+++ b/newlib/libm/complex/Makefile.am
@@ -12,7 +12,8 @@ src = cabs.c cacos.c cacosh.c carg.c casin.c casinh.c \
 
 lsrc = cabsl.c creall.c cimagl.c ccoshl.c cacoshl.c \ 
        clogl.c csqrtl.c cargl.c cprojl.c cexpl.c cephes_subrl.c\
-       cacosl.c ccosl.c cpowl.c conjl.c
+       cacosl.c ccosl.c cpowl.c conjl.c \
+       ctanl.c
 
 fsrc =	cabsf.c casinf.c ccosf.c cimagf.c cprojf.c  \
         csqrtf.c cacosf.c casinhf.c ccoshf.c clogf.c clog10f.c \
diff --git a/newlib/libm/complex/ctanl.c b/newlib/libm/complex/ctanl.c
new file mode 100644
index 0000000..9255bdb
--- /dev/null
+++ b/newlib/libm/complex/ctanl.c
@@ -0,0 +1,56 @@
+/* $NetBSD: ctanl.c,v 1.1 2014/10/10 00:48:18 christos Exp $ */
+
+/*-
+ * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software written by Stephen L. Moshier.
+ * It is redistributed by the NetBSD Foundation by permission of the author.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include <complex.h>
+#include <math.h>
+#include "cephes_subrl.h"
+
+long double complex
+ctanl(long double complex z)
+{
+	long double complex w;
+	long double d;
+
+	d = cosl(2.0L * creall(z)) + coshl(2.0L * cimagl(z));
+
+	if (fabsl(d) < 0.25L)
+		d = _ctansl(z);
+
+	if (d == 0.0L) {
+		/* mtherr ("ctan", OVERFLOW); */
+		w = HUGE_VALF + HUGE_VALF * I;
+		return w;
+	}
+
+	w = sinl(2.0L * creall(z)) / d + (sinhl(2.0L * cimagl(z)) / d) * I;
+	return w;
+}
-- 
2.7.4


^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2022-11-08 20:25 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-28 20:35 Long double complex methods Aditya Upadhyay
2017-06-28 21:36 ` Dionna Amalie Glaze via newlib
2017-06-28 21:57   ` Joel Sherrill
2017-06-29 16:18     ` Joseph Myers
2017-06-29 16:31       ` Joel Sherrill
2017-06-29  6:39 ` Corinna Vinschen
2017-06-29  7:11   ` Aditya Upadhyay
2017-06-29 11:53     ` Corinna Vinschen
2017-06-29 12:04       ` Corinna Vinschen
2017-06-29 19:38         ` Yaakov Selkowitz
2017-06-29 21:17           ` Joel Sherrill
2017-06-30  9:11             ` Aditya Upadhyay
2017-07-04 21:31               ` Aditya Upadhyay
2017-07-04 21:56                 ` Aditya Upadhyay
2017-07-05  8:27                   ` Corinna Vinschen
2017-07-05  9:02                     ` Aditya Upadhyay
2017-07-05 12:40                       ` Corinna Vinschen
2022-11-08 18:31                       ` [newlib] Generally make all 'long double complex' methods available in <complex.h> Thomas Schwinge
2022-11-08 20:24                         ` Jeff Johnston
2017-06-29 13:47   ` Long double complex methods Joel Sherrill
  -- strict thread matches above, loose matches on Subject: below --
2017-06-28 13:53 Aditya Upadhyay

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).