Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

c_sqrt.c

Go to the documentation of this file.
00001 #include "f2c.h"
00002 
00003 #ifdef KR_headers
00004 extern double sqrt(), f__cabs();
00005 
00006 VOID c_sqrt(r, z) complex *r, *z;
00007 #else
00008 #undef abs
00009 #include "mathh.h"
00010 extern double f__cabs(double, double);
00011 
00012 void c_sqrt(complex *r, complex *z)
00013 #endif
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 }
 

Powered by Plone

This site conforms to the following standards: