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_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 c_div(c, a, b)
00006 complex *a, *b, *c;
00007 #else
00008 extern void sig_die(char*,int);
00009 void c_div(complex *c, complex *a, complex *b)
00010 #endif
00011 {
00012 double ratio, den;
00013 double abr, abi;
00014 
00015 if( (abr = b->r) < 0.)
00016         abr = - abr;
00017 if( (abi = b->i) < 0.)
00018         abi = - abi;
00019 if( abr <= abi )
00020         {
00021         if(abi == 0)
00022                 sig_die("complex division by zero", 1);
00023         ratio = (double)b->r / b->i ;
00024         den = b->i * (1 + ratio*ratio);
00025         c->r = (a->r*ratio + a->i) / den;
00026         c->i = (a->i*ratio - a->r) / den;
00027         }
00028 
00029 else
00030         {
00031         ratio = (double)b->i / b->r ;
00032         den = b->r * (1 + ratio*ratio);
00033         c->r = (a->r + a->i*ratio) / den;
00034         c->i = (a->i - a->r*ratio) / den;
00035         }
00036 }
 

Powered by Plone

This site conforms to the following standards: