1: #include "complex"
   2: 
   3: c_sqrt(r, z)
   4: complex *r, *z;
   5: {
   6: double mag, sqrt(), cabs();
   7: 
   8: if( (mag = cabs(z->real, z->imag)) == 0.)
   9:     r->real = r->imag = 0.;
  10: else if(z->real > 0)
  11:     {
  12:     r->real = sqrt(0.5 * (mag + z->real) );
  13:     r->imag = z->imag / r->real / 2;
  14:     }
  15: else
  16:     {
  17:     r->imag = sqrt(0.5 * (mag - z->real) );
  18:     if(z->imag < 0)
  19:         r->imag = - r->imag;
  20:     r->real = z->imag / r->imag /2;
  21:     }
  22: }

Defined functions

c_sqrt defined in line 3; never used
Last modified: 1979-01-10
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 418
Valid CSS Valid XHTML 1.0 Strict