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:  *	@(#)z_div.c	5.1	6/7/85
   7:  */
   8: 
   9: #include "complex"
  10: #include <stdio.h>
  11: #include <errno.h>
  12: 
  13: z_div(c, a, b)
  14: dcomplex *a, *b, *c;
  15: {
  16: double ratio, den;
  17: double abr, abi;
  18: 
  19: if( (abr = b->dreal) < 0.)
  20:     abr = - abr;
  21: if( (abi = b->dimag) < 0.)
  22:     abi = - abi;
  23: if( abr <= abi )
  24:     {
  25:     if(abi == 0) {
  26:         fprintf( stderr, "Double complex division by zero\n" );
  27:         f77_abort(1, EDOM);
  28:     }
  29:     ratio = b->dreal / b->dimag ;
  30:     den = b->dimag * (1 + ratio*ratio);
  31:     c->dreal = (a->dreal*ratio + a->dimag) / den;
  32:     c->dimag = (a->dimag*ratio - a->dreal) / den;
  33:     }
  34: 
  35: else
  36:     {
  37:     ratio = b->dimag / b->dreal ;
  38:     den = b->dreal * (1 + ratio*ratio);
  39:     c->dreal = (a->dreal + a->dimag*ratio) / den;
  40:     c->dimag = (a->dimag - a->dreal*ratio) / den;
  41:     }
  42: 
  43: }

Defined functions

z_div defined in line 13; used 1 times
Last modified: 1988-12-26
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2389
Valid CSS Valid XHTML 1.0 Strict