summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authordas <das@FreeBSD.org>2008-08-07 15:07:48 +0000
committerdas <das@FreeBSD.org>2008-08-07 15:07:48 +0000
commitec47be13ee00be2b6199952305615cedee91890a (patch)
tree8025e6cf1286830dfa72a371de57c7ed4fc50aa8 /lib
parent0fcff3686b2759a5962aec115d42856976db5e5c (diff)
downloadFreeBSD-src-ec47be13ee00be2b6199952305615cedee91890a.zip
FreeBSD-src-ec47be13ee00be2b6199952305615cedee91890a.tar.gz
Implement cproj{,f,l}().
Diffstat (limited to 'lib')
-rw-r--r--lib/msun/Makefile6
-rw-r--r--lib/msun/Symbol.map3
-rw-r--r--lib/msun/man/cimag.335
-rw-r--r--lib/msun/src/s_cproj.c47
-rw-r--r--lib/msun/src/s_cprojf.c43
-rw-r--r--lib/msun/src/s_cprojl.c43
6 files changed, 170 insertions, 7 deletions
diff --git a/lib/msun/Makefile b/lib/msun/Makefile
index 11aabef..4a1b73a 100644
--- a/lib/msun/Makefile
+++ b/lib/msun/Makefile
@@ -87,7 +87,8 @@ COMMON_SRCS+= s_copysignl.c s_fabsl.c s_llrintl.c s_lrintl.c s_modfl.c
COMMON_SRCS+= e_acosl.c e_asinl.c e_atan2l.c e_fmodl.c \
e_hypotl.c e_remainderl.c e_sqrtl.c \
invtrig.c k_cosl.c k_sinl.c k_tanl.c \
- s_atanl.c s_ceill.c s_cosl.c s_csqrtl.c s_exp2l.c s_floorl.c s_fmal.c \
+ s_atanl.c s_ceill.c s_cosl.c s_cprojl.c s_csqrtl.c s_exp2l.c \
+ s_floorl.c s_fmal.c \
s_frexpl.c s_logbl.c s_nanl.c s_nextafterl.c s_nexttoward.c \
s_remquol.c s_rintl.c s_scalbnl.c \
s_sinl.c s_tanl.c s_truncl.c w_cabsl.c
@@ -95,7 +96,7 @@ COMMON_SRCS+= e_acosl.c e_asinl.c e_atan2l.c e_fmodl.c \
# C99 complex functions
COMMON_SRCS+= s_cimag.c s_cimagf.c s_cimagl.c s_conj.c s_conjf.c s_conjl.c \
- s_creal.c s_crealf.c s_creall.c
+ s_cproj.c s_cprojf.c s_creal.c s_crealf.c s_creall.c
# FreeBSD's C library supplies these functions:
#COMMON_SRCS+= s_fabs.c s_frexp.c s_isnan.c s_ldexp.c s_modf.c
@@ -131,6 +132,7 @@ MLINKS+=atan2.3 atan2f.3 atan2.3 atan2l.3 \
MLINKS+=ceil.3 ceilf.3 ceil.3 ceill.3
MLINKS+=cimag.3 cimagf.3 cimag.3 cimagl.3 \
cimag.3 conj.3 cimag.3 conjf.3 cimag.3 conjl.3 \
+ cimag.3 cproj.3 cimag.3 cprojf.3 cimag.3 cprojl.3 \
cimag.3 creal.3 cimag.3 crealf.3 cimag.3 creall.3
MLINKS+=copysign.3 copysignf.3 copysign.3 copysignl.3
MLINKS+=cos.3 cosf.3 cos.3 cosl.3
diff --git a/lib/msun/Symbol.map b/lib/msun/Symbol.map
index e1e8c4a..39196bd 100644
--- a/lib/msun/Symbol.map
+++ b/lib/msun/Symbol.map
@@ -214,4 +214,7 @@ FBSD_1.1 {
atan2l;
atanl;
cargl;
+ cproj;
+ cprojf;
+ cprojl;
};
diff --git a/lib/msun/man/cimag.3 b/lib/msun/man/cimag.3
index 10a3b2c..18fefc4 100644
--- a/lib/msun/man/cimag.3
+++ b/lib/msun/man/cimag.3
@@ -24,12 +24,13 @@
.\"
.\" $FreeBSD$
.\"
-.Dd August 7, 2004
+.Dd August 7, 2008
.Dt CIMAG 3
.Os
.Sh NAME
.Nm cimag , cimagf , cimagl ,
.Nm conj , conjf , conjl ,
+.Nm cproj , cprojf , cprojl ,
.Nm creal , crealf , creall
.Nd "functions to manipulate complex numbers"
.Sh LIBRARY
@@ -48,6 +49,12 @@
.Fn conjf "float complex z"
.Ft "long double complex"
.Fn conjl "long double complex z"
+.Ft "double complex"
+.Fn cproj "double complex z"
+.Ft "float complex"
+.Fn cprojf "float complex z"
+.Ft "long double complex"
+.Fn cprojl "long double complex z"
.Ft double
.Fn creal "double complex z"
.Ft float
@@ -63,6 +70,10 @@ denote the complex number
.Fa z .
.Pp
The
+.Fn creal
+functions return the real part
+.Fa a ,
+and the
.Fn cimag
functions return the imaginary part
.Fa b .
@@ -75,13 +86,23 @@ functions return the complex conjugate
.Sm on
.Pp
The
-.Fn creal
-functions return the real part
-.Fa a .
+.Fn cproj
+functions return the projection onto the Riemann sphere.
+If
+.Fa z
+contains an infinite component, then the result is
+.Fa \*(If \*(Pm 0 Ns * Ns Em i ,
+where the (zero) imaginary part of the result has the same sign as
+.Fa b .
+Otherwise, the result is
+.Fa z .
+.Pp
+These functions do not signal any floating point exceptions.
.Sh STANDARDS
The
.Fn cimag ,
-.Fn conj
+.Fn conj ,
+.Fn cproj ,
and
.Fn creal
functions conform to
@@ -94,3 +115,7 @@ and
.Fn creal
functions first appeared in
.Fx 5.3 .
+The
+.Fn cproj
+functions appeared in
+.Fx 8.0.
diff --git a/lib/msun/src/s_cproj.c b/lib/msun/src/s_cproj.c
new file mode 100644
index 0000000..8e9404c
--- /dev/null
+++ b/lib/msun/src/s_cproj.c
@@ -0,0 +1,47 @@
+/*-
+ * Copyright (c) 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>
+__FBSDID("$FreeBSD$");
+
+#include <complex.h>
+#include <math.h>
+
+#include "math_private.h"
+
+double complex
+cproj(double complex z)
+{
+
+ if (!isinf(creal(z)) && !isinf(cimag(z)))
+ return (z);
+ else
+ return (cpack(INFINITY, copysign(0.0, cimag(z))));
+}
+
+#if LDBL_MANT_DIG == 53
+__weak_reference(cproj, cprojl);
+#endif
diff --git a/lib/msun/src/s_cprojf.c b/lib/msun/src/s_cprojf.c
new file mode 100644
index 0000000..68ea77b
--- /dev/null
+++ b/lib/msun/src/s_cprojf.c
@@ -0,0 +1,43 @@
+/*-
+ * Copyright (c) 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>
+__FBSDID("$FreeBSD$");
+
+#include <complex.h>
+#include <math.h>
+
+#include "math_private.h"
+
+float complex
+cprojf(float complex z)
+{
+
+ if (!isinf(crealf(z)) && !isinf(cimagf(z)))
+ return (z);
+ else
+ return (cpackf(INFINITY, copysignf(0.0, cimagf(z))));
+}
diff --git a/lib/msun/src/s_cprojl.c b/lib/msun/src/s_cprojl.c
new file mode 100644
index 0000000..07385bc
--- /dev/null
+++ b/lib/msun/src/s_cprojl.c
@@ -0,0 +1,43 @@
+/*-
+ * Copyright (c) 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>
+__FBSDID("$FreeBSD$");
+
+#include <complex.h>
+#include <math.h>
+
+#include "math_private.h"
+
+long double complex
+cprojl(long double complex z)
+{
+
+ if (!isinf(creall(z)) && !isinf(cimagl(z)))
+ return (z);
+ else
+ return (cpackl(INFINITY, copysignl(0.0, cimagl(z))));
+}
OpenPOWER on IntegriCloud