summaryrefslogtreecommitdiffstats
path: root/contrib/libf2c/libF77/cabs.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/libf2c/libF77/cabs.c')
-rw-r--r--contrib/libf2c/libF77/cabs.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/contrib/libf2c/libF77/cabs.c b/contrib/libf2c/libF77/cabs.c
new file mode 100644
index 0000000..5d2142e
--- /dev/null
+++ b/contrib/libf2c/libF77/cabs.c
@@ -0,0 +1,24 @@
+#undef abs
+#include <math.h>
+double
+f__cabs (double real, double imag)
+{
+ double temp;
+
+ if (real < 0)
+ real = -real;
+ if (imag < 0)
+ imag = -imag;
+ if (imag > real)
+ {
+ temp = real;
+ real = imag;
+ imag = temp;
+ }
+ if ((real + imag) == real)
+ return (real);
+
+ temp = imag / real;
+ temp = real * sqrt (1.0 + temp * temp); /*overflow!! */
+ return (temp);
+}
OpenPOWER on IntegriCloud