Full switch to clang/ELF. Drop ack. Simplify.

There is important information about booting non-ack images in
docs/UPDATING. ack/aout-format images can't be built any more, and
booting clang/ELF-format ones is a little different. Updating to the
new boot monitor is recommended.

Changes in this commit:

	. drop boot monitor -> allowing dropping ack support
	. facility to copy ELF boot files to /boot so that old boot monitor
	  can still boot fairly easily, see UPDATING
	. no more ack-format libraries -> single-case libraries
	. some cleanup of OBJECT_FMT, COMPILER_TYPE, etc cases
	. drop several ack toolchain commands, but not all support
	  commands (e.g. aal is gone but acksize is not yet).
	. a few libc files moved to netbsd libc dir
	. new /bin/date as minix date used code in libc/
	. test compile fix
	. harmonize includes
	. /usr/lib is no longer special: without ack, /usr/lib plays no
	  kind of special bootstrapping role any more and bootstrapping
	  is done exclusively through packages, so releases depend even
	  less on the state of the machine making them now.
	. rename nbsd_lib* to lib*
	. reduce mtree
This commit is contained in:
Ben Gras
2012-02-11 19:31:25 +01:00
parent 2487445f5f
commit 2fe8fb192f
5056 changed files with 16216 additions and 133169 deletions

View File

@@ -0,0 +1,28 @@
# $NetBSD: Makefile.inc,v 1.3 2010/09/15 16:11:29 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
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 cpow.3 cpowf.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

53
lib/libm/complex/cabs.3 Normal file
View File

@@ -0,0 +1,53 @@
.\" $NetBSD: cabs.3,v 1.1 2008/02/20 09:55:38 drochner Exp $
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
.TH "CABS" 3P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
.\" cabs
.SH NAME
cabs, cabsf \- return a complex absolute value
.SH SYNOPSIS
.LP
\fB#include <complex.h>
.br
.sp
double cabs(double complex\fP \fIz\fP\fB);
.br
float cabsf(float complex\fP \fIz\fP\fB);
.br
\fP
.SH DESCRIPTION
.LP
These functions compute the complex absolute value (also called
norm, modulus, or magnitude) of \fIz\fP.
.SH RETURN VALUE
.LP
These functions return the complex absolute value.
.SH ERRORS
.LP
No errors are defined.
.LP
\fIThe following sections are informative.\fP
.SH EXAMPLES
.LP
None.
.SH APPLICATION USAGE
.LP
None.
.SH RATIONALE
.LP
None.
.SH FUTURE DIRECTIONS
.LP
None.
.SH SEE ALSO
.LP
The Base Definitions volume of IEEE\ Std\ 1003.1-2001, \fI<complex.h>\fP
.SH COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. In the
event of any discrepancy between this version and the original IEEE and
The Open Group Standard, the original IEEE and The Open Group Standard
is the referee document. The original Standard can be obtained online at
http://www.opengroup.org/unix/online.html .

17
lib/libm/complex/cabs.c Normal file
View File

@@ -0,0 +1,17 @@
/* $NetBSD: cabs.c,v 1.1 2007/08/20 16:01:30 drochner Exp $ */
/*
* Written by Matthias Drochner <drochner@NetBSD.org>.
* Public domain.
*/
#include "../src/namespace.h"
#include <complex.h>
#include <math.h>
double
cabs(double complex z)
{
return hypot(__real__ z, __imag__ z);
}

17
lib/libm/complex/cabsf.c Normal file
View File

@@ -0,0 +1,17 @@
/* $NetBSD: cabsf.c,v 1.1 2007/08/20 16:01:30 drochner Exp $ */
/*
* Written by Matthias Drochner <drochner@NetBSD.org>.
* Public domain.
*/
#include "../src/namespace.h"
#include <complex.h>
#include <math.h>
float
cabsf(float complex z)
{
return hypotf(__real__ z, __imag__ z);
}

57
lib/libm/complex/cacos.3 Normal file
View File

@@ -0,0 +1,57 @@
.\" $NetBSD: cacos.3,v 1.1 2008/02/20 09:55:38 drochner Exp $
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
.TH "CACOS" 3P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
.\" cacos
.SH NAME
cacos, cacosf \- complex arc cosine functions
.SH SYNOPSIS
.LP
\fB#include <complex.h>
.br
.sp
double complex cacos(double complex\fP \fIz\fP\fB);
.br
float complex cacosf(float complex\fP \fIz\fP\fB);
.br
\fP
.SH DESCRIPTION
.LP
These functions compute the complex arc cosine of \fIz\fP, with
branch cuts outside the interval [-1,\ +1] along the
real axis.
.SH RETURN VALUE
.LP
These functions return the complex arc cosine value, in the
range of a strip mathematically unbounded along the imaginary
axis and in the interval [0,\ pi] along the real axis.
.SH ERRORS
.LP
No errors are defined.
.LP
\fIThe following sections are informative.\fP
.SH EXAMPLES
.LP
None.
.SH APPLICATION USAGE
.LP
None.
.SH RATIONALE
.LP
None.
.SH FUTURE DIRECTIONS
.LP
None.
.SH SEE ALSO
.LP
\fIccos\fP(), the Base Definitions volume of IEEE\ Std\ 1003.1-2001,
\fI<complex.h>\fP
.SH COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. In the
event of any discrepancy between this version and the original IEEE and
The Open Group Standard, the original IEEE and The Open Group Standard
is the referee document. The original Standard can be obtained online at
http://www.opengroup.org/unix/online.html .

44
lib/libm/complex/cacos.c Normal file
View File

@@ -0,0 +1,44 @@
/* $NetBSD: cacos.c,v 1.1 2007/08/20 16:01:30 drochner 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>
double complex
cacos(double complex z)
{
double complex w;
w = casin(z);
w = (M_PI_2 - creal(w)) - cimag(w) * I;
return w;
}

44
lib/libm/complex/cacosf.c Normal file
View File

@@ -0,0 +1,44 @@
/* $NetBSD: cacosf.c,v 1.1 2007/08/20 16:01:30 drochner 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>
float complex
cacosf(float complex z)
{
float complex w;
w = casinf(z);
w = ((float)M_PI_2 - crealf(w)) - cimagf(w) * I;
return w;
}

58
lib/libm/complex/cacosh.3 Normal file
View File

@@ -0,0 +1,58 @@
.\" $NetBSD: cacosh.3,v 1.1 2008/02/20 09:55:38 drochner Exp $
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
.TH "CACOSH" 3P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
.\" cacosh
.SH NAME
cacosh, cacoshf \- complex arc hyperbolic cosine functions
.SH SYNOPSIS
.LP
\fB#include <complex.h>
.br
.sp
double complex cacosh(double complex\fP \fIz\fP\fB);
.br
float complex cacoshf(float complex\fP \fIz\fP\fB);
.br
\fP
.SH DESCRIPTION
.LP
These functions compute the complex arc hyperbolic cosine of
\fIz\fP, with a branch cut at values less than 1 along the
real axis.
.SH RETURN VALUE
.LP
These functions return the complex arc hyperbolic cosine value,
in the range of a half-strip of non-negative values along
the real axis and in the interval [-\fIi\fPpi,\ +\fIi\fPpi] along
the imaginary axis.
.SH ERRORS
.LP
No errors are defined.
.LP
\fIThe following sections are informative.\fP
.SH EXAMPLES
.LP
None.
.SH APPLICATION USAGE
.LP
None.
.SH RATIONALE
.LP
None.
.SH FUTURE DIRECTIONS
.LP
None.
.SH SEE ALSO
.LP
\fIccosh\fP(), the Base Definitions volume of IEEE\ Std\ 1003.1-2001,
\fI<complex.h>\fP
.SH COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. In the
event of any discrepancy between this version and the original IEEE and
The Open Group Standard, the original IEEE and The Open Group Standard
is the referee document. The original Standard can be obtained online at
http://www.opengroup.org/unix/online.html .

45
lib/libm/complex/cacosh.c Normal file
View File

@@ -0,0 +1,45 @@
/* $NetBSD: cacosh.c,v 1.2 2009/08/03 19:41:32 drochner 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>
double complex
cacosh(double complex z)
{
double complex w;
#if 0 /* does not give the principal value */
w = I * cacos(z);
#else
w = clog(z + csqrt(z + 1) * csqrt(z - 1));
#endif
return w;
}

View File

@@ -0,0 +1,45 @@
/* $NetBSD: cacoshf.c,v 1.2 2009/08/03 19:41:32 drochner 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>
float complex
cacoshf(float complex z)
{
float complex w;
#if 0 /* does not give the principal value */
w = I * cacosf(z);
#else
w = clogf(z + csqrtf(z + 1) * csqrtf(z - 1));
#endif
return w;
}

56
lib/libm/complex/carg.3 Normal file
View File

@@ -0,0 +1,56 @@
.\" $NetBSD: carg.3,v 1.1 2008/02/20 09:55:38 drochner Exp $
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
.TH "CARG" 3P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
.\" carg
.SH NAME
carg, cargf \- complex argument functions
.SH SYNOPSIS
.LP
\fB#include <complex.h>
.br
.sp
double carg(double complex\fP \fIz\fP\fB);
.br
float cargf(float complex\fP \fIz\fP\fB);
.br
\fP
.SH DESCRIPTION
.LP
These functions compute the argument (also called phase angle)
of \fIz\fP, with a branch cut along the negative real
axis.
.SH RETURN VALUE
.LP
These functions return the value of the argument in the interval
[-pi,\ +pi].
.SH ERRORS
.LP
No errors are defined.
.LP
\fIThe following sections are informative.\fP
.SH EXAMPLES
.LP
None.
.SH APPLICATION USAGE
.LP
None.
.SH RATIONALE
.LP
None.
.SH FUTURE DIRECTIONS
.LP
None.
.SH SEE ALSO
.LP
\fIcimag\fP(), \fIconj\fP(), \fIcproj\fP(), the
Base Definitions volume of IEEE\ Std\ 1003.1-2001, \fI<complex.h>\fP
.SH COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. In the
event of any discrepancy between this version and the original IEEE and
The Open Group Standard, the original IEEE and The Open Group Standard
is the referee document. The original Standard can be obtained online at
http://www.opengroup.org/unix/online.html .

17
lib/libm/complex/carg.c Normal file
View File

@@ -0,0 +1,17 @@
/* $NetBSD: carg.c,v 1.1 2007/08/20 16:01:31 drochner Exp $ */
/*
* Written by Matthias Drochner <drochner@NetBSD.org>.
* Public domain.
*/
#include "../src/namespace.h"
#include <complex.h>
#include <math.h>
double
carg(double complex z)
{
return atan2(__imag__ z, __real__ z);
}

17
lib/libm/complex/cargf.c Normal file
View File

@@ -0,0 +1,17 @@
/* $NetBSD: cargf.c,v 1.1 2007/08/20 16:01:31 drochner Exp $ */
/*
* Written by Matthias Drochner <drochner@NetBSD.org>.
* Public domain.
*/
#include "../src/namespace.h"
#include <complex.h>
#include <math.h>
float
cargf(float complex z)
{
return atan2f(__imag__ z, __real__ z);
}

58
lib/libm/complex/casin.3 Normal file
View File

@@ -0,0 +1,58 @@
.\" $NetBSD: casin.3,v 1.1 2008/02/20 09:55:38 drochner Exp $
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
.TH "CASIN" 3P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
.\" casin
.SH NAME
casin, casinf \- complex arc sine functions
.SH SYNOPSIS
.LP
\fB#include <complex.h>
.br
.sp
double complex casin(double complex\fP \fIz\fP\fB);
.br
float complex casinf(float complex\fP \fIz\fP\fB);
.br
\fP
.SH DESCRIPTION
.LP
These functions compute the complex arc sine of \fIz\fP, with
branch cuts outside the interval [-1,\ +1] along the
real axis.
.SH RETURN VALUE
.LP
These functions return the complex arc sine value, in the range
of a strip mathematically unbounded along the imaginary
axis and in the interval [-pi/2,\ +pi/2] along the
real axis.
.SH ERRORS
.LP
No errors are defined.
.LP
\fIThe following sections are informative.\fP
.SH EXAMPLES
.LP
None.
.SH APPLICATION USAGE
.LP
None.
.SH RATIONALE
.LP
None.
.SH FUTURE DIRECTIONS
.LP
None.
.SH SEE ALSO
.LP
\fIcsin\fP(), the Base Definitions volume of IEEE\ Std\ 1003.1-2001,
\fI<complex.h>\fP
.SH COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. In the
event of any discrepancy between this version and the original IEEE and
The Open Group Standard, the original IEEE and The Open Group Standard
is the referee document. The original Standard can be obtained online at
http://www.opengroup.org/unix/online.html .

120
lib/libm/complex/casin.c Normal file
View File

@@ -0,0 +1,120 @@
/* $NetBSD: casin.c,v 1.1 2007/08/20 16:01:31 drochner 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(casin, _casin)
#endif
double complex
casin(double complex z)
{
double complex w;
double complex ca, ct, zz, z2;
double x, y;
x = creal(z);
y = cimag(z);
#if 0 /* MD: test is incorrect, casin(>1) is defined */
if (y == 0.0) {
if (fabs(x) > 1.0) {
w = M_PI_2 + 0.0 * I;
#if 0
mtherr ("casin", DOMAIN);
#endif
} else {
w = asin(x) + 0.0 * I;
}
return w;
}
#endif
/* Power series expansion */
/*
b = cabs(z);
if( b < 0.125 )
{
z2.r = (x - y) * (x + y);
z2.i = 2.0 * x * y;
cn = 1.0;
n = 1.0;
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 = fabs(ct.r) + fabs(ct.i);
}
while( b > MACHEP );
w->r = sum.r;
w->i = sum.i;
return;
}
*/
ca = x + y * I;
ct = ca * I;
/* sqrt( 1 - z*z) */
/* cmul( &ca, &ca, &zz ) */
/*x * x - y * y */
zz = (x - y) * (x + y) + (2.0 * x * y) * I;
zz = 1.0 - creal(zz) - cimag(zz) * I;
z2 = csqrt(zz);
zz = ct + z2;
zz = clog(zz);
/* multiply by 1/i = -i */
w = zz * (-1.0 * I);
return w;
}

120
lib/libm/complex/casinf.c Normal file
View File

@@ -0,0 +1,120 @@
/* $NetBSD: casinf.c,v 1.1 2007/08/20 16:01:31 drochner 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(casinf, _casinf)
#endif
float complex
casinf(float complex z)
{
float complex w;
float complex ca, ct, zz, z2;
float x, y;
x = crealf(z);
y = cimagf(z);
#if 0 /* MD: test is incorrect, casin(>1) is defined */
if (y == 0.0f) {
if (fabsf(x) > 1.0) {
w = M_PI_2 + 0.0f * I;
#if 0
mtherr ("casin", DOMAIN);
#endif
} else {
w = asinf(x) + 0.0f * I;
}
return w;
}
#endif
/* Power series expansion */
/*
b = cabsf(z);
if( b < 0.125 )
{
z2.r = (x - y) * (x + y);
z2.i = 2.0 * x * y;
cn = 1.0;
n = 1.0;
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 = fabsf(ct.r) + fabsf(ct.i);
}
while( b > MACHEP );
w->r = sum.r;
w->i = sum.i;
return;
}
*/
ca = x + y * I;
ct = ca * I;
/* sqrt( 1 - z*z) */
/* cmul( &ca, &ca, &zz ) */
/*x * x - y * y */
zz = (x - y) * (x + y) + (2.0f * x * y) * I;
zz = 1.0f - crealf(zz) - cimagf(zz) * I;
z2 = csqrtf(zz);
zz = ct + z2;
zz = clogf(zz);
/* multiply by 1/i = -i */
w = zz * (-1.0f * I);
return w;
}

58
lib/libm/complex/casinh.3 Normal file
View File

@@ -0,0 +1,58 @@
.\" $NetBSD: casinh.3,v 1.1 2008/02/20 09:55:38 drochner Exp $
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
.TH "CASINH" 3P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
.\" casinh
.SH NAME
casinh, casinhf \- complex arc hyperbolic sine functions
.SH SYNOPSIS
.LP
\fB#include <complex.h>
.br
.sp
double complex casinh(double complex\fP \fIz\fP\fB);
.br
float complex casinhf(float complex\fP \fIz\fP\fB);
.br
\fP
.SH DESCRIPTION
.LP
These functions compute the complex arc hyperbolic sine of \fIz\fP,
with branch cuts outside the interval
[-\fIi\fP,\ +\fIi\fP] along the imaginary axis.
.SH RETURN VALUE
.LP
These functions return the complex arc hyperbolic sine value,
in the range of a strip mathematically unbounded along the
real axis and in the interval [-\fIi\fPpi/2,\ +\fIi\fPpi/2] along
the imaginary axis.
.SH ERRORS
.LP
No errors are defined.
.LP
\fIThe following sections are informative.\fP
.SH EXAMPLES
.LP
None.
.SH APPLICATION USAGE
.LP
None.
.SH RATIONALE
.LP
None.
.SH FUTURE DIRECTIONS
.LP
None.
.SH SEE ALSO
.LP
\fIcsinh\fP(), the Base Definitions volume of IEEE\ Std\ 1003.1-2001,
\fI<complex.h>\fP
.SH COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. In the
event of any discrepancy between this version and the original IEEE and
The Open Group Standard, the original IEEE and The Open Group Standard
is the referee document. The original Standard can be obtained online at
http://www.opengroup.org/unix/online.html .

42
lib/libm/complex/casinh.c Normal file
View File

@@ -0,0 +1,42 @@
/* $NetBSD: casinh.c,v 1.1 2007/08/20 16:01:31 drochner 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>
double complex
casinh(double complex z)
{
double complex w;
w = -1.0 * I * casin(z * I);
return w;
}

View File

@@ -0,0 +1,42 @@
/* $NetBSD: casinhf.c,v 1.1 2007/08/20 16:01:32 drochner 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>
float complex
casinhf(float complex z)
{
float complex w;
w = -1.0f * I * casinf(z * I);
return w;
}

58
lib/libm/complex/catan.3 Normal file
View File

@@ -0,0 +1,58 @@
.\" $NetBSD: catan.3,v 1.1 2008/02/20 09:55:38 drochner Exp $
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
.TH "CATAN" 3P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
.\" catan
.SH NAME
catan, catanf \- complex arc tangent functions
.SH SYNOPSIS
.LP
\fB#include <complex.h>
.br
.sp
double complex catan(double complex\fP \fIz\fP\fB);
.br
float complex catanf(float complex\fP \fIz\fP\fB);
.br
\fP
.SH DESCRIPTION
.LP
These functions compute the complex arc tangent of \fIz\fP,
with branch cuts outside the interval
[-\fIi\fP,\ +\fIi\fP] along the imaginary axis.
.SH RETURN VALUE
.LP
These functions return the complex arc tangent value, in the
range of a strip mathematically unbounded along the imaginary
axis and in the interval [-pi/2,\ +pi/2] along the
real axis.
.SH ERRORS
.LP
No errors are defined.
.LP
\fIThe following sections are informative.\fP
.SH EXAMPLES
.LP
None.
.SH APPLICATION USAGE
.LP
None.
.SH RATIONALE
.LP
None.
.SH FUTURE DIRECTIONS
.LP
None.
.SH SEE ALSO
.LP
\fIctan\fP(), the Base Definitions volume of IEEE\ Std\ 1003.1-2001,
\fI<complex.h>\fP
.SH COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. In the
event of any discrepancy between this version and the original IEEE and
The Open Group Standard, the original IEEE and The Open Group Standard
is the referee document. The original Standard can be obtained online at
http://www.opengroup.org/unix/online.html .

79
lib/libm/complex/catan.c Normal file
View File

@@ -0,0 +1,79 @@
/* $NetBSD: catan.c,v 1.1 2007/08/20 16:01:32 drochner 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_subr.h"
#ifdef __weak_alias
__weak_alias(catan, _catan)
#endif
#define MAXNUM 1.0e308
double complex
catan(double complex z)
{
double complex w;
double a, t, x, x2, y;
x = creal(z);
y = cimag(z);
if ((x == 0.0) && (y > 1.0))
goto ovrf;
x2 = x * x;
a = 1.0 - x2 - (y * y);
if (a == 0.0)
goto ovrf;
t = 0.5 * atan2(2.0 * x, a);
w = _redupi(t);
t = y - 1.0;
a = x2 + (t * t);
if (a == 0.0)
goto ovrf;
t = y + 1.0;
a = (x2 + (t * t))/a;
w = w + (0.25 * log(a)) * I;
return w;
ovrf:
#if 0
mtherr ("catan", OVERFLOW);
#endif
w = MAXNUM + MAXNUM * I;
return w;
}

79
lib/libm/complex/catanf.c Normal file
View File

@@ -0,0 +1,79 @@
/* $NetBSD: catanf.c,v 1.1 2007/08/20 16:01:32 drochner 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_subrf.h"
#ifdef __weak_alias
__weak_alias(catanf, _catanf)
#endif
#define MAXNUMF 1.0e38F
float complex
catanf(float complex z)
{
float complex w;
float a, t, x, x2, y;
x = crealf(z);
y = cimagf(z);
if ((x == 0.0f) && (y > 1.0f))
goto ovrf;
x2 = x * x;
a = 1.0f - x2 - (y * y);
if (a == 0.0f)
goto ovrf;
t = 0.5f * atan2f(2.0f * x, a);
w = _redupif(t);
t = y - 1.0f;
a = x2 + (t * t);
if (a == 0.0f)
goto ovrf;
t = y + 1.0f;
a = (x2 + (t * t))/a;
w = w + (0.25f * logf(a)) * I;
return w;
ovrf:
#if 0
mtherr ("catan", OVERFLOW);
#endif
w = MAXNUMF + MAXNUMF * I;
return w;
}

58
lib/libm/complex/catanh.3 Normal file
View File

@@ -0,0 +1,58 @@
.\" $NetBSD: catanh.3,v 1.1 2008/02/20 09:55:38 drochner Exp $
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
.TH "CATANH" 3P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
.\" catanh
.SH NAME
catanh, catanhf \- complex arc hyperbolic tangent functions
.SH SYNOPSIS
.LP
\fB#include <complex.h>
.br
.sp
double complex catanh(double complex\fP \fIz\fP\fB);
.br
float complex catanhf(float complex\fP \fIz\fP\fB);
.br
\fP
.SH DESCRIPTION
.LP
These functions compute the complex arc hyperbolic tangent of
\fIz\fP, with branch cuts outside the interval
[-1,\ +1] along the real axis.
.SH RETURN VALUE
.LP
These functions return the complex arc hyperbolic tangent value,
in the range of a strip mathematically unbounded along
the real axis and in the interval [-\fIi\fPpi/2,\ +\fIi\fPpi/2] along
the imaginary axis.
.SH ERRORS
.LP
No errors are defined.
.LP
\fIThe following sections are informative.\fP
.SH EXAMPLES
.LP
None.
.SH APPLICATION USAGE
.LP
None.
.SH RATIONALE
.LP
None.
.SH FUTURE DIRECTIONS
.LP
None.
.SH SEE ALSO
.LP
\fIctanh\fP(), the Base Definitions volume of IEEE\ Std\ 1003.1-2001,
\fI<complex.h>\fP
.SH COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. In the
event of any discrepancy between this version and the original IEEE and
The Open Group Standard, the original IEEE and The Open Group Standard
is the referee document. The original Standard can be obtained online at
http://www.opengroup.org/unix/online.html .

42
lib/libm/complex/catanh.c Normal file
View File

@@ -0,0 +1,42 @@
/* $NetBSD: catanh.c,v 1.1 2007/08/20 16:01:32 drochner 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>
double complex
catanh(double complex z)
{
double complex w;
w = -1.0 * I * catan(z * I);
return w;
}

View File

@@ -0,0 +1,42 @@
/* $NetBSD: catanhf.c,v 1.1 2007/08/20 16:01:32 drochner 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>
float complex
catanhf(float complex z)
{
float complex w;
w = -1.0f * I * catanf(z * I);
return w;
}

53
lib/libm/complex/ccos.3 Normal file
View File

@@ -0,0 +1,53 @@
.\" $NetBSD: ccos.3,v 1.1 2008/02/20 09:55:38 drochner Exp $
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
.TH "CCOS" 3P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
.\" ccos
.SH NAME
ccos, ccosf \- complex cosine functions
.SH SYNOPSIS
.LP
\fB#include <complex.h>
.br
.sp
double complex ccos(double complex\fP \fIz\fP\fB);
.br
float complex ccosf(float complex\fP \fIz\fP\fB);
.br
\fP
.SH DESCRIPTION
.LP
These functions compute the complex cosine of \fIz\fP.
.SH RETURN VALUE
.LP
These functions return the complex cosine value.
.SH ERRORS
.LP
No errors are defined.
.LP
\fIThe following sections are informative.\fP
.SH EXAMPLES
.LP
None.
.SH APPLICATION USAGE
.LP
None.
.SH RATIONALE
.LP
None.
.SH FUTURE DIRECTIONS
.LP
None.
.SH SEE ALSO
.LP
\fIcacos\fP(), the Base Definitions volume of IEEE\ Std\ 1003.1-2001,
\fI<complex.h>\fP
.SH COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. In the
event of any discrepancy between this version and the original IEEE and
The Open Group Standard, the original IEEE and The Open Group Standard
is the referee document. The original Standard can be obtained online at
http://www.opengroup.org/unix/online.html .

46
lib/libm/complex/ccos.c Normal file
View File

@@ -0,0 +1,46 @@
/* $NetBSD: ccos.c,v 1.1 2007/08/20 16:01:32 drochner 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_subr.h"
double complex
ccos(double complex z)
{
double complex w;
double ch, sh;
_cchsh(cimag(z), &ch, &sh);
w = cos(creal(z)) * ch - (sin(creal(z)) * sh) * I;
return w;
}

46
lib/libm/complex/ccosf.c Normal file
View File

@@ -0,0 +1,46 @@
/* $NetBSD: ccosf.c,v 1.1 2007/08/20 16:01:33 drochner 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_subrf.h"
float complex
ccosf(float complex z)
{
float complex w;
float ch, sh;
_cchshf(cimagf(z), &ch, &sh);
w = cosf(crealf(z)) * ch - (sinf(crealf(z)) * sh) * I;
return w;
}

53
lib/libm/complex/ccosh.3 Normal file
View File

@@ -0,0 +1,53 @@
.\" $NetBSD: ccosh.3,v 1.1 2008/02/20 09:55:38 drochner Exp $
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
.TH "CCOSH" 3P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
.\" ccosh
.SH NAME
ccosh, ccoshf \- complex hyperbolic cosine functions
.SH SYNOPSIS
.LP
\fB#include <complex.h>
.br
.sp
double complex ccosh(double complex\fP \fIz\fP\fB);
.br
float complex ccoshf(float complex\fP \fIz\fP\fB);
.br
\fP
.SH DESCRIPTION
.LP
These functions compute the complex hyperbolic cosine of \fIz\fP.
.SH RETURN VALUE
.LP
These functions return the complex hyperbolic cosine value.
.SH ERRORS
.LP
No errors are defined.
.LP
\fIThe following sections are informative.\fP
.SH EXAMPLES
.LP
None.
.SH APPLICATION USAGE
.LP
None.
.SH RATIONALE
.LP
None.
.SH FUTURE DIRECTIONS
.LP
None.
.SH SEE ALSO
.LP
\fIcacosh\fP(), the Base Definitions volume of IEEE\ Std\ 1003.1-2001,
\fI<complex.h>\fP
.SH COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. In the
event of any discrepancy between this version and the original IEEE and
The Open Group Standard, the original IEEE and The Open Group Standard
is the referee document. The original Standard can be obtained online at
http://www.opengroup.org/unix/online.html .

46
lib/libm/complex/ccosh.c Normal file
View File

@@ -0,0 +1,46 @@
/* $NetBSD: ccosh.c,v 1.1 2007/08/20 16:01:33 drochner 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>
double complex
ccosh(double complex z)
{
double complex w;
double x, y;
x = creal(z);
y = cimag(z);
w = cosh(x) * cos(y) + (sinh(x) * sin(y)) * I;
return w;
}

46
lib/libm/complex/ccoshf.c Normal file
View File

@@ -0,0 +1,46 @@
/* $NetBSD: ccoshf.c,v 1.1 2007/08/20 16:01:33 drochner 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>
float complex
ccoshf(float complex z)
{
float complex w;
float x, y;
x = crealf(z);
y = cimagf(z);
w = coshf(x) * cosf(y) + (sinhf(x) * sinf(y)) * I;
return w;
}

View File

@@ -0,0 +1,124 @@
/* $NetBSD: cephes_subr.c,v 1.1 2007/08/20 16:01:33 drochner 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_subr.h"
/* calculate cosh and sinh */
void
_cchsh(double x, double *c, double *s)
{
double e, ei;
if (fabs(x) <= 0.5) {
*c = cosh(x);
*s = sinh(x);
} else {
e = exp(x);
ei = 0.5 / e;
e = 0.5 * e;
*s = e - ei;
*c = e + ei;
}
}
/* Program to subtract nearest integer multiple of PI */
/* extended precision value of PI: */
static const double DP1 = 3.14159265160560607910E0;
static const double DP2 = 1.98418714791870343106E-9;
static const double DP3 = 1.14423774522196636802E-17;
#define MACHEP 1.1e-16
double
_redupi(double x)
{
double t;
long i;
t = x / M_PI;
if (t >= 0.0)
t += 0.5;
else
t -= 0.5;
i = t; /* the multiple */
t = i;
t = ((x - t * DP1) - t * DP2) - t * DP3;
return t;
}
/* Taylor series expansion for cosh(2y) - cos(2x) */
double
_ctans(double complex z)
{
double f, x, x2, y, y2, rn, t;
double d;
x = fabs(2.0 * creal(z));
y = fabs(2.0 * cimag(z));
x = _redupi(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.0;
f *= rn;
rn += 1.0;
f *= rn;
x2 *= x;
y2 *= y;
t = y2 + x2;
t /= f;
d += t;
rn += 1.0;
f *= rn;
rn += 1.0;
f *= rn;
x2 *= x;
y2 *= y;
t = y2 - x2;
t /= f;
d += t;
} while (fabs(t/d) > MACHEP);
return d;
}

View File

@@ -0,0 +1,5 @@
/* $NetBSD: cephes_subr.h,v 1.1 2007/08/20 16:01:33 drochner Exp $ */
void _cchsh(double, double *, double *);
double _redupi(double);
double _ctans(double complex);

View File

@@ -0,0 +1,123 @@
/* $NetBSD: cephes_subrf.c,v 1.1 2007/08/20 16:01:34 drochner 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_subrf.h"
/* calculate cosh and sinh */
void
_cchshf(float x, float *c, float *s)
{
float e, ei;
if (fabsf(x) <= 0.5f) {
*c = coshf(x);
*s = sinhf(x);
} else {
e = expf(x);
ei = 0.5f / e;
e = 0.5f * e;
*s = e - ei;
*c = e + ei;
}
}
/* Program to subtract nearest integer multiple of PI */
/* extended precision value of PI: */
static const double DP1 = 3.140625;
static const double DP2 = 9.67502593994140625E-4;
static const double DP3 = 1.509957990978376432E-7;
#define MACHEPF 3.0e-8
float
_redupif(float x)
{
float t;
long i;
t = x / (float)M_PI;
if (t >= 0.0f)
t += 0.5f;
else
t -= 0.5f;
i = t; /* the multiple */
t = i;
t = ((x - t * DP1) - t * DP2) - t * DP3;
return t;
}
/* Taylor series expansion for cosh(2y) - cos(2x) */
float
_ctansf(float complex z)
{
float f, x, x2, y, y2, rn, t, d;
x = fabsf(2.0f * crealf(z));
y = fabsf(2.0f * cimagf(z));
x = _redupif(x);
x = x * x;
y = y * y;
x2 = 1.0f;
y2 = 1.0f;
f = 1.0f;
rn = 0.0f;
d = 0.0f;
do {
rn += 1.0f;
f *= rn;
rn += 1.0f;
f *= rn;
x2 *= x;
y2 *= y;
t = y2 + x2;
t /= f;
d += t;
rn += 1.0f;
f *= rn;
rn += 1.0f;
f *= rn;
x2 *= x;
y2 *= y;
t = y2 - x2;
t /= f;
d += t;
} while (fabsf(t/d) > MACHEPF);
return d;
}

View File

@@ -0,0 +1,5 @@
/* $NetBSD: cephes_subrf.h,v 1.1 2007/08/20 16:01:34 drochner Exp $ */
void _cchshf(float, float *, float *);
float _redupif(float);
float _ctansf(float complex);

54
lib/libm/complex/cexp.3 Normal file
View File

@@ -0,0 +1,54 @@
.\" $NetBSD: cexp.3,v 1.1 2008/02/20 09:55:38 drochner Exp $
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
.TH "CEXP" 3P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
.\" cexp
.SH NAME
cexp, cexpf \- complex exponential functions
.SH SYNOPSIS
.LP
\fB#include <complex.h>
.br
.sp
double complex cexp(double complex\fP \fIz\fP\fB);
.br
float complex cexpf(float complex\fP \fIz\fP\fB);
.br
\fP
.SH DESCRIPTION
.LP
These functions compute the complex exponent of \fIz\fP, defined
as \fIe**z\fP.
.SH RETURN VALUE
.LP
These functions return the complex exponential value of \fIz\fP.
.SH ERRORS
.LP
No errors are defined.
.LP
\fIThe following sections are informative.\fP
.SH EXAMPLES
.LP
None.
.SH APPLICATION USAGE
.LP
None.
.SH RATIONALE
.LP
None.
.SH FUTURE DIRECTIONS
.LP
None.
.SH SEE ALSO
.LP
\fIclog\fP(), the Base Definitions volume of IEEE\ Std\ 1003.1-2001,
\fI<complex.h>\fP
.SH COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. In the
event of any discrepancy between this version and the original IEEE and
The Open Group Standard, the original IEEE and The Open Group Standard
is the referee document. The original Standard can be obtained online at
http://www.opengroup.org/unix/online.html .

47
lib/libm/complex/cexp.c Normal file
View File

@@ -0,0 +1,47 @@
/* $NetBSD: cexp.c,v 1.1 2007/08/20 16:01:34 drochner 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>
double complex
cexp(double complex z)
{
double complex w;
double r, x, y;
x = creal(z);
y = cimag(z);
r = exp(x);
w = r * cos(y) + r * sin(y) * I;
return w;
}

47
lib/libm/complex/cexpf.c Normal file
View File

@@ -0,0 +1,47 @@
/* $NetBSD: cexpf.c,v 1.1 2007/08/20 16:01:34 drochner 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>
float complex
cexpf(float complex z)
{
float complex w;
float r, x, y;
x = crealf(z);
y = cimagf(z);
r = expf(x);
w = r * cosf(y) + r * sinf(y) * I;
return w;
}

63
lib/libm/complex/cimag.3 Normal file
View File

@@ -0,0 +1,63 @@
.\" $NetBSD: cimag.3,v 1.3 2010/09/15 18:40:27 wiz Exp $
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
.TH "CIMAG" 3P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
.\" cimag
.SH NAME
cimag, cimagf \- complex imaginary functions
.SH SYNOPSIS
.LP
\fB#include <complex.h>
.br
.sp
double cimag(double complex\fP \fIz\fP\fB);
.br
float cimagf(float complex\fP \fIz\fP\fB);
.br
long double cimagl(long double complex\fP \fIz\fP\fB);
.br
\fP
.SH DESCRIPTION
.LP
These functions compute the imaginary part of \fIz\fP.
.SH RETURN VALUE
.LP
These functions return the imaginary part value (as a real).
.SH ERRORS
.LP
No errors are defined.
.LP
\fIThe following sections are informative.\fP
.SH EXAMPLES
.LP
None.
.SH APPLICATION USAGE
.LP
For a variable \fIz\fP of complex type:
.sp
.RS
.nf
\fBz == creal(z) + cimag(z)*I
\fP
.fi
.RE
.SH RATIONALE
.LP
None.
.SH FUTURE DIRECTIONS
.LP
None.
.SH SEE ALSO
.LP
\fIcarg\fP(), \fIconj\fP(), \fIcproj\fP(), \fIcreal\fP(), the
Base Definitions volume of IEEE\ Std\ 1003.1-2001, \fI<complex.h>\fP
.SH COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. In the
event of any discrepancy between this version and the original IEEE and
The Open Group Standard, the original IEEE and The Open Group Standard
is the referee document. The original Standard can be obtained online at
http://www.opengroup.org/unix/online.html .

17
lib/libm/complex/cimag.c Normal file
View File

@@ -0,0 +1,17 @@
/* $NetBSD: cimag.c,v 1.2 2010/09/15 16:11:29 christos Exp $ */
/*
* Written by Matthias Drochner <drochner@NetBSD.org>.
* Public domain.
*/
#include <complex.h>
#include "../src/math_private.h"
double
cimag(double complex z)
{
double_complex w = { .z = z };
return (IMAG_PART(w));
}

17
lib/libm/complex/cimagf.c Normal file
View File

@@ -0,0 +1,17 @@
/* $NetBSD: cimagf.c,v 1.2 2010/09/15 16:11:29 christos Exp $ */
/*
* Written by Matthias Drochner <drochner@NetBSD.org>.
* Public domain.
*/
#include <complex.h>
#include "../src/math_private.h"
float
cimagf(float complex z)
{
float_complex w = { .z = z };
return (IMAG_PART(w));
}

44
lib/libm/complex/cimagl.c Normal file
View File

@@ -0,0 +1,44 @@
/* $NetBSD: cimagl.c,v 1.3 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: cimagl.c,v 1.3 2010/09/20 16:55:20 christos Exp $");
#include <complex.h>
#include "../src/math_private.h"
/*
* cimagl(long double complex z)
* This function returns the imaginary part value (as a real) of z.
*/
long double
cimagl(long double complex z)
{
long_double_complex w = { .z = z };
return (IMAG_PART(w));
}

58
lib/libm/complex/clog.3 Normal file
View File

@@ -0,0 +1,58 @@
.\" $NetBSD: clog.3,v 1.1 2008/02/20 09:55:38 drochner Exp $
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
.TH "CLOG" 3P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
.\" clog
.SH NAME
clog, clogf \- complex natural logarithm functions
.SH SYNOPSIS
.LP
\fB#include <complex.h>
.br
.sp
double complex clog(double complex\fP \fIz\fP\fB);
.br
float complex clogf(float complex\fP \fIz\fP\fB);
.br
\fP
.SH DESCRIPTION
.LP
These functions compute the complex natural (base \fIe\fP) logarithm
of \fIz\fP, with a branch cut along the negative
real axis.
.SH RETURN VALUE
.LP
These functions return the complex natural logarithm value,
in the range of a strip mathematically unbounded along the
real axis and in the interval [-\fIi\fPpi,\ +\fIi\fPpi] along the
imaginary axis.
.SH ERRORS
.LP
No errors are defined.
.LP
\fIThe following sections are informative.\fP
.SH EXAMPLES
.LP
None.
.SH APPLICATION USAGE
.LP
None.
.SH RATIONALE
.LP
None.
.SH FUTURE DIRECTIONS
.LP
None.
.SH SEE ALSO
.LP
\fIcexp\fP(), the Base Definitions volume of IEEE\ Std\ 1003.1-2001,
\fI<complex.h>\fP
.SH COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. In the
event of any discrepancy between this version and the original IEEE and
The Open Group Standard, the original IEEE and The Open Group Standard
is the referee document. The original Standard can be obtained online at
http://www.opengroup.org/unix/online.html .

47
lib/libm/complex/clog.c Normal file
View File

@@ -0,0 +1,47 @@
/* $NetBSD: clog.c,v 1.1 2007/08/20 16:01:35 drochner 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>
double complex
clog(double complex z)
{
double complex w;
double p, rr;
rr = cabs(z);
p = log(rr);
rr = atan2(cimag(z), creal(z));
w = p + rr * I;
return w;
}

47
lib/libm/complex/clogf.c Normal file
View File

@@ -0,0 +1,47 @@
/* $NetBSD: clogf.c,v 1.1 2007/08/20 16:01:35 drochner 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>
float complex
clogf(float complex z)
{
float complex w;
float p, rr;
rr = cabsf(z);
p = logf(rr);
rr = atan2f(cimagf(z), crealf(z));
w = p + rr * I;
return w;
}

56
lib/libm/complex/conj.3 Normal file
View File

@@ -0,0 +1,56 @@
.\" $NetBSD: conj.3,v 1.3 2010/09/15 18:40:27 wiz Exp $
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
.TH "CONJ" 3P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
.\" conj
.SH NAME
conj, conjf \- complex conjugate functions
.SH SYNOPSIS
.LP
\fB#include <complex.h>
.br
.sp
double complex conj(double complex\fP \fIz\fP\fB);
.br
float complex conjf(float complex\fP \fIz\fP\fB);
.br
long double complex conjl(long double complex\fP \fIz\fP\fB, long double complex\fP \fIz\fP\fB);
.br
\fP
.SH DESCRIPTION
.LP
These functions compute the complex conjugate of \fIz\fP, by
reversing the sign of its imaginary part.
.SH RETURN VALUE
.LP
These functions return the complex conjugate value.
.SH ERRORS
.LP
No errors are defined.
.LP
\fIThe following sections are informative.\fP
.SH EXAMPLES
.LP
None.
.SH APPLICATION USAGE
.LP
None.
.SH RATIONALE
.LP
None.
.SH FUTURE DIRECTIONS
.LP
None.
.SH SEE ALSO
.LP
\fIcarg\fP(), \fIcimag\fP(), \fIcproj\fP(), \fIcreal\fP(), the
Base Definitions volume of IEEE\ Std\ 1003.1-2001, \fI<complex.h>\fP
.SH COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. In the
event of any discrepancy between this version and the original IEEE and
The Open Group Standard, the original IEEE and The Open Group Standard
is the referee document. The original Standard can be obtained online at
http://www.opengroup.org/unix/online.html .

19
lib/libm/complex/conj.c Normal file
View File

@@ -0,0 +1,19 @@
/* $NetBSD: conj.c,v 1.2 2010/09/15 16:11:29 christos Exp $ */
/*
* Written by Matthias Drochner <drochner@NetBSD.org>.
* Public domain.
*/
#include <complex.h>
#include "../src/math_private.h"
double complex
conj(double complex z)
{
double_complex w = { .z = z };
IMAG_PART(w) = -IMAG_PART(w);
return (w.z);
}

19
lib/libm/complex/conjf.c Normal file
View File

@@ -0,0 +1,19 @@
/* $NetBSD: conjf.c,v 1.2 2010/09/15 16:11:29 christos Exp $ */
/*
* Written by Matthias Drochner <drochner@NetBSD.org>.
* Public domain.
*/
#include <complex.h>
#include "../src/math_private.h"
float complex
conjf(float complex z)
{
float_complex w = { .z = z };
IMAG_PART(w) = -IMAG_PART(w);
return (w.z);
}

48
lib/libm/complex/conjl.c Normal file
View File

@@ -0,0 +1,48 @@
/* $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 <math.h>
#include "../src/math_private.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);
}

57
lib/libm/complex/cpow.3 Normal file
View File

@@ -0,0 +1,57 @@
.\" $NetBSD: cpow.3,v 1.1 2008/02/20 09:55:38 drochner Exp $
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
.TH "CPOW" 3P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
.\" cpow
.SH NAME
cpow, cpowf \- complex power functions
.SH SYNOPSIS
.LP
\fB#include <complex.h>
.br
.sp
double complex cpow(double complex\fP \fIx\fP\fB, double complex\fP
\fIy\fP\fB);
.br
float complex cpowf(float complex\fP \fIx\fP\fB, float complex\fP
\fIy\fP\fB);
.br
\fP
.SH DESCRIPTION
.LP
These functions compute the complex power function \fIx**y\fP,
with a branch cut for the first
parameter along the negative real axis.
.SH RETURN VALUE
.LP
These functions return the complex power function value.
.SH ERRORS
.LP
No errors are defined.
.LP
\fIThe following sections are informative.\fP
.SH EXAMPLES
.LP
None.
.SH APPLICATION USAGE
.LP
None.
.SH RATIONALE
.LP
None.
.SH FUTURE DIRECTIONS
.LP
None.
.SH SEE ALSO
.LP
\fIcabs\fP(), \fIcsqrt\fP(), the Base Definitions volume of
IEEE\ Std\ 1003.1-2001, \fI<complex.h>\fP
.SH COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. In the
event of any discrepancy between this version and the original IEEE and
The Open Group Standard, the original IEEE and The Open Group Standard
is the referee document. The original Standard can be obtained online at
http://www.opengroup.org/unix/online.html .

57
lib/libm/complex/cpow.c Normal file
View File

@@ -0,0 +1,57 @@
/* $NetBSD: cpow.c,v 1.1 2007/08/20 16:01:35 drochner 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>
double complex
cpow(double complex a, double complex z)
{
double complex w;
double x, y, r, theta, absa, arga;
x = creal(z);
y = cimag(z);
absa = cabs(a);
if (absa == 0.0) {
return (0.0 + 0.0 * I);
}
arga = carg(a);
r = pow(absa, x);
theta = x * arga;
if (y != 0.0) {
r = r * exp(-y * arga);
theta = theta + y * log(absa);
}
w = r * cos(theta) + (r * sin(theta)) * I;
return w;
}

57
lib/libm/complex/cpowf.c Normal file
View File

@@ -0,0 +1,57 @@
/* $NetBSD: cpowf.c,v 1.1 2007/08/20 16:01:36 drochner 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>
float complex
cpowf(float complex a, float complex z)
{
float complex w;
float x, y, r, theta, absa, arga;
x = crealf(z);
y = cimagf(z);
absa = cabsf(a);
if (absa == 0.0f) {
return (0.0f + 0.0f * I);
}
arga = cargf(a);
r = powf(absa, x);
theta = x * arga;
if (y != 0.0f) {
r = r * expf(-y * arga);
theta = theta + y * logf(absa);
}
w = r * cosf(theta) + (r * sinf(theta)) * I;
return w;
}

59
lib/libm/complex/cproj.3 Normal file
View File

@@ -0,0 +1,59 @@
.\" $NetBSD: cproj.3,v 1.2 2010/09/15 18:40:27 wiz Exp $
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
.TH "CPROJ" 3P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
.\" cproj
.SH NAME
cproj, cprojf, cprojl \- complex projection functions
.SH SYNOPSIS
.LP
\fB#include <complex.h>
.br
.sp
double cproj(double complex\fP \fIz\fP\fB);
.br
float cprojf(float complex\fP \fIz\fP\fB);
.br
long double cprojl(long double complex\fP \fIz\fP\fB);
.br
\fP
.SH DESCRIPTION
.LP
These functions compute a projection of \fIz\fP ono the Riemann sphere:
\fIz\fP projects to \fIz\fP , except that all complex infinities (even those
with one infinite part and one NaN part) project to positive infinity on the
real axis. If \fIz\fP has an infinite part, then cproj(z) shall be equivalent to:
INFINITY + I * copysign(0.0, cimag(z))
.SH RETURN VALUE
.LP
These functions return the value of the projection onto the Riemann sphere.
.SH ERRORS
.LP
No errors are defined.
.LP
\fIThe following sections are informative.\fP
.SH EXAMPLES
.LP
None.
.SH APPLICATION USAGE
.LP
None.
.SH RATIONALE
.LP
None.
.SH FUTURE DIRECTIONS
.LP
None.
.SH SEE ALSO
.LP
\fIcarg\fP(), \fIcimag\fP(), \fIconj\fP(), \fIcreal\fP() the
Base Definitions volume of IEEE\ Std\ 1003.1-2001, \fI<complex.h>\fP
.SH COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. In the
event of any discrepancy between this version and the original IEEE and
The Open Group Standard, the original IEEE and The Open Group Standard
is the referee document. The original Standard can be obtained online at
http://www.opengroup.org/unix/online.html .

63
lib/libm/complex/cproj.c Normal file
View File

@@ -0,0 +1,63 @@
/* $NetBSD: cproj.c,v 1.3 2010/09/20 17:51:38 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: cproj.c,v 1.3 2010/09/20 17:51:38 christos Exp $");
#include <complex.h>
#include <math.h>
#include "../src/math_private.h"
/*
* cproj(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))
*/
double complex
cproj(double complex z)
{
double_complex w = { .z = z };
if (isinf(creal(z) || isinf(cimag(z)))) {
#ifdef __INFINITY
REAL_PART(w) = __INFINITY;
#else
REAL_PART(w) = INFINITY;
#endif
IMAG_PART(w) = copysign(0.0, cimag(z));
}
return (w.z);
}

64
lib/libm/complex/cprojf.c Normal file
View File

@@ -0,0 +1,64 @@
/* $NetBSD: cprojf.c,v 1.3 2010/09/20 17:51:38 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: cprojf.c,v 1.3 2010/09/20 17:51:38 christos Exp $");
#include <complex.h>
#include <math.h>
#include "../src/math_private.h"
/*
* cprojf(float 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))
*/
float complex
cprojf(float complex z)
{
float_complex w = { .z = z };
if (isinf(crealf(z) || isinf(cimagf(z)))) {
#ifdef __INFINITY
REAL_PART(w) = __INFINITY;
#else
REAL_PART(w) = INFINITY;
#endif
IMAG_PART(w) = copysignf(0.0, cimagf(z));
}
return (w.z);
}

63
lib/libm/complex/cprojl.c Normal file
View File

@@ -0,0 +1,63 @@
/* $NetBSD: cprojl.c,v 1.4 2010/09/20 17:51:38 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.4 2010/09/20 17:51:38 christos Exp $");
#include <complex.h>
#include <math.h>
#include "../src/math_private.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 };
if (isinf(creall(z) || isinf(cimagl(z)))) {
#ifdef __INFINITY
REAL_PART(w) = __INFINITY;
#else
REAL_PART(w) = INFINITY;
#endif
IMAG_PART(w) = copysignl(0.0, cimagl(z));
}
return (w.z);
}

63
lib/libm/complex/creal.3 Normal file
View File

@@ -0,0 +1,63 @@
.\" $NetBSD: creal.3,v 1.3 2010/09/15 18:40:27 wiz Exp $
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
.TH "CREAL" 3P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
.\" creal
.SH NAME
creal, crealf \- complex real functions
.SH SYNOPSIS
.LP
\fB#include <complex.h>
.br
.sp
double creal(double complex\fP \fIz\fP\fB);
.br
float crealf(float complex\fP \fIz\fP\fB);
.br
long double creall(long double complex\fP \fIz\fP\fB);
.br
\fP
.SH DESCRIPTION
.LP
These functions compute the real part of \fIz\fP.
.SH RETURN VALUE
.LP
These functions return the real part value.
.SH ERRORS
.LP
No errors are defined.
.LP
\fIThe following sections are informative.\fP
.SH EXAMPLES
.LP
None.
.SH APPLICATION USAGE
.LP
For a variable \fIz\fP of type \fBcomplex\fP:
.sp
.RS
.nf
\fBz == creal(z) + cimag(z)*I
\fP
.fi
.RE
.SH RATIONALE
.LP
None.
.SH FUTURE DIRECTIONS
.LP
None.
.SH SEE ALSO
.LP
\fIcarg\fP(), \fIcimag\fP(), \fIconj\fP(), \fIcproj\fP(), the
Base Definitions volume of IEEE\ Std\ 1003.1-2001, \fI<complex.h>\fP
.SH COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. In the
event of any discrepancy between this version and the original IEEE and
The Open Group Standard, the original IEEE and The Open Group Standard
is the referee document. The original Standard can be obtained online at
http://www.opengroup.org/unix/online.html .

17
lib/libm/complex/creal.c Normal file
View File

@@ -0,0 +1,17 @@
/* $NetBSD: creal.c,v 1.2 2010/09/15 16:11:29 christos Exp $ */
/*
* Written by Matthias Drochner <drochner@NetBSD.org>.
* Public domain.
*/
#include <complex.h>
#include "../src/math_private.h"
double
creal(double complex z)
{
double_complex w = { .z = z };
return (REAL_PART(w));
}

17
lib/libm/complex/crealf.c Normal file
View File

@@ -0,0 +1,17 @@
/* $NetBSD: crealf.c,v 1.2 2010/09/15 16:11:29 christos Exp $ */
/*
* Written by Matthias Drochner <drochner@NetBSD.org>.
* Public domain.
*/
#include <complex.h>
#include "../src/math_private.h"
float
crealf(float complex z)
{
float_complex w = { .z = z };
return (REAL_PART(w));
}

44
lib/libm/complex/creall.c Normal file
View File

@@ -0,0 +1,44 @@
/* $NetBSD: creall.c,v 1.3 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: creall.c,v 1.3 2010/09/20 16:55:20 christos Exp $");
#include <complex.h>
#include "../src/math_private.h"
/*
* creall(long double complex z)
* This function returns the real part value of z.
*/
long double
creall(long double complex z)
{
long_double_complex w = { .z = z };
return (REAL_PART(w));
}

53
lib/libm/complex/csin.3 Normal file
View File

@@ -0,0 +1,53 @@
.\" $NetBSD: csin.3,v 1.1 2008/02/20 09:55:38 drochner Exp $
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
.TH "CSIN" 3P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
.\" csin
.SH NAME
csin, csinf \- complex sine functions
.SH SYNOPSIS
.LP
\fB#include <complex.h>
.br
.sp
double complex csin(double complex\fP \fIz\fP\fB);
.br
float complex csinf(float complex\fP \fIz\fP\fB);
.br
\fP
.SH DESCRIPTION
.LP
These functions compute the complex sine of \fIz\fP.
.SH RETURN VALUE
.LP
These functions return the complex sine value.
.SH ERRORS
.LP
No errors are defined.
.LP
\fIThe following sections are informative.\fP
.SH EXAMPLES
.LP
None.
.SH APPLICATION USAGE
.LP
None.
.SH RATIONALE
.LP
None.
.SH FUTURE DIRECTIONS
.LP
None.
.SH SEE ALSO
.LP
\fIcasin\fP(), the Base Definitions volume of IEEE\ Std\ 1003.1-2001,
\fI<complex.h>\fP
.SH COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. In the
event of any discrepancy between this version and the original IEEE and
The Open Group Standard, the original IEEE and The Open Group Standard
is the referee document. The original Standard can be obtained online at
http://www.opengroup.org/unix/online.html .

46
lib/libm/complex/csin.c Normal file
View File

@@ -0,0 +1,46 @@
/* $NetBSD: csin.c,v 1.1 2007/08/20 16:01:36 drochner 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_subr.h"
double complex
csin(double complex z)
{
double complex w;
double ch, sh;
_cchsh(cimag(z), &ch, &sh);
w = sin(creal(z)) * ch + (cos(creal(z)) * sh) * I;
return w;
}

46
lib/libm/complex/csinf.c Normal file
View File

@@ -0,0 +1,46 @@
/* $NetBSD: csinf.c,v 1.1 2007/08/20 16:01:36 drochner 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_subrf.h"
float complex
csinf(float complex z)
{
float complex w;
float ch, sh;
_cchshf(cimagf(z), &ch, &sh);
w = sinf(crealf(z)) * ch + (cosf(crealf(z)) * sh) * I;
return w;
}

53
lib/libm/complex/csinh.3 Normal file
View File

@@ -0,0 +1,53 @@
.\" $NetBSD: csinh.3,v 1.1 2008/02/20 09:55:38 drochner Exp $
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
.TH "CSINH" 3P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
.\" csinh
.SH NAME
csinh, csinhf \- complex hyperbolic sine functions
.SH SYNOPSIS
.LP
\fB#include <complex.h>
.br
.sp
double complex csinh(double complex\fP \fIz\fP\fB);
.br
float complex csinhf(float complex\fP \fIz\fP\fB);
.br
\fP
.SH DESCRIPTION
.LP
These functions compute the complex hyperbolic sine of \fIz\fP.
.SH RETURN VALUE
.LP
These functions return the complex hyperbolic sine value.
.SH ERRORS
.LP
No errors are defined.
.LP
\fIThe following sections are informative.\fP
.SH EXAMPLES
.LP
None.
.SH APPLICATION USAGE
.LP
None.
.SH RATIONALE
.LP
None.
.SH FUTURE DIRECTIONS
.LP
None.
.SH SEE ALSO
.LP
\fIcasinh\fP(), the Base Definitions volume of IEEE\ Std\ 1003.1-2001,
\fI<complex.h>\fP
.SH COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. In the
event of any discrepancy between this version and the original IEEE and
The Open Group Standard, the original IEEE and The Open Group Standard
is the referee document. The original Standard can be obtained online at
http://www.opengroup.org/unix/online.html .

46
lib/libm/complex/csinh.c Normal file
View File

@@ -0,0 +1,46 @@
/* $NetBSD: csinh.c,v 1.1 2007/08/20 16:01:36 drochner 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>
double complex
csinh(double complex z)
{
double complex w;
double x, y;
x = creal(z);
y = cimag(z);
w = sinh(x) * cos(y) + (cosh(x) * sin(y)) * I;
return w;
}

46
lib/libm/complex/csinhf.c Normal file
View File

@@ -0,0 +1,46 @@
/* $NetBSD: csinhf.c,v 1.1 2007/08/20 16:01:37 drochner 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>
float complex
csinhf(float complex z)
{
float complex w;
float x, y;
x = crealf(z);
y = cimagf(z);
w = sinhf(x) * cosf(y) + (coshf(x) * sinf(y)) * I;
return w;
}

56
lib/libm/complex/csqrt.3 Normal file
View File

@@ -0,0 +1,56 @@
.\" $NetBSD: csqrt.3,v 1.1 2008/02/20 09:55:38 drochner Exp $
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
.TH "CSQRT" 3P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
.\" csqrt
.SH NAME
csqrt, csqrtf \- complex square root functions
.SH SYNOPSIS
.LP
\fB#include <complex.h>
.br
.sp
double complex csqrt(double complex\fP \fIz\fP\fB);
.br
float complex csqrtf(float complex\fP \fIz\fP\fB);
.br
\fP
.SH DESCRIPTION
.LP
These functions compute the complex square root of \fIz\fP,
with a branch cut along the negative real axis.
.SH RETURN VALUE
.LP
These functions return the complex square root value, in the
range of the right half-plane (including the imaginary
axis).
.SH ERRORS
.LP
No errors are defined.
.LP
\fIThe following sections are informative.\fP
.SH EXAMPLES
.LP
None.
.SH APPLICATION USAGE
.LP
None.
.SH RATIONALE
.LP
None.
.SH FUTURE DIRECTIONS
.LP
None.
.SH SEE ALSO
.LP
\fIcabs\fP(), \fIcpow\fP(), the Base Definitions volume of
IEEE\ Std\ 1003.1-2001, \fI<complex.h>\fP
.SH COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. In the
event of any discrepancy between this version and the original IEEE and
The Open Group Standard, the original IEEE and The Open Group Standard
is the referee document. The original Standard can be obtained online at
http://www.opengroup.org/unix/online.html .

99
lib/libm/complex/csqrt.c Normal file
View File

@@ -0,0 +1,99 @@
/* $NetBSD: csqrt.c,v 1.1 2007/08/20 16:01:37 drochner 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>
double complex
csqrt(double complex z)
{
double complex w;
double x, y, r, t, scale;
x = creal (z);
y = cimag (z);
if (y == 0.0) {
if (x == 0.0) {
w = 0.0 + y * I;
} else {
r = fabs(x);
r = sqrt(r);
if (x < 0.0) {
w = 0.0 + r * I;
} else {
w = r + y * I;
}
}
return w;
}
if (x == 0.0) {
r = fabs(y);
r = sqrt(0.5 * r);
if (y > 0)
w = r + r * I;
else
w = r - r * I;
return w;
}
/* Rescale to avoid internal overflow or underflow. */
if ((fabs(x) > 4.0) || (fabs(y) > 4.0)) {
x *= 0.25;
y *= 0.25;
scale = 2.0;
} else {
#if 1
x *= 1.8014398509481984e16; /* 2^54 */
y *= 1.8014398509481984e16;
scale = 7.450580596923828125e-9; /* 2^-27 */
#else
x *= 4.0;
y *= 4.0;
scale = 0.5;
#endif
}
w = x + y * I;
r = cabs(w);
if (x > 0) {
t = sqrt(0.5 * r + 0.5 * x);
r = scale * fabs((0.5 * y) / t );
t *= scale;
} else {
r = sqrt(0.5 * r - 0.5 * x);
t = scale * fabs((0.5 * y) / r);
r *= scale;
}
if (y < 0)
w = t - r * I;
else
w = t + r * I;
return w;
}

99
lib/libm/complex/csqrtf.c Normal file
View File

@@ -0,0 +1,99 @@
/* $NetBSD: csqrtf.c,v 1.1 2007/08/20 16:01:37 drochner 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>
float complex
csqrtf(float complex z)
{
float complex w;
float x, y, r, t, scale;
x = crealf (z);
y = cimagf (z);
if (y == 0.0f) {
if (x < 0.0f) {
w = 0.0f + sqrtf(-x) * I;
return w;
} else if (x == 0.0f) {
return (0.0f + y * I);
} else {
w = sqrtf(x) + y * I;
return w;
}
}
if (x == 0.0f) {
r = fabsf(y);
r = sqrtf(0.5f * r);
if (y > 0)
w = r + r * I;
else
w = r - r * I;
return w;
}
/* Rescale to avoid internal overflow or underflow. */
if ((fabsf(x) > 4.0f) || (fabsf(y) > 4.0f)) {
x *= 0.25f;
y *= 0.25f;
scale = 2.0f;
} else {
#if 1
x *= 6.7108864e7f; /* 2^26 */
y *= 6.7108864e7f;
scale = 1.220703125e-4f; /* 2^-13 */
#else
x *= 4.0f;
y *= 4.0f;
scale = 0.5f;
#endif
}
w = x + y * I;
r = cabsf(w);
if( x > 0 ) {
t = sqrtf(0.5f * r + 0.5f * x);
r = scale * fabsf((0.5f * y) / t);
t *= scale;
} else {
r = sqrtf(0.5f * r - 0.5f * x);
t = scale * fabsf((0.5f * y) / r);
r *= scale;
}
if (y < 0)
w = t - r * I;
else
w = t + r * I;
return w;
}

53
lib/libm/complex/ctan.3 Normal file
View File

@@ -0,0 +1,53 @@
.\" $NetBSD: ctan.3,v 1.1 2008/02/20 09:55:38 drochner Exp $
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
.TH "CTAN" 3P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
.\" ctan
.SH NAME
ctan, ctanf \- complex tangent functions
.SH SYNOPSIS
.LP
\fB#include <complex.h>
.br
.sp
double complex ctan(double complex\fP \fIz\fP\fB);
.br
float complex ctanf(float complex\fP \fIz\fP\fB);
.br
\fP
.SH DESCRIPTION
.LP
These functions compute the complex tangent of \fIz\fP.
.SH RETURN VALUE
.LP
These functions return the complex tangent value.
.SH ERRORS
.LP
No errors are defined.
.LP
\fIThe following sections are informative.\fP
.SH EXAMPLES
.LP
None.
.SH APPLICATION USAGE
.LP
None.
.SH RATIONALE
.LP
None.
.SH FUTURE DIRECTIONS
.LP
None.
.SH SEE ALSO
.LP
\fIcatan\fP(), the Base Definitions volume of IEEE\ Std\ 1003.1-2001,
\fI<complex.h>\fP
.SH COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. In the
event of any discrepancy between this version and the original IEEE and
The Open Group Standard, the original IEEE and The Open Group Standard
is the referee document. The original Standard can be obtained online at
http://www.opengroup.org/unix/online.html .

58
lib/libm/complex/ctan.c Normal file
View File

@@ -0,0 +1,58 @@
/* $NetBSD: ctan.c,v 1.1 2007/08/20 16:01:37 drochner 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_subr.h"
#define MAXNUM 1.0e308
double complex
ctan(double complex z)
{
double complex w;
double d;
d = cos(2.0 * creal(z)) + cosh(2.0 * cimag(z));
if (fabs(d) < 0.25)
d = _ctans(z);
if (d == 0.0) {
/* mtherr ("ctan", OVERFLOW); */
w = MAXNUM + MAXNUM * I;
return w;
}
w = sin(2.0 * creal(z)) / d + (sinh(2.0 * cimag(z)) / d) * I;
return w;
}

58
lib/libm/complex/ctanf.c Normal file
View File

@@ -0,0 +1,58 @@
/* $NetBSD: ctanf.c,v 1.1 2007/08/20 16:01:38 drochner 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_subrf.h"
#define MAXNUMF 1.0e38f
float complex
ctanf(float complex z)
{
float complex w;
float d;
d = cosf(2.0f * crealf(z)) + coshf(2.0f * cimagf(z));
if (fabsf(d) < 0.25f)
d = _ctansf(z);
if (d == 0.0f) {
/* mtherr ("ctan", OVERFLOW); */
w = MAXNUMF + MAXNUMF * I;
return w;
}
w = sinf(2.0f * crealf(z)) / d + (sinhf(2.0f * cimagf(z)) / d) * I;
return w;
}

53
lib/libm/complex/ctanh.3 Normal file
View File

@@ -0,0 +1,53 @@
.\" $NetBSD: ctanh.3,v 1.1 2008/02/20 09:55:38 drochner Exp $
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
.TH "CTANH" 3P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
.\" ctanh
.SH NAME
ctanh, ctanhf \- complex hyperbolic tangent functions
.SH SYNOPSIS
.LP
\fB#include <complex.h>
.br
.sp
double complex ctanh(double complex\fP \fIz\fP\fB);
.br
float complex ctanhf(float complex\fP \fIz\fP\fB);
.br
\fP
.SH DESCRIPTION
.LP
These functions compute the complex hyperbolic tangent of \fIz\fP.
.SH RETURN VALUE
.LP
These functions return the complex hyperbolic tangent value.
.SH ERRORS
.LP
No errors are defined.
.LP
\fIThe following sections are informative.\fP
.SH EXAMPLES
.LP
None.
.SH APPLICATION USAGE
.LP
None.
.SH RATIONALE
.LP
None.
.SH FUTURE DIRECTIONS
.LP
None.
.SH SEE ALSO
.LP
\fIcatanh\fP(), the Base Definitions volume of IEEE\ Std\ 1003.1-2001,
\fI<complex.h>\fP
.SH COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. In the
event of any discrepancy between this version and the original IEEE and
The Open Group Standard, the original IEEE and The Open Group Standard
is the referee document. The original Standard can be obtained online at
http://www.opengroup.org/unix/online.html .

48
lib/libm/complex/ctanh.c Normal file
View File

@@ -0,0 +1,48 @@
/* $NetBSD: ctanh.c,v 1.1 2007/08/20 16:01:38 drochner 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>
double complex
ctanh(double complex z)
{
double complex w;
double x, y, d;
x = creal(z);
y = cimag(z);
d = cosh(2.0 * x) + cos(2.0 * y);
w = sinh(2.0 * x) / d + (sin(2.0 * y) / d) * I;
return w;
}

48
lib/libm/complex/ctanhf.c Normal file
View File

@@ -0,0 +1,48 @@
/* $NetBSD: ctanhf.c,v 1.1 2007/08/20 16:01:38 drochner 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>
float complex
ctanhf(float complex z)
{
float complex w;
float x, y, d;
x = crealf(z);
y = cimagf(z);
d = coshf(2.0f * x) + cosf(2.0f * y);
w = sinhf(2.0f * x) / d + (sinf(2.0f * y) / d) * I;
return w;
}