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_sqrt.c	5.1	6/7/85
   7:  */
   8: 
   9: #include "complex"
  10: 
  11: c_sqrt(r, z)
  12: complex *r, *z;
  13: {
  14: double mag, sqrt(), cabs();
  15: 
  16: if( (mag = cabs(z->real, z->imag)) == 0.)
  17:     r->real = r->imag = 0.;
  18: else if(z->real > 0)
  19:     {
  20:     r->real = sqrt(0.5 * (mag + z->real) );
  21:     r->imag = z->imag / r->real / 2;
  22:     }
  23: else
  24:     {
  25:     r->imag = sqrt(0.5 * (mag - z->real) );
  26:     if(z->imag < 0)
  27:         r->imag = - r->imag;
  28:     r->real = z->imag / r->imag /2;
  29:     }
  30: }

Defined functions

c_sqrt defined in line 11; never used
Last modified: 1987-02-18
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 945
Valid CSS Valid XHTML 1.0 Strict