110517Sdlw /* 222941Skre * Copyright (c) 1980 Regents of the University of California. 322941Skre * All rights reserved. The Berkeley software License Agreement 422941Skre * specifies the terms and conditions for redistribution. 522941Skre * 6*29968Smckusick * @(#)pow_zz.c 5.2 11/03/86 710517Sdlw */ 810517Sdlw 910517Sdlw #include "complex" 10*29968Smckusick #ifdef tahoe 11*29968Smckusick #define cabs zabs 12*29968Smckusick #endif tahoe 1310517Sdlw 1410517Sdlw pow_zz(r,a,b) 1510517Sdlw dcomplex *r, *a, *b; 1610517Sdlw { 1710517Sdlw double logr, logi, x, y; 1810517Sdlw double log(), exp(), cos(), sin(), atan2(), cabs(); 1910517Sdlw 2010517Sdlw logr = log( cabs(a->dreal, a->dimag) ); 2110517Sdlw logi = atan2(a->dimag, a->dreal); 2210517Sdlw 2310517Sdlw x = exp( logr * b->dreal - logi * b->dimag ); 2410517Sdlw y = logr * b->dimag + logi * b->dreal; 2510517Sdlw 2610517Sdlw r->dreal = x * cos(y); 2710517Sdlw r->dimag = x * sin(y); 2810517Sdlw } 29