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  

z_div.c

Go to the documentation of this file.
00001 #include "f2c.h"
00002 
00003 #ifdef KR_headers
00004 extern void sig_die();
00005 VOID z_div(c, a, b) doublecomplex *a, *b, *c;
00006 #else
00007 extern void sig_die(char*, int);
00008 void z_div(doublecomplex *c, doublecomplex *a, doublecomplex *b)
00009 #endif
00010 {
00011 double ratio, den;
00012 double abr, abi;
00013 
00014 if( (abr = b->r) < 0.)
00015         abr = - abr;
00016 if( (abi = b->i) < 0.)
00017         abi = - abi;
00018 if( abr <= abi )
00019         {
00020         if(abi == 0)
00021                 sig_die("complex division by zero", 1);
00022         ratio = b->r / b->i ;
00023         den = b->i * (1 + ratio*ratio);
00024         c->r = (a->r*ratio + a->i) / den;
00025         c->i = (a->i*ratio - a->r) / den;
00026         }
00027 
00028 else
00029         {
00030         ratio = b->i / b->r ;
00031         den = b->r * (1 + ratio*ratio);
00032         c->r = (a->r + a->i*ratio) / den;
00033         c->i = (a->i - a->r*ratio) / den;
00034         }
00035 
00036 }
 

Powered by Plone

This site conforms to the following standards: