libroot: added a complex.h header based on ...
http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/complex.h.html * added missing parts from glibc. * x86_64 was already complete, x86 was missing a few functions. * should help with #12202, provided that the gcc4 buildtools are rebuilt.
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright 2015 Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _COMPLEX_H_
|
||||
#define _COMPLEX_H_
|
||||
|
||||
#ifdef __GNUC__
|
||||
# if __STDC_VERSION__ < 199901L
|
||||
# define _Complex __complex__
|
||||
#endif
|
||||
#define _Complex_I ((float _Complex)1.0i)
|
||||
#endif
|
||||
|
||||
#define complex _Complex
|
||||
#define I _Complex_I
|
||||
|
||||
extern double cabs(double complex);
|
||||
extern float cabsf(float complex);
|
||||
extern long double cabsl(long double complex);
|
||||
extern double complex cacos(double complex);
|
||||
extern float complex cacosf(float complex);
|
||||
extern double complex cacosh(double complex);
|
||||
extern float complex cacoshf(float complex);
|
||||
extern long double complex cacoshl(long double complex);
|
||||
extern long double complex cacosl(long double complex);
|
||||
extern double carg(double complex);
|
||||
extern float cargf(float complex);
|
||||
extern long double cargl(long double complex);
|
||||
extern double complex casin(double complex);
|
||||
extern float complex casinf(float complex);
|
||||
extern double complex casinh(double complex);
|
||||
extern float complex casinhf(float complex);
|
||||
extern long double complex casinhl(long double complex);
|
||||
extern long double complex casinl(long double complex);
|
||||
extern double complex catan(double complex);
|
||||
extern float complex catanf(float complex);
|
||||
extern double complex catanh(double complex);
|
||||
extern float complex catanhf(float complex);
|
||||
extern long double complex catanhl(long double complex);
|
||||
extern long double complex catanl(long double complex);
|
||||
extern double complex ccos(double complex);
|
||||
extern float complex ccosf(float complex);
|
||||
extern double complex ccosh(double complex);
|
||||
extern float complex ccoshf(float complex);
|
||||
extern long double complex ccoshl(long double complex);
|
||||
extern long double complex ccosl(long double complex);
|
||||
extern double complex cexp(double complex);
|
||||
extern float complex cexpf(float complex);
|
||||
extern long double complex cexpl(long double complex);
|
||||
extern double cimag(double complex);
|
||||
extern float cimagf(float complex);
|
||||
extern long double cimagl(long double complex);
|
||||
extern double complex clog(double complex);
|
||||
extern float complex clogf(float complex);
|
||||
extern long double complex clogl(long double complex);
|
||||
extern double complex conj(double complex);
|
||||
extern float complex conjf(float complex);
|
||||
extern long double complex conjl(long double complex);
|
||||
extern double complex cpow(double complex, double complex);
|
||||
extern float complex cpowf(float complex, float complex);
|
||||
extern long double complex cpowl(long double complex, long double complex);
|
||||
extern double complex cproj(double complex);
|
||||
extern float complex cprojf(float complex);
|
||||
extern long double complex cprojl(long double complex);
|
||||
extern double creal(double complex);
|
||||
extern float crealf(float complex);
|
||||
extern long double creall(long double complex);
|
||||
extern double complex csin(double complex);
|
||||
extern float complex csinf(float complex);
|
||||
extern double complex csinh(double complex);
|
||||
extern float complex csinhf(float complex);
|
||||
extern long double complex csinhl(long double complex);
|
||||
extern long double complex csinl(long double complex);
|
||||
extern double complex csqrt(double complex);
|
||||
extern float complex csqrtf(float complex);
|
||||
extern long double complex csqrtl(long double complex);
|
||||
extern double complex ctan(double complex);
|
||||
extern float complex ctanf(float complex);
|
||||
extern double complex ctanh(double complex);
|
||||
extern float complex ctanhf(float complex);
|
||||
extern long double complex ctanhl(long double complex);
|
||||
extern long double complex ctanl(long double complex);
|
||||
|
||||
#endif /* _COMPLEX_H_ */
|
||||
@@ -41,6 +41,7 @@ for architectureObject in [ MultiArchSubDirSetup ] {
|
||||
posix_gnu_iconv.o
|
||||
posix_gnu_libio.o
|
||||
posix_gnu_locale.o
|
||||
posix_gnu_math.o
|
||||
posix_gnu_misc.o
|
||||
posix_gnu_regex.o
|
||||
posix_gnu_stdio.o
|
||||
|
||||
@@ -10,6 +10,7 @@ SubInclude HAIKU_TOP src system libroot posix glibc extensions ;
|
||||
SubInclude HAIKU_TOP src system libroot posix glibc iconv ;
|
||||
SubInclude HAIKU_TOP src system libroot posix glibc libio ;
|
||||
SubInclude HAIKU_TOP src system libroot posix glibc locale ;
|
||||
SubInclude HAIKU_TOP src system libroot posix glibc math ;
|
||||
SubInclude HAIKU_TOP src system libroot posix glibc misc ;
|
||||
SubInclude HAIKU_TOP src system libroot posix glibc regex ;
|
||||
SubInclude HAIKU_TOP src system libroot posix glibc stdio-common ;
|
||||
|
||||
@@ -39,23 +39,23 @@ local genericSources =
|
||||
k_cos.c k_cosf.c
|
||||
k_sin.c k_sinf.c
|
||||
k_tan.c k_tanf.c
|
||||
s_cacos.c s_cacosf.c
|
||||
s_cacosh.c s_cacoshf.c
|
||||
s_casin.c s_casinf.c
|
||||
s_casinh.c s_casinhf.c
|
||||
s_catan.c s_catanf.c
|
||||
s_catanh.c s_catanhf.c
|
||||
s_ccos.c s_ccosf.c #s_ccosl.c
|
||||
s_ccosh.c s_ccoshf.c #s_ccoshl.c
|
||||
s_clog.c s_clogf.c #s_clogl.c
|
||||
s_clog10.c s_clog10f.c #s_clog10l.c
|
||||
s_cpow.c s_cpowf.c #s_cpowl.c
|
||||
s_cproj.c s_cprojf.c #s_cprojl.c
|
||||
s_csin.c s_csinf.c #s_csinl.c
|
||||
s_csinh.c s_csinhf.c #s_csinhl.c
|
||||
s_csqrt.c s_csqrtf.c #s_csqrtl.c
|
||||
s_ctan.c s_ctanf.c #s_ctanl.c
|
||||
s_ctanh.c s_ctanhf.c #s_ctanhl.c
|
||||
s_cacos.c s_cacosf.c s_cacosl.c
|
||||
s_cacosh.c s_cacoshf.c s_cacoshl.c
|
||||
s_casin.c s_casinf.c s_casinl.c
|
||||
s_casinh.c s_casinhf.c s_casinhl.c
|
||||
s_catan.c s_catanf.c s_catanl.c
|
||||
s_catanh.c s_catanhf.c s_catanhl.c
|
||||
s_ccos.c s_ccosf.c s_ccosl.c
|
||||
s_ccosh.c s_ccoshf.c s_ccoshl.c
|
||||
s_clog.c s_clogf.c s_clogl.c
|
||||
s_clog10.c s_clog10f.c s_clog10l.c
|
||||
s_cpow.c s_cpowf.c s_cpowl.c
|
||||
s_cproj.c s_cprojf.c s_cprojl.c
|
||||
s_csin.c s_csinf.c s_csinl.c
|
||||
s_csinh.c s_csinhf.c s_csinhl.c
|
||||
s_csqrt.c s_csqrtf.c s_csqrtl.c
|
||||
s_ctan.c s_ctanf.c s_ctanl.c
|
||||
s_ctanh.c s_ctanhf.c s_ctanhl.c
|
||||
s_erf.c s_erff.c s_erfl.c
|
||||
s_fpclassify.c s_fpclassifyf.c # s_fpclassifyl.c
|
||||
s_isinf.c s_isinff.c
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
SubDir HAIKU_TOP src system libroot posix glibc math ;
|
||||
|
||||
SubDirCcFlags -D_GNU_SOURCE -DUSE_IN_LIBIO ;
|
||||
|
||||
local architectureObject ;
|
||||
for architectureObject in [ MultiArchSubDirSetup ] {
|
||||
on $(architectureObject) {
|
||||
local architecture = $(TARGET_PACKAGING_ARCH) ;
|
||||
|
||||
SubDirSysHdrs $(HAIKU_TOP) src system libroot posix glibc include arch
|
||||
$(TARGET_ARCH) ;
|
||||
SubDirSysHdrs $(HAIKU_TOP) src system libroot posix glibc include arch
|
||||
generic ;
|
||||
SubDirSysHdrs $(HAIKU_TOP) src system libroot posix glibc include ;
|
||||
SubDirSysHdrs $(HAIKU_TOP) src system libroot posix glibc math ;
|
||||
SubDirSysHdrs $(HAIKU_TOP) src system libroot posix glibc ;
|
||||
|
||||
UsePrivateHeaders libroot ;
|
||||
|
||||
MergeObject <$(architecture)>posix_gnu_math.o :
|
||||
cabs.c cabsf.c cabsl.c
|
||||
carg.c cargf.c cargl.c
|
||||
cimag.c cimagf.c cimagl.c
|
||||
conj.c conjf.c conjl.c
|
||||
creal.c crealf.c creall.c
|
||||
|
||||
k_casinh.c k_casinhf.c k_casinhl.c
|
||||
;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/* Return the complex absolute value of double complex value.
|
||||
Copyright (C) 1997-2015 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Ulrich Drepper <[email protected]>, 1997.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <complex.h>
|
||||
#include <math.h>
|
||||
|
||||
double
|
||||
__cabs (double _Complex z)
|
||||
{
|
||||
return __hypot (__real__ z, __imag__ z);
|
||||
}
|
||||
weak_alias (__cabs, cabs)
|
||||
#ifdef NO_LONG_DOUBLE
|
||||
strong_alias (__cabs, __cabsl)
|
||||
weak_alias (__cabs, cabsl)
|
||||
#endif
|
||||
@@ -0,0 +1,28 @@
|
||||
/* Return the complex absolute value of float complex value.
|
||||
Copyright (C) 1997-2015 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Ulrich Drepper <[email protected]>, 1997.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <complex.h>
|
||||
#include <math.h>
|
||||
|
||||
float
|
||||
__cabsf (float _Complex z)
|
||||
{
|
||||
return __hypotf (__real__ z, __imag__ z);
|
||||
}
|
||||
weak_alias (__cabsf, cabsf)
|
||||
@@ -0,0 +1,28 @@
|
||||
/* Return the complex absolute value of long double complex value.
|
||||
Copyright (C) 1997-2015 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Ulrich Drepper <[email protected]>, 1997.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <complex.h>
|
||||
#include <math.h>
|
||||
|
||||
long double
|
||||
__cabsl (long double _Complex z)
|
||||
{
|
||||
return __hypotl (__real__ z, __imag__ z);
|
||||
}
|
||||
weak_alias (__cabsl, cabsl)
|
||||
@@ -0,0 +1,32 @@
|
||||
/* Compute argument of complex double value.
|
||||
Copyright (C) 1997-2015 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Ulrich Drepper <[email protected]>, 1997.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <complex.h>
|
||||
#include <math.h>
|
||||
|
||||
double
|
||||
__carg (__complex__ double x)
|
||||
{
|
||||
return __atan2 (__imag__ x, __real__ x);
|
||||
}
|
||||
weak_alias (__carg, carg)
|
||||
#ifdef NO_LONG_DOUBLE
|
||||
strong_alias (__carg, __cargl)
|
||||
weak_alias (__carg, cargl)
|
||||
#endif
|
||||
@@ -0,0 +1,28 @@
|
||||
/* Compute argument of complex float value.
|
||||
Copyright (C) 1997-2015 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Ulrich Drepper <[email protected]>, 1997.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <complex.h>
|
||||
#include <math.h>
|
||||
|
||||
float
|
||||
__cargf (__complex__ float x)
|
||||
{
|
||||
return __atan2f (__imag__ x, __real__ x);
|
||||
}
|
||||
weak_alias (__cargf, cargf)
|
||||
@@ -0,0 +1,28 @@
|
||||
/* Compute argument of complex long double value.
|
||||
Copyright (C) 1997-2015 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Ulrich Drepper <[email protected]>, 1997.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <complex.h>
|
||||
#include <math.h>
|
||||
|
||||
long double
|
||||
__cargl (__complex__ long double x)
|
||||
{
|
||||
return __atan2l (__imag__ x, __real__ x);
|
||||
}
|
||||
weak_alias (__cargl, cargl)
|
||||
@@ -0,0 +1,31 @@
|
||||
/* Return imaginary part of complex double value.
|
||||
Copyright (C) 1997-2015 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Ulrich Drepper <[email protected]>, 1997.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <complex.h>
|
||||
|
||||
double
|
||||
__cimag (double _Complex z)
|
||||
{
|
||||
return __imag__ z;
|
||||
}
|
||||
weak_alias (__cimag, cimag)
|
||||
#ifdef NO_LONG_DOUBLE
|
||||
strong_alias (__cimag, __cimagl)
|
||||
weak_alias (__cimag, cimagl)
|
||||
#endif
|
||||
@@ -0,0 +1,27 @@
|
||||
/* Return imaginary part of complex float value.
|
||||
Copyright (C) 1997-2015 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Ulrich Drepper <[email protected]>, 1997.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <complex.h>
|
||||
|
||||
float
|
||||
__cimagf (float _Complex z)
|
||||
{
|
||||
return __imag__ z;
|
||||
}
|
||||
weak_alias (__cimagf, cimagf)
|
||||
@@ -0,0 +1,27 @@
|
||||
/* Return imaginary part of complex long double value.
|
||||
Copyright (C) 1997-2015 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Ulrich Drepper <[email protected]>, 1997.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <complex.h>
|
||||
|
||||
long double
|
||||
__cimagl (long double _Complex z)
|
||||
{
|
||||
return __imag__ z;
|
||||
}
|
||||
weak_alias (__cimagl, cimagl)
|
||||
@@ -0,0 +1,31 @@
|
||||
/* Return complex conjugate of complex double value.
|
||||
Copyright (C) 1997-2015 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Ulrich Drepper <[email protected]>, 1997.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <complex.h>
|
||||
|
||||
double _Complex
|
||||
__conj (double _Complex z)
|
||||
{
|
||||
return ~z;
|
||||
}
|
||||
weak_alias (__conj, conj)
|
||||
#ifdef NO_LONG_DOUBLE
|
||||
strong_alias (__conj, __conjl)
|
||||
weak_alias (__conj, conjl)
|
||||
#endif
|
||||
@@ -0,0 +1,27 @@
|
||||
/* Return complex conjugate of complex float value.
|
||||
Copyright (C) 1997-2015 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Ulrich Drepper <[email protected]>, 1997.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <complex.h>
|
||||
|
||||
float _Complex
|
||||
__conjf (float _Complex z)
|
||||
{
|
||||
return ~z;
|
||||
}
|
||||
weak_alias (__conjf, conjf)
|
||||
@@ -0,0 +1,27 @@
|
||||
/* Return complex conjugate of complex long double value.
|
||||
Copyright (C) 1997-2015 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Ulrich Drepper <[email protected]>, 1997.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <complex.h>
|
||||
|
||||
long double _Complex
|
||||
__conjl (long double _Complex z)
|
||||
{
|
||||
return ~z;
|
||||
}
|
||||
weak_alias (__conjl, conjl)
|
||||
@@ -0,0 +1,31 @@
|
||||
/* Return real part of complex double value.
|
||||
Copyright (C) 1997-2015 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Ulrich Drepper <[email protected]>, 1997.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <complex.h>
|
||||
|
||||
double
|
||||
__creal (double _Complex z)
|
||||
{
|
||||
return __real__ z;
|
||||
}
|
||||
weak_alias (__creal, creal)
|
||||
#ifdef NO_LONG_DOUBLE
|
||||
strong_alias (__creal, __creall)
|
||||
weak_alias (__creal, creall)
|
||||
#endif
|
||||
@@ -0,0 +1,27 @@
|
||||
/* Return real part of complex float value.
|
||||
Copyright (C) 1997-2015 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Ulrich Drepper <[email protected]>, 1997.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <complex.h>
|
||||
|
||||
float
|
||||
__crealf (float _Complex z)
|
||||
{
|
||||
return __real__ z;
|
||||
}
|
||||
weak_alias (__crealf, crealf)
|
||||
@@ -0,0 +1,27 @@
|
||||
/* Return real part of complex long double value.
|
||||
Copyright (C) 1997-2015 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Ulrich Drepper <[email protected]>, 1997.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <complex.h>
|
||||
|
||||
long double
|
||||
__creall (long double _Complex z)
|
||||
{
|
||||
return __real__ z;
|
||||
}
|
||||
weak_alias (__creall, creall)
|
||||
@@ -0,0 +1,214 @@
|
||||
/* Return arc hyperbole sine for double value, with the imaginary part
|
||||
of the result possibly adjusted for use in computing other
|
||||
functions.
|
||||
Copyright (C) 1997-2015 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <complex.h>
|
||||
#include <math.h>
|
||||
#include <math_private.h>
|
||||
#include <float.h>
|
||||
|
||||
/* Return the complex inverse hyperbolic sine of finite nonzero Z,
|
||||
with the imaginary part of the result subtracted from pi/2 if ADJ
|
||||
is nonzero. */
|
||||
|
||||
__complex__ double
|
||||
__kernel_casinh (__complex__ double x, int adj)
|
||||
{
|
||||
__complex__ double res;
|
||||
double rx, ix;
|
||||
__complex__ double y;
|
||||
|
||||
/* Avoid cancellation by reducing to the first quadrant. */
|
||||
rx = fabs (__real__ x);
|
||||
ix = fabs (__imag__ x);
|
||||
|
||||
if (rx >= 1.0 / DBL_EPSILON || ix >= 1.0 / DBL_EPSILON)
|
||||
{
|
||||
/* For large x in the first quadrant, x + csqrt (1 + x * x)
|
||||
is sufficiently close to 2 * x to make no significant
|
||||
difference to the result; avoid possible overflow from
|
||||
the squaring and addition. */
|
||||
__real__ y = rx;
|
||||
__imag__ y = ix;
|
||||
|
||||
if (adj)
|
||||
{
|
||||
double t = __real__ y;
|
||||
__real__ y = __copysign (__imag__ y, __imag__ x);
|
||||
__imag__ y = t;
|
||||
}
|
||||
|
||||
res = __clog (y);
|
||||
__real__ res += M_LN2;
|
||||
}
|
||||
else if (rx >= 0.5 && ix < DBL_EPSILON / 8.0)
|
||||
{
|
||||
double s = __ieee754_hypot (1.0, rx);
|
||||
|
||||
__real__ res = __ieee754_log (rx + s);
|
||||
if (adj)
|
||||
__imag__ res = __ieee754_atan2 (s, __imag__ x);
|
||||
else
|
||||
__imag__ res = __ieee754_atan2 (ix, s);
|
||||
}
|
||||
else if (rx < DBL_EPSILON / 8.0 && ix >= 1.5)
|
||||
{
|
||||
double s = __ieee754_sqrt ((ix + 1.0) * (ix - 1.0));
|
||||
|
||||
__real__ res = __ieee754_log (ix + s);
|
||||
if (adj)
|
||||
__imag__ res = __ieee754_atan2 (rx, __copysign (s, __imag__ x));
|
||||
else
|
||||
__imag__ res = __ieee754_atan2 (s, rx);
|
||||
}
|
||||
else if (ix > 1.0 && ix < 1.5 && rx < 0.5)
|
||||
{
|
||||
if (rx < DBL_EPSILON * DBL_EPSILON)
|
||||
{
|
||||
double ix2m1 = (ix + 1.0) * (ix - 1.0);
|
||||
double s = __ieee754_sqrt (ix2m1);
|
||||
|
||||
__real__ res = __log1p (2.0 * (ix2m1 + ix * s)) / 2.0;
|
||||
if (adj)
|
||||
__imag__ res = __ieee754_atan2 (rx, __copysign (s, __imag__ x));
|
||||
else
|
||||
__imag__ res = __ieee754_atan2 (s, rx);
|
||||
}
|
||||
else
|
||||
{
|
||||
double ix2m1 = (ix + 1.0) * (ix - 1.0);
|
||||
double rx2 = rx * rx;
|
||||
double f = rx2 * (2.0 + rx2 + 2.0 * ix * ix);
|
||||
double d = __ieee754_sqrt (ix2m1 * ix2m1 + f);
|
||||
double dp = d + ix2m1;
|
||||
double dm = f / dp;
|
||||
double r1 = __ieee754_sqrt ((dm + rx2) / 2.0);
|
||||
double r2 = rx * ix / r1;
|
||||
|
||||
__real__ res = __log1p (rx2 + dp + 2.0 * (rx * r1 + ix * r2)) / 2.0;
|
||||
if (adj)
|
||||
__imag__ res = __ieee754_atan2 (rx + r1, __copysign (ix + r2,
|
||||
__imag__ x));
|
||||
else
|
||||
__imag__ res = __ieee754_atan2 (ix + r2, rx + r1);
|
||||
}
|
||||
}
|
||||
else if (ix == 1.0 && rx < 0.5)
|
||||
{
|
||||
if (rx < DBL_EPSILON / 8.0)
|
||||
{
|
||||
__real__ res = __log1p (2.0 * (rx + __ieee754_sqrt (rx))) / 2.0;
|
||||
if (adj)
|
||||
__imag__ res = __ieee754_atan2 (__ieee754_sqrt (rx),
|
||||
__copysign (1.0, __imag__ x));
|
||||
else
|
||||
__imag__ res = __ieee754_atan2 (1.0, __ieee754_sqrt (rx));
|
||||
}
|
||||
else
|
||||
{
|
||||
double d = rx * __ieee754_sqrt (4.0 + rx * rx);
|
||||
double s1 = __ieee754_sqrt ((d + rx * rx) / 2.0);
|
||||
double s2 = __ieee754_sqrt ((d - rx * rx) / 2.0);
|
||||
|
||||
__real__ res = __log1p (rx * rx + d + 2.0 * (rx * s1 + s2)) / 2.0;
|
||||
if (adj)
|
||||
__imag__ res = __ieee754_atan2 (rx + s1, __copysign (1.0 + s2,
|
||||
__imag__ x));
|
||||
else
|
||||
__imag__ res = __ieee754_atan2 (1.0 + s2, rx + s1);
|
||||
}
|
||||
}
|
||||
else if (ix < 1.0 && rx < 0.5)
|
||||
{
|
||||
if (ix >= DBL_EPSILON)
|
||||
{
|
||||
if (rx < DBL_EPSILON * DBL_EPSILON)
|
||||
{
|
||||
double onemix2 = (1.0 + ix) * (1.0 - ix);
|
||||
double s = __ieee754_sqrt (onemix2);
|
||||
|
||||
__real__ res = __log1p (2.0 * rx / s) / 2.0;
|
||||
if (adj)
|
||||
__imag__ res = __ieee754_atan2 (s, __imag__ x);
|
||||
else
|
||||
__imag__ res = __ieee754_atan2 (ix, s);
|
||||
}
|
||||
else
|
||||
{
|
||||
double onemix2 = (1.0 + ix) * (1.0 - ix);
|
||||
double rx2 = rx * rx;
|
||||
double f = rx2 * (2.0 + rx2 + 2.0 * ix * ix);
|
||||
double d = __ieee754_sqrt (onemix2 * onemix2 + f);
|
||||
double dp = d + onemix2;
|
||||
double dm = f / dp;
|
||||
double r1 = __ieee754_sqrt ((dp + rx2) / 2.0);
|
||||
double r2 = rx * ix / r1;
|
||||
|
||||
__real__ res
|
||||
= __log1p (rx2 + dm + 2.0 * (rx * r1 + ix * r2)) / 2.0;
|
||||
if (adj)
|
||||
__imag__ res = __ieee754_atan2 (rx + r1,
|
||||
__copysign (ix + r2,
|
||||
__imag__ x));
|
||||
else
|
||||
__imag__ res = __ieee754_atan2 (ix + r2, rx + r1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
double s = __ieee754_hypot (1.0, rx);
|
||||
|
||||
__real__ res = __log1p (2.0 * rx * (rx + s)) / 2.0;
|
||||
if (adj)
|
||||
__imag__ res = __ieee754_atan2 (s, __imag__ x);
|
||||
else
|
||||
__imag__ res = __ieee754_atan2 (ix, s);
|
||||
}
|
||||
if (__real__ res < DBL_MIN)
|
||||
{
|
||||
volatile double force_underflow = __real__ res * __real__ res;
|
||||
(void) force_underflow;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
__real__ y = (rx - ix) * (rx + ix) + 1.0;
|
||||
__imag__ y = 2.0 * rx * ix;
|
||||
|
||||
y = __csqrt (y);
|
||||
|
||||
__real__ y += rx;
|
||||
__imag__ y += ix;
|
||||
|
||||
if (adj)
|
||||
{
|
||||
double t = __real__ y;
|
||||
__real__ y = __copysign (__imag__ y, __imag__ x);
|
||||
__imag__ y = t;
|
||||
}
|
||||
|
||||
res = __clog (y);
|
||||
}
|
||||
|
||||
/* Give results the correct sign for the original argument. */
|
||||
__real__ res = __copysign (__real__ res, __real__ x);
|
||||
__imag__ res = __copysign (__imag__ res, (adj ? 1.0 : __imag__ x));
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -0,0 +1,216 @@
|
||||
/* Return arc hyperbole sine for float value, with the imaginary part
|
||||
of the result possibly adjusted for use in computing other
|
||||
functions.
|
||||
Copyright (C) 1997-2015 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <complex.h>
|
||||
#include <math.h>
|
||||
#include <math_private.h>
|
||||
#include <float.h>
|
||||
|
||||
/* Return the complex inverse hyperbolic sine of finite nonzero Z,
|
||||
with the imaginary part of the result subtracted from pi/2 if ADJ
|
||||
is nonzero. */
|
||||
|
||||
__complex__ float
|
||||
__kernel_casinhf (__complex__ float x, int adj)
|
||||
{
|
||||
__complex__ float res;
|
||||
float rx, ix;
|
||||
__complex__ float y;
|
||||
|
||||
/* Avoid cancellation by reducing to the first quadrant. */
|
||||
rx = fabsf (__real__ x);
|
||||
ix = fabsf (__imag__ x);
|
||||
|
||||
if (rx >= 1.0f / FLT_EPSILON || ix >= 1.0f / FLT_EPSILON)
|
||||
{
|
||||
/* For large x in the first quadrant, x + csqrt (1 + x * x)
|
||||
is sufficiently close to 2 * x to make no significant
|
||||
difference to the result; avoid possible overflow from
|
||||
the squaring and addition. */
|
||||
__real__ y = rx;
|
||||
__imag__ y = ix;
|
||||
|
||||
if (adj)
|
||||
{
|
||||
float t = __real__ y;
|
||||
__real__ y = __copysignf (__imag__ y, __imag__ x);
|
||||
__imag__ y = t;
|
||||
}
|
||||
|
||||
res = __clogf (y);
|
||||
__real__ res += (float) M_LN2;
|
||||
}
|
||||
else if (rx >= 0.5f && ix < FLT_EPSILON / 8.0f)
|
||||
{
|
||||
float s = __ieee754_hypotf (1.0f, rx);
|
||||
|
||||
__real__ res = __ieee754_logf (rx + s);
|
||||
if (adj)
|
||||
__imag__ res = __ieee754_atan2f (s, __imag__ x);
|
||||
else
|
||||
__imag__ res = __ieee754_atan2f (ix, s);
|
||||
}
|
||||
else if (rx < FLT_EPSILON / 8.0f && ix >= 1.5f)
|
||||
{
|
||||
float s = __ieee754_sqrtf ((ix + 1.0f) * (ix - 1.0f));
|
||||
|
||||
__real__ res = __ieee754_logf (ix + s);
|
||||
if (adj)
|
||||
__imag__ res = __ieee754_atan2f (rx, __copysignf (s, __imag__ x));
|
||||
else
|
||||
__imag__ res = __ieee754_atan2f (s, rx);
|
||||
}
|
||||
else if (ix > 1.0f && ix < 1.5f && rx < 0.5f)
|
||||
{
|
||||
if (rx < FLT_EPSILON * FLT_EPSILON)
|
||||
{
|
||||
float ix2m1 = (ix + 1.0f) * (ix - 1.0f);
|
||||
float s = __ieee754_sqrtf (ix2m1);
|
||||
|
||||
__real__ res = __log1pf (2.0f * (ix2m1 + ix * s)) / 2.0f;
|
||||
if (adj)
|
||||
__imag__ res = __ieee754_atan2f (rx, __copysignf (s, __imag__ x));
|
||||
else
|
||||
__imag__ res = __ieee754_atan2f (s, rx);
|
||||
}
|
||||
else
|
||||
{
|
||||
float ix2m1 = (ix + 1.0f) * (ix - 1.0f);
|
||||
float rx2 = rx * rx;
|
||||
float f = rx2 * (2.0f + rx2 + 2.0f * ix * ix);
|
||||
float d = __ieee754_sqrtf (ix2m1 * ix2m1 + f);
|
||||
float dp = d + ix2m1;
|
||||
float dm = f / dp;
|
||||
float r1 = __ieee754_sqrtf ((dm + rx2) / 2.0f);
|
||||
float r2 = rx * ix / r1;
|
||||
|
||||
__real__ res
|
||||
= __log1pf (rx2 + dp + 2.0f * (rx * r1 + ix * r2)) / 2.0f;
|
||||
if (adj)
|
||||
__imag__ res = __ieee754_atan2f (rx + r1, __copysignf (ix + r2,
|
||||
__imag__ x));
|
||||
else
|
||||
__imag__ res = __ieee754_atan2f (ix + r2, rx + r1);
|
||||
}
|
||||
}
|
||||
else if (ix == 1.0f && rx < 0.5f)
|
||||
{
|
||||
if (rx < FLT_EPSILON / 8.0f)
|
||||
{
|
||||
__real__ res = __log1pf (2.0f * (rx + __ieee754_sqrtf (rx))) / 2.0f;
|
||||
if (adj)
|
||||
__imag__ res = __ieee754_atan2f (__ieee754_sqrtf (rx),
|
||||
__copysignf (1.0f, __imag__ x));
|
||||
else
|
||||
__imag__ res = __ieee754_atan2f (1.0f, __ieee754_sqrtf (rx));
|
||||
}
|
||||
else
|
||||
{
|
||||
float d = rx * __ieee754_sqrtf (4.0f + rx * rx);
|
||||
float s1 = __ieee754_sqrtf ((d + rx * rx) / 2.0f);
|
||||
float s2 = __ieee754_sqrtf ((d - rx * rx) / 2.0f);
|
||||
|
||||
__real__ res = __log1pf (rx * rx + d + 2.0f * (rx * s1 + s2)) / 2.0f;
|
||||
if (adj)
|
||||
__imag__ res = __ieee754_atan2f (rx + s1,
|
||||
__copysignf (1.0f + s2,
|
||||
__imag__ x));
|
||||
else
|
||||
__imag__ res = __ieee754_atan2f (1.0f + s2, rx + s1);
|
||||
}
|
||||
}
|
||||
else if (ix < 1.0f && rx < 0.5f)
|
||||
{
|
||||
if (ix >= FLT_EPSILON)
|
||||
{
|
||||
if (rx < FLT_EPSILON * FLT_EPSILON)
|
||||
{
|
||||
float onemix2 = (1.0f + ix) * (1.0f - ix);
|
||||
float s = __ieee754_sqrtf (onemix2);
|
||||
|
||||
__real__ res = __log1pf (2.0f * rx / s) / 2.0f;
|
||||
if (adj)
|
||||
__imag__ res = __ieee754_atan2f (s, __imag__ x);
|
||||
else
|
||||
__imag__ res = __ieee754_atan2f (ix, s);
|
||||
}
|
||||
else
|
||||
{
|
||||
float onemix2 = (1.0f + ix) * (1.0f - ix);
|
||||
float rx2 = rx * rx;
|
||||
float f = rx2 * (2.0f + rx2 + 2.0f * ix * ix);
|
||||
float d = __ieee754_sqrtf (onemix2 * onemix2 + f);
|
||||
float dp = d + onemix2;
|
||||
float dm = f / dp;
|
||||
float r1 = __ieee754_sqrtf ((dp + rx2) / 2.0f);
|
||||
float r2 = rx * ix / r1;
|
||||
|
||||
__real__ res
|
||||
= __log1pf (rx2 + dm + 2.0f * (rx * r1 + ix * r2)) / 2.0f;
|
||||
if (adj)
|
||||
__imag__ res = __ieee754_atan2f (rx + r1,
|
||||
__copysignf (ix + r2,
|
||||
__imag__ x));
|
||||
else
|
||||
__imag__ res = __ieee754_atan2f (ix + r2, rx + r1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
float s = __ieee754_hypotf (1.0f, rx);
|
||||
|
||||
__real__ res = __log1pf (2.0f * rx * (rx + s)) / 2.0f;
|
||||
if (adj)
|
||||
__imag__ res = __ieee754_atan2f (s, __imag__ x);
|
||||
else
|
||||
__imag__ res = __ieee754_atan2f (ix, s);
|
||||
}
|
||||
if (__real__ res < FLT_MIN)
|
||||
{
|
||||
volatile float force_underflow = __real__ res * __real__ res;
|
||||
(void) force_underflow;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
__real__ y = (rx - ix) * (rx + ix) + 1.0f;
|
||||
__imag__ y = 2.0f * rx * ix;
|
||||
|
||||
y = __csqrtf (y);
|
||||
|
||||
__real__ y += rx;
|
||||
__imag__ y += ix;
|
||||
|
||||
if (adj)
|
||||
{
|
||||
float t = __real__ y;
|
||||
__real__ y = __copysignf (__imag__ y, __imag__ x);
|
||||
__imag__ y = t;
|
||||
}
|
||||
|
||||
res = __clogf (y);
|
||||
}
|
||||
|
||||
/* Give results the correct sign for the original argument. */
|
||||
__real__ res = __copysignf (__real__ res, __real__ x);
|
||||
__imag__ res = __copysignf (__imag__ res, (adj ? 1.0f : __imag__ x));
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -0,0 +1,223 @@
|
||||
/* Return arc hyperbole sine for long double value, with the imaginary
|
||||
part of the result possibly adjusted for use in computing other
|
||||
functions.
|
||||
Copyright (C) 1997-2015 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <complex.h>
|
||||
#include <math.h>
|
||||
#include <math_private.h>
|
||||
#include <float.h>
|
||||
|
||||
/* To avoid spurious overflows, use this definition to treat IBM long
|
||||
double as approximating an IEEE-style format. */
|
||||
#if LDBL_MANT_DIG == 106
|
||||
# undef LDBL_EPSILON
|
||||
# define LDBL_EPSILON 0x1p-106L
|
||||
#endif
|
||||
|
||||
/* Return the complex inverse hyperbolic sine of finite nonzero Z,
|
||||
with the imaginary part of the result subtracted from pi/2 if ADJ
|
||||
is nonzero. */
|
||||
|
||||
__complex__ long double
|
||||
__kernel_casinhl (__complex__ long double x, int adj)
|
||||
{
|
||||
__complex__ long double res;
|
||||
long double rx, ix;
|
||||
__complex__ long double y;
|
||||
|
||||
/* Avoid cancellation by reducing to the first quadrant. */
|
||||
rx = fabsl (__real__ x);
|
||||
ix = fabsl (__imag__ x);
|
||||
|
||||
if (rx >= 1.0L / LDBL_EPSILON || ix >= 1.0L / LDBL_EPSILON)
|
||||
{
|
||||
/* For large x in the first quadrant, x + csqrt (1 + x * x)
|
||||
is sufficiently close to 2 * x to make no significant
|
||||
difference to the result; avoid possible overflow from
|
||||
the squaring and addition. */
|
||||
__real__ y = rx;
|
||||
__imag__ y = ix;
|
||||
|
||||
if (adj)
|
||||
{
|
||||
long double t = __real__ y;
|
||||
__real__ y = __copysignl (__imag__ y, __imag__ x);
|
||||
__imag__ y = t;
|
||||
}
|
||||
|
||||
res = __clogl (y);
|
||||
__real__ res += M_LN2l;
|
||||
}
|
||||
else if (rx >= 0.5L && ix < LDBL_EPSILON / 8.0L)
|
||||
{
|
||||
long double s = __ieee754_hypotl (1.0L, rx);
|
||||
|
||||
__real__ res = __ieee754_logl (rx + s);
|
||||
if (adj)
|
||||
__imag__ res = __ieee754_atan2l (s, __imag__ x);
|
||||
else
|
||||
__imag__ res = __ieee754_atan2l (ix, s);
|
||||
}
|
||||
else if (rx < LDBL_EPSILON / 8.0L && ix >= 1.5L)
|
||||
{
|
||||
long double s = __ieee754_sqrtl ((ix + 1.0L) * (ix - 1.0L));
|
||||
|
||||
__real__ res = __ieee754_logl (ix + s);
|
||||
if (adj)
|
||||
__imag__ res = __ieee754_atan2l (rx, __copysignl (s, __imag__ x));
|
||||
else
|
||||
__imag__ res = __ieee754_atan2l (s, rx);
|
||||
}
|
||||
else if (ix > 1.0L && ix < 1.5L && rx < 0.5L)
|
||||
{
|
||||
if (rx < LDBL_EPSILON * LDBL_EPSILON)
|
||||
{
|
||||
long double ix2m1 = (ix + 1.0L) * (ix - 1.0L);
|
||||
long double s = __ieee754_sqrtl (ix2m1);
|
||||
|
||||
__real__ res = __log1pl (2.0L * (ix2m1 + ix * s)) / 2.0L;
|
||||
if (adj)
|
||||
__imag__ res = __ieee754_atan2l (rx, __copysignl (s, __imag__ x));
|
||||
else
|
||||
__imag__ res = __ieee754_atan2l (s, rx);
|
||||
}
|
||||
else
|
||||
{
|
||||
long double ix2m1 = (ix + 1.0L) * (ix - 1.0L);
|
||||
long double rx2 = rx * rx;
|
||||
long double f = rx2 * (2.0L + rx2 + 2.0L * ix * ix);
|
||||
long double d = __ieee754_sqrtl (ix2m1 * ix2m1 + f);
|
||||
long double dp = d + ix2m1;
|
||||
long double dm = f / dp;
|
||||
long double r1 = __ieee754_sqrtl ((dm + rx2) / 2.0L);
|
||||
long double r2 = rx * ix / r1;
|
||||
|
||||
__real__ res
|
||||
= __log1pl (rx2 + dp + 2.0L * (rx * r1 + ix * r2)) / 2.0L;
|
||||
if (adj)
|
||||
__imag__ res = __ieee754_atan2l (rx + r1, __copysignl (ix + r2,
|
||||
__imag__ x));
|
||||
else
|
||||
__imag__ res = __ieee754_atan2l (ix + r2, rx + r1);
|
||||
}
|
||||
}
|
||||
else if (ix == 1.0L && rx < 0.5L)
|
||||
{
|
||||
if (rx < LDBL_EPSILON / 8.0L)
|
||||
{
|
||||
__real__ res = __log1pl (2.0L * (rx + __ieee754_sqrtl (rx))) / 2.0L;
|
||||
if (adj)
|
||||
__imag__ res = __ieee754_atan2l (__ieee754_sqrtl (rx),
|
||||
__copysignl (1.0L, __imag__ x));
|
||||
else
|
||||
__imag__ res = __ieee754_atan2l (1.0L, __ieee754_sqrtl (rx));
|
||||
}
|
||||
else
|
||||
{
|
||||
long double d = rx * __ieee754_sqrtl (4.0L + rx * rx);
|
||||
long double s1 = __ieee754_sqrtl ((d + rx * rx) / 2.0L);
|
||||
long double s2 = __ieee754_sqrtl ((d - rx * rx) / 2.0L);
|
||||
|
||||
__real__ res = __log1pl (rx * rx + d + 2.0L * (rx * s1 + s2)) / 2.0L;
|
||||
if (adj)
|
||||
__imag__ res = __ieee754_atan2l (rx + s1,
|
||||
__copysignl (1.0L + s2,
|
||||
__imag__ x));
|
||||
else
|
||||
__imag__ res = __ieee754_atan2l (1.0L + s2, rx + s1);
|
||||
}
|
||||
}
|
||||
else if (ix < 1.0L && rx < 0.5L)
|
||||
{
|
||||
if (ix >= LDBL_EPSILON)
|
||||
{
|
||||
if (rx < LDBL_EPSILON * LDBL_EPSILON)
|
||||
{
|
||||
long double onemix2 = (1.0L + ix) * (1.0L - ix);
|
||||
long double s = __ieee754_sqrtl (onemix2);
|
||||
|
||||
__real__ res = __log1pl (2.0L * rx / s) / 2.0L;
|
||||
if (adj)
|
||||
__imag__ res = __ieee754_atan2l (s, __imag__ x);
|
||||
else
|
||||
__imag__ res = __ieee754_atan2l (ix, s);
|
||||
}
|
||||
else
|
||||
{
|
||||
long double onemix2 = (1.0L + ix) * (1.0L - ix);
|
||||
long double rx2 = rx * rx;
|
||||
long double f = rx2 * (2.0L + rx2 + 2.0L * ix * ix);
|
||||
long double d = __ieee754_sqrtl (onemix2 * onemix2 + f);
|
||||
long double dp = d + onemix2;
|
||||
long double dm = f / dp;
|
||||
long double r1 = __ieee754_sqrtl ((dp + rx2) / 2.0L);
|
||||
long double r2 = rx * ix / r1;
|
||||
|
||||
__real__ res
|
||||
= __log1pl (rx2 + dm + 2.0L * (rx * r1 + ix * r2)) / 2.0L;
|
||||
if (adj)
|
||||
__imag__ res = __ieee754_atan2l (rx + r1,
|
||||
__copysignl (ix + r2,
|
||||
__imag__ x));
|
||||
else
|
||||
__imag__ res = __ieee754_atan2l (ix + r2, rx + r1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
long double s = __ieee754_hypotl (1.0L, rx);
|
||||
|
||||
__real__ res = __log1pl (2.0L * rx * (rx + s)) / 2.0L;
|
||||
if (adj)
|
||||
__imag__ res = __ieee754_atan2l (s, __imag__ x);
|
||||
else
|
||||
__imag__ res = __ieee754_atan2l (ix, s);
|
||||
}
|
||||
if (__real__ res < LDBL_MIN)
|
||||
{
|
||||
volatile long double force_underflow = __real__ res * __real__ res;
|
||||
(void) force_underflow;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
__real__ y = (rx - ix) * (rx + ix) + 1.0L;
|
||||
__imag__ y = 2.0L * rx * ix;
|
||||
|
||||
y = __csqrtl (y);
|
||||
|
||||
__real__ y += rx;
|
||||
__imag__ y += ix;
|
||||
|
||||
if (adj)
|
||||
{
|
||||
long double t = __real__ y;
|
||||
__real__ y = __copysignl (__imag__ y, __imag__ x);
|
||||
__imag__ y = t;
|
||||
}
|
||||
|
||||
res = __clogl (y);
|
||||
}
|
||||
|
||||
/* Give results the correct sign for the original argument. */
|
||||
__real__ res = __copysignl (__real__ res, __real__ x);
|
||||
__imag__ res = __copysignl (__imag__ res, (adj ? 1.0L : __imag__ x));
|
||||
|
||||
return res;
|
||||
}
|
||||
Reference in New Issue
Block a user