Namespaces
Variants

cpowf, cpow, cpowl

From cppreference.net
Definiert im Header <complex.h>
float complex cpowf ( float complex x, float complex y ) ;
(1) (seit C99)
double complex cpow ( double complex x, double complex y ) ;
(2) (seit C99)
long double complex cpowl ( long double complex x, long double complex y ) ;
(3) (seit C99)
Definiert im Header <tgmath.h>
#define pow( x, y )
(4) (seit C99)
1-3) Berechnet die komplexe Potenzfunktion x y
, mit einem Verzweigungsschnitt für den ersten Parameter entlang der negativen reellen Achse.
4) Typgenerisches Makro: Wenn ein Argument den Typ long double complex hat, wird cpowl aufgerufen. Wenn ein Argument den Typ double complex hat, wird cpow aufgerufen. Wenn ein Argument den Typ float complex hat, wird cpowf aufgerufen. Wenn die Argumente reell oder ganzzahlig sind, ruft das Makro die entsprechende reelle Funktion auf ( powf , pow , powl ). Wenn ein Argument imaginär ist, wird die entsprechende komplexe Zahlenversion aufgerufen.

Inhaltsverzeichnis

Parameter

x, y - komplexes Argument

Rückgabewert

Wenn keine Fehler auftreten, wird die komplexe Potenz x y
zurückgegeben.

Fehler und Sonderfälle werden behandelt, als ob die Operation durch cexp ( y * clog ( x ) ) implementiert wäre, mit der Ausnahme, dass die Implementierung Sonderfälle sorgfältiger behandeln darf.

Beispiel

#include <stdio.h>
#include <complex.h>
int main(void)
{    
    double complex z = cpow(1.0+2.0*I, 2);
    printf("(1+2i)^2 = %.1f%+.1fi\n", creal(z), cimag(z));
    double complex z2 = cpow(-1, 0.5);
    printf("(-1+0i)^0.5 = %.1f%+.1fi\n", creal(z2), cimag(z2));
    double complex z3 = cpow(conj(-1), 0.5); // other side of the cut
    printf("(-1-0i)^0.5 = %.1f%+.1fi\n", creal(z3), cimag(z3));
    double complex z4 = cpow(I, I); // i^i = exp(-pi/2)
    printf("i^i = %f%+fi\n", creal(z4), cimag(z4));
}

Ausgabe:

(1+2i)^2 = -3.0+4.0i
(-1+0i)^0.5 = 0.0+1.0i
(-1-0i)^0.5 = 0.0-1.0i
i^i = 0.207880+0.000000i

Referenzen

  • C11-Standard (ISO/IEC 9899:2011):
  • 7.3.8.2 The cpow functions (S. 195-196)
  • 7.25 Type-generic math <tgmath.h> (S. 373-375)
  • G.6.4.1 The cpow functions (S. 544)
  • G.7 Type-generic math <tgmath.h> (S. 545)
  • C99-Standard (ISO/IEC 9899:1999):
  • 7.3.8.2 The cpow functions (S. 177)
  • 7.22 Type-generic math <tgmath.h> (S. 335-337)
  • G.6.4.1 The cpow functions (S. 479)
  • G.7 Type-generic math <tgmath.h> (S. 480)

Siehe auch

(C99) (C99) (C99)
berechnet die komplexe Quadratwurzel
(Funktion)
(C99) (C99)
berechnet eine Zahl potenziert mit dem gegebenen Exponenten ( x y )
(Funktion)