Annotation of 43BSDReno/lib/libF77/pow_ci.c, revision 1.1.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:  *     @(#)pow_ci.c    5.3     1/24/88
                      7:  */
                      8: 
                      9: #include "complex"
                     10: 
                     11: #ifdef tahoe
                     12: 
                     13: #define        C_MULEQ(A,B)    \
                     14:        t = (A).real * (B).real - (A).imag * (B).imag,\
                     15:        (A).imag = (A).real * (B).imag + (A).imag * (B).real,\
                     16:        (A).real = t    /* A *= B */
                     17: 
                     18: void
                     19: pow_ci(p, a, b)        /* p = a**b  */
                     20:        complex *p, *a;
                     21:        long *b;
                     22: {
                     23:        register long n = *b;
                     24:        register float t;
                     25:        complex x;
                     26: 
                     27:        x = *a;
                     28:        p->real = (float)1, p->imag = (float)0;
                     29:        if (!n)
                     30:                return;
                     31:        if (n < 0) {
                     32:                c_div(&x, p, a);
                     33:                n = -n;
                     34:        }
                     35:        while (!(n&1)) {
                     36:                C_MULEQ(x, x);
                     37:                n >>= 1;
                     38:        }
                     39:        for (*p = x; --n > 0; C_MULEQ(*p, x))
                     40:                while (!(n&1)) {
                     41:                        C_MULEQ(x, x);
                     42:                        n >>= 1;
                     43:                }
                     44: }
                     45: 
                     46: #else /* !tahoe */
                     47: 
                     48: extern void pow_zi();
                     49: 
                     50: void
                     51: pow_ci(p, a, b)        /* p = a**b  */
                     52:        complex *p, *a;
                     53:        long *b;
                     54: {
                     55:        dcomplex p1, a1;
                     56: 
                     57:        a1.dreal = a->real;
                     58:        a1.dimag = a->imag;
                     59: 
                     60:        pow_zi(&p1, &a1, b);
                     61: 
                     62:        p->real = p1.dreal;
                     63:        p->imag = p1.dimag;
                     64: }
                     65: 
                     66: #endif /* tahoe */

unix.superglobalmegacorp.com

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