Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libm Add the missing complex functions.



details:   https://anonhg.NetBSD.org/src/rev/b8911f0f1852
branches:  trunk
changeset: 332803:b8911f0f1852
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Oct 10 00:48:18 2014 +0000

description:
Add the missing complex functions.

diffstat:

 lib/libm/complex/Makefile.inc   |   35 +++--------
 lib/libm/complex/cabsl.c        |   16 +++++
 lib/libm/complex/cacoshl.c      |   45 ++++++++++++++
 lib/libm/complex/cacosl.c       |   45 ++++++++++++++
 lib/libm/complex/cargl.c        |   16 +++++
 lib/libm/complex/casinhl.c      |   42 +++++++++++++
 lib/libm/complex/casinl.c       |  120 ++++++++++++++++++++++++++++++++++++++
 lib/libm/complex/catanl.c       |   80 +++++++++++++++++++++++++
 lib/libm/complex/ccoshl.c       |   46 ++++++++++++++
 lib/libm/complex/ccosl.c        |   46 ++++++++++++++
 lib/libm/complex/cephes_subrl.c |  124 ++++++++++++++++++++++++++++++++++++++++
 lib/libm/complex/cephes_subrl.h |    9 ++
 lib/libm/complex/cexpl.c        |   47 +++++++++++++++
 lib/libm/complex/clogl.c        |   47 +++++++++++++++
 lib/libm/complex/cpowl.c        |   57 ++++++++++++++++++
 lib/libm/complex/cprojl.c       |    6 +-
 lib/libm/complex/csinhl.c       |   46 ++++++++++++++
 lib/libm/complex/csinl.c        |   46 ++++++++++++++
 lib/libm/complex/csqrtl.c       |  113 ++++++++++++++++++++++++++++++++++++
 lib/libm/complex/ctanhl.c       |   48 +++++++++++++++
 lib/libm/complex/ctanl.c        |   59 +++++++++++++++++++
 lib/libm/shlib_version          |    4 +-
 22 files changed, 1067 insertions(+), 30 deletions(-)

diffs (truncated from 1209 to 300 lines):

diff -r 02a232e723af -r b8911f0f1852 lib/libm/complex/Makefile.inc
--- a/lib/libm/complex/Makefile.inc     Thu Oct 09 23:52:47 2014 +0000
+++ b/lib/libm/complex/Makefile.inc     Fri Oct 10 00:48:18 2014 +0000
@@ -1,29 +1,14 @@
-# $NetBSD: Makefile.inc,v 1.4 2011/03/18 00:57:22 joerg Exp $
+# $NetBSD: Makefile.inc,v 1.5 2014/10/10 00:48:18 christos Exp $
 
 .PATH: ${.CURDIR}/complex
 
-SRCS+= cabs.c cabsf.c carg.c cargf.c
-SRCS+= creal.c crealf.c creall.c cimag.c cimagf.c cimagl.c
-SRCS+= conj.c conjf.c conjl.c
-SRCS+= csqrt.c cexp.c clog.c cpow.c
-SRCS+= cephes_subr.c csin.c ccos.c ctan.c csinh.c ccosh.c ctanh.c
-SRCS+= casin.c cacos.c catan.c casinh.c cacosh.c catanh.c
-SRCS+= csqrtf.c cexpf.c clogf.c cpowf.c
-SRCS+= cephes_subrf.c csinf.c ccosf.c ctanf.c csinhf.c ccoshf.c ctanhf.c
-SRCS+= casinf.c cacosf.c catanf.c casinhf.c cacoshf.c catanhf.c
-SRCS+= cproj.c cprojf.c cprojl.c
+COMPLEX_SRCS = cabs.c cacos.c cacosh.c carg.c casin.c casinh.c catan.c \
+       ccos.c ccosh.c cephes_subr.c cexp.c clog.c conj.c cpow.c cproj.c\
+       creal.c csin.c csinh.c csqrt.c ctan.c ctanh.c
 
-MAN+= cabs.3 cacos.3 cacosh.3 carg.3 casin.3 casinh.3 catan.3 catanh.3
-MAN+= ccos.3 ccosh.3 cexp.3 cimag.3 clog.3 conj.3 cpow.3 cproj.3 creal.3
-MAN+= csin.3 csinh.3 csqrt.3 ctan.3 ctanh.3
-
-MLINKS+= cabs.3 cabsf.3 cacos.3 cacosf.3 cacosh.3 cacoshf.3
-MLINKS+= carg.3 cargf.3 casin.3 casinf.3 casinh.3 casinhf.3
-MLINKS+= catan.3 catanf.3 catanh.3 catanhf.3 ccos.3 ccosf.3
-MLINKS+= ccosh.3 ccoshf.3 cexp.3 cexpf.3
-MLINKS+= cimag.3 cimagf.3 cimag.3 cimagl.3
-MLINKS+= clog.3 clogf.3 conj.3 conjf.3 conj.3 conjl.3 cpow.3 cpowf.3
-MLINKS+= cproj.3 cprojf.3 cproj.3 cprojl.3
-MLINKS+= creal.3 crealf.3 creal.3 creall.3
-MLINKS+= csin.3 csinf.3 csinh.3 csinhf.3
-MLINKS+= csqrt.3 csqrtf.3 ctan.3 ctanf.3 ctanh.3 ctanhf.3
+.for i in ${COMPLEX_SRCS}
+SRCS+= $i ${i:S/.c/f.c/} ${i:S/.c/l.c/}
+MAN+= ${i:Ncephes_*:S/.c/.3/}
+MLINKS+= ${i:Ncephes_*:S/.c/.3/} ${i:Ncephes_*:S/.c/f.3/}
+MLINKS+= ${i:Ncephes_*:S/.c/.3/} ${i:Ncephes_*:S/.c/l.3/}
+.endfor
diff -r 02a232e723af -r b8911f0f1852 lib/libm/complex/cabsl.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libm/complex/cabsl.c  Fri Oct 10 00:48:18 2014 +0000
@@ -0,0 +1,16 @@
+/* $NetBSD: cabsl.c,v 1.1 2014/10/10 00:48:18 christos Exp $ */
+
+/*
+ * Public domain.
+ */
+
+#include "../src/namespace.h"
+#include <complex.h>
+#include <math.h>
+
+long double
+cabsl(long double complex z)
+{
+
+       return hypotl(__real__ z, __imag__ z);
+}
diff -r 02a232e723af -r b8911f0f1852 lib/libm/complex/cacoshl.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libm/complex/cacoshl.c        Fri Oct 10 00:48:18 2014 +0000
@@ -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;
+}
diff -r 02a232e723af -r b8911f0f1852 lib/libm/complex/cacosl.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libm/complex/cacosl.c Fri Oct 10 00:48:18 2014 +0000
@@ -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 "../src/namespace.h"
+#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;
+}
diff -r 02a232e723af -r b8911f0f1852 lib/libm/complex/cargl.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libm/complex/cargl.c  Fri Oct 10 00:48:18 2014 +0000
@@ -0,0 +1,16 @@
+/* $NetBSD: cargl.c,v 1.1 2014/10/10 00:48:18 christos Exp $ */
+
+/*
+ * Public domain.
+ */
+
+#include "../src/namespace.h"
+#include <complex.h>
+#include <math.h>
+
+long double
+cargl(long double complex z)
+{
+
+       return atan2l(__imag__ z, __real__ z);
+}
diff -r 02a232e723af -r b8911f0f1852 lib/libm/complex/casinhl.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libm/complex/casinhl.c        Fri Oct 10 00:48:18 2014 +0000
@@ -0,0 +1,42 @@
+/* $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 "../src/namespace.h"
+#include <complex.h>
+
+long double complex
+casinhl(long double complex z)
+{
+       long double complex w;
+
+       w = -1.0L * I * casinl(z * I);
+       return w;
+}
diff -r 02a232e723af -r b8911f0f1852 lib/libm/complex/casinl.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libm/complex/casinl.c Fri Oct 10 00:48:18 2014 +0000
@@ -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 "../src/namespace.h"
+#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);



Home | Main Index | Thread Index | Old Index