xref: /original-bsd/usr.bin/f77/libF77/pow_zz.c (revision a1c2194a)
1 /*-
2  * Copyright (c) 1980 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.proprietary.c%
6  */
7 
8 #ifndef lint
9 static char sccsid[] = "@(#)pow_zz.c	5.3 (Berkeley) 04/12/91";
10 #endif /* not lint */
11 
12 #include "complex"
13 #ifdef tahoe
14 #define cabs zabs
15 #endif tahoe
16 
17 pow_zz(r,a,b)
18 dcomplex *r, *a, *b;
19 {
20 double logr, logi, x, y;
21 double log(), exp(), cos(), sin(), atan2(), cabs();
22 
23 logr = log( cabs(a->dreal, a->dimag) );
24 logi = atan2(a->dimag, a->dreal);
25 
26 x = exp( logr * b->dreal - logi * b->dimag );
27 y = logr * b->dimag + logi * b->dreal;
28 
29 r->dreal = x * cos(y);
30 r->dimag = x * sin(y);
31 }
32