csqrt
Compute the square root of complex number x.
Interface Definition
C interface:
float complex csqrtf(float complex x);
double complex csqrt(double complex x);
long double complex csqrtl(long double complex x);
Fortran interface:
RES = SQRTF(X);
RES = SQRT(X);
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
x |
|
Floating-point value of the input data. |
Input |
Return Value
Real Part of the Input (x.real) |
Imaginary Part of the Input (x.imag) |
Real Part of the Output (y.real) |
Imaginary Part of the Output (y.imag) |
|---|---|---|---|
±0 |
+0 |
+0 |
+0 |
±0 |
-0 |
+0 |
-0 |
±0 |
+inf |
+inf |
+inf |
±0 |
-inf |
+inf |
-inf |
+inf |
+0 |
+inf |
+0 |
+inf |
-0 |
+inf |
-0 |
-inf |
+0 |
+0 |
+inf |
-inf |
-0 |
+0 |
-inf |
±inf |
+inf |
+inf |
+inf |
±inf |
-inf |
+inf |
-inf |
Any |
nan |
nan |
nan |
nan |
Any |
nan |
nan |
Dependency
C: "km.h"
Examples
C interface:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | // typical usage double x1 = 1.0, x2 = 2.0, x3 = 3.0, x4 = 4.0; double complex cx1 = __builtin_complex(x1, x2); double complex cx2 = __builtin_complex(x3, x4); // print result double ry; double iy; ry = __real__ csqrt(cx1); iy = __imag__ csqrt(cx1); printf("csqrt(cx1) = %.15f, %.15f\n", ry, iy); ry = __real__ csqrt(cx2); iy = __imag__ csqrt(cx2); printf("csqrt(cx2) = %.15f, %.15f\n", ry, iy); /* * csqrt(cx1) = 1.272019649514069, 0.786151377757423 * csqrt(cx2) = 2.000000000000000, 1.000000000000000 * */ |
Fortran interface:
REAL(8) :: X = 3.0
PRINT*, SQRT(X)
!
! OUTPUT
! 1.732050807568877
!
Parent topic: Complex Functions