2 * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net>
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 * Complex power function
25 * float complex cpowf();
26 * float complex a, z, w;
34 * Raises complex A to the complex Zth power.
35 * Definition is per AMS55 # 4.2.8,
36 * analytically equivalent to cpow(a,z) = cexp(z clog(a)).
41 * arithmetic domain # trials peak rms
42 * IEEE -10,+10 30000 9.4e-15 1.5e-15
46 #include <sys/cdefs.h>
47 __FBSDID("$FreeBSD$");
51 #include "math_private.h"
54 cpowf(float complex a, float complex z)
57 float x, y, r, theta, absa, arga;
63 return (CMPLXF(0.0f, 0.0f));
69 r = r * expf (-y * arga);
70 theta = theta + y * logf (absa);
72 w = CMPLXF(r * cosf (theta), r * sinf (theta));