user: implement mlibc as the libc, finally.

It's finally done..

Signed-off-by: kaguya <vpshinomiya@protonmail.com>
This commit is contained in:
kaguya
2026-05-02 03:31:49 -04:00
parent 2fa39ad85a
commit 9a9b91c940
2387 changed files with 152741 additions and 315 deletions
@@ -0,0 +1,59 @@
/* $NetBSD: cabs.c,v 1.1 2007/08/20 16:01:30 drochner Exp $ */
/*
* Written by Matthias Drochner <drochner@NetBSD.org>.
* Public domain.
*
* imported and modified include for newlib 2010/10/03
* Marco Atzeri <marco_atzeri@yahoo.it>
*/
/*
FUNCTION
<<cabs>>, <<cabsf>>, <<cabsl>>---complex absolute-value
INDEX
cabs
INDEX
cabsf
INDEX
cabsl
SYNOPSIS
#include <complex.h>
double cabs(double complex <[z]>);
float cabsf(float complex <[z]>);
long double cabsl(long double complex <[z]>);
DESCRIPTION
These functions compute compute the complex absolute value
(also called norm, modulus, or magnitude) of <[z]>.
<<cabsf>> is identical to <<cabs>>, except that it performs
its calculations on <<float complex>>.
<<cabsl>> is identical to <<cabs>>, except that it performs
its calculations on <<long double complex>>.
RETURNS
The cabs* functions return the complex absolute value.
PORTABILITY
<<cabs>>, <<cabsf>> and <<cabsl>> are ISO C99
QUICKREF
<<cabs>>, <<cabsf>> and <<cabsl>> are ISO C99
*/
#include <complex.h>
#include <math.h>
double
cabs(double complex z)
{
return hypot( creal(z), cimag(z) );
}
@@ -0,0 +1,19 @@
/* $NetBSD: cabsf.c,v 1.1 2007/08/20 16:01:30 drochner Exp $ */
/*
* Written by Matthias Drochner <drochner@NetBSD.org>.
* Public domain.
*
* imported and modified include for newlib 2010/10/03
* Marco Atzeri <marco_atzeri@yahoo.it>
*/
#include <complex.h>
#include <math.h>
float
cabsf(float complex z)
{
return hypotf( crealf(z), cimagf(z) );
}
@@ -0,0 +1,99 @@
/* $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.
*
* imported and modified include for newlib 2010/10/03
* Marco Atzeri <marco_atzeri@yahoo.it>
*/
/*
FUNCTION
<<cacos>>, <<cacosf>>---complex arc cosine
INDEX
cacos
INDEX
cacosf
SYNOPSIS
#include <complex.h>
double complex cacos(double complex <[z]>);
float complex cacosf(float complex <[z]>);
DESCRIPTION
These functions compute the complex arc cosine of <[z]>,
with branch cuts outside the interval [-1, +1] along the real axis.
<<cacosf>> is identical to <<cacos>>, except that it performs
its calculations on <<floats complex>>.
RETURNS
@ifnottex
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.
@end ifnottex
@tex
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.
@end tex
PORTABILITY
<<cacos>> and <<cacosf>> are ISO C99
QUICKREF
<<cacos>> and <<cacosf>> are ISO C99
*/
#include <complex.h>
#include <math.h>
double complex
cacos(double complex z)
{
double complex w;
/* FIXME: The original NetBSD code results in an ICE when trying to
build this function on ARM/Thumb using gcc 4.5.1. For now we use
a hopefully temporary workaround. */
#if 0
w = casin(z);
w = (M_PI_2 - creal(w)) - cimag(w) * I;
#else
double complex tmp0, tmp1;
tmp0 = casin(z);
tmp1 = M_PI_2 - creal(tmp0);
w = tmp1 - (cimag(tmp0) * I);
#endif
return w;
}
@@ -0,0 +1,46 @@
/* $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.
*
* imported and modified include for newlib 2010/10/03
* Marco Atzeri <marco_atzeri@yahoo.it>
*/
#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;
}
@@ -0,0 +1,93 @@
/* $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.
*
* imported and modified include for newlib 2010/10/03
* Marco Atzeri <marco_atzeri@yahoo.it>
*/
/*
FUNCTION
<<cacosh>>, <<cacoshf>>---complex arc hyperbolic cosine
INDEX
cacosh
INDEX
cacoshf
SYNOPSIS
#include <complex.h>
double complex cacosh(double complex <[z]>);
float complex cacoshf(float complex <[z]>);
DESCRIPTION
These functions compute the complex arc hyperbolic cosine of <[z]>,
with a branch cut at values less than 1 along the real axis.
<<cacoshf>> is identical to <<cacosh>>, except that it performs
its calculations on <<floats complex>>.
RETURNS
@ifnottex
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 [-i * pi, +i * pi] along the
imaginary axis.
@end ifnottex
@tex
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 [$-i\pi$, $+i\pi$] along the
imaginary axis.
@end tex
PORTABILITY
<<cacosh>> and <<cacoshf>> are ISO C99
QUICKREF
<<cacosh>> and <<cacoshf>> are ISO C99
*/
#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;
}
@@ -0,0 +1,48 @@
/* $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.
*
* imported and modified include for newlib 2010/10/03
* Marco Atzeri <marco_atzeri@yahoo.it>
*/
#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;
}
@@ -0,0 +1,59 @@
/* $NetBSD: carg.c,v 1.1 2007/08/20 16:01:31 drochner Exp $ */
/*
* Written by Matthias Drochner <drochner@NetBSD.org>.
* Public domain.
*
* imported and modified include for newlib 2010/10/03
* Marco Atzeri <marco_atzeri@yahoo.it>
*/
/*
FUNCTION
<<carg>>, <<cargf>>---argument (phase angle)
INDEX
carg
INDEX
cargf
SYNOPSIS
#include <complex.h>
double carg(double complex <[z]>);
float cargf(float complex <[z]>);
DESCRIPTION
These functions compute the argument (also called phase angle)
of <[z]>, with a branch cut along the negative real axis.
<<cargf>> is identical to <<carg>>, except that it performs
its calculations on <<floats complex>>.
RETURNS
@ifnottex
The carg functions return the value of the argument in the
interval [-pi, +pi]
@end ifnottex
@tex
The carg functions return the value of the argument in the
interval [$-\pi$, $+\pi$]
@end tex
PORTABILITY
<<carg>> and <<cargf>> are ISO C99
QUICKREF
<<carg>> and <<cargf>> are ISO C99
*/
#include <complex.h>
#include <math.h>
double
carg(double complex z)
{
return atan2( cimag(z) , creal(z) );
}
@@ -0,0 +1,19 @@
/* $NetBSD: cargf.c,v 1.1 2007/08/20 16:01:31 drochner Exp $ */
/*
* Written by Matthias Drochner <drochner@NetBSD.org>.
* Public domain.
*
* imported and modified include for newlib 2010/10/03
* Marco Atzeri <marco_atzeri@yahoo.it>
*/
#include <complex.h>
#include <math.h>
float
cargf(float complex z)
{
return atan2f( cimagf(z), crealf(z) );
}
@@ -0,0 +1,165 @@
/* $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.
*
* imported and modified include for newlib 2010/10/03
* Marco Atzeri <marco_atzeri@yahoo.it>
*/
/*
FUNCTION
<<casin>>, <<casinf>>---complex arc sine
INDEX
casin
INDEX
casinf
SYNOPSIS
#include <complex.h>
double complex casin(double complex <[z]>);
float complex casinf(float complex <[z]>);
DESCRIPTION
These functions compute the complex arc sine of <[z]>,
with branch cuts outside the interval [-1, +1] along the real axis.
<<casinf>> is identical to <<casin>>, except that it performs
its calculations on <<floats complex>>.
RETURNS
@ifnottex
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.
@end ifnottex
@tex
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.
@end tex
PORTABILITY
<<casin>> and <<casinf>> are ISO C99
QUICKREF
<<casin>> and <<casinf>> are ISO C99
*/
#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;
}
@@ -0,0 +1,122 @@
/* $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.
*
* imported and modified include for newlib 2010/10/03
* Marco Atzeri <marco_atzeri@yahoo.it>
*/
#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;
}
@@ -0,0 +1,97 @@
/* $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.
*
* imported and modified include for newlib 2010/10/03
* Marco Atzeri <marco_atzeri@yahoo.it>
*/
/*
FUNCTION
<<casinh>>, <<casinhf>>---complex arc hyperbolic sine
INDEX
casinh
INDEX
casinhf
SYNOPSIS
#include <complex.h>
double complex casinh(double complex <[z]>);
float complex casinhf(float complex <[z]>);
DESCRIPTION
@ifnottex
These functions compute the complex arc hyperbolic sine of <[z]>,
with branch cuts outside the interval [-i, +i] along the
imaginary axis.
@end ifnottex
@tex
These functions compute the complex arc hyperbolic sine of <[z]>,
with branch cuts outside the interval [$-i$, $+i$] along the
imaginary axis.
@end tex
<<casinhf>> is identical to <<casinh>>, except that it performs
its calculations on <<floats complex>>.
RETURNS
@ifnottex
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 [-i*p/2, +i*p/2] along the
imaginary axis.
@end ifnottex
@tex
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 [$-i\pi/2$, $+i\pi/2$] along the
imaginary axis.
@end tex
PORTABILITY
<<casinh>> and <<casinhf>> are ISO C99
QUICKREF
<<casinh>> and <<casinhf>> are ISO C99
*/
#include <complex.h>
double complex
casinh(double complex z)
{
double complex w;
w = -1.0 * I * casin(z * I);
return w;
}
@@ -0,0 +1,44 @@
/* $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.
*
* imported and modified include for newlib 2010/10/03
* Marco Atzeri <marco_atzeri@yahoo.it>
*/
#include <complex.h>
float complex
casinhf(float complex z)
{
float complex w;
w = -1.0f * I * casinf(z * I);
return w;
}
@@ -0,0 +1,128 @@
/* $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.
*
* imported and modified include for newlib 2010/10/03
* Marco Atzeri <marco_atzeri@yahoo.it>
*/
/*
FUNCTION
<<catan>>, <<catanf>>---complex arc tangent
INDEX
catan
INDEX
catanf
SYNOPSIS
#include <complex.h>
double complex catan(double complex <[z]>);
float complex catanf(float complex <[z]>);
DESCRIPTION
@ifnottex
These functions compute the complex arc tangent of <[z]>,
with branch cuts outside the interval [-i, +i] along the
imaginary axis.
@end ifnottex
@tex
These functions compute the complex arc tangent of <[z]>,
with branch cuts outside the interval [$-i$, $+i$] along the
imaginary axis.
@end tex
<<catanf>> is identical to <<catan>>, except that it performs
its calculations on <<floats complex>>.
RETURNS
@ifnottex
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.
@end ifnottex
@tex
These functions return the complex arc tangent, in the range
of a strip mathematically unbounded along the imaginary axis
and in the interval [$-\pi/2$, $+\pi/2$] along the real axis.
@end tex
PORTABILITY
<<catan>> and <<catanf>> are ISO C99
QUICKREF
<<catan>> and <<catanf>> are ISO C99
*/
#include <complex.h>
#include <math.h>
#include "cephes_subr.h"
#ifdef __weak_alias
__weak_alias(catan, _catan)
#endif
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);
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 = HUGE_VAL + HUGE_VAL * I;
return w;
}
@@ -0,0 +1,77 @@
/* $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.
*
* imported and modified include for newlib 2010/10/03
* Marco Atzeri <marco_atzeri@yahoo.it>
*/
#include <complex.h>
#include <math.h>
#include "cephes_subrf.h"
#ifdef __weak_alias
__weak_alias(catanf, _catanf)
#endif
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);
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 = HUGE_VALF + HUGE_VALF * I;
return w;
}
@@ -0,0 +1,90 @@
/* $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.
*
* imported and modified include for newlib 2010/10/03
* Marco Atzeri <marco_atzeri@yahoo.it>
*/
/*
FUNCTION
<<catanh>>, <<catanhf>>---complex arc hyperbolic tangent
INDEX
catanh
INDEX
catanhf
SYNOPSIS
#include <complex.h>
double complex catanh(double complex <[z]>);
float complex catanhf(float complex <[z]>);
DESCRIPTION
These functions compute the complex arc hyperbolic tan of <[z]>,
with branch cuts outside the interval [-1, +1] along the
real axis.
<<catanhf>> is identical to <<catanh>>, except that it performs
its calculations on <<floats complex>>.
RETURNS
@ifnottex
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 [-i*p/2, +i*p/2] along the
imaginary axis.
@end ifnottex
@tex
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 [$-i\pi/2$, $+i\pi/2$] along the
imaginary axis.
@end tex
PORTABILITY
<<catanh>> and <<catanhf>> are ISO C99
QUICKREF
<<catanh>> and <<catanhf>> are ISO C99
*/
#include <complex.h>
double complex
catanh(double complex z)
{
double complex w;
w = -1.0 * I * catan(z * I);
return w;
}
@@ -0,0 +1,44 @@
/* $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.
*
* imported and modified include for newlib 2010/10/03
* Marco Atzeri <marco_atzeri@yahoo.it>
*/
#include <complex.h>
float complex
catanhf(float complex z)
{
float complex w;
w = -1.0f * I * catanf(z * I);
return w;
}
@@ -0,0 +1,81 @@
/* $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.
*
* imported and modified include for newlib 2010/10/03
* Marco Atzeri <marco_atzeri@yahoo.it>
*/
/*
FUNCTION
<<ccos>>, <<ccosf>>---complex cosine
INDEX
ccos
INDEX
ccosf
SYNOPSIS
#include <complex.h>
double complex ccos(double complex <[z]>);
float complex ccosf(float complex <[z]>);
DESCRIPTION
These functions compute the complex cosine of <[z]>.
<<ccosf>> is identical to <<ccos>>, except that it performs
its calculations on <<floats complex>>.
RETURNS
These functions return the complex cosine value.
PORTABILITY
<<ccos>> and <<ccosf>> are ISO C99
QUICKREF
<<ccos>> and <<ccosf>> are ISO C99
*/
#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;
}
@@ -0,0 +1,48 @@
/* $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.
*
* imported and modified include for newlib 2010/10/03
* Marco Atzeri <marco_atzeri@yahoo.it>
*/
#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;
}
@@ -0,0 +1,81 @@
/* $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.
*
* imported and modified include for newlib 2010/10/03
* Marco Atzeri <marco_atzeri@yahoo.it>
*/
/*
FUNCTION
<<ccosh>>, <<ccoshf>>---complex hyperbolic cosine
INDEX
ccosh
INDEX
ccoshf
SYNOPSIS
#include <complex.h>
double complex ccosh(double complex <[z]>);
float complex ccoshf(float complex <[z]>);
DESCRIPTION
These functions compute the complex hyperbolic cosine of <[z]>.
<<ccoshf>> is identical to <<ccosh>>, except that it performs
its calculations on <<floats complex>>.
RETURNS
These functions return the complex hyperbolic cosine value.
PORTABILITY
<<ccosh>> and <<ccoshf>> are ISO C99
QUICKREF
<<ccosh>> and <<ccoshf>> are ISO C99
*/
#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;
}
@@ -0,0 +1,48 @@
/* $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.
*
* imported and modified include for newlib 2010/10/03
* Marco Atzeri <marco_atzeri@yahoo.it>
*/
#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;
}
@@ -0,0 +1,126 @@
/* $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.
*
* imported and modified include for newlib 2010/10/03
* Marco Atzeri <marco_atzeri@yahoo.it>
*/
#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;
}
@@ -0,0 +1,8 @@
/* $NetBSD: cephes_subr.h,v 1.1 2007/08/20 16:01:33 drochner Exp $ */
__attribute__((__visibility__("hidden")))
void _cchsh(double, double *, double *);
__attribute__((__visibility__("hidden")))
double _redupi(double);
__attribute__((__visibility__("hidden")))
double _ctans(double complex);
@@ -0,0 +1,125 @@
/* $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.
*
* imported and modified include for newlib 2010/10/03
* Marco Atzeri <marco_atzeri@yahoo.it>
*/
#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;
}
@@ -0,0 +1,8 @@
/* $NetBSD: cephes_subrf.h,v 1.1 2007/08/20 16:01:34 drochner Exp $ */
__attribute__((__visibility__("hidden")))
void _cchshf(float, float *, float *);
__attribute__((__visibility__("hidden")))
float _redupif(float);
__attribute__((__visibility__("hidden")))
float _ctansf(float complex);
@@ -0,0 +1,82 @@
/* $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.
*
* imported and modified include for newlib 2010/10/03
* Marco Atzeri <marco_atzeri@yahoo.it>
*/
/*
FUNCTION
<<cexp>>, <<cexpf>>---complex base-e exponential
INDEX
cexp
INDEX
cexpf
SYNOPSIS
#include <complex.h>
double complex cexp(double complex <[z]>);
float complex cexpf(float complex <[z]>);
DESCRIPTION
These functions compute the complex base-<[e]> exponential of <[z]>.
<<cexpf>> is identical to <<cexp>>, except that it performs
its calculations on <<floats complex>>.
RETURNS
The cexp functions return the complex base-<[e]> exponential value.
PORTABILITY
<<cexp>> and <<cexpf>> are ISO C99
QUICKREF
<<cexp>> and <<cexpf>> are ISO C99
*/
#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;
}
@@ -0,0 +1,49 @@
/* $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.
*
* imported and modified include for newlib 2010/10/03
* Marco Atzeri <marco_atzeri@yahoo.it>
*/
#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;
}
@@ -0,0 +1,60 @@
/* $NetBSD: cimag.c,v 1.2 2010/09/15 16:11:29 christos Exp $ */
/*
* Written by Matthias Drochner <drochner@NetBSD.org>.
* Public domain.
*
* imported and modified include for newlib 2010/10/03
* Marco Atzeri <marco_atzeri@yahoo.it>
*/
/*
FUNCTION
<<cimag>>, <<cimagf>>, <<cimagl>>---imaginary part
INDEX
cimag
INDEX
cimagf
INDEX
cimagl
SYNOPSIS
#include <complex.h>
double cimag(double complex <[z]>);
float cimagf(float complex <[z]>);
long double cimagl(long double complex <[z]>);
DESCRIPTION
These functions compute the imaginary part of <[z]>.
<<cimagf>> is identical to <<cimag>>, except that it performs
its calculations on <<float complex>>.
<<cimagl>> is identical to <<cimag>>, except that it performs
its calculations on <<long double complex>>.
RETURNS
The cimag* functions return the imaginary part value (as a real).
PORTABILITY
<<cimag>>, <<cimagf>> and <<cimagl>> are ISO C99
QUICKREF
<<cimag>>, <<cimagf>> and <<cimagl>> are ISO C99
*/
#include <complex.h>
#include "fdlibm.h"
double
cimag(double complex z)
{
double_complex w = { .z = z };
return (IMAG_PART(w));
}
@@ -0,0 +1,21 @@
/* $NetBSD: cimagf.c,v 1.2 2010/09/15 16:11:29 christos Exp $ */
/*
* Written by Matthias Drochner <drochner@NetBSD.org>.
* Public domain.
*
* imported and modified include for newlib 2010/10/03
* Marco Atzeri <marco_atzeri@yahoo.it>
*/
#include <complex.h>
#include "fdlibm.h"
float
cimagf(float complex z)
{
float_complex w = { .z = z };
return (IMAG_PART(w));
}
@@ -0,0 +1,91 @@
/* $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.
*
* imported and modified include for newlib 2010/10/03
* Marco Atzeri <marco_atzeri@yahoo.it>
*/
/*
FUNCTION
<<clog>>, <<clogf>>---complex base-e logarithm
INDEX
clog
INDEX
clogf
SYNOPSIS
#include <complex.h>
double complex clog(double complex <[z]>);
float complex clogf(float complex <[z]>);
DESCRIPTION
These functions compute the complex natural (base-<[e]>) logarithm
of <[z]>, with a branch cut along the negative real axis.
<<clogf>> is identical to <<clog>>, except that it performs
its calculations on <<floats complex>>.
RETURNS
@ifnottex
The clog functions return the complex natural logarithm value, in
the range of a strip mathematically unbounded along the real axis
and in the interval [-i*pi , +i*pi] along the imaginary axis.
@end ifnottex
@tex
The clog functions return the complex natural logarithm value, in
the range of a strip mathematically unbounded along the real axis
and in the interval [$-i\pi$, $+i\pi$] along the imaginary axis.
@end tex
PORTABILITY
<<clog>> and <<clogf>> are ISO C99
QUICKREF
<<clog>> and <<clogf>> are ISO C99
*/
#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;
}
@@ -0,0 +1,49 @@
/* $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.
*
* imported and modified include for newlib 2010/10/03
* Marco Atzeri <marco_atzeri@yahoo.it>
*/
#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;
}
@@ -0,0 +1,56 @@
/* $NetBSD: conj.c,v 1.2 2010/09/15 16:11:29 christos Exp $ */
/*
* Written by Matthias Drochner <drochner@NetBSD.org>.
* Public domain.
*
* imported and modified include for newlib 2010/10/03
* Marco Atzeri <marco_atzeri@yahoo.it>
*/
/*
FUNCTION
<<conj>>, <<conjf>>---complex conjugate
INDEX
conj
INDEX
conjf
SYNOPSIS
#include <complex.h>
double complex conj(double complex <[z]>);
float complex conjf(float complex <[z]>);
DESCRIPTION
These functions compute the complex conjugate of <[z]>,
by reversing the sign of its imaginary part.
<<conjf>> is identical to <<conj>>, except that it performs
its calculations on <<floats complex>>.
RETURNS
The conj functions return the complex conjugate value.
PORTABILITY
<<conj>> and <<conjf>> are ISO C99
QUICKREF
<<conj>> and <<conjf>> are ISO C99
*/
#include <complex.h>
#include "fdlibm.h"
double complex
conj(double complex z)
{
double_complex w = { .z = z };
IMAG_PART(w) = -IMAG_PART(w);
return (w.z);
}
@@ -0,0 +1,23 @@
/* $NetBSD: conjf.c,v 1.2 2010/09/15 16:11:29 christos Exp $ */
/*
* Written by Matthias Drochner <drochner@NetBSD.org>.
* Public domain.
*
* imported and modified include for newlib 2010/10/03
* Marco Atzeri <marco_atzeri@yahoo.it>
*/
#include <complex.h>
#include "fdlibm.h"
float complex
conjf(float complex z)
{
float_complex w = { .z = z };
IMAG_PART(w) = -IMAG_PART(w);
return (w.z);
}
@@ -0,0 +1,101 @@
/* $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.
*
* imported and modified include for newlib 2010/10/03
* Marco Atzeri <marco_atzeri@yahoo.it>
*/
/*
FUNCTION
<<cpow>>, <<cpowf>>---complex power
INDEX
cpow
INDEX
cpowf
SYNOPSIS
#include <complex.h>
double complex cpow(double complex <[x]>, double complex <[y]>);
float complex cpowf(float complex <[x]>, float complex <[y]>);
DESCRIPTION
@ifnottex
The cpow functions compute the complex power function x^y
power, with a branch cut for the first parameter along the
negative real axis.
@end ifnottex
@tex
The cpow functions compute the complex power function $x^y$
power, with a branch cut for the first parameter along the
negative real axis.
@end tex
<<cpowf>> is identical to <<cpow>>, except that it performs
its calculations on <<floats complex>>.
RETURNS
The cpow functions return the complex power function value.
PORTABILITY
<<cpow>> and <<cpowf>> are ISO C99
QUICKREF
<<cpow>> and <<cpowf>> are ISO C99
*/
#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;
}
@@ -0,0 +1,59 @@
/* $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.
*
* imported and modified include for newlib 2010/10/03
* Marco Atzeri <marco_atzeri@yahoo.it>
*/
#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;
}
@@ -0,0 +1,105 @@
/* $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.
*
* imported and modified include for newlib 2010/10/03
* Marco Atzeri <marco_atzeri@yahoo.it>
*/
/*
FUNCTION
<<cproj>>, <<cprojf>>--- Riemann sphere projection
INDEX
cproj
INDEX
cprojf
SYNOPSIS
#include <complex.h>
double complex cproj(double complex <[z]>);
float complex cprojf(float complex <[z]>);
DESCRIPTION
These functions compute a projection of <[z]> 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]>) is equivalent to
INFINITY + I * copysign(0.0, cimag(z))
<<cprojf>> is identical to <<cproj>>, except that it performs
its calculations on <<floats complex>>.
RETURNS
The cproj functions return the value of the projection onto
the Riemann sphere.
PORTABILITY
<<cproj>> and <<cprojf>> are ISO C99
QUICKREF
<<cproj>> and <<cprojf>> are ISO C99
*/
/*__RCSID("$NetBSD: cproj.c,v 1.3 2010/09/20 17:51:38 christos Exp $"); */
#include <complex.h>
#include <math.h>
#include "fdlibm.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);
}
@@ -0,0 +1,67 @@
/* $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.
*
* imported and modified include for newlib 2010/10/03
* Marco Atzeri <marco_atzeri@yahoo.it>
*/
/*__RCSID("$NetBSD: cprojf.c,v 1.3 2010/09/20 17:51:38 christos Exp $"); */
#include <complex.h>
#include <math.h>
#include "fdlibm.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);
}
@@ -0,0 +1,60 @@
/* $NetBSD: creal.c,v 1.2 2010/09/15 16:11:29 christos Exp $ */
/*
* Written by Matthias Drochner <drochner@NetBSD.org>.
* Public domain.
*
* imported and modified include for newlib 2010/10/03
* Marco Atzeri <marco_atzeri@yahoo.it>
*/
/*
FUNCTION
<<creal>>, <<crealf>>, <<creall>>---real part
INDEX
creal
INDEX
crealf
INDEX
creall
SYNOPSIS
#include <complex.h>
double creal(double complex <[z]>);
float crealf(float complex <[z]>);
double long creall(long double complex <[z]>);
DESCRIPTION
These functions compute the real part of <[z]>.
<<crealf>> is identical to <<creal>>, except that it performs
its calculations on <<float complex>>.
<<creall>> is identical to <<creal>>, except that it performs
its calculations on <<long double complex>>.
RETURNS
The creal* functions return the real part value.
PORTABILITY
<<creal>>, <<crealf>> and <<creall>> are ISO C99
QUICKREF
<<creal>>, <<crealf>> and <<creall>> are ISO C99
*/
#include <complex.h>
#include "fdlibm.h"
double
creal(double complex z)
{
double_complex w = { .z = z };
return (REAL_PART(w));
}
@@ -0,0 +1,21 @@
/* $NetBSD: crealf.c,v 1.2 2010/09/15 16:11:29 christos Exp $ */
/*
* Written by Matthias Drochner <drochner@NetBSD.org>.
* Public domain.
*
* imported and modified include for newlib 2010/10/03
* Marco Atzeri <marco_atzeri@yahoo.it>
*/
#include <complex.h>
#include "fdlibm.h"
float
crealf(float complex z)
{
float_complex w = { .z = z };
return (REAL_PART(w));
}
@@ -0,0 +1,81 @@
/* $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.
*
* imported and modified include for newlib 2010/10/03
* Marco Atzeri <marco_atzeri@yahoo.it>
*/
/*
FUNCTION
<<csin>>, <<csinf>>---complex sine
INDEX
csin
INDEX
csinf
SYNOPSIS
#include <complex.h>
double complex csin(double complex <[z]>);
float complex csinf(float complex <[z]>);
DESCRIPTION
These functions compute the complex sine of <[z]>.
<<csinf>> is identical to <<csin>>, except that it performs
its calculations on <<floats complex>>.
RETURNS
These functions return the complex sine value.
PORTABILITY
<<csin>> and <<csinf>> are ISO C99
QUICKREF
<<csin>> and <<csinf>> are ISO C99
*/
#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;
}
@@ -0,0 +1,48 @@
/* $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.
*
* imported and modified include for newlib 2010/10/03
* Marco Atzeri <marco_atzeri@yahoo.it>
*/
#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;
}
@@ -0,0 +1,80 @@
/* $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.
*
* imported and modified include for newlib 2010/10/03
* Marco Atzeri <marco_atzeri@yahoo.it>
*/
/*
FUNCTION
<<csinh>>, <<csinhf>>---complex hyperbolic sine
INDEX
csinh
INDEX
csinhf
SYNOPSIS
#include <complex.h>
double complex csinh(double complex <[z]>);
float complex csinhf(float complex <[z]>);
DESCRIPTION
These functions compute the complex hyperbolic sine of <[z]>.
<<ccoshf>> is identical to <<ccosh>>, except that it performs
its calculations on <<floats complex>>.
RETURNS
These functions return the complex hyperbolic sine value.
PORTABILITY
<<csinh>> and <<csinhf>> are ISO C99
QUICKREF
<<csinh>> and <<csinhf>> are ISO C99
*/
#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;
}
@@ -0,0 +1,48 @@
/* $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.
*
* imported and modified include for newlib 2010/10/03
* Marco Atzeri <marco_atzeri@yahoo.it>
*/
#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;
}
@@ -0,0 +1,137 @@
/* $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.
*
* imported and modified include for newlib 2010/10/03
* Marco Atzeri <marco_atzeri@yahoo.it>
*/
/*
FUNCTION
<<csqrt>>, <<csqrtf>>---complex square root
INDEX
csqrt
INDEX
csqrtf
SYNOPSIS
#include <complex.h>
double complex csqrt(double complex <[z]>);
float complex csqrtf(float complex <[z]>);
DESCRIPTION
These functions compute the complex square root of <[z]>, with
a branch cut along the negative real axis.
<<csqrtf>> is identical to <<csqrt>>, except that it performs
its calculations on <<floats complex>>.
RETURNS
The csqrt functions return the complex square root value, in
the range of the right halfplane (including the imaginary axis).
PORTABILITY
<<csqrt>> and <<csqrtf>> are ISO C99
QUICKREF
<<csqrt>> and <<csqrtf>> are ISO C99
*/
#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;
}
@@ -0,0 +1,102 @@
/* $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.
*
* imported and modified include for newlib 2010/10/03
* Marco Atzeri <marco_atzeri@yahoo.it>
*/
#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;
}
@@ -0,0 +1,91 @@
/* $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.
*
* imported and modified include for newlib 2010/10/03
* Marco Atzeri <marco_atzeri@yahoo.it>
*/
/*
FUNCTION
<<ctan>>, <<ctanf>>---complex tangent
INDEX
ctan
INDEX
ctanf
SYNOPSIS
#include <complex.h>
double complex ctan(double complex <[z]>);
float complex ctanf(float complex <[z]>);
DESCRIPTION
These functions compute the complex tangent of <[z]>.
<<ctanf>> is identical to <<ctan>>, except that it performs
its calculations on <<floats complex>>.
RETURNS
These functions return the complex tangent value.
PORTABILITY
<<ctan>> and <<ctanf>> are ISO C99
QUICKREF
<<ctan>> and <<ctanf>> are ISO C99
*/
#include <complex.h>
#include <math.h>
#include "cephes_subr.h"
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 = HUGE_VAL + HUGE_VAL * I;
return w;
}
w = sin(2.0 * creal(z)) / d + (sinh(2.0 * cimag(z)) / d) * I;
return w;
}
@@ -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.
*
* imported and modified include for newlib 2010/10/03
* Marco Atzeri <marco_atzeri@yahoo.it>
*/
#include <complex.h>
#include <math.h>
#include "cephes_subrf.h"
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 = HUGE_VALF + HUGE_VALF * I;
return w;
}
w = sinf(2.0f * crealf(z)) / d + (sinhf(2.0f * cimagf(z)) / d) * I;
return w;
}
@@ -0,0 +1,83 @@
/* $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.
*
* imported and modified include for newlib 2010/10/03
* Marco Atzeri <marco_atzeri@yahoo.it>
*/
/*
FUNCTION
<<ctanh>>, <<ctanf>>---complex hyperbolic tangent
INDEX
ctanh
INDEX
ctanhf
SYNOPSIS
#include <complex.h>
double complex ctanh(double complex <[z]>);
float complex ctanhf(float complex <[z]>);
DESCRIPTION
These functions compute the complex hyperbolic tangent of <[z]>.
<<ctanhf>> is identical to <<ctanh>>, except that it performs
its calculations on <<floats complex>>.
RETURNS
These functions return the complex hyperbolic tangent value.
PORTABILITY
<<ctanh>> and <<ctanhf>> are ISO C99
QUICKREF
<<ctanh>> and <<ctanhf>> are ISO C99
*/
#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;
}
@@ -0,0 +1,50 @@
/* $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.
*
* imported and modified include for newlib 2010/10/03
* Marco Atzeri <marco_atzeri@yahoo.it>
*/
#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;
}
@@ -0,0 +1,17 @@
#ifndef __MLIBC_FDLIBM_H
#define __MLIBC_FDLIBM_H
#define REAL_PART(z) ((z).parts[0])
#define IMAG_PART(z) ((z).parts[1])
typedef union {
float complex z;
float parts[2];
} float_complex;
typedef union {
double complex z;
double parts[2];
} double_complex;
#endif