Annotation of researchv10no/libF77/c_div.c, revision 1.1

1.1     ! root        1: #include "f2c.h"
        !             2: 
        !             3: #ifdef KR_headers
        !             4: extern VOID sig_die();
        !             5: VOID c_div(c, a, b)
        !             6: complex *a, *b, *c;
        !             7: #else
        !             8: extern void sig_die(char*,int);
        !             9: void c_div(complex *c, complex *a, complex *b)
        !            10: #endif
        !            11: {
        !            12: double ratio, den;
        !            13: double abr, abi;
        !            14: 
        !            15: if( (abr = b->r) < 0.)
        !            16:        abr = - abr;
        !            17: if( (abi = b->i) < 0.)
        !            18:        abi = - abi;
        !            19: if( abr <= abi )
        !            20:        {
        !            21:        if(abi == 0)
        !            22:                sig_die("complex division by zero", 1);
        !            23:        ratio = (double)b->r / b->i ;
        !            24:        den = b->i * (1 + ratio*ratio);
        !            25:        c->r = (a->r*ratio + a->i) / den;
        !            26:        c->i = (a->i*ratio - a->r) / den;
        !            27:        }
        !            28: 
        !            29: else
        !            30:        {
        !            31:        ratio = (double)b->i / b->r ;
        !            32:        den = b->r * (1 + ratio*ratio);
        !            33:        c->r = (a->r + a->i*ratio) / den;
        !            34:        c->i = (a->i - a->r*ratio) / den;
        !            35:        }
        !            36: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.