Annotation of 41BSD/lib/libF77/z_div.c, revision 1.1

1.1     ! root        1: struct dcomplex { double dreal, dimag; };
        !             2: 
        !             3: z_div(c, a, b)
        !             4: struct dcomplex *a, *b, *c;
        !             5: {
        !             6: double ratio, den;
        !             7: double abr, abi;
        !             8: 
        !             9: if( (abr = b->dreal) < 0.)
        !            10:        abr = - abr;
        !            11: if( (abi = b->dimag) < 0.)
        !            12:        abi = - abi;
        !            13: if( abr <= abi )
        !            14:        {
        !            15:        if(abi == 0)
        !            16:                abort(); /* fatal("complex division by zero"); */
        !            17:        ratio = b->dreal / b->dimag ;
        !            18:        den = b->dimag * (1 + ratio*ratio);
        !            19:        c->dreal = (a->dreal*ratio + a->dimag) / den;
        !            20:        c->dimag = (a->dimag*ratio - a->dreal) / den;
        !            21:        }
        !            22: 
        !            23: else
        !            24:        {
        !            25:        ratio = b->dimag / b->dreal ;
        !            26:        den = b->dreal * (1 + ratio*ratio);
        !            27:        c->dreal = (a->dreal + a->dimag*ratio) / den;
        !            28:        c->dimag = (a->dimag - a->dreal*ratio) / den;
        !            29:        }
        !            30: 
        !            31: }

unix.superglobalmegacorp.com

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