Doxygen Source Code Documentation
c_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 | c_sqrt (complex *r, complex *z) |
Function Documentation
|
Definition at line 12 of file c_sqrt.c.
00014 { 00015 double mag, t; 00016 00017 if( (mag = f__cabs(z->r, z->i)) == 0.) 00018 r->r = r->i = 0.; 00019 else if(z->r > 0) 00020 { 00021 r->r = t = sqrt(0.5 * (mag + z->r) ); 00022 t = z->i / t; 00023 r->i = 0.5 * t; 00024 } 00025 else 00026 { 00027 t = sqrt(0.5 * (mag - z->r) ); 00028 if(z->i < 0) 00029 t = -t; 00030 r->i = t; 00031 t = z->i / t; 00032 r->r = 0.5 * t; 00033 } 00034 } |
|
Definition at line 7 of file cabs.c.
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 } |