date and time created 83/01/21 11:20:10 by dlw
authorDavid Wasley <dlw@ucbvax.Berkeley.EDU>
Sat, 22 Jan 1983 03:20:10 +0000 (19:20 -0800)
committerDavid Wasley <dlw@ucbvax.Berkeley.EDU>
Sat, 22 Jan 1983 03:20:10 +0000 (19:20 -0800)
SCCS-vsn: usr.bin/f77/libF77/z_div.c 1.1

usr/src/usr.bin/f77/libF77/z_div.c [new file with mode: 0644]

diff --git a/usr/src/usr.bin/f77/libF77/z_div.c b/usr/src/usr.bin/f77/libF77/z_div.c
new file mode 100644 (file)
index 0000000..fa47fe7
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ *     "@(#)z_div.c    1.1"
+ */
+
+#include "complex"
+
+z_div(c, a, b)
+dcomplex *a, *b, *c;
+{
+double ratio, den;
+double abr, abi;
+
+if( (abr = b->dreal) < 0.)
+       abr = - abr;
+if( (abi = b->dimag) < 0.)
+       abi = - abi;
+if( abr <= abi )
+       {
+       if(abi == 0)
+               abort(); /* fatal("complex division by zero"); */
+       ratio = b->dreal / b->dimag ;
+       den = b->dimag * (1 + ratio*ratio);
+       c->dreal = (a->dreal*ratio + a->dimag) / den;
+       c->dimag = (a->dimag*ratio - a->dreal) / den;
+       }
+
+else
+       {
+       ratio = b->dimag / b->dreal ;
+       den = b->dreal * (1 + ratio*ratio);
+       c->dreal = (a->dreal + a->dimag*ratio) / den;
+       c->dimag = (a->dimag - a->dreal*ratio) / den;
+       }
+
+}