cpow(), cpowf(), cpowl() — Calculate the complex power
Standards
Standards / Extensions | C or C++ | Dependencies |
---|---|---|
C99 |
both | z/OS V1R7 |
Format
#include <complex.h>
double complex cpow(double complex x, double complex y);
float complex cpowf(float complex x, float complex y);
long double complex cpowl(long double complex x, long double complex y);
General description
The cpow() family of
functions computes the complex value of x to
the power of y, with a branch cut for the
first parameter along the negative real axis.
Note: The following
table shows the viable formats for these functions. See IEEE binary floating-point for more information about IEEE
Binary Floating-Point.
Function | Hex | IEEE |
---|---|---|
cpow | X | X |
cpowf | X | X |
cpowl | X | X |
Returned value
The cpow() family of functions return the complex power value.
Example
/*
* This example illustrates the complex power of complex number 'z'
*/
#include <complex.h>
#include <stdio.h>
void main()
{
long double complex zl=-0.5 + I*0.5, zpowl=(long double complex)3.0;
double complex zd=(double complex)zl, zpowd=(double complex)zpowl;
float complex zf=(float complex)zd, zpowf=(float complex)zpowl;
long double resl;
double resd;
float resf;
printf("Illustrates the cpow function. Expected result is 0.25 in all cases\n");
resd = cpow(zd,zpowd);
resf = cpowf(zf,zpowf);
resl = cpowl(zl,zpowl);
printf("\tcpow(%f + I*%f,%f + I*%f) = %f\n",creal(zd), cimag(zd),
creal(zpowd), cimag(zpowd), resd);
printf("\tcpowf(%f + I*%f,%f + I*%f) = %f\n",crealf(zd), cimagf(zd),
crealf(zpowf), cimagf(zpowf), resf);
printf("\tcpowl(%Lf + I*%Lf,%Lf + I*%Lf) = %Lf\n",creall(zl), cimagl(zl),
creall(zpowl), cimagl(zpowl), resl);
}
Output
Illustrates the cpow function. Expected result is 0.25
cpow(-0.500000 + I*0.500000,3.000000 + I*0.000000) = 0.250000
cpowf(-0.500000 + I*0.500000,3.000000 + I*0.000000) = 0.250000
cpowl(-0.500000 + I*0.500000,3.000000 + I*0.000000) = 0.250000