c_div.c
Go to the documentation of this file.
00001 #include "f2c.h"
00002 #ifdef __cplusplus
00003 extern "C" {
00004 #endif
00005 
00006 #ifdef KR_headers
00007 extern VOID sig_die();
00008 VOID c_div(c, a, b)
00009 complex *a, *b, *c;
00010 #else
00011 extern void sig_die(const char*,int);
00012 void c_div(complex *c, complex *a, complex *b)
00013 #endif
00014 {
00015         double ratio, den;
00016         double abr, abi, cr;
00017 
00018         if( (abr = b->r) < 0.)
00019                 abr = - abr;
00020         if( (abi = b->i) < 0.)
00021                 abi = - abi;
00022         if( abr <= abi )
00023                 {
00024                 if(abi == 0) {
00025 #ifdef IEEE_COMPLEX_DIVIDE
00026                         float af, bf;
00027                         af = bf = abr;
00028                         if (a->i != 0 || a->r != 0)
00029                                 af = 1.;
00030                         c->i = c->r = af / bf;
00031                         return;
00032 #else
00033                         sig_die("complex division by zero", 1);
00034 #endif
00035                         }
00036                 ratio = (double)b->r / b->i ;
00037                 den = b->i * (1 + ratio*ratio);
00038                 cr = (a->r*ratio + a->i) / den;
00039                 c->i = (a->i*ratio - a->r) / den;
00040                 }
00041 
00042         else
00043                 {
00044                 ratio = (double)b->i / b->r ;
00045                 den = b->r * (1 + ratio*ratio);
00046                 cr = (a->r + a->i*ratio) / den;
00047                 c->i = (a->i - a->r*ratio) / den;
00048                 }
00049         c->r = cr;
00050         }
00051 #ifdef __cplusplus
00052 }
00053 #endif


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:55:15