1: /*
2: * Copyright (c) 1980 Regents of the University of California.
3: * All rights reserved. The Berkeley software License Agreement
4: * specifies the terms and conditions for redistribution.
5: *
6: * @(#)c_div.c 5.1 6/7/85
7: */
8:
9: #include "complex"
10: #include <stdio.h>
11: #include <errno.h>
12:
13: c_div(c, a, b)
14: complex *a, *b, *c;
15: {
16: double ratio, den;
17: double abr, abi;
18:
19: if( (abr = b->real) < 0.)
20: abr = - abr;
21: if( (abi = b->imag) < 0.)
22: abi = - abi;
23: if( abr <= abi )
24: {
25: if(abi == 0) {
26: fprintf(stderr,"complex division by zero\n");
27: f77_abort(EDOM);
28: }
29: ratio = b->real / b->imag ;
30: den = b->imag * (1 + ratio*ratio);
31: c->real = (a->real*ratio + a->imag) / den;
32: c->imag = (a->imag*ratio - a->real) / den;
33: }
34:
35: else
36: {
37: ratio = b->imag / b->real ;
38: den = b->real * (1 + ratio*ratio);
39: c->real = (a->real + a->imag*ratio) / den;
40: c->imag = (a->imag - a->real*ratio) / den;
41: }
42:
43: }
Defined functions
c_div
defined in line
13;
never used