Commit 1e38f159 by Paul Brook Committed by Paul Brook

re PR fortran/16303 (Complex logarithm function sometimes chooses a non-principal branch)

	PR fortran/16303
	* m4/cexp.m4 (carg): Return -pi to pi.
	* generated/exp_c?.c: Regenerate.

From-SVN: r84516
parent 0bbf5891
2004-07-11 Paul Brook <paul@codesourcery.com>
PR fortran/16303
* m4/cexp.m4 (carg): Return -pi to pi.
* generated/exp_c?.c: Regenerate.
2004-07-08 Andreas Krebbel <krebbel1@de.ibm.com> 2004-07-08 Andreas Krebbel <krebbel1@de.ibm.com>
PR fortran/16291 PR fortran/16291
......
...@@ -30,17 +30,14 @@ cabsf (GFC_COMPLEX_4 z) ...@@ -30,17 +30,14 @@ cabsf (GFC_COMPLEX_4 z)
return hypotf (REALPART (z), IMAGPART (z)); return hypotf (REALPART (z), IMAGPART (z));
} }
/* Complex argument. The angle made with the +ve real axis. Range 0-2pi. */ /* Complex argument. The angle made with the +ve real axis.
Range -pi-pi. */
GFC_REAL_4 GFC_REAL_4
cargf (GFC_COMPLEX_4 z) cargf (GFC_COMPLEX_4 z)
{ {
GFC_REAL_4 arg; GFC_REAL_4 arg;
arg = atan2f (IMAGPART (z), REALPART (z)); return atan2f (IMAGPART (z), REALPART (z));
if (arg < 0)
return arg + 2 * M_PI;
else
return arg;
} }
/* exp(z) = exp(a)*(cos(b) + isin(b)) */ /* exp(z) = exp(a)*(cos(b) + isin(b)) */
......
...@@ -30,17 +30,14 @@ cabs (GFC_COMPLEX_8 z) ...@@ -30,17 +30,14 @@ cabs (GFC_COMPLEX_8 z)
return hypot (REALPART (z), IMAGPART (z)); return hypot (REALPART (z), IMAGPART (z));
} }
/* Complex argument. The angle made with the +ve real axis. Range 0-2pi. */ /* Complex argument. The angle made with the +ve real axis.
Range -pi-pi. */
GFC_REAL_8 GFC_REAL_8
carg (GFC_COMPLEX_8 z) carg (GFC_COMPLEX_8 z)
{ {
GFC_REAL_8 arg; GFC_REAL_8 arg;
arg = atan2 (IMAGPART (z), REALPART (z)); return atan2 (IMAGPART (z), REALPART (z));
if (arg < 0)
return arg + 2 * M_PI;
else
return arg;
} }
/* exp(z) = exp(a)*(cos(b) + isin(b)) */ /* exp(z) = exp(a)*(cos(b) + isin(b)) */
......
...@@ -31,17 +31,14 @@ cabs`'q (complex_type z) ...@@ -31,17 +31,14 @@ cabs`'q (complex_type z)
return hypot`'q (REALPART (z), IMAGPART (z)); return hypot`'q (REALPART (z), IMAGPART (z));
} }
/* Complex argument. The angle made with the +ve real axis. Range 0-2pi. */ /* Complex argument. The angle made with the +ve real axis.
Range -pi-pi. */
real_type real_type
carg`'q (complex_type z) carg`'q (complex_type z)
{ {
real_type arg; real_type arg;
arg = atan2`'q (IMAGPART (z), REALPART (z)); return atan2`'q (IMAGPART (z), REALPART (z));
if (arg < 0)
return arg + 2 * M_PI;
else
return arg;
} }
/* exp(z) = exp(a)*(cos(b) + isin(b)) */ /* exp(z) = exp(a)*(cos(b) + isin(b)) */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment