added more math functions (complex ones)

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16394 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval
2006-02-14 14:57:33 +00:00
parent 879c65a301
commit ba41c65055
44 changed files with 3826 additions and 8 deletions
@@ -0,0 +1,80 @@
/* Return cosine of complex double value.
Copyright (C) 1997 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, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <complex.h>
#include <fenv.h>
#include <math.h>
__complex__ double
__ccos (__complex__ double x)
{
__complex__ double res;
if (!isfinite (__real__ x) || __isnan (__imag__ x))
{
if (__real__ x == 0.0 || __imag__ x == 0.0)
{
__real__ res = __nan ("");
__imag__ res = 0.0;
#ifdef FE_INVALID
if (__isinf (__real__ x))
feraiseexcept (FE_INVALID);
#endif
}
else if (__isinf (__imag__ x))
{
__real__ res = HUGE_VAL;
__imag__ res = __nan ("");
#ifdef FE_INVALID
if (__isinf (__real__ x))
feraiseexcept (FE_INVALID);
#endif
}
else
{
__real__ res = __nan ("");
__imag__ res = __nan ("");
#ifdef FE_INVALID
if (isfinite (__imag__ x))
feraiseexcept (FE_INVALID);
#endif
}
}
else
{
__complex__ double y;
__real__ y = -__imag__ x;
__imag__ y = __real__ x;
res = __ccosh (y);
}
return res;
}
weak_alias (__ccos, ccos)
#ifdef NO_LONG_DOUBLE
strong_alias (__ccos, __ccosl)
weak_alias (__ccos, ccosl)
#endif
@@ -0,0 +1,78 @@
/* Return cosine of complex float value.
Copyright (C) 1997 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, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <complex.h>
#include <fenv.h>
#include <math.h>
__complex__ float
__ccosf (__complex__ float x)
{
__complex__ float res;
if (!isfinite (__real__ x) || __isnanf (__imag__ x))
{
if (__real__ x == 0.0 || __imag__ x == 0.0)
{
__real__ res = __nanf ("");
__imag__ res = 0.0;
#ifdef FE_INVALID
if (__isinff (__real__ x))
feraiseexcept (FE_INVALID);
#endif
}
else if (__isinff (__imag__ x))
{
__real__ res = HUGE_VALF;
__imag__ res = __nanf ("");
#ifdef FE_INVALID
if (__isinff (__real__ x))
feraiseexcept (FE_INVALID);
#endif
}
else
{
__real__ res = __nanf ("");
__imag__ res = __nanf ("");
#ifdef FE_INVALID
if (isfinite (__imag__ x))
feraiseexcept (FE_INVALID);
#endif
}
}
else
{
__complex__ float y;
__real__ y = -__imag__ x;
__imag__ y = __real__ x;
res = __ccoshf (y);
}
return res;
}
#ifndef __ccosf
weak_alias (__ccosf, ccosf)
#endif
@@ -0,0 +1,105 @@
/* Complex cosine hyperbole function for double.
Copyright (C) 1997 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, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <complex.h>
#include <fenv.h>
#include <math.h>
#include "math_private.h"
__complex__ double
__ccosh (__complex__ double x)
{
__complex__ double retval;
int rcls = fpclassify (__real__ x);
int icls = fpclassify (__imag__ x);
if (rcls >= FP_ZERO)
{
/* Real part is finite. */
if (icls >= FP_ZERO)
{
/* Imaginary part is finite. */
double sinh_val = __ieee754_sinh (__real__ x);
double cosh_val = __ieee754_cosh (__real__ x);
double sinix, cosix;
__sincos (__imag__ x, &sinix, &cosix);
__real__ retval = cosh_val * cosix;
__imag__ retval = sinh_val * sinix;
}
else
{
__imag__ retval = __real__ x == 0.0 ? 0.0 : __nan ("");
__real__ retval = __nan ("") + __nan ("");
#ifdef FE_INVALID
if (icls == FP_INFINITE)
feraiseexcept (FE_INVALID);
#endif
}
}
else if (rcls == FP_INFINITE)
{
/* Real part is infinite. */
if (icls == FP_ZERO)
{
/* Imaginary part is 0.0. */
__real__ retval = HUGE_VAL;
__imag__ retval = __imag__ x * __copysign (1.0, __real__ x);
}
else if (icls > FP_ZERO)
{
/* Imaginary part is finite. */
double sinix, cosix;
__sincos (__imag__ x, &sinix, &cosix);
__real__ retval = __copysign (HUGE_VAL, cosix);
__imag__ retval = (__copysign (HUGE_VAL, sinix)
* __copysign (1.0, __real__ x));
}
else
{
/* The addition raises the invalid exception. */
__real__ retval = HUGE_VAL;
__imag__ retval = __nan ("") + __nan ("");
#ifdef FE_INVALID
if (icls == FP_INFINITE)
feraiseexcept (FE_INVALID);
#endif
}
}
else
{
__real__ retval = __nan ("");
__imag__ retval = __imag__ x == 0.0 ? __imag__ x : __nan ("");
}
return retval;
}
weak_alias (__ccosh, ccosh)
#ifdef NO_LONG_DOUBLE
strong_alias (__ccosh, __ccoshl)
weak_alias (__ccosh, ccoshl)
#endif
@@ -0,0 +1,103 @@
/* Complex cosine hyperbole function for float.
Copyright (C) 1997 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, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <complex.h>
#include <fenv.h>
#include <math.h>
#include "math_private.h"
__complex__ float
__ccoshf (__complex__ float x)
{
__complex__ float retval;
int rcls = fpclassify (__real__ x);
int icls = fpclassify (__imag__ x);
if (rcls >= FP_ZERO)
{
/* Real part is finite. */
if (icls >= FP_ZERO)
{
/* Imaginary part is finite. */
float sinh_val = __ieee754_sinhf (__real__ x);
float cosh_val = __ieee754_coshf (__real__ x);
float sinix, cosix;
__sincosf (__imag__ x, &sinix, &cosix);
__real__ retval = cosh_val * cosix;
__imag__ retval = sinh_val * sinix;
}
else
{
__imag__ retval = __real__ x == 0.0 ? 0.0 : __nanf ("");
__real__ retval = __nanf ("");
#ifdef FE_INVALID
if (icls == FP_INFINITE)
feraiseexcept (FE_INVALID);
#endif
}
}
else if (rcls == FP_INFINITE)
{
/* Real part is infinite. */
if (icls == FP_ZERO)
{
/* Imaginary part is 0.0. */
__real__ retval = HUGE_VALF;
__imag__ retval = __imag__ x * __copysignf (1.0, __real__ x);
}
else if (icls > FP_ZERO)
{
/* Imaginary part is finite. */
float sinix, cosix;
__sincosf (__imag__ x, &sinix, &cosix);
__real__ retval = __copysignf (HUGE_VALF, cosix);
__imag__ retval = (__copysignf (HUGE_VALF, sinix)
* __copysignf (1.0, __real__ x));
}
else
{
/* The addition raises the invalid exception. */
__real__ retval = HUGE_VALF;
__imag__ retval = __nanf ("") + __nanf ("");
#ifdef FE_INVALID
if (icls == FP_INFINITE)
feraiseexcept (FE_INVALID);
#endif
}
}
else
{
__real__ retval = __nanf ("");
__imag__ retval = __imag__ x == 0.0 ? __imag__ x : __nanf ("");
}
return retval;
}
#ifndef __ccoshf
weak_alias (__ccoshf, ccoshf)
#endif
@@ -0,0 +1,101 @@
/* Complex cosine hyperbole function for long double.
Copyright (C) 1997 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, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <complex.h>
#include <fenv.h>
#include <math.h>
#include "math_private.h"
__complex__ long double
__ccoshl (__complex__ long double x)
{
__complex__ long double retval;
int rcls = fpclassify (__real__ x);
int icls = fpclassify (__imag__ x);
if (rcls >= FP_ZERO)
{
/* Real part is finite. */
if (icls >= FP_ZERO)
{
/* Imaginary part is finite. */
long double sinh_val = __ieee754_sinhl (__real__ x);
long double cosh_val = __ieee754_coshl (__real__ x);
long double sinix, cosix;
__sincosl (__imag__ x, &sinix, &cosix);
__real__ retval = cosh_val * cosix;
__imag__ retval = sinh_val * sinix;
}
else
{
__imag__ retval = __real__ x == 0.0 ? 0.0 : __nanl ("");
__real__ retval = __nanl ("") + __nanl ("");
#ifdef FE_INVALID
if (icls == FP_INFINITE)
feraiseexcept (FE_INVALID);
#endif
}
}
else if (rcls == FP_INFINITE)
{
/* Real part is infinite. */
if (icls == FP_ZERO)
{
/* Imaginary part is 0.0. */
__real__ retval = HUGE_VALL;
__imag__ retval = __imag__ x * __copysignl (1.0, __real__ x);
}
else if (icls > FP_ZERO)
{
/* Imaginary part is finite. */
long double sinix, cosix;
__sincosl (__imag__ x, &sinix, &cosix);
__real__ retval = __copysignl (HUGE_VALL, cosix);
__imag__ retval = (__copysignl (HUGE_VALL, sinix)
* __copysignl (1.0, __real__ x));
}
else
{
/* The addition raises the invalid exception. */
__real__ retval = HUGE_VALL;
__imag__ retval = __nanl ("") + __nanl ("");
#ifdef FE_INVALID
if (icls == FP_INFINITE)
feraiseexcept (FE_INVALID);
#endif
}
}
else
{
__real__ retval = __nanl ("");
__imag__ retval = __imag__ x == 0.0 ? __imag__ x : __nanl ("");
}
return retval;
}
weak_alias (__ccoshl, ccoshl)
@@ -0,0 +1,76 @@
/* Return cosine of complex long double value.
Copyright (C) 1997 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, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <complex.h>
#include <fenv.h>
#include <math.h>
__complex__ long double
__ccosl (__complex__ long double x)
{
__complex__ long double res;
if (!isfinite (__real__ x) || __isnanl (__imag__ x))
{
if (__real__ x == 0.0 || __imag__ x == 0.0)
{
__real__ res = __nanl ("");
__imag__ res = 0.0;
#ifdef FE_INVALID
if (__isinfl (__real__ x))
feraiseexcept (FE_INVALID);
#endif
}
else if (__isinfl (__imag__ x))
{
__real__ res = HUGE_VALL;
__imag__ res = __nanl ("");
#ifdef FE_INVALID
if (__isinfl (__real__ x))
feraiseexcept (FE_INVALID);
#endif
}
else
{
__real__ res = __nanl ("");
__imag__ res = __nanl ("");
#ifdef FE_INVALID
if (isfinite (__imag__ x))
feraiseexcept (FE_INVALID);
#endif
}
}
else
{
__complex__ long double y;
__real__ y = -__imag__ x;
__imag__ y = __real__ x;
res = __ccoshl (y);
}
return res;
}
weak_alias (__ccosl, ccosl)
@@ -0,0 +1,127 @@
/* Return value of complex exponential function for double complex value.
Copyright (C) 1997 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, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <complex.h>
#include <fenv.h>
#include <math.h>
#include "math_private.h"
__complex__ double
__cexp (__complex__ double x)
{
__complex__ double retval;
int rcls = fpclassify (__real__ x);
int icls = fpclassify (__imag__ x);
if (rcls >= FP_ZERO)
{
/* Real part is finite. */
if (icls >= FP_ZERO)
{
/* Imaginary part is finite. */
double exp_val = __ieee754_exp (__real__ x);
double sinix, cosix;
__sincos (__imag__ x, &sinix, &cosix);
if (isfinite (exp_val))
{
__real__ retval = exp_val * cosix;
__imag__ retval = exp_val * sinix;
}
else
{
__real__ retval = __copysign (exp_val, cosix);
__imag__ retval = __copysign (exp_val, sinix);
}
}
else
{
/* If the imaginary part is +-inf or NaN and the real part
is not +-inf the result is NaN + iNaN. */
__real__ retval = __nan ("");
__imag__ retval = __nan ("");
#ifdef FE_INVALID
feraiseexcept (FE_INVALID);
#endif
}
}
else if (rcls == FP_INFINITE)
{
/* Real part is infinite. */
if (icls >= FP_ZERO)
{
/* Imaginary part is finite. */
double value = signbit (__real__ x) ? 0.0 : HUGE_VAL;
if (icls == FP_ZERO)
{
/* Imaginary part is 0.0. */
__real__ retval = value;
__imag__ retval = __imag__ x;
}
else
{
double sinix, cosix;
__sincos (__imag__ x, &sinix, &cosix);
__real__ retval = __copysign (value, cosix);
__imag__ retval = __copysign (value, sinix);
}
}
else if (signbit (__real__ x) == 0)
{
__real__ retval = HUGE_VAL;
__imag__ retval = __nan ("");
#ifdef FE_INVALID
if (icls == FP_INFINITE)
feraiseexcept (FE_INVALID);
#endif
}
else
{
__real__ retval = 0.0;
__imag__ retval = __copysign (0.0, __imag__ x);
}
}
else
{
/* If the real part is NaN the result is NaN + iNaN. */
__real__ retval = __nan ("");
__imag__ retval = __nan ("");
#ifdef FE_INVALID
if (rcls != FP_NAN || icls != FP_NAN)
feraiseexcept (FE_INVALID);
#endif
}
return retval;
}
weak_alias (__cexp, cexp)
#ifdef NO_LONG_DOUBLE
strong_alias (__cexp, __cexpl)
weak_alias (__cexp, cexpl)
#endif
@@ -0,0 +1,125 @@
/* Return value of complex exponential function for float complex value.
Copyright (C) 1997 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, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <complex.h>
#include <fenv.h>
#include <math.h>
#include "math_private.h"
__complex__ float
__cexpf (__complex__ float x)
{
__complex__ float retval;
int rcls = fpclassify (__real__ x);
int icls = fpclassify (__imag__ x);
if (rcls >= FP_ZERO)
{
/* Real part is finite. */
if (icls >= FP_ZERO)
{
/* Imaginary part is finite. */
float exp_val = __ieee754_expf (__real__ x);
float sinix, cosix;
__sincosf (__imag__ x, &sinix, &cosix);
if (isfinite (exp_val))
{
__real__ retval = exp_val * cosix;
__imag__ retval = exp_val * sinix;
}
else
{
__real__ retval = __copysignf (exp_val, cosix);
__imag__ retval = __copysignf (exp_val, sinix);
}
}
else
{
/* If the imaginary part is +-inf or NaN and the real part
is not +-inf the result is NaN + iNaN. */
__real__ retval = __nanf ("");
__imag__ retval = __nanf ("");
#ifdef FE_INVALID
feraiseexcept (FE_INVALID);
#endif
}
}
else if (rcls == FP_INFINITE)
{
/* Real part is infinite. */
if (icls >= FP_ZERO)
{
/* Imaginary part is finite. */
float value = signbit (__real__ x) ? 0.0 : HUGE_VALF;
if (icls == FP_ZERO)
{
/* Imaginary part is 0.0. */
__real__ retval = value;
__imag__ retval = __imag__ x;
}
else
{
float sinix, cosix;
__sincosf (__imag__ x, &sinix, &cosix);
__real__ retval = __copysignf (value, cosix);
__imag__ retval = __copysignf (value, sinix);
}
}
else if (signbit (__real__ x) == 0)
{
__real__ retval = HUGE_VALF;
__imag__ retval = __nanf ("");
#ifdef FE_INVALID
if (icls == FP_INFINITE)
feraiseexcept (FE_INVALID);
#endif
}
else
{
__real__ retval = 0.0;
__imag__ retval = __copysignf (0.0, __imag__ x);
}
}
else
{
/* If the real part is NaN the result is NaN + iNaN. */
__real__ retval = __nanf ("");
__imag__ retval = __nanf ("");
#ifdef FE_INVALID
if (rcls != FP_NAN || icls != FP_NAN)
feraiseexcept (FE_INVALID);
#endif
}
return retval;
}
#ifndef __cexpf
weak_alias (__cexpf, cexpf)
#endif
@@ -0,0 +1,123 @@
/* Return value of complex exponential function for long double complex value.
Copyright (C) 1997 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, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <complex.h>
#include <fenv.h>
#include <math.h>
#include "math_private.h"
__complex__ long double
__cexpl (__complex__ long double x)
{
__complex__ long double retval;
int rcls = fpclassify (__real__ x);
int icls = fpclassify (__imag__ x);
if (rcls >= FP_ZERO)
{
/* Real part is finite. */
if (icls >= FP_ZERO)
{
/* Imaginary part is finite. */
long double exp_val = __ieee754_expl (__real__ x);
long double sinix, cosix;
__sincosl (__imag__ x, &sinix, &cosix);
if (isfinite (exp_val))
{
__real__ retval = exp_val * cosix;
__imag__ retval = exp_val * sinix;
}
else
{
__real__ retval = __copysignl (exp_val, cosix);
__imag__ retval = __copysignl (exp_val, sinix);
}
}
else
{
/* If the imaginary part is +-inf or NaN and the real part
is not +-inf the result is NaN + iNaN. */
__real__ retval = __nanl ("");
__imag__ retval = __nanl ("");
#ifdef FE_INVALID
feraiseexcept (FE_INVALID);
#endif
}
}
else if (rcls == FP_INFINITE)
{
/* Real part is infinite. */
if (icls >= FP_ZERO)
{
/* Imaginary part is finite. */
long double value = signbit (__real__ x) ? 0.0 : HUGE_VALL;
if (icls == FP_ZERO)
{
/* Imaginary part is 0.0. */
__real__ retval = value;
__imag__ retval = __imag__ x;
}
else
{
long double sinix, cosix;
__sincosl (__imag__ x, &sinix, &cosix);
__real__ retval = __copysignl (value, cosix);
__imag__ retval = __copysignl (value, sinix);
}
}
else if (signbit (__real__ x) == 0)
{
__real__ retval = HUGE_VALL;
__imag__ retval = __nanl ("");
#ifdef FE_INVALID
if (icls == FP_INFINITE)
feraiseexcept (FE_INVALID);
#endif
}
else
{
__real__ retval = 0.0;
__imag__ retval = __copysignl (0.0, __imag__ x);
}
}
else
{
/* If the real part is NaN the result is NaN + iNaN. */
__real__ retval = __nanl ("");
__imag__ retval = __nanl ("");
#ifdef FE_INVALID
if (rcls != FP_NAN || icls != FP_NAN)
feraiseexcept (FE_INVALID);
#endif
}
return retval;
}
weak_alias (__cexpl, cexpl)
@@ -0,0 +1,65 @@
/* Compute complex base 10 logarithm.
Copyright (C) 1997 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, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <complex.h>
#include <math.h>
#include "math_private.h"
__complex__ double
__clog10 (__complex__ double x)
{
__complex__ double result;
int rcls = fpclassify (__real__ x);
int icls = fpclassify (__imag__ x);
if (rcls == FP_ZERO && icls == FP_ZERO)
{
/* Real and imaginary part are 0.0. */
__imag__ result = signbit (__real__ x) ? M_PI : 0.0;
__imag__ result = __copysign (__imag__ result, __imag__ x);
/* Yes, the following line raises an exception. */
__real__ result = -1.0 / fabs (__real__ x);
}
else if (rcls != FP_NAN && icls != FP_NAN)
{
/* Neither real nor imaginary part is NaN. */
__real__ result = __ieee754_log10 (__ieee754_hypot (__real__ x,
__imag__ x));
__imag__ result = M_LOG10E * __ieee754_atan2 (__imag__ x, __real__ x);
}
else
{
__imag__ result = __nan ("");
if (rcls == FP_INFINITE || icls == FP_INFINITE)
/* Real or imaginary part is infinite. */
__real__ result = HUGE_VAL;
else
__real__ result = __nan ("");
}
return result;
}
weak_alias (__clog10, clog10)
#ifdef NO_LONG_DOUBLE
strong_alias (__clog10, __clog10l)
weak_alias (__clog10, clog10l)
#endif
@@ -0,0 +1,63 @@
/* Compute complex base 10 logarithm.
Copyright (C) 1997 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, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <complex.h>
#include <math.h>
#include "math_private.h"
__complex__ float
__clog10f (__complex__ float x)
{
__complex__ float result;
int rcls = fpclassify (__real__ x);
int icls = fpclassify (__imag__ x);
if (rcls == FP_ZERO && icls == FP_ZERO)
{
/* Real and imaginary part are 0.0. */
__imag__ result = signbit (__real__ x) ? M_PI : 0.0;
__imag__ result = __copysignf (__imag__ result, __imag__ x);
/* Yes, the following line raises an exception. */
__real__ result = -1.0 / fabsf (__real__ x);
}
else if (rcls != FP_NAN && icls != FP_NAN)
{
/* Neither real nor imaginary part is NaN. */
__real__ result = __ieee754_log10f (__ieee754_hypotf (__real__ x,
__imag__ x));
__imag__ result = M_LOG10E * __ieee754_atan2f (__imag__ x, __real__ x);
}
else
{
__imag__ result = __nanf ("");
if (rcls == FP_INFINITE || icls == FP_INFINITE)
/* Real or imaginary part is infinite. */
__real__ result = HUGE_VALF;
else
__real__ result = __nanf ("");
}
return result;
}
#ifndef __clog10f
weak_alias (__clog10f, clog10f)
#endif
@@ -0,0 +1,61 @@
/* Compute complex base 10 logarithm.
Copyright (C) 1997, 1998 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, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <complex.h>
#include <math.h>
#include "math_private.h"
__complex__ long double
__clog10l (__complex__ long double x)
{
__complex__ long double result;
int rcls = fpclassify (__real__ x);
int icls = fpclassify (__imag__ x);
if (rcls == FP_ZERO && icls == FP_ZERO)
{
/* Real and imaginary part are 0.0. */
__imag__ result = signbit (__real__ x) ? M_PIl : 0.0;
__imag__ result = __copysignl (__imag__ result, __imag__ x);
/* Yes, the following line raises an exception. */
__real__ result = -1.0 / fabsl (__real__ x);
}
else if (rcls != FP_NAN && icls != FP_NAN)
{
/* Neither real nor imaginary part is NaN. */
__real__ result = __ieee754_log10l (__ieee754_hypotl (__real__ x,
__imag__ x));
__imag__ result = M_LOG10El * __ieee754_atan2l (__imag__ x, __real__ x);
}
else
{
__imag__ result = __nanl ("");
if (rcls == FP_INFINITE || icls == FP_INFINITE)
/* Real or imaginary part is infinite. */
__real__ result = HUGE_VALL;
else
__real__ result = __nanl ("");
}
return result;
}
weak_alias (__clog10l, clog10l)
@@ -0,0 +1,34 @@
/* Complex power of double values.
Copyright (C) 1997 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, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <complex.h>
#include <math.h>
__complex__ double
__cpow (__complex__ double x, __complex__ double c)
{
return __cexp (c * __clog (x));
}
weak_alias (__cpow, cpow)
#ifdef NO_LONG_DOUBLE
strong_alias (__cpow, __cpowl)
weak_alias (__cpow, cpowl)
#endif
@@ -0,0 +1,32 @@
/* Complex power of float values.
Copyright (C) 1997 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, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <complex.h>
#include <math.h>
__complex__ float
__cpowf (__complex__ float x, __complex__ float c)
{
return __cexpf (c * __clogf (x));
}
#ifndef __cpowf
weak_alias (__cpowf, cpowf)
#endif
@@ -0,0 +1,30 @@
/* Complex power of long double values.
Copyright (C) 1997 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, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <complex.h>
#include <math.h>
__complex__ long double
__cpowl (__complex__ long double x, __complex__ long double c)
{
return __cexpl (c * __clogl (x));
}
weak_alias (__cpowl, cpowl)
@@ -0,0 +1,51 @@
/* Compute projection of complex double value to Riemann sphere.
Copyright (C) 1997, 1999 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, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <complex.h>
#include <math.h>
__complex__ double
__cproj (__complex__ double x)
{
__complex__ double res;
if (isnan (__real__ x) && isnan (__imag__ x))
return x;
else if (!isfinite (__real__ x) || !isfinite (__imag__ x))
{
__real__ res = INFINITY;
__imag__ res = __copysign (0.0, __imag__ x);
}
else
{
double den = __real__ x * __real__ x + __imag__ x * __imag__ x + 1.0;
__real__ res = (2.0 * __real__ x) / den;
__imag__ res = (2.0 * __imag__ x) / den;
}
return res;
}
weak_alias (__cproj, cproj)
#ifdef NO_LONG_DOUBLE
strong_alias (__cproj, __cprojl)
weak_alias (__cproj, cprojl)
#endif
@@ -0,0 +1,49 @@
/* Compute projection of complex float value to Riemann sphere.
Copyright (C) 1997, 1999 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, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <complex.h>
#include <math.h>
__complex__ float
__cprojf (__complex__ float x)
{
__complex__ float res;
if (isnan (__real__ x) && isnan (__imag__ x))
return x;
else if (!isfinite (__real__ x) || !isfinite (__imag__ x))
{
__real__ res = INFINITY;
__imag__ res = __copysignf (0.0, __imag__ x);
}
else
{
float den = __real__ x * __real__ x + __imag__ x * __imag__ x + 1.0;
__real__ res = (2.0 * __real__ x) / den;
__imag__ res = (2.0 * __imag__ x) / den;
}
return res;
}
#ifndef __cprojf
weak_alias (__cprojf, cprojf)
#endif
@@ -0,0 +1,48 @@
/* Compute projection of complex long double value to Riemann sphere.
Copyright (C) 1997, 1999 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, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <complex.h>
#include <math.h>
__complex__ long double
__cprojl (__complex__ long double x)
{
__complex__ long double res;
if (isnan (__real__ x) && isnan (__imag__ x))
return x;
else if (!isfinite (__real__ x) || !isfinite (__imag__ x))
{
__real__ res = INFINITY;
__imag__ res = __copysignl (0.0, __imag__ x);
}
else
{
long double den = (__real__ x * __real__ x + __imag__ x * __imag__ x
+ 1.0);
__real__ res = (2.0 * __real__ x) / den;
__imag__ res = (2.0 * __imag__ x) / den;
}
return res;
}
weak_alias (__cprojl, cprojl)
@@ -0,0 +1,131 @@
/* Complex sine function for double.
Copyright (C) 1997 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, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <complex.h>
#include <fenv.h>
#include <math.h>
#include "math_private.h"
__complex__ double
__csin (__complex__ double x)
{
__complex__ double retval;
int negate = signbit (__real__ x);
int rcls = fpclassify (__real__ x);
int icls = fpclassify (__imag__ x);
__real__ x = fabs (__real__ x);
if (icls >= FP_ZERO)
{
/* Imaginary part is finite. */
if (rcls >= FP_ZERO)
{
/* Real part is finite. */
double sinh_val = __ieee754_sinh (__imag__ x);
double cosh_val = __ieee754_cosh (__imag__ x);
double sinix, cosix;
__sincos (__real__ x, &sinix, &cosix);
__real__ retval = cosh_val * sinix;
__imag__ retval = sinh_val * cosix;
if (negate)
__real__ retval = -__real__ retval;
}
else
{
if (icls == FP_ZERO)
{
/* Imaginary part is 0.0. */
__real__ retval = __nan ("");
__imag__ retval = __imag__ x;
#ifdef FE_INVALID
if (rcls == FP_INFINITE)
feraiseexcept (FE_INVALID);
#endif
}
else
{
__real__ retval = __nan ("");
__imag__ retval = __nan ("");
#ifdef FE_INVALID
feraiseexcept (FE_INVALID);
#endif
}
}
}
else if (icls == FP_INFINITE)
{
/* Imaginary part is infinite. */
if (rcls == FP_ZERO)
{
/* Real part is 0.0. */
__real__ retval = __copysign (0.0, negate ? -1.0 : 1.0);
__imag__ retval = __imag__ x;
}
else if (rcls > FP_ZERO)
{
/* Real part is finite. */
double sinix, cosix;
__sincos (__real__ x, &sinix, &cosix);
__real__ retval = __copysign (HUGE_VAL, sinix);
__imag__ retval = __copysign (HUGE_VAL, cosix);
if (negate)
__real__ retval = -__real__ retval;
if (signbit (__imag__ x))
__imag__ retval = -__imag__ retval;
}
else
{
/* The addition raises the invalid exception. */
__real__ retval = __nan ("");
__imag__ retval = HUGE_VAL;
#ifdef FE_INVALID
if (rcls == FP_INFINITE)
feraiseexcept (FE_INVALID);
#endif
}
}
else
{
if (rcls == FP_ZERO)
__real__ retval = __copysign (0.0, negate ? -1.0 : 1.0);
else
__real__ retval = __nan ("");
__imag__ retval = __nan ("");
}
return retval;
}
weak_alias (__csin, csin)
#ifdef NO_LONG_DOUBLE
strong_alias (__csin, __csinl)
weak_alias (__csin, csinl)
#endif
@@ -0,0 +1,129 @@
/* Complex sine function for float.
Copyright (C) 1997 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, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <complex.h>
#include <fenv.h>
#include <math.h>
#include "math_private.h"
__complex__ float
__csinf (__complex__ float x)
{
__complex__ float retval;
int negate = signbit (__real__ x);
int rcls = fpclassify (__real__ x);
int icls = fpclassify (__imag__ x);
__real__ x = fabsf (__real__ x);
if (icls >= FP_ZERO)
{
/* Imaginary part is finite. */
if (rcls >= FP_ZERO)
{
/* Real part is finite. */
float sinh_val = __ieee754_sinhf (__imag__ x);
float cosh_val = __ieee754_coshf (__imag__ x);
float sinix, cosix;
__sincosf (__real__ x, &sinix, &cosix);
__real__ retval = cosh_val * sinix;
__imag__ retval = sinh_val * cosix;
if (negate)
__real__ retval = -__real__ retval;
}
else
{
if (icls == FP_ZERO)
{
/* Imaginary part is 0.0. */
__real__ retval = __nanf ("");
__imag__ retval = __imag__ x;
#ifdef FE_INVALID
if (rcls == FP_INFINITE)
feraiseexcept (FE_INVALID);
#endif
}
else
{
__real__ retval = __nanf ("");
__imag__ retval = __nanf ("");
#ifdef FE_INVALID
feraiseexcept (FE_INVALID);
#endif
}
}
}
else if (icls == FP_INFINITE)
{
/* Imaginary part is infinite. */
if (rcls == FP_ZERO)
{
/* Real part is 0.0. */
__real__ retval = __copysignf (0.0, negate ? -1.0 : 1.0);
__imag__ retval = __imag__ x;
}
else if (rcls > FP_ZERO)
{
/* Real part is finite. */
float sinix, cosix;
__sincosf (__real__ x, &sinix, &cosix);
__real__ retval = __copysignf (HUGE_VALF, sinix);
__imag__ retval = __copysignf (HUGE_VALF, cosix);
if (negate)
__real__ retval = -__real__ retval;
if (signbit (__imag__ x))
__imag__ retval = -__imag__ retval;
}
else
{
/* The addition raises the invalid exception. */
__real__ retval = __nanf ("");
__imag__ retval = HUGE_VALF;
#ifdef FE_INVALID
if (rcls == FP_INFINITE)
feraiseexcept (FE_INVALID);
#endif
}
}
else
{
if (rcls == FP_ZERO)
__real__ retval = __copysignf (0.0, negate ? -1.0 : 1.0);
else
__real__ retval = __nanf ("");
__imag__ retval = __nanf ("");
}
return retval;
}
#ifndef __csinf
weak_alias (__csinf, csinf)
#endif
@@ -0,0 +1,126 @@
/* Complex sine hyperbole function for double.
Copyright (C) 1997 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, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <complex.h>
#include <fenv.h>
#include <math.h>
#include "math_private.h"
__complex__ double
__csinh (__complex__ double x)
{
__complex__ double retval;
int negate = signbit (__real__ x);
int rcls = fpclassify (__real__ x);
int icls = fpclassify (__imag__ x);
__real__ x = fabs (__real__ x);
if (rcls >= FP_ZERO)
{
/* Real part is finite. */
if (icls >= FP_ZERO)
{
/* Imaginary part is finite. */
double sinh_val = __ieee754_sinh (__real__ x);
double cosh_val = __ieee754_cosh (__real__ x);
double sinix, cosix;
__sincos (__imag__ x, &sinix, &cosix);
__real__ retval = sinh_val * cosix;
__imag__ retval = cosh_val * sinix;
if (negate)
__real__ retval = -__real__ retval;
}
else
{
if (rcls == FP_ZERO)
{
/* Real part is 0.0. */
__real__ retval = __copysign (0.0, negate ? -1.0 : 1.0);
__imag__ retval = __nan ("") + __nan ("");
#ifdef FE_INVALID
if (icls == FP_INFINITE)
feraiseexcept (FE_INVALID);
#endif
}
else
{
__real__ retval = __nan ("");
__imag__ retval = __nan ("");
#ifdef FE_INVALID
feraiseexcept (FE_INVALID);
#endif
}
}
}
else if (rcls == FP_INFINITE)
{
/* Real part is infinite. */
if (icls == FP_ZERO)
{
/* Imaginary part is 0.0. */
__real__ retval = negate ? -HUGE_VAL : HUGE_VAL;
__imag__ retval = __imag__ x;
}
else if (icls > FP_ZERO)
{
/* Imaginary part is finite. */
double sinix, cosix;
__sincos (__imag__ x, &sinix, &cosix);
__real__ retval = __copysign (HUGE_VAL, cosix);
__imag__ retval = __copysign (HUGE_VAL, sinix);
if (negate)
__real__ retval = -__real__ retval;
}
else
{
/* The addition raises the invalid exception. */
__real__ retval = HUGE_VAL;
__imag__ retval = __nan ("") + __nan ("");
#ifdef FE_INVALID
if (icls == FP_INFINITE)
feraiseexcept (FE_INVALID);
#endif
}
}
else
{
__real__ retval = __nan ("");
__imag__ retval = __imag__ x == 0.0 ? __imag__ x : __nan ("");
}
return retval;
}
weak_alias (__csinh, csinh)
#ifdef NO_LONG_DOUBLE
strong_alias (__csinh, __csinhl)
weak_alias (__csinh, csinhl)
#endif
@@ -0,0 +1,124 @@
/* Complex sine hyperbole function for float.
Copyright (C) 1997 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, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <complex.h>
#include <fenv.h>
#include <math.h>
#include "math_private.h"
__complex__ float
__csinhf (__complex__ float x)
{
__complex__ float retval;
int negate = signbit (__real__ x);
int rcls = fpclassify (__real__ x);
int icls = fpclassify (__imag__ x);
__real__ x = fabsf (__real__ x);
if (rcls >= FP_ZERO)
{
/* Real part is finite. */
if (icls >= FP_ZERO)
{
/* Imaginary part is finite. */
float sinh_val = __ieee754_sinhf (__real__ x);
float cosh_val = __ieee754_coshf (__real__ x);
float sinix, cosix;
__sincosf (__imag__ x, &sinix, &cosix);
__real__ retval = sinh_val * cosix;
__imag__ retval = cosh_val * sinix;
if (negate)
__real__ retval = -__real__ retval;
}
else
{
if (rcls == FP_ZERO)
{
/* Real part is 0.0. */
__real__ retval = __copysignf (0.0, negate ? -1.0 : 1.0);
__imag__ retval = __nanf ("") + __nanf ("");
#ifdef FE_INVALID
if (icls == FP_INFINITE)
feraiseexcept (FE_INVALID);
#endif
}
else
{
__real__ retval = __nanf ("");
__imag__ retval = __nanf ("");
#ifdef FE_INVALID
feraiseexcept (FE_INVALID);
#endif
}
}
}
else if (rcls == FP_INFINITE)
{
/* Real part is infinite. */
if (icls == FP_ZERO)
{
/* Imaginary part is 0.0. */
__real__ retval = negate ? -HUGE_VALF : HUGE_VALF;
__imag__ retval = __imag__ x;
}
else if (icls > FP_ZERO)
{
/* Imaginary part is finite. */
float sinix, cosix;
__sincosf (__imag__ x, &sinix, &cosix);
__real__ retval = __copysignf (HUGE_VALF, cosix);
__imag__ retval = __copysignf (HUGE_VALF, sinix);
if (negate)
__real__ retval = -__real__ retval;
}
else
{
/* The addition raises the invalid exception. */
__real__ retval = HUGE_VALF;
__imag__ retval = __nanf ("") + __nanf ("");
#ifdef FE_INVALID
if (icls == FP_INFINITE)
feraiseexcept (FE_INVALID);
#endif
}
}
else
{
__real__ retval = __nanf ("");
__imag__ retval = __imag__ x == 0.0 ? __imag__ x : __nanf ("");
}
return retval;
}
#ifndef __csinhf
weak_alias (__csinhf, csinhf)
#endif
@@ -0,0 +1,122 @@
/* Complex sine hyperbole function for long double.
Copyright (C) 1997 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, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <complex.h>
#include <fenv.h>
#include <math.h>
#include "math_private.h"
__complex__ long double
__csinhl (__complex__ long double x)
{
__complex__ long double retval;
int negate = signbit (__real__ x);
int rcls = fpclassify (__real__ x);
int icls = fpclassify (__imag__ x);
__real__ x = fabsl (__real__ x);
if (rcls >= FP_ZERO)
{
/* Real part is finite. */
if (icls >= FP_ZERO)
{
/* Imaginary part is finite. */
long double sinh_val = __ieee754_sinhl (__real__ x);
long double cosh_val = __ieee754_coshl (__real__ x);
long double sinix, cosix;
__sincosl (__imag__ x, &sinix, &cosix);
__real__ retval = sinh_val * cosix;
__imag__ retval = cosh_val * sinix;
if (negate)
__real__ retval = -__real__ retval;
}
else
{
if (rcls == FP_ZERO)
{
/* Real part is 0.0. */
__real__ retval = __copysignl (0.0, negate ? -1.0 : 1.0);
__imag__ retval = __nanl ("") + __nanl ("");
#ifdef FE_INVALID
if (icls == FP_INFINITE)
feraiseexcept (FE_INVALID);
#endif
}
else
{
__real__ retval = __nanl ("");
__imag__ retval = __nanl ("");
#ifdef FE_INVALID
feraiseexcept (FE_INVALID);
#endif
}
}
}
else if (rcls == FP_INFINITE)
{
/* Real part is infinite. */
if (icls == FP_ZERO)
{
/* Imaginary part is 0.0. */
__real__ retval = negate ? -HUGE_VALL : HUGE_VALL;
__imag__ retval = __imag__ x;
}
else if (icls > FP_ZERO)
{
/* Imaginary part is finite. */
long double sinix, cosix;
__sincosl (__imag__ x, &sinix, &cosix);
__real__ retval = __copysignl (HUGE_VALL, cosix);
__imag__ retval = __copysignl (HUGE_VALL, sinix);
if (negate)
__real__ retval = -__real__ retval;
}
else
{
/* The addition raises the invalid exception. */
__real__ retval = HUGE_VALL;
__imag__ retval = __nanl ("") + __nanl ("");
#ifdef FE_INVALID
if (icls == FP_INFINITE)
feraiseexcept (FE_INVALID);
#endif
}
}
else
{
__real__ retval = __nanl ("");
__imag__ retval = __imag__ x == 0.0 ? __imag__ x : __nanl ("");
}
return retval;
}
weak_alias (__csinhl, csinhl)
@@ -0,0 +1,127 @@
/* Complex sine function for long double.
Copyright (C) 1997 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, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <complex.h>
#include <fenv.h>
#include <math.h>
#include "math_private.h"
__complex__ long double
__csinl (__complex__ long double x)
{
__complex__ long double retval;
int negate = signbit (__real__ x);
int rcls = fpclassify (__real__ x);
int icls = fpclassify (__imag__ x);
__real__ x = fabsl (__real__ x);
if (icls >= FP_ZERO)
{
/* Imaginary part is finite. */
if (rcls >= FP_ZERO)
{
/* Real part is finite. */
long double sinh_val = __ieee754_sinhl (__imag__ x);
long double cosh_val = __ieee754_coshl (__imag__ x);
long double sinix, cosix;
__sincosl (__real__ x, &sinix, &cosix);
__real__ retval = cosh_val * sinix;
__imag__ retval = sinh_val * cosix;
if (negate)
__real__ retval = -__real__ retval;
}
else
{
if (icls == FP_ZERO)
{
/* Imaginary part is 0.0. */
__real__ retval = __nanl ("");
__imag__ retval = __imag__ x;
#ifdef FE_INVALID
if (rcls == FP_INFINITE)
feraiseexcept (FE_INVALID);
#endif
}
else
{
__real__ retval = __nanl ("");
__imag__ retval = __nanl ("");
#ifdef FE_INVALID
feraiseexcept (FE_INVALID);
#endif
}
}
}
else if (icls == FP_INFINITE)
{
/* Imaginary part is infinite. */
if (rcls == FP_ZERO)
{
/* Real part is 0.0. */
__real__ retval = __copysignl (0.0, negate ? -1.0 : 1.0);
__imag__ retval = __imag__ x;
}
else if (rcls > FP_ZERO)
{
/* Real part is finite. */
long double sinix, cosix;
__sincosl (__real__ x, &sinix, &cosix);
__real__ retval = __copysignl (HUGE_VALL, sinix);
__imag__ retval = __copysignl (HUGE_VALL, cosix);
if (negate)
__real__ retval = -__real__ retval;
if (signbit (__imag__ x))
__imag__ retval = -__imag__ retval;
}
else
{
/* The addition raises the invalid exception. */
__real__ retval = __nanl ("");
__imag__ retval = HUGE_VALL;
#ifdef FE_INVALID
if (rcls == FP_INFINITE)
feraiseexcept (FE_INVALID);
#endif
}
}
else
{
if (rcls == FP_ZERO)
__real__ retval = __copysignl (0.0, negate ? -1.0 : 1.0);
else
__real__ retval = __nanl ("");
__imag__ retval = __nanl ("");
}
return retval;
}
weak_alias (__csinl, csinl)
@@ -0,0 +1,74 @@
/* Complex tangent function for double.
Copyright (C) 1997 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, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <complex.h>
#include <fenv.h>
#include <math.h>
#include "math_private.h"
__complex__ double
__ctan (__complex__ double x)
{
__complex__ double res;
if (!isfinite (__real__ x) || !isfinite (__imag__ x))
{
if (__isinf (__imag__ x))
{
__real__ res = __copysign (0.0, __real__ x);
__imag__ res = __copysign (1.0, __imag__ x);
}
else if (__real__ x == 0.0)
{
res = x;
}
else
{
__real__ res = __nan ("");
__imag__ res = __nan ("");
#ifdef FE_INVALID
if (__isinf (__real__ x))
feraiseexcept (FE_INVALID);
#endif
}
}
else
{
double sin2rx, cos2rx;
double den;
__sincos (2.0 * __real__ x, &sin2rx, &cos2rx);
den = cos2rx + __ieee754_cosh (2.0 * __imag__ x);
__real__ res = sin2rx / den;
__imag__ res = __ieee754_sinh (2.0 * __imag__ x) / den;
}
return res;
}
weak_alias (__ctan, ctan)
#ifdef NO_LONG_DOUBLE
strong_alias (__ctan, __ctanl)
weak_alias (__ctan, ctanl)
#endif
@@ -0,0 +1,72 @@
/* Complex tangent function for float.
Copyright (C) 1997 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, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <complex.h>
#include <fenv.h>
#include <math.h>
#include "math_private.h"
__complex__ float
__ctanf (__complex__ float x)
{
__complex__ float res;
if (!isfinite (__real__ x) || !isfinite (__imag__ x))
{
if (__isinff (__imag__ x))
{
__real__ res = __copysignf (0.0, __real__ x);
__imag__ res = __copysignf (1.0, __imag__ x);
}
else if (__real__ x == 0.0)
{
res = x;
}
else
{
__real__ res = __nanf ("");
__imag__ res = __nanf ("");
#ifdef FE_INVALID
if (__isinff (__real__ x))
feraiseexcept (FE_INVALID);
#endif
}
}
else
{
float sin2rx, cos2rx;
float den;
__sincosf (2.0 * __real__ x, &sin2rx, &cos2rx);
den = cos2rx + __ieee754_coshf (2.0 * __imag__ x);
__real__ res = sin2rx / den;
__imag__ res = __ieee754_sinhf (2.0 * __imag__ x) / den;
}
return res;
}
#ifndef __ctanf
weak_alias (__ctanf, ctanf)
#endif
@@ -0,0 +1,74 @@
/* Complex hyperbole tangent for double.
Copyright (C) 1997 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, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <complex.h>
#include <fenv.h>
#include <math.h>
#include "math_private.h"
__complex__ double
__ctanh (__complex__ double x)
{
__complex__ double res;
if (!isfinite (__real__ x) || !isfinite (__imag__ x))
{
if (__isinf (__real__ x))
{
__real__ res = __copysign (1.0, __real__ x);
__imag__ res = __copysign (0.0, __imag__ x);
}
else if (__imag__ x == 0.0)
{
res = x;
}
else
{
__real__ res = __nan ("");
__imag__ res = __nan ("");
#ifdef FE_INVALID
if (__isinf (__imag__ x))
feraiseexcept (FE_INVALID);
#endif
}
}
else
{
double sin2ix, cos2ix;
double den;
__sincos (2.0 * __imag__ x, &sin2ix, &cos2ix);
den = (__ieee754_cosh (2.0 * __real__ x) + cos2ix);
__real__ res = __ieee754_sinh (2.0 * __real__ x) / den;
__imag__ res = sin2ix / den;
}
return res;
}
weak_alias (__ctanh, ctanh)
#ifdef NO_LONG_DOUBLE
strong_alias (__ctanh, __ctanhl)
weak_alias (__ctanh, ctanhl)
#endif
@@ -0,0 +1,72 @@
/* Complex hyperbole tangent for float.
Copyright (C) 1997 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, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <complex.h>
#include <fenv.h>
#include <math.h>
#include "math_private.h"
__complex__ float
__ctanhf (__complex__ float x)
{
__complex__ float res;
if (!isfinite (__real__ x) || !isfinite (__imag__ x))
{
if (__isinff (__real__ x))
{
__real__ res = __copysignf (1.0, __real__ x);
__imag__ res = __copysignf (0.0, __imag__ x);
}
else if (__imag__ x == 0.0)
{
res = x;
}
else
{
__real__ res = __nanf ("");
__imag__ res = __nanf ("");
#ifdef FE_INVALID
if (__isinff (__imag__ x))
feraiseexcept (FE_INVALID);
#endif
}
}
else
{
float sin2ix, cos2ix;
float den;
__sincosf (2.0 * __imag__ x, &sin2ix, &cos2ix);
den = (__ieee754_coshf (2.0 * __real__ x) + cos2ix);
__real__ res = __ieee754_sinhf (2.0 * __real__ x) / den;
__imag__ res = sin2ix / den;
}
return res;
}
#ifndef __ctanhf
weak_alias (__ctanhf, ctanhf)
#endif
@@ -0,0 +1,70 @@
/* Complex hyperbole tangent for long double.
Copyright (C) 1997 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, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <complex.h>
#include <fenv.h>
#include <math.h>
#include "math_private.h"
__complex__ long double
__ctanhl (__complex__ long double x)
{
__complex__ long double res;
if (!isfinite (__real__ x) || !isfinite (__imag__ x))
{
if (__isinfl (__real__ x))
{
__real__ res = __copysignl (1.0, __real__ x);
__imag__ res = __copysignl (0.0, __imag__ x);
}
else if (__imag__ x == 0.0)
{
res = x;
}
else
{
__real__ res = __nanl ("");
__imag__ res = __nanl ("");
#ifdef FE_INVALID
if (__isinfl (__imag__ x))
feraiseexcept (FE_INVALID);
#endif
}
}
else
{
long double sin2ix, cos2ix;
long double den;
__sincosl (2.0 * __imag__ x, &sin2ix, &cos2ix);
den = (__ieee754_coshl (2.0 * __real__ x) + cos2ix);
__real__ res = __ieee754_sinhl (2.0 * __real__ x) / den;
__imag__ res = sin2ix / den;
}
return res;
}
weak_alias (__ctanhl, ctanhl)
@@ -0,0 +1,70 @@
/* Complex tangent function for long double.
Copyright (C) 1997 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, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <complex.h>
#include <fenv.h>
#include <math.h>
#include "math_private.h"
__complex__ long double
__ctanl (__complex__ long double x)
{
__complex__ long double res;
if (!isfinite (__real__ x) || !isfinite (__imag__ x))
{
if (__isinfl (__imag__ x))
{
__real__ res = __copysignl (0.0, __real__ x);
__imag__ res = __copysignl (1.0, __imag__ x);
}
else if (__real__ x == 0.0)
{
res = x;
}
else
{
__real__ res = __nanl ("");
__imag__ res = __nanl ("");
#ifdef FE_INVALID
if (__isinfl (__real__ x))
feraiseexcept (FE_INVALID);
#endif
}
}
else
{
long double sin2rx, cos2rx;
long double den;
__sincosl (2.0 * __real__ x, &sin2rx, &cos2rx);
den = cos2rx + __ieee754_coshl (2.0 * __imag__ x);
__real__ res = sin2rx / den;
__imag__ res = __ieee754_sinhl (2.0 * __imag__ x) / den;
}
return res;
}
weak_alias (__ctanl, ctanl)
@@ -0,0 +1,40 @@
/* @(#)s_fabs.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* Developed at SunPro, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
#if defined(LIBM_SCCS) && !defined(lint)
static char rcsid[] = "$NetBSD: s_fabs.c,v 1.7 1995/05/10 20:47:13 jtc Exp $";
#endif
/*
* fabs(x) returns the absolute value of x.
*/
#include "math.h"
#include "math_private.h"
#ifdef __STDC__
double __fabs(double x)
#else
double __fabs(x)
double x;
#endif
{
u_int32_t high;
GET_HIGH_WORD(high,x);
SET_HIGH_WORD(x,high&0x7fffffff);
return x;
}
weak_alias (__fabs, fabs)
#ifdef NO_LONG_DOUBLE
strong_alias (__fabs, __fabsl)
weak_alias (__fabs, fabsl)
#endif
@@ -0,0 +1,39 @@
/* s_fabsf.c -- float version of s_fabs.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, [email protected].
*/
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* Developed at SunPro, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
#if defined(LIBM_SCCS) && !defined(lint)
static char rcsid[] = "$NetBSD: s_fabsf.c,v 1.4 1995/05/10 20:47:15 jtc Exp $";
#endif
/*
* fabsf(x) returns the absolute value of x.
*/
#include "math.h"
#include "math_private.h"
#ifdef __STDC__
float __fabsf(float x)
#else
float __fabsf(x)
float x;
#endif
{
u_int32_t ix;
GET_FLOAT_WORD(ix,x);
SET_FLOAT_WORD(x,ix&0x7fffffff);
return x;
}
weak_alias (__fabsf, fabsf)
@@ -0,0 +1,100 @@
/* @(#)s_nextafter.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* Developed at SunPro, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
#if defined(LIBM_SCCS) && !defined(lint)
static char rcsid[] = "$NetBSD: s_nextafter.c,v 1.8 1995/05/10 20:47:58 jtc Exp $";
#endif
/* IEEE functions
* nextafter(x,y)
* return the next machine floating-point number of x in the
* direction toward y.
* Special cases:
*/
/* Ugly hack so that the aliasing works. */
#define __nexttoward __internal___nexttoward
#define nexttoward __internal_nexttoward
#include "math.h"
#include "math_private.h"
#include <float.h>
#ifdef __STDC__
double __nextafter(double x, double y)
#else
double __nextafter(x,y)
double x,y;
#endif
{
int32_t hx,hy,ix,iy;
u_int32_t lx,ly;
EXTRACT_WORDS(hx,lx,x);
EXTRACT_WORDS(hy,ly,y);
ix = hx&0x7fffffff; /* |x| */
iy = hy&0x7fffffff; /* |y| */
if(((ix>=0x7ff00000)&&((ix-0x7ff00000)|lx)!=0) || /* x is nan */
((iy>=0x7ff00000)&&((iy-0x7ff00000)|ly)!=0)) /* y is nan */
return x+y;
if(x==y) return y; /* x=y, return y */
if((ix|lx)==0) { /* x == 0 */
INSERT_WORDS(x,hy&0x80000000,1); /* return +-minsubnormal */
y = x*x;
if(y==x) return y; else return x; /* raise underflow flag */
}
if(hx>=0) { /* x > 0 */
if(hx>hy||((hx==hy)&&(lx>ly))) { /* x > y, x -= ulp */
if(lx==0) hx -= 1;
lx -= 1;
} else { /* x < y, x += ulp */
lx += 1;
if(lx==0) hx += 1;
}
} else { /* x < 0 */
if(hy>=0||hx>hy||((hx==hy)&&(lx>ly))){/* x < y, x -= ulp */
if(lx==0) hx -= 1;
lx -= 1;
} else { /* x > y, x += ulp */
lx += 1;
if(lx==0) hx += 1;
}
}
hy = hx&0x7ff00000;
if(hy>=0x7ff00000) {
x = x+x; /* overflow */
if (FLT_EVAL_METHOD != 0 && FLT_EVAL_METHOD != 1)
asm ("" : "=m"(x) : "m"(x));
return x; /* overflow */
}
if(hy<0x00100000) { /* underflow */
y = x*x;
if(y!=x) { /* raise underflow flag */
INSERT_WORDS(y,hx,lx);
return y;
}
}
INSERT_WORDS(x,hx,lx);
return x;
}
weak_alias (__nextafter, nextafter)
#ifdef NO_LONG_DOUBLE
strong_alias (__nextafter, __nextafterl)
weak_alias (__nextafter, nextafterl)
strong_alias (__nextafter, __nexttowardl)
weak_alias (__nexttowardl, nexttowardl)
#undef __nexttoward
strong_alias (__nextafter, __nexttoward)
#undef nexttoward
weak_alias (__nextafter, nexttoward)
#endif
@@ -37,8 +37,17 @@ local genericSources =
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_erf.c s_erff.c # s_erfl.c
s_fpclassify.c s_fpclassifyf.c # s_fpclassifyl.c
s_isinf.c s_isinff.c
@@ -46,6 +55,7 @@ local genericSources =
s_ldexp.c s_ldexpf.c #s_ldexpl.c
s_modf.c s_modff.c # s_modfl.c
s_nan.c s_nanf.c
s_nextafter.c
s_signbit.c s_signbitl.c
s_round.c s_roundf.c # s_roundl.c
s_signgam.c
@@ -82,6 +92,7 @@ local genericSources =
MergeObject posix_gnu_arch_$(TARGET_ARCH)_other.o :
add_n.S
addmul_1.S
fraiseexcpt.c
ldbl2mpn.c
mpa.c mpatan.c mpatan2.c mptan.c
@@ -118,6 +129,7 @@ MergeObject posix_gnu_arch_$(TARGET_ARCH)_s.o :
s_atan.S s_atanf.S s_atanl.c
s_cbrt.S s_cbrtf.S s_cbrtl.S
s_ceil.S s_ceilf.S s_ceill.S
s_cexp.S s_cexpf.S s_cexpl.S
s_copysign.S s_copysignf.S s_copysignl.S
s_cos.S s_cosf.S s_cosl.S
s_expm1.S s_expm1f.S s_expm1l.S
@@ -0,0 +1,124 @@
/* Raise given exceptions.
Copyright (C) 1997,99,2000,01,02 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, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <fenv.h>
#include <math.h>
int
__feraiseexcept (int excepts)
{
/* Raise exceptions represented by EXPECTS. But we must raise only
one signal at a time. It is important that if the overflow/underflow
exception and the inexact exception are given at the same time,
the overflow/underflow exception follows the inexact exception. */
/* First: invalid exception. */
if ((FE_INVALID & excepts) != 0)
{
/* One example of a invalid operation is 0.0 / 0.0. */
double d;
__asm__ __volatile__ ("fldz; fdiv %%st, %%st(0); fwait" : "=t" (d));
(void) &d;
}
/* Next: division by zero. */
if ((FE_DIVBYZERO & excepts) != 0)
{
double d;
__asm__ __volatile__ ("fldz; fld1; fdivp %%st, %%st(1); fwait"
: "=t" (d));
(void) &d;
}
/* Next: overflow. */
if ((FE_OVERFLOW & excepts) != 0)
{
/* There is no way to raise only the overflow flag. Do it the
hard way. */
fenv_t temp;
/* Bah, we have to clear selected exceptions. Since there is no
`fldsw' instruction we have to do it the hard way. */
__asm__ __volatile__ ("fnstenv %0" : "=m" (*&temp));
/* Set the relevant bits. */
temp.__status_word |= FE_OVERFLOW;
/* Put the new data in effect. */
__asm__ __volatile__ ("fldenv %0" : : "m" (*&temp));
/* And raise the exception. */
__asm__ __volatile__ ("fwait");
}
/* Next: underflow. */
if ((FE_UNDERFLOW & excepts) != 0)
{
/* There is no way to raise only the underflow flag. Do it the
hard way. */
fenv_t temp;
/* Bah, we have to clear selected exceptions. Since there is no
`fldsw' instruction we have to do it the hard way. */
__asm__ __volatile__ ("fnstenv %0" : "=m" (*&temp));
/* Set the relevant bits. */
temp.__status_word |= FE_UNDERFLOW;
/* Put the new data in effect. */
__asm__ __volatile__ ("fldenv %0" : : "m" (*&temp));
/* And raise the exception. */
__asm__ __volatile__ ("fwait");
}
/* Last: inexact. */
if ((FE_INEXACT & excepts) != 0)
{
/* There is no way to raise only the inexact flag. Do it the
hard way. */
fenv_t temp;
/* Bah, we have to clear selected exceptions. Since there is no
`fldsw' instruction we have to do it the hard way. */
__asm__ __volatile__ ("fnstenv %0" : "=m" (*&temp));
/* Set the relevant bits. */
temp.__status_word |= FE_INEXACT;
/* Put the new data in effect. */
__asm__ __volatile__ ("fldenv %0" : : "m" (*&temp));
/* And raise the exception. */
__asm__ __volatile__ ("fwait");
}
/* Success. */
return 0;
}
#include <shlib-compat.h>
#if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_2)
strong_alias (__feraiseexcept, __old_feraiseexcept)
compat_symbol (libm, __old_feraiseexcept, feraiseexcept, GLIBC_2_1);
#endif
libm_hidden_ver (__feraiseexcept, feraiseexcept)
versioned_symbol (libm, __feraiseexcept, feraiseexcept, GLIBC_2_2);
@@ -0,0 +1,259 @@
/* ix87 specific implementation of complex exponential function for double.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 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, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <sysdep.h>
#ifdef __ELF__
.section .rodata
#else
.text
#endif
.align ALIGNARG(4)
ASM_TYPE_DIRECTIVE(huge_nan_null_null,@object)
huge_nan_null_null:
.byte 0, 0, 0, 0, 0, 0, 0xf0, 0x7f
.byte 0, 0, 0, 0, 0, 0, 0xff, 0x7f
.double 0.0
zero: .double 0.0
infinity:
.byte 0, 0, 0, 0, 0, 0, 0xf0, 0x7f
.byte 0, 0, 0, 0, 0, 0, 0xff, 0x7f
.double 0.0
.byte 0, 0, 0, 0, 0, 0, 0, 0x80
ASM_SIZE_DIRECTIVE(huge_nan_null_null)
ASM_TYPE_DIRECTIVE(twopi,@object)
twopi:
.byte 0x35, 0xc2, 0x68, 0x21, 0xa2, 0xda, 0xf, 0xc9, 0x1, 0x40
.byte 0, 0, 0, 0, 0, 0
ASM_SIZE_DIRECTIVE(twopi)
ASM_TYPE_DIRECTIVE(l2e,@object)
l2e:
.byte 0xbc, 0xf0, 0x17, 0x5c, 0x29, 0x3b, 0xaa, 0xb8, 0xff, 0x3f
.byte 0, 0, 0, 0, 0, 0
ASM_SIZE_DIRECTIVE(l2e)
ASM_TYPE_DIRECTIVE(one,@object)
one: .double 1.0
ASM_SIZE_DIRECTIVE(one)
#ifdef PIC
#define MO(op) op##@GOTOFF(%ecx)
#define MOX(op,x,f) op##@GOTOFF(%ecx,x,f)
#else
#define MO(op) op
#define MOX(op,x,f) op(,x,f)
#endif
.text
ENTRY(__cexp)
fldl 8(%esp) /* x */
fxam
fnstsw
fldl 16(%esp) /* y : x */
#ifdef PIC
call 1f
1: popl %ecx
addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %ecx
#endif
movb %ah, %dh
andb $0x45, %ah
cmpb $0x05, %ah
je 1f /* Jump if real part is +-Inf */
cmpb $0x01, %ah
je 2f /* Jump if real part is NaN */
fxam /* y : x */
fnstsw
/* If the imaginary part is not finite we return NaN+i NaN, as
for the case when the real part is NaN. A test for +-Inf and
NaN would be necessary. But since we know the stack register
we applied `fxam' to is not empty we can simply use one test.
Check your FPU manual for more information. */
andb $0x01, %ah
cmpb $0x01, %ah
je 20f
/* We have finite numbers in the real and imaginary part. Do
the real work now. */
fxch /* x : y */
fldt MO(l2e) /* log2(e) : x : y */
fmulp /* x * log2(e) : y */
fld %st /* x * log2(e) : x * log2(e) : y */
frndint /* int(x * log2(e)) : x * log2(e) : y */
fsubr %st, %st(1) /* int(x * log2(e)) : frac(x * log2(e)) : y */
fxch /* frac(x * log2(e)) : int(x * log2(e)) : y */
f2xm1 /* 2^frac(x * log2(e))-1 : int(x * log2(e)) : y */
faddl MO(one) /* 2^frac(x * log2(e)) : int(x * log2(e)) : y */
fscale /* e^x : int(x * log2(e)) : y */
fst %st(1) /* e^x : e^x : y */
fxch %st(2) /* y : e^x : e^x */
fsincos /* cos(y) : sin(y) : e^x : e^x */
fnstsw
testl $0x400, %eax
jnz 7f
fmulp %st, %st(3) /* sin(y) : e^x : e^x * cos(y) */
fmulp %st, %st(1) /* e^x * sin(y) : e^x * cos(y) */
movl 4(%esp), %eax /* Pointer to memory for result. */
fstpl 8(%eax)
fstpl (%eax)
ret $4
/* We have to reduce the argument to fsincos. */
.align ALIGNARG(4)
7: fldt MO(twopi) /* 2*pi : y : e^x : e^x */
fxch /* y : 2*pi : e^x : e^x */
8: fprem1 /* y%(2*pi) : 2*pi : e^x : e^x */
fnstsw
testl $0x400, %eax
jnz 8b
fstp %st(1) /* y%(2*pi) : e^x : e^x */
fsincos /* cos(y) : sin(y) : e^x : e^x */
fmulp %st, %st(3)
fmulp %st, %st(1)
movl 4(%esp), %eax /* Pointer to memory for result. */
fstpl 8(%eax)
fstpl (%eax)
ret $4
/* The real part is +-inf. We must make further differences. */
.align ALIGNARG(4)
1: fxam /* y : x */
fnstsw
movb %ah, %dl
testb $0x01, %ah /* See above why 0x01 is usable here. */
jne 3f
/* The real part is +-Inf and the imaginary part is finite. */
andl $0x245, %edx
cmpb $0x40, %dl /* Imaginary part == 0? */
je 4f /* Yes -> */
fxch /* x : y */
shrl $5, %edx
fstp %st(0) /* y */ /* Drop the real part. */
andl $16, %edx /* This puts the sign bit of the real part
in bit 4. So we can use it to index a
small array to select 0 or Inf. */
fsincos /* cos(y) : sin(y) */
fnstsw
testl $0x0400, %eax
jnz 5f
fldl MOX(huge_nan_null_null,%edx,1)
movl 4(%esp), %edx /* Pointer to memory for result. */
fstl 8(%edx)
fstpl (%edx)
ftst
fnstsw
shll $23, %eax
andl $0x80000000, %eax
orl %eax, 4(%edx)
fstp %st(0)
ftst
fnstsw
shll $23, %eax
andl $0x80000000, %eax
orl %eax, 12(%edx)
fstp %st(0)
ret $4
/* We must reduce the argument to fsincos. */
.align ALIGNARG(4)
5: fldt MO(twopi)
fxch
6: fprem1
fnstsw
testl $0x400, %eax
jnz 6b
fstp %st(1)
fsincos
fldl MOX(huge_nan_null_null,%edx,1)
movl 4(%esp), %edx /* Pointer to memory for result. */
fstl 8(%edx)
fstpl (%edx)
ftst
fnstsw
shll $23, %eax
andl $0x80000000, %eax
orl %eax, 4(%edx)
fstp %st(0)
ftst
fnstsw
shll $23, %eax
andl $0x80000000, %eax
orl %eax, 12(%edx)
fstp %st(0)
ret $4
/* The real part is +-Inf and the imaginary part is +-0. So return
+-Inf+-0i. */
.align ALIGNARG(4)
4: movl 4(%esp), %eax /* Pointer to memory for result. */
fstpl 8(%eax)
shrl $5, %edx
fstp %st(0)
andl $16, %edx
fldl MOX(huge_nan_null_null,%edx,1)
fstpl (%eax)
ret $4
/* The real part is +-Inf, the imaginary is also is not finite. */
.align ALIGNARG(4)
3: fstp %st(0)
fstp %st(0) /* <empty> */
andb $0x45, %ah
andb $0x47, %dh
xorb %dh, %ah
jnz 30f
fldl MO(infinity) /* Raise invalid exception. */
fmull MO(zero)
fstp %st(0)
30: movl %edx, %eax
shrl $5, %edx
shll $4, %eax
andl $16, %edx
andl $32, %eax
orl %eax, %edx
movl 4(%esp), %eax /* Pointer to memory for result. */
fldl MOX(huge_nan_null_null,%edx,1)
fldl MOX(huge_nan_null_null+8,%edx,1)
fxch
fstpl (%eax)
fstpl 8(%eax)
ret $4
/* The real part is NaN. */
.align ALIGNARG(4)
20: fldl MO(infinity) /* Raise invalid exception. */
fmull MO(zero)
fstp %st(0)
2: fstp %st(0)
fstp %st(0)
movl 4(%esp), %eax /* Pointer to memory for result. */
fldl MO(huge_nan_null_null+8)
fstl (%eax)
fstpl 8(%eax)
ret $4
END(__cexp)
weak_alias (__cexp, cexp)
@@ -0,0 +1,255 @@
/* ix87 specific implementation of complex exponential function for double.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 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, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <sysdep.h>
#ifdef __ELF__
.section .rodata
#else
.text
#endif
.align ALIGNARG(4)
ASM_TYPE_DIRECTIVE(huge_nan_null_null,@object)
huge_nan_null_null:
.byte 0, 0, 0x80, 0x7f
.byte 0, 0, 0xc0, 0x7f
.float 0.0
zero: .float 0.0
infinity:
.byte 0, 0, 0x80, 0x7f
.byte 0, 0, 0xc0, 0x7f
.float 0.0
.byte 0, 0, 0, 0x80
ASM_SIZE_DIRECTIVE(huge_nan_null_null)
ASM_TYPE_DIRECTIVE(twopi,@object)
twopi:
.byte 0x35, 0xc2, 0x68, 0x21, 0xa2, 0xda, 0xf, 0xc9, 0x1, 0x40
.byte 0, 0, 0, 0, 0, 0
ASM_SIZE_DIRECTIVE(twopi)
ASM_TYPE_DIRECTIVE(l2e,@object)
l2e:
.byte 0xbc, 0xf0, 0x17, 0x5c, 0x29, 0x3b, 0xaa, 0xb8, 0xff, 0x3f
.byte 0, 0, 0, 0, 0, 0
ASM_SIZE_DIRECTIVE(l2e)
ASM_TYPE_DIRECTIVE(one,@object)
one: .double 1.0
ASM_SIZE_DIRECTIVE(one)
#ifdef PIC
#define MO(op) op##@GOTOFF(%ecx)
#define MOX(op,x,f) op##@GOTOFF(%ecx,x,f)
#else
#define MO(op) op
#define MOX(op,x,f) op(,x,f)
#endif
.text
ENTRY(__cexpf)
flds 4(%esp) /* x */
fxam
fnstsw
flds 8(%esp) /* y : x */
#ifdef PIC
call 1f
1: popl %ecx
addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %ecx
#endif
movb %ah, %dh
andb $0x45, %ah
cmpb $0x05, %ah
je 1f /* Jump if real part is +-Inf */
cmpb $0x01, %ah
je 2f /* Jump if real part is NaN */
fxam /* y : x */
fnstsw
/* If the imaginary part is not finite we return NaN+i NaN, as
for the case when the real part is NaN. A test for +-Inf and
NaN would be necessary. But since we know the stack register
we applied `fxam' to is not empty we can simply use one test.
Check your FPU manual for more information. */
andb $0x01, %ah
cmpb $0x01, %ah
je 20f
/* We have finite numbers in the real and imaginary part. Do
the real work now. */
fxch /* x : y */
fldt MO(l2e) /* log2(e) : x : y */
fmulp /* x * log2(e) : y */
fld %st /* x * log2(e) : x * log2(e) : y */
frndint /* int(x * log2(e)) : x * log2(e) : y */
fsubr %st, %st(1) /* int(x * log2(e)) : frac(x * log2(e)) : y */
fxch /* frac(x * log2(e)) : int(x * log2(e)) : y */
f2xm1 /* 2^frac(x * log2(e))-1 : int(x * log2(e)) : y */
faddl MO(one) /* 2^frac(x * log2(e)) : int(x * log2(e)) : y */
fscale /* e^x : int(x * log2(e)) : y */
fst %st(1) /* e^x : e^x : y */
fxch %st(2) /* y : e^x : e^x */
fsincos /* cos(y) : sin(y) : e^x : e^x */
fnstsw
testl $0x400, %eax
jnz 7f
fmulp %st, %st(3) /* sin(y) : e^x : e^x * cos(y) */
fmulp %st, %st(1) /* e^x * sin(y) : e^x * cos(y) */
subl $8, %esp
fstps 4(%esp)
fstps (%esp)
popl %eax
popl %edx
ret
/* We have to reduce the argument to fsincos. */
.align ALIGNARG(4)
7: fldt MO(twopi) /* 2*pi : y : e^x : e^x */
fxch /* y : 2*pi : e^x : e^x */
8: fprem1 /* y%(2*pi) : 2*pi : e^x : e^x */
fnstsw
testl $0x400, %eax
jnz 8b
fstp %st(1) /* y%(2*pi) : e^x : e^x */
fsincos /* cos(y) : sin(y) : e^x : e^x */
fmulp %st, %st(3)
fmulp %st, %st(1)
subl $8, %esp
fstps 4(%esp)
fstps (%esp)
popl %eax
popl %edx
ret
/* The real part is +-inf. We must make further differences. */
.align ALIGNARG(4)
1: fxam /* y : x */
fnstsw
movb %ah, %dl
testb $0x01, %ah /* See above why 0x01 is usable here. */
jne 3f
/* The real part is +-Inf and the imaginary part is finite. */
andl $0x245, %edx
cmpb $0x40, %dl /* Imaginary part == 0? */
je 4f /* Yes -> */
fxch /* x : y */
shrl $6, %edx
fstp %st(0) /* y */ /* Drop the real part. */
andl $8, %edx /* This puts the sign bit of the real part
in bit 3. So we can use it to index a
small array to select 0 or Inf. */
fsincos /* cos(y) : sin(y) */
fnstsw
testl $0x0400, %eax
jnz 5f
fxch
ftst
fnstsw
fstp %st(0)
shll $23, %eax
andl $0x80000000, %eax
orl MOX(huge_nan_null_null,%edx,1), %eax
movl MOX(huge_nan_null_null,%edx,1), %ecx
movl %eax, %edx
ftst
fnstsw
fstp %st(0)
shll $23, %eax
andl $0x80000000, %eax
orl %ecx, %eax
ret
/* We must reduce the argument to fsincos. */
.align ALIGNARG(4)
5: fldt MO(twopi)
fxch
6: fprem1
fnstsw
testl $0x400, %eax
jnz 6b
fstp %st(1)
fsincos
fxch
ftst
fnstsw
fstp %st(0)
shll $23, %eax
andl $0x80000000, %eax
orl MOX(huge_nan_null_null,%edx,1), %eax
movl MOX(huge_nan_null_null,%edx,1), %ecx
movl %eax, %edx
ftst
fnstsw
fstp %st(0)
shll $23, %eax
andl $0x80000000, %eax
orl %ecx, %eax
ret
/* The real part is +-Inf and the imaginary part is +-0. So return
+-Inf+-0i. */
.align ALIGNARG(4)
4: subl $4, %esp
fstps (%esp)
shrl $6, %edx
fstp %st(0)
andl $8, %edx
movl MOX(huge_nan_null_null,%edx,1), %eax
popl %edx
ret
/* The real part is +-Inf, the imaginary is also is not finite. */
.align ALIGNARG(4)
3: fstp %st(0)
fstp %st(0) /* <empty> */
andb $0x45, %ah
andb $0x47, %dh
xorb %dh, %ah
jnz 30f
flds MO(infinity) /* Raise invalid exception. */
fmuls MO(zero)
fstp %st(0)
30: movl %edx, %eax
shrl $6, %edx
shll $3, %eax
andl $8, %edx
andl $16, %eax
orl %eax, %edx
movl MOX(huge_nan_null_null,%edx,1), %eax
movl MOX(huge_nan_null_null+4,%edx,1), %edx
ret
/* The real part is NaN. */
.align ALIGNARG(4)
20: flds MO(infinity) /* Raise invalid exception. */
fmuls MO(zero)
fstp %st(0)
2: fstp %st(0)
fstp %st(0)
movl MO(huge_nan_null_null+4), %eax
movl %eax, %edx
ret
END(__cexpf)
weak_alias (__cexpf, cexpf)
@@ -0,0 +1,262 @@
/* ix87 specific implementation of complex exponential function for double.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 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, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <sysdep.h>
#ifdef __ELF__
.section .rodata
#else
.text
#endif
.align ALIGNARG(4)
ASM_TYPE_DIRECTIVE(huge_nan_null_null,@object)
huge_nan_null_null:
.byte 0, 0, 0, 0, 0, 0, 0xf0, 0x7f
.byte 0, 0, 0, 0, 0, 0, 0xff, 0x7f
.double 0.0
zero: .double 0.0
infinity:
.byte 0, 0, 0, 0, 0, 0, 0xf0, 0x7f
.byte 0, 0, 0, 0, 0, 0, 0xff, 0x7f
.double 0.0
.byte 0, 0, 0, 0, 0, 0, 0, 0x80
ASM_SIZE_DIRECTIVE(huge_nan_null_null)
ASM_TYPE_DIRECTIVE(twopi,@object)
twopi:
.byte 0x35, 0xc2, 0x68, 0x21, 0xa2, 0xda, 0xf, 0xc9, 0x1, 0x40
.byte 0, 0, 0, 0, 0, 0
ASM_SIZE_DIRECTIVE(twopi)
ASM_TYPE_DIRECTIVE(l2e,@object)
l2e:
.byte 0xbc, 0xf0, 0x17, 0x5c, 0x29, 0x3b, 0xaa, 0xb8, 0xff, 0x3f
.byte 0, 0, 0, 0, 0, 0
ASM_SIZE_DIRECTIVE(l2e)
ASM_TYPE_DIRECTIVE(one,@object)
one: .double 1.0
ASM_SIZE_DIRECTIVE(one)
#ifdef PIC
#define MO(op) op##@GOTOFF(%ecx)
#define MOX(op,x,f) op##@GOTOFF(%ecx,x,f)
#else
#define MO(op) op
#define MOX(op,x,f) op(,x,f)
#endif
.text
ENTRY(__cexpl)
fldt 8(%esp) /* x */
fxam
fnstsw
fldt 20(%esp) /* y : x */
#ifdef PIC
call 1f
1: popl %ecx
addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %ecx
#endif
movb %ah, %dh
andb $0x45, %ah
cmpb $0x05, %ah
je 1f /* Jump if real part is +-Inf */
cmpb $0x01, %ah
je 2f /* Jump if real part is NaN */
fxam /* y : x */
fnstsw
/* If the imaginary part is not finite we return NaN+i NaN, as
for the case when the real part is NaN. A test for +-Inf and
NaN would be necessary. But since we know the stack register
we applied `fxam' to is not empty we can simply use one test.
Check your FPU manual for more information. */
andb $0x01, %ah
cmpb $0x01, %ah
je 20f
/* We have finite numbers in the real and imaginary part. Do
the real work now. */
fxch /* x : y */
fldt MO(l2e) /* log2(e) : x : y */
fmulp /* x * log2(e) : y */
fld %st /* x * log2(e) : x * log2(e) : y */
frndint /* int(x * log2(e)) : x * log2(e) : y */
fsubr %st, %st(1) /* int(x * log2(e)) : frac(x * log2(e)) : y */
fxch /* frac(x * log2(e)) : int(x * log2(e)) : y */
f2xm1 /* 2^frac(x * log2(e))-1 : int(x * log2(e)) : y */
faddl MO(one) /* 2^frac(x * log2(e)) : int(x * log2(e)) : y */
fscale /* e^x : int(x * log2(e)) : y */
fst %st(1) /* e^x : e^x : y */
fxch %st(2) /* y : e^x : e^x */
fsincos /* cos(y) : sin(y) : e^x : e^x */
fnstsw
testl $0x400, %eax
jnz 7f
fmulp %st, %st(3) /* sin(y) : e^x : e^x * cos(y) */
fmulp %st, %st(1) /* e^x * sin(y) : e^x * cos(y) */
movl 4(%esp), %eax /* Pointer to memory for result. */
fstpt 12(%eax)
fstpt (%eax)
ret $4
/* We have to reduce the argument to fsincos. */
.align ALIGNARG(4)
7: fldt MO(twopi) /* 2*pi : y : e^x : e^x */
fxch /* y : 2*pi : e^x : e^x */
8: fprem1 /* y%(2*pi) : 2*pi : e^x : e^x */
fnstsw
testl $0x400, %eax
jnz 8b
fstp %st(1) /* y%(2*pi) : e^x : e^x */
fsincos /* cos(y) : sin(y) : e^x : e^x */
fmulp %st, %st(3)
fmulp %st, %st(1)
movl 4(%esp), %eax /* Pointer to memory for result. */
fstpt 12(%eax)
fstpt (%eax)
ret $4
/* The real part is +-inf. We must make further differences. */
.align ALIGNARG(4)
1: fxam /* y : x */
fnstsw
movb %ah, %dl
testb $0x01, %ah /* See above why 0x01 is usable here. */
jne 3f
/* The real part is +-Inf and the imaginary part is finite. */
andl $0x245, %edx
cmpb $0x40, %dl /* Imaginary part == 0? */
je 4f /* Yes -> */
fxch /* x : y */
shrl $5, %edx
fstp %st(0) /* y */ /* Drop the real part. */
andl $16, %edx /* This puts the sign bit of the real part
in bit 4. So we can use it to index a
small array to select 0 or Inf. */
fsincos /* cos(y) : sin(y) */
fnstsw
testl $0x0400, %eax
jnz 5f
fldl MOX(huge_nan_null_null,%edx,1)
movl 4(%esp), %edx /* Pointer to memory for result. */
fld %st
fstpt 12(%edx)
fstpt (%edx)
ftst
fnstsw
shll $7, %eax
andl $0x8000, %eax
orl %eax, 8(%edx)
fstp %st(0)
ftst
fnstsw
shll $7, %eax
andl $0x8000, %eax
orl %eax, 20(%edx)
fstp %st(0)
ret $4
/* We must reduce the argument to fsincos. */
.align ALIGNARG(4)
5: fldt MO(twopi)
fxch
6: fprem1
fnstsw
testl $0x400, %eax
jnz 6b
fstp %st(1)
fsincos
fldl MOX(huge_nan_null_null,%edx,1)
movl 4(%esp), %edx /* Pointer to memory for result. */
fld %st
fstpt 12(%edx)
fstpt (%edx)
ftst
fnstsw
shll $7, %eax
andl $0x8000, %eax
orl %eax, 8(%edx)
fstp %st(0)
ftst
fnstsw
shll $7, %eax
andl $0x8000, %eax
orl %eax, 20(%edx)
fstp %st(0)
ret $4
/* The real part is +-Inf and the imaginary part is +-0. So return
+-Inf+-0i. */
.align ALIGNARG(4)
4: movl 4(%esp), %eax /* Pointer to memory for result. */
fstpt 12(%eax)
shrl $5, %edx
fstp %st(0)
andl $16, %edx
fldl MOX(huge_nan_null_null,%edx,1)
fstpt (%eax)
ret $4
/* The real part is +-Inf, the imaginary is also is not finite. */
.align ALIGNARG(4)
3: fstp %st(0)
fstp %st(0) /* <empty> */
andb $0x45, %ah
andb $0x47, %dh
xorb %dh, %ah
jnz 30f
fldl MO(infinity) /* Raise invalid exception. */
fmull MO(zero)
fstp %st(0)
30: movl %edx, %eax
shrl $5, %edx
shll $4, %eax
andl $16, %edx
andl $32, %eax
orl %eax, %edx
movl 4(%esp), %eax /* Pointer to memory for result. */
fldl MOX(huge_nan_null_null,%edx,1)
fldl MOX(huge_nan_null_null+8,%edx,1)
fxch
fstpt (%eax)
fstpt 12(%eax)
ret $4
/* The real part is NaN. */
.align ALIGNARG(4)
20: fldl MO(infinity) /* Raise invalid exception. */
fmull MO(zero)
fstp %st(0)
2: fstp %st(0)
fstp %st(0)
movl 4(%esp), %eax /* Pointer to memory for result. */
fldl MO(huge_nan_null_null+8)
fld %st(0)
fstpt (%eax)
fstpt 12(%eax)
ret $4
END(__cexpl)
weak_alias (__cexpl, cexpl)
@@ -0,0 +1,77 @@
/* s_nextafterf.c -- float version of s_nextafter.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, [email protected].
*/
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* Developed at SunPro, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
#if defined(LIBM_SCCS) && !defined(lint)
static char rcsid[] = "$NetBSD: s_nextafterf.c,v 1.4 1995/05/10 20:48:01 jtc Exp $";
#endif
#include "math.h"
#include "math_private.h"
#include <float.h>
#ifdef __STDC__
float __nextafterf(float x, float y)
#else
float __nextafterf(x,y)
float x,y;
#endif
{
int32_t hx,hy,ix,iy;
GET_FLOAT_WORD(hx,x);
GET_FLOAT_WORD(hy,y);
ix = hx&0x7fffffff; /* |x| */
iy = hy&0x7fffffff; /* |y| */
if((ix>0x7f800000) || /* x is nan */
(iy>0x7f800000)) /* y is nan */
return x+y;
if(x==y) return y; /* x=y, return y */
if(ix==0) { /* x == 0 */
SET_FLOAT_WORD(x,(hy&0x80000000)|1);/* return +-minsubnormal */
y = x*x;
if(y==x) return y; else return x; /* raise underflow flag */
}
if(hx>=0) { /* x > 0 */
if(hx>hy) { /* x > y, x -= ulp */
hx -= 1;
} else { /* x < y, x += ulp */
hx += 1;
}
} else { /* x < 0 */
if(hy>=0||hx>hy){ /* x < y, x -= ulp */
hx -= 1;
} else { /* x > y, x += ulp */
hx += 1;
}
}
hy = hx&0x7f800000;
if(hy>=0x7f800000) {
x = x+x; /* overflow */
if (FLT_EVAL_METHOD != 0)
asm ("" : "=m"(x) : "m"(x));
return x; /* overflow */
}
if(hy<0x00800000) { /* underflow */
y = x*x;
if(y!=x) { /* raise underflow flag */
SET_FLOAT_WORD(y,hx);
return y;
}
}
SET_FLOAT_WORD(x,hx);
return x;
}
weak_alias (__nextafterf, nextafterf)
@@ -0,0 +1,2 @@
/* Nothing to do. This function is the same as scalbn. So we define an
alias. */
@@ -0,0 +1,2 @@
/* Nothing to do. This function is the same as scalbnf. So we define an
alias. */
@@ -0,0 +1,90 @@
/* Copyright (C) 1997, 1998, 1999, 2000 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, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#ifndef _FENV_H
# error "Never use <bits/fenv.h> directly; include <fenv.h> instead."
#endif
/* Define bits representing the exception. We use the bit positions
of the appropriate bits in the FPU control word. */
enum
{
FE_INVALID = 0x01,
#define FE_INVALID FE_INVALID
__FE_DENORM = 0x02,
FE_DIVBYZERO = 0x04,
#define FE_DIVBYZERO FE_DIVBYZERO
FE_OVERFLOW = 0x08,
#define FE_OVERFLOW FE_OVERFLOW
FE_UNDERFLOW = 0x10,
#define FE_UNDERFLOW FE_UNDERFLOW
FE_INEXACT = 0x20
#define FE_INEXACT FE_INEXACT
};
#define FE_ALL_EXCEPT \
(FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID)
/* The ix87 FPU supports all of the four defined rounding modes. We
use again the bit positions in the FPU control word as the values
for the appropriate macros. */
enum
{
FE_TONEAREST = 0,
#define FE_TONEAREST FE_TONEAREST
FE_DOWNWARD = 0x400,
#define FE_DOWNWARD FE_DOWNWARD
FE_UPWARD = 0x800,
#define FE_UPWARD FE_UPWARD
FE_TOWARDZERO = 0xc00
#define FE_TOWARDZERO FE_TOWARDZERO
};
/* Type representing exception flags. */
typedef unsigned short int fexcept_t;
/* Type representing floating-point environment. This function corresponds
to the layout of the block written by the `fstenv'. */
typedef struct
{
unsigned short int __control_word;
unsigned short int __unused1;
unsigned short int __status_word;
unsigned short int __unused2;
unsigned short int __tags;
unsigned short int __unused3;
unsigned int __eip;
unsigned short int __cs_selector;
unsigned int __opcode:11;
unsigned int __unused4:5;
unsigned int __data_offset;
unsigned short int __data_selector;
unsigned short int __unused5;
}
fenv_t;
/* If the default argument is used we use this value. */
#define FE_DFL_ENV ((__const fenv_t *) -1)
#ifdef __USE_GNU
/* Floating-point environment where none of the exception is masked. */
# define FE_NOMASK_ENV ((__const fenv_t *) -2)
#endif
@@ -0,0 +1,8 @@
/* This file provides inline versions of floating-pint environment
handling functions. If there were any. */
#ifndef __NO_MATH_INLINES
/* Here is where the code would go. */
#endif
@@ -2,19 +2,19 @@
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.
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 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.
Library 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, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#if !defined _MATH_H && !defined _COMPLEX_H
# error "Never use <bits/mathdef.h> directly; include <math.h> instead"
@@ -31,6 +31,9 @@ typedef long double float_t; /* `float' expressions are evaluated as
typedef long double double_t; /* `double' expressions are evaluated as
`long double'. */
/* Signal that both types are `long double'. */
# define FLT_EVAL_METHOD 2
/* Define `INFINITY' as value of type `float'. */
# define INFINITY HUGE_VALF
@@ -38,4 +41,7 @@ typedef long double double_t; /* `double' expressions are evaluated as
# define FP_ILOGB0 (-2147483647 - 1)
# define FP_ILOGBNAN (-2147483647 - 1)
/* Number of decimal digits for the `long double' type. */
# define DECIMAL_DIG 21
#endif /* ISO C99 */