diff options
author | fxcoudert <fxcoudert@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-09-25 21:39:58 +0000 |
---|---|---|
committer | fxcoudert <fxcoudert@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-09-25 21:39:58 +0000 |
commit | d213114b2a5d70c391d65ba42095ca8c4b49c46c (patch) | |
tree | 03f679a4e6e5541f1f29cf7b38a296b55f8061f8 /libgfortran/m4 | |
parent | 0c39c16d21f7ff3867d5ae79cb413fc498aff866 (diff) | |
download | gcc-d213114b2a5d70c391d65ba42095ca8c4b49c46c.tar.gz |
* c99_protos.h: Add prototypes for C99 complex functions.
* libgfortran.h: Include complex.h before c99_protos.h.
* intrinsics/c99_functions.c: Define HAVE_ macros for the
fallback functions we provide.
(cabsf, cabs, cabsl, cargf, carg, cargl, cexpf, cexp, cexpl,
clogf, clog, clogl, clog10f, clog10, clog10l, cpowf, cpow, cpowl,
cqsrtf, csqrt, csqrtl, csinhf, csinh, csinhl, ccoshf, ccosh,
ccoshl, ctanhf, ctanh, ctanhl, csinf, csin, csinl, ccosf, ccos,
ccosl, ctanf, ctan, ctanl): New fallback functions.
* Makefile.am (gfor_math_trig_c, gfor_math_trig_obj,
gfor_specific_c, gfor_cmath_src, gfor_cmath_obj): Remove.
* Makefile.in: Regenerate.
* configure.ac: Remove checks for csin. Add checks for all C99
complex functions.
* config.h.in: Regenerate.
* configure: Regenerate.
* aclocal.m4: Regenerate.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@104626 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran/m4')
-rw-r--r-- | libgfortran/m4/cexp.m4 | 146 | ||||
-rw-r--r-- | libgfortran/m4/chyp.m4 | 81 | ||||
-rw-r--r-- | libgfortran/m4/ctrig.m4 | 81 |
3 files changed, 0 insertions, 308 deletions
diff --git a/libgfortran/m4/cexp.m4 b/libgfortran/m4/cexp.m4 deleted file mode 100644 index eda0a256077..00000000000 --- a/libgfortran/m4/cexp.m4 +++ /dev/null @@ -1,146 +0,0 @@ -`/* Complex exponential functions - Copyright 2002, 2004 Free Software Foundation, Inc. - Contributed by Paul Brook <paul@nowt.org> - -This file is part of the GNU Fortran 95 runtime library (libgfortran). - -Libgfortran is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -In addition to the permissions in the GNU General Public License, the -Free Software Foundation gives you unlimited permission to link the -compiled version of this file into combinations with other programs, -and to distribute those combinations without any restriction coming -from the use of this file. (The General Public License restrictions -do apply in other respects; for example, they cover modification of -the file, and distribution when not linked into a combine -executable.) - -Libgfortran 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 General Public License for more details. - -You should have received a copy of the GNU General Public -License along with libgfortran; see the file COPYING. If not, -write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -Boston, MA 02110-1301, USA. */ -#include <math.h> -#include "libgfortran.h"' - -include(`mtype.m4')dnl - -/* z = a + ib */ -/* Absolute value. */ -real_type -cabs`'q (complex_type z) -{ - return hypot`'q (REALPART (z), IMAGPART (z)); -} - -/* Complex argument. The angle made with the +ve real axis. - Range -pi-pi. */ -real_type -carg`'q (complex_type z) -{ - real_type arg; - - return atan2`'q (IMAGPART (z), REALPART (z)); -} - -/* exp(z) = exp(a)*(cos(b) + isin(b)) */ -complex_type -cexp`'q (complex_type z) -{ - real_type a; - real_type b; - complex_type v; - - a = REALPART (z); - b = IMAGPART (z); - COMPLEX_ASSIGN (v, cos`'q (b), sin`'q (b)); - return exp`'q (a) * v; -} - -/* log(z) = log (cabs(z)) + i*carg(z) */ -complex_type -clog`'q (complex_type z) -{ - complex_type v; - - COMPLEX_ASSIGN (v, log`'q (cabs`'q (z)), carg`'q (z)); - return v; -} - -/* log10(z) = log10 (cabs(z)) + i*carg(z) */ -complex_type -clog10`'q (complex_type z) -{ - complex_type v; - - COMPLEX_ASSIGN (v, log10`'q (cabs`'q (z)), carg`'q (z)); - return v; -} - -/* pow(base, power) = cexp (power * clog (base)) */ -complex_type -cpow`'q (complex_type base, complex_type power) -{ - return cexp`'q (power * clog`'q (base)); -} - -/* sqrt(z). Algorithm pulled from glibc. */ -complex_type -csqrt`'q (complex_type z) -{ - real_type re; - real_type im; - complex_type v; - - re = REALPART (z); - im = IMAGPART (z); - if (im == 0.0) - { - if (re < 0.0) - { - COMPLEX_ASSIGN (v, 0.0, copysign`'q (sqrt`'q (-re), im)); - } - else - { - COMPLEX_ASSIGN (v, fabs`'q (sqrt`'q (re)), - copysign`'q (0.0, im)); - } - } - else if (re == 0.0) - { - real_type r; - - r = sqrt`'q (0.5 * fabs`'q (im)); - - COMPLEX_ASSIGN (v, copysign`'q (r, im), r); - } - else - { - real_type d, r, s; - - d = hypot`'q (re, im); - /* Use the identity 2 Re res Im res = Im x - to avoid cancellation error in d +/- Re x. */ - if (re > 0) - { - r = sqrt`'q (0.5 * d + 0.5 * re); - s = (0.5 * im) / r; - } - else - { - s = sqrt`'q (0.5 * d - 0.5 * re); - r = fabs`'q ((0.5 * im) / s); - } - - COMPLEX_ASSIGN (v, r, copysign`'q (s, im)); - } - return v; -} - diff --git a/libgfortran/m4/chyp.m4 b/libgfortran/m4/chyp.m4 deleted file mode 100644 index f520fa40987..00000000000 --- a/libgfortran/m4/chyp.m4 +++ /dev/null @@ -1,81 +0,0 @@ -`/* Complex hyperbolic functions - Copyright 2002 Free Software Foundation, Inc. - Contributed by Paul Brook <paul@nowt.org> - -This file is part of the GNU Fortran 95 runtime library (libgfortran). - -Libgfortran is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -In addition to the permissions in the GNU General Public License, the -Free Software Foundation gives you unlimited permission to link the -compiled version of this file into combinations with other programs, -and to distribute those combinations without any restriction coming -from the use of this file. (The General Public License restrictions -do apply in other respects; for example, they cover modification of -the file, and distribution when not linked into a combine -executable.) - -Libgfortran 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 General Public License for more details. - -You should have received a copy of the GNU General Public -License along with libgfortran; see the file COPYING. If not, -write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -Boston, MA 02110-1301, USA. */ -#include <math.h> -#include "libgfortran.h"' - -include(`mtype.m4')dnl - -/* Complex number z = a + ib. */ - -/* sinh(z) = sinh(a)cos(b) + icosh(a)sin(b) */ -complex_type -csinh`'q (complex_type a) -{ - real_type r; - real_type i; - complex_type v; - - r = REALPART (a); - i = IMAGPART (a); - COMPLEX_ASSIGN (v, sinh`'q (r) * cos`'q (i), cosh`'q (r) * sin`'q (i)); - return v; -} - -/* cosh(z) = cosh(a)cos(b) - isinh(a)sin(b) */ -complex_type -ccosh`'q (complex_type a) -{ - real_type r; - real_type i; - complex_type v; - - r = REALPART (a); - i = IMAGPART (a); - COMPLEX_ASSIGN (v, cosh`'q (r) * cos`'q (i), - (sinh`'q (r) * sin`'q (i))); - return v; -} - -/* tanh(z) = (tanh(a) + itan(b)) / (1 - itanh(a)tan(b)) */ -complex_type -ctanh`'q (complex_type a) -{ - real_type rt; - real_type it; - complex_type n; - complex_type d; - - rt = tanh`'q (REALPART (a)); - it = tan`'q (IMAGPART (a)); - COMPLEX_ASSIGN (n, rt, it); - COMPLEX_ASSIGN (d, 1, - (rt * it)); - - return n / d; -} - diff --git a/libgfortran/m4/ctrig.m4 b/libgfortran/m4/ctrig.m4 deleted file mode 100644 index 9b2429c7f26..00000000000 --- a/libgfortran/m4/ctrig.m4 +++ /dev/null @@ -1,81 +0,0 @@ -`/* Complex trig functions - Copyright 2002 Free Software Foundation, Inc. - Contributed by Paul Brook <paul@nowt.org> - -This file is part of the GNU Fortran 95 runtime library (libgfortran). - -Libgfortran is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -In addition to the permissions in the GNU General Public License, the -Free Software Foundation gives you unlimited permission to link the -compiled version of this file into combinations with other programs, -and to distribute those combinations without any restriction coming -from the use of this file. (The General Public License restrictions -do apply in other respects; for example, they cover modification of -the file, and distribution when not linked into a combine -executable.) - -Libgfortran 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 General Public License for more details. - -You should have received a copy of the GNU General Public -License along with libgfortran; see the file COPYING. If not, -write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -Boston, MA 02110-1301, USA. */ -#include <math.h> -#include "libgfortran.h"' - -include(`mtype.m4')dnl - -/* Complex number z = a + ib. */ - -/* sin(z) = sin(a)cosh(b) + icos(a)sinh(b) */ -complex_type -csin`'q (complex_type a) -{ - real_type r; - real_type i; - complex_type v; - - r = REALPART (a); - i = IMAGPART (a); - COMPLEX_ASSIGN (v, sin`'q (r) * cosh`'q (i), cos`'q (r) * sinh`'q (i)); - return v; -} - -/* cos(z) = cos(a)cosh(b) - isin(a)sinh(b) */ -complex_type -ccos`'q (complex_type a) -{ - real_type r; - real_type i; - complex_type v; - - r = REALPART (a); - i = IMAGPART (a); - COMPLEX_ASSIGN (v, cos`'q (r) * cosh`'q (i), - (sin`'q (r) * sinh`'q (i))); - return v; -} - -/* tan(z) = (tan(a) + itanh(b)) / (1 - itan(a)tanh(b)) */ -complex_type -ctan`'q (complex_type a) -{ - real_type rt; - real_type it; - complex_type n; - complex_type d; - - rt = tan`'q (REALPART (a)); - it = tanh`'q (IMAGPART (a)); - COMPLEX_ASSIGN (n, rt, it); - COMPLEX_ASSIGN (d , 1, - (rt * it)); - - return n / d; -} - |