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

Defined functions

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