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

1.1     ! root        1: /*
        !             2:  * Copyright (c) 1980 Regents of the University of California.
        !             3:  * All rights reserved.  The Berkeley software License Agreement
        !             4:  * specifies the terms and conditions for redistribution.
        !             5:  *
        !             6:  *     @(#)z_div.c     5.1     6/7/85
        !             7:  */
        !             8: 
        !             9: #include "complex"
        !            10: #include <stdio.h>
        !            11: #include <errno.h>
        !            12: 
        !            13: z_div(c, a, b)
        !            14: dcomplex *a, *b, *c;
        !            15: {
        !            16: double ratio, den;
        !            17: double abr, abi;
        !            18: 
        !            19: if( (abr = b->dreal) < 0.)
        !            20:        abr = - abr;
        !            21: if( (abi = b->dimag) < 0.)
        !            22:        abi = - abi;
        !            23: if( abr <= abi )
        !            24:        {
        !            25:        if(abi == 0) {
        !            26:                fprintf( stderr, "Double complex division by zero\n" );
        !            27:                f77_abort(EDOM);
        !            28:        }
        !            29:        ratio = b->dreal / b->dimag ;
        !            30:        den = b->dimag * (1 + ratio*ratio);
        !            31:        c->dreal = (a->dreal*ratio + a->dimag) / den;
        !            32:        c->dimag = (a->dimag*ratio - a->dreal) / den;
        !            33:        }
        !            34: 
        !            35: else
        !            36:        {
        !            37:        ratio = b->dimag / b->dreal ;
        !            38:        den = b->dreal * (1 + ratio*ratio);
        !            39:        c->dreal = (a->dreal + a->dimag*ratio) / den;
        !            40:        c->dimag = (a->dimag - a->dreal*ratio) / den;
        !            41:        }
        !            42: 
        !            43: }

unix.superglobalmegacorp.com

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