Doxygen Source Code Documentation
z_sqrt.c File Reference
#include "f2c.h"#include "mathh.h"Go to the source code of this file.
Functions | |
| double | f__cabs (double, double) |
| void | z_sqrt (doublecomplex *r, doublecomplex *z) |
Function Documentation
|
||||||||||||
|
Definition at line 7 of file cabs.c. Referenced by c_abs(), c_log(), c_sqrt(), pow_zz(), z_abs(), z_log(), and z_sqrt().
00009 {
00010 double temp;
00011
00012 if(real < 0)
00013 real = -real;
00014 if(imag < 0)
00015 imag = -imag;
00016 if(imag > real){
00017 temp = real;
00018 real = imag;
00019 imag = temp;
00020 }
00021 if((real+imag) == real)
00022 return(real);
00023
00024 temp = imag/real;
00025 temp = real*sqrt(1.0 + temp*temp); /*overflow!!*/
00026 return(temp);
00027 }
|
|
||||||||||||
|
Definition at line 10 of file z_sqrt.c.
00012 {
00013 double mag;
00014
00015 if( (mag = f__cabs(z->r, z->i)) == 0.)
00016 r->r = r->i = 0.;
00017 else if(z->r > 0)
00018 {
00019 r->r = sqrt(0.5 * (mag + z->r) );
00020 r->i = z->i / r->r / 2;
00021 }
00022 else
00023 {
00024 r->i = sqrt(0.5 * (mag - z->r) );
00025 if(z->i < 0)
00026 r->i = - r->i;
00027 r->r = z->i / r->i / 2;
00028 }
00029 }
|