summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authordas <das@FreeBSD.org>2007-12-12 23:43:51 +0000
committerdas <das@FreeBSD.org>2007-12-12 23:43:51 +0000
commitb9a043d44cc426b5fe354db2cf705e59e5b3a867 (patch)
tree79fcbb5dd5acb03b187bc82dfc2af59cd0cc2e55 /lib
parentfacc60167bbbf9e19b3968e7e98afe0f6af4231a (diff)
downloadFreeBSD-src-b9a043d44cc426b5fe354db2cf705e59e5b3a867.zip
FreeBSD-src-b9a043d44cc426b5fe354db2cf705e59e5b3a867.tar.gz
Implement carg(3) and cargf(3).
Rotting in an old src tree since: March 2005
Diffstat (limited to 'lib')
-rw-r--r--lib/msun/Makefile6
-rw-r--r--lib/msun/man/atan2.344
-rw-r--r--lib/msun/man/hypot.33
-rw-r--r--lib/msun/src/s_carg.c38
-rw-r--r--lib/msun/src/s_cargf.c38
5 files changed, 120 insertions, 9 deletions
diff --git a/lib/msun/Makefile b/lib/msun/Makefile
index 48aeba6..8a04ef2 100644
--- a/lib/msun/Makefile
+++ b/lib/msun/Makefile
@@ -38,8 +38,8 @@ COMMON_SRCS= b_exp.c b_log.c b_tgamma.c \
e_sinh.c e_sinhf.c e_sqrt.c e_sqrtf.c fenv.c \
k_cos.c k_cosf.c k_rem_pio2.c k_sin.c k_sinf.c \
k_tan.c k_tanf.c \
- s_asinh.c s_asinhf.c s_atan.c s_atanf.c s_cbrt.c s_cbrtf.c \
- s_ceil.c s_ceilf.c s_ceill.c \
+ s_asinh.c s_asinhf.c s_atan.c s_atanf.c s_carg.c s_cargf.c \
+ s_cbrt.c s_cbrtf.c s_ceil.c s_ceilf.c s_ceill.c \
s_copysign.c s_copysignf.c s_cos.c s_cosf.c s_erf.c s_erff.c \
s_exp2.c s_exp2f.c s_expm1.c s_expm1f.c s_fabsf.c s_fdim.c \
s_finite.c s_finitef.c \
@@ -106,7 +106,7 @@ MLINKS+=asin.3 asinf.3
MLINKS+=asinh.3 asinhf.3
MLINKS+=atan.3 atanf.3
MLINKS+=atanh.3 atanhf.3
-MLINKS+=atan2.3 atan2f.3
+MLINKS+=atan2.3 atan2f.3 atan2.3 carg.3 atan2.3 cargf.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 \
diff --git a/lib/msun/man/atan2.3 b/lib/msun/man/atan2.3
index 6619297..eecfcde 100644
--- a/lib/msun/man/atan2.3
+++ b/lib/msun/man/atan2.3
@@ -28,13 +28,15 @@
.\" from: @(#)atan2.3 5.1 (Berkeley) 5/2/91
.\" $FreeBSD$
.\"
-.Dd January 14, 2005
+.Dd December 12, 2007
.Dt ATAN2 3
.Os
.Sh NAME
.Nm atan2 ,
-.Nm atan2f
-.Nd arc tangent functions of two variables
+.Nm atan2f ,
+.Nm carg ,
+.Nm cargf
+.Nd arc tangent and complex phase angle functions
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
@@ -43,6 +45,10 @@
.Fn atan2 "double y" "double x"
.Ft float
.Fn atan2f "float y" "float x"
+.Ft double
+.Fn carg "double complex z"
+.Ft float
+.Fn cargf "float complex z"
.Sh DESCRIPTION
The
.Fn atan2
@@ -52,6 +58,29 @@ functions compute the principal value of the arc tangent of
.Fa y/ Ns Ar x ,
using the signs of both arguments to determine the quadrant of
the return value.
+.ie '\*[.T]'utf8' \{\
+. ds Th \[*h]
+.\}
+.el \{\
+. ds Th theta
+.\}
+.Pp
+The
+.Fn carg
+and
+.Fn cargf
+functions compute the complex argument (or phase angle) of
+.Fa z .
+The complex argument is the number \*(Th such that
+.Li z = r * e^(I * \*(Th) ,
+where
+.Li r = cabs(z) .
+The call
+.Li carg(z)
+is equivalent to
+.Li atan2(cimag(z), creal(z)) ,
+and similarly for
+.Fn cargf .
.Sh RETURN VALUES
The
.Fn atan2
@@ -169,6 +198,7 @@ r := \(sr(x\(**x+y\(**y);\0\0if r = 0 then x := copysign(1,x);
.Xr acos 3 ,
.Xr asin 3 ,
.Xr atan 3 ,
+.Xr cabs 3 ,
.Xr cos 3 ,
.Xr cosh 3 ,
.Xr math 3 ,
@@ -178,6 +208,10 @@ r := \(sr(x\(**x+y\(**y);\0\0if r = 0 then x := copysign(1,x);
.Xr tanh 3
.Sh STANDARDS
The
-.Fn atan2
-function conforms to
+.Fn atan2 ,
+.Fn atan2f ,
+.Fn carg ,
+and
+.Fn cargf
+functions conform to
.St -isoC .
diff --git a/lib/msun/man/hypot.3 b/lib/msun/man/hypot.3
index 2b353f7..978b390 100644
--- a/lib/msun/man/hypot.3
+++ b/lib/msun/man/hypot.3
@@ -28,7 +28,7 @@
.\" from: @(#)hypot.3 6.7 (Berkeley) 5/6/91
.\" $FreeBSD$
.\"
-.Dd January 14, 2005
+.Dd December 12, 2007
.Dt HYPOT 3
.Os
.Sh NAME
@@ -118,6 +118,7 @@ the
disappear when it turns out to be irrelevant, as it does in
.Fn hypot "\*(If" "\*(Na" .
.Sh SEE ALSO
+.Xr carg 3 ,
.Xr math 3 ,
.Xr sqrt 3
.Sh HISTORY
diff --git a/lib/msun/src/s_carg.c b/lib/msun/src/s_carg.c
new file mode 100644
index 0000000..ea1a0d7
--- /dev/null
+++ b/lib/msun/src/s_carg.c
@@ -0,0 +1,38 @@
+/*-
+ * Copyright (c) 2005 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>
+
+double
+carg(double complex z)
+{
+
+ return (atan2(cimag(z), creal(z)));
+}
diff --git a/lib/msun/src/s_cargf.c b/lib/msun/src/s_cargf.c
new file mode 100644
index 0000000..90232d0
--- /dev/null
+++ b/lib/msun/src/s_cargf.c
@@ -0,0 +1,38 @@
+/*-
+ * Copyright (c) 2005 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>
+
+float
+cargf(float complex z)
+{
+
+ return (atan2f(cimagf(z), crealf(z)));
+}
OpenPOWER on IntegriCloud