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_zz.c 5.1 6/7/85 7: */ 8: 9: #include "complex" 10: 11: pow_zz(r,a,b) 12: dcomplex *r, *a, *b; 13: { 14: double logr, logi, x, y; 15: double log(), exp(), cos(), sin(), atan2(), cabs(); 16: 17: logr = log( cabs(a->dreal, a->dimag) ); 18: logi = atan2(a->dimag, a->dreal); 19: 20: x = exp( logr * b->dreal - logi * b->dimag ); 21: y = logr * b->dimag + logi * b->dreal; 22: 23: r->dreal = x * cos(y); 24: r->dimag = x * sin(y); 25: }