Annotation of researchv10no/cmd/cfront/libC/complex/exp.c, revision 1.1

1.1     ! root        1: 
        !             2: #include "complex.h"
        !             3: #include "const.h"
        !             4: 
        !             5: 
        !             6: complex exp(complex z)
        !             7: /*
        !             8:        The complex exponentiation function: e**z, e being 2.718281828...
        !             9: 
        !            10:        In case of overflow, return EXPHUGE with the appropriate phase.
        !            11:        In case of underflow return 0.
        !            12:        In case of ridiculous input to "sin" and "cos", return 0.
        !            13: */
        !            14: {
        !            15:        complex answer;
        !            16:        double  radius, sin_theta, cos_theta;
        !            17: 
        !            18: #define EXPHUGE        1e38
        !            19: #define EXPGOOD        1e7
        !            20: 
        !            21:        if (z.re > MAX_EXPONENT) {
        !            22:                complex_error(C_EXP_RE_POS, z.re);
        !            23:                radius = EXPHUGE;
        !            24:        }
        !            25:        else if (z.re < MIN_EXPONENT) {
        !            26:                complex_error(C_EXP_RE_NEG, z.re);
        !            27:                radius = 0;
        !            28:        }
        !            29:        else {
        !            30:                radius = exp(z.re);
        !            31:        }
        !            32: 
        !            33:        if (z.im > EXPGOOD || z.im < -EXPGOOD) {
        !            34:                complex_error(C_EXP_IM, z.im);
        !            35:                sin_theta = cos_theta = 0;
        !            36:        }
        !            37:        else {
        !            38:                sin_theta = sin(z.im);
        !            39:                cos_theta = cos(z.im);
        !            40:        }
        !            41: 
        !            42:        answer.re = radius * cos_theta;
        !            43:        answer.im = radius * sin_theta;
        !            44: 
        !            45:        return answer;
        !            46: }

unix.superglobalmegacorp.com

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