- C 標準庫
- C 庫 - 首頁
- C 庫 - <assert.h>
- C 庫 - <complex.h>
- C 庫 - <ctype.h>
- C 庫 - <errno.h>
- C 庫 - <fenv.h>
- C 庫 - <float.h>
- C 庫 - <inttypes.h>
- C 庫 - <iso646.h>
- C 庫 - <limits.h>
- C 庫 - <locale.h>
- C 庫 - <math.h>
- C 庫 - <setjmp.h>
- C 庫 - <signal.h>
- C 庫 - <stdalign.h>
- C 庫 - <stdarg.h>
- C 庫 - <stdbool.h>
- C 庫 - <stddef.h>
- C 庫 - <stdio.h>
- C 庫 - <stdlib.h>
- C 庫 - <string.h>
- C 庫 - <tgmath.h>
- C 庫 - <time.h>
- C 庫 - <wctype.h>
- C 標準庫資源
- C 庫 - 快速指南
- C 庫 - 有用資源
- C 庫 - 討論
- C 程式設計資源
- C 程式設計 - 教程
- C - 有用資源
C 庫 - cproj() 函式
C 的複數庫 cproj() 函式用於計算 z(複數)在黎曼球面上的投影。投影是指將點或點集從一個空間對映到另一個空間的對映或變換。
在數學中,黎曼球面是複平面的模型。它將平面上的所有點對映到球面上的點,引入了無窮大作為複函式在無窮大處的行為的表示。
語法
以下是 cproj() 函式的 C 庫語法:
double complex cproj( double complex z );
引數
此函式接受單個引數:
-
Z - 它表示我們要計算其投影的複數。
返回值
此函式返回一個複數值,其型別可以是 double、float 或 long double,表示 z 在黎曼球面上的投影。
示例 1
以下是一個基本的 c 程式,用於演示如何使用複數的 cproj()。
#include <stdio.h>
#include <complex.h>
#include <math.h>
int main()
{
double complex proj1 = cproj(1 + 2*I);
printf("cproj(1+2i) = %.1f%+.1fi\n", creal(proj1),cimag(proj1));
double complex proj2 = cproj(INFINITY+2.0*I);
printf("cproj(Inf+2i) = %.1f%+.1fi\n", creal(proj2),cimag(proj2));
}
輸出
以下是輸出:
cproj(1+2i) = 1.0+2.0i cproj(Inf+2i) = inf+0.0i
示例 2
讓我們來看另一個例子,我們使用 CMPLX() 建立一個複數。然後我們使用 cproj() 計算複數的投影。
#include <stdio.h>
#include <complex.h>
#include <math.h>
int main()
{
double real = 3;
double imag = 4;
double complex z = CMPLX(real, imag);
double proj = cproj(z);
printf("Complex number: %.1f + %.1fi\n", creal(z), cimag(z));
printf("Projection of complex number = %.1f + %.1fi\n", creal(proj),cimag(proj));
}
輸出
以下是輸出:
Complex number: 3.0 + 4.0i Projection of complex number = 3.0 + 0.0i
示例 3
下面的 c 示例計算負複數的投影。
#include <stdio.h>
#include <complex.h>
int main(void) {
double complex z = -3.0 + -4.0*I;
// find the project of complex number
double proj = cproj(z);
printf("Complex number: %.2f + %.2fi\n", creal(z), cimag(z));
printf("project of complex number: %.2f + %.2fi", creal(proj), creal(proj));
return 0;
}
輸出
以下是輸出:
Complex number: -3.00 + -4.00i project of complex number: -3.00 + -3.00i
c_library_complex_h.htm
廣告