csqrtf, csqrt, csqrtl
From cppreference.net
|
Definiert im Header
<complex.h>
|
||
| (1) | (seit C99) | |
| (2) | (seit C99) | |
| (3) | (seit C99) | |
|
Definiert im Header
<tgmath.h>
|
||
|
#define sqrt( z )
|
(4) | (seit C99) |
1-3)
Berechnet die komplexe Quadratwurzel von
z
mit dem Verzweigungsschnitt entlang der negativen reellen Achse.
4)
Typgenerisches Makro: Wenn
z
den Typ
long
double
complex
hat, wird
csqrtl
aufgerufen. Wenn
z
den Typ
double
complex
hat, wird
csqrt
aufgerufen. Wenn
z
den Typ
float
complex
hat, wird
csqrtf
aufgerufen. Wenn
z
reell oder ganzzahlig ist, ruft das Makro die entsprechende reelle Funktion auf (
sqrtf
,
sqrt
,
sqrtl
). Wenn
z
imaginär ist, wird die entsprechende komplexe Zahlenversion aufgerufen.
Inhaltsverzeichnis |
Parameter
| z | - | komplexes Argument |
Rückgabewert
Wenn keine Fehler auftreten, wird die Quadratwurzel von
z
zurückgegeben, im Bereich der rechten Halbebene, einschließlich der imaginären Achse (
[0; +∞)
entlang der reellen Achse und
(−∞; +∞)
entlang der imaginären Achse.)
Fehlerbehandlung und spezielle Werte
Fehler werden gemeldet konsistent mit math_errhandling
Wenn die Implementierung IEEE-Gleitkommaarithmetik unterstützt,
- Die Funktion ist entlang des Verzweigungsschnitts stetig unter Berücksichtigung des Vorzeichens des Imaginärteils
- csqrt ( conj ( z ) ) == conj ( csqrt ( z ) )
-
Wenn
z±0+0iist, ist das Ergebnis+0+0i -
Wenn
zx+∞iist, ist das Ergebnis+∞+∞iselbst wenn x NaN ist -
Wenn
zx+NaNiist, ist das ErgebnisNaN+NaNi(sofern x nicht ±∞ ist) und FE_INVALID kann ausgelöst werden -
Wenn
z-∞+yiist, ist das Ergebnis+0+∞ifür endliches positives y -
Wenn
z+∞+yiist, ist das Ergebnis+∞+0i)für endliches positives y -
Wenn
z-∞+NaNiist, ist das ErgebnisNaN±∞i(Vorzeichen des Imaginärteils nicht spezifiziert) -
Wenn
z+∞+NaNiist, ist das Ergebnis+∞+NaNi -
Wenn
zNaN+yiist, ist das ErgebnisNaN+NaNiund FE_INVALID kann ausgelöst werden -
Wenn
zNaN+NaNiist, ist das ErgebnisNaN+NaNi
Beispiel
Diesen Code ausführen
#include <stdio.h> #include <complex.h> int main(void) { double complex z1 = csqrt(-4); printf("Square root of -4 is %.1f%+.1fi\n", creal(z1), cimag(z1)); double complex z2 = csqrt(conj(-4)); // or, in C11, CMPLX(-4, -0.0) printf("Square root of -4-0i, the other side of the cut, is " "%.1f%+.1fi\n", creal(z2), cimag(z2)); }
Ausgabe:
Square root of -4 is 0.0+2.0i Square root of -4-0i, the other side of the cut, is 0.0-2.0i
Referenzen
- C11-Standard (ISO/IEC 9899:2011):
-
- 7.3.8.3 The csqrt functions (S. 196)
-
- 7.25 Type-generic math <tgmath.h> (S. 373-375)
-
- G.6.4.2 The csqrt functions (S. 544)
-
- G.7 Type-generic math <tgmath.h> (S. 545)
- C99-Standard (ISO/IEC 9899:1999):
-
- 7.3.8.3 The csqrt functions (S. 178)
-
- 7.22 Type-generic math <tgmath.h> (S. 335-337)
-
- G.6.4.2 The csqrt functions (S. 479)
-
- G.7 Type-generic math <tgmath.h> (S. 480)
Siehe auch
|
(C99)
(C99)
(C99)
|
berechnet die komplexe Potenzfunktion
(Funktion) |
|
(C99)
(C99)
|
berechnet Quadratwurzel (
√
x
)
(Funktion) |
|
C++-Dokumentation
für
sqrt
|
|