cpow()、cpowf()、cpowl() - 複素数べき乗の計算

標準

標準/拡張機能 C/C++ 依存項目

C99
Single UNIX Specification、バージョン 3

両方

z/OS V1R7
C99 をサポートするように
設計されたコンパイラー

形式

#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);

機能説明

cpow() ファミリーの関数は、負の実軸に沿って最初のパラメーターに対する分岐線法を使用して、xy 乗の複素数値を計算します。
注: 下表は、これらの関数の実行可能な形式を示しています。 IEEE 2 進数浮動小数点の詳細は、IEEE 2 進数浮動小数点を参照してください。
関数 Hex IEEE
cpow X X
cpowf X X
cpowl X X

戻り値

cpow() ファミリーの関数は、複素数べき乗の値を戻します。

/*
 *  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);
}
出力:

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

関連情報