csqrt
计算复数x的平方根。
接口定义
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);
参数
参数名 |
类型 |
描述 |
输入/输出 |
|---|---|---|---|
x |
|
表示输入数据的浮点值。 |
输入 |
返回值
输入值实部(x.real) |
输入值虚部(x.imag) |
输出值实部(y.real) |
输出值虚部(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 |
任意数 |
nan |
nan |
nan |
nan |
任意数 |
nan |
nan |
依赖
C: "km.h"
示例
C interface:
// 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
!
父主题: 复数函数