z_sqrt.c
Go to the documentation of this file.
00001 #include "f2c.h"
00002 
00003 #ifdef KR_headers
00004 double sqrt(), f__cabs();
00005 VOID z_sqrt(r, z) doublecomplex *r, *z;
00006 #else
00007 #undef abs
00008 #include "math.h"
00009 #ifdef __cplusplus
00010 extern "C" {
00011 #endif
00012 extern double f__cabs(double, double);
00013 void z_sqrt(doublecomplex *r, doublecomplex *z)
00014 #endif
00015 {
00016         double mag, zi = z->i, zr = z->r;
00017 
00018         if( (mag = f__cabs(zr, zi)) == 0.)
00019                 r->r = r->i = 0.;
00020         else if(zr > 0)
00021                 {
00022                 r->r = sqrt(0.5 * (mag + zr) );
00023                 r->i = zi / r->r / 2;
00024                 }
00025         else
00026                 {
00027                 r->i = sqrt(0.5 * (mag - zr) );
00028                 if(zi < 0)
00029                         r->i = - r->i;
00030                 r->r = zi / r->i / 2;
00031                 }
00032         }
00033 #ifdef __cplusplus
00034 }
00035 #endif


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:56:16