Namespaces
Variants

cargf, carg, cargl

From cppreference.net
헤더 파일에 정의됨 <complex.h>
float cargf ( float complex z ) ;
(1) (C99부터)
double carg ( double complex z ) ;
(2) (C99부터)
long double cargl ( long double complex z ) ;
(3) (C99부터)
헤더 파일에 정의됨 <tgmath.h>
#define carg( z )
(4) (C99부터)
1-3) 음의 실수 축을 따라 가지 절단(branch cut)을 가지며 z 의 편각(phase angle)을 계산합니다.
4) 타입-제네릭 매크로: 만약 z long double complex , long double imaginary , 또는 long double 타입을 가지면 cargl 이 호출됩니다. 만약 z float complex , float imaginary , 또는 float 타입을 가지면 cargf 이 호출됩니다. 만약 z double complex , double imaginary , double , 또는 임의의 정수 타입을 가지면 carg 이 호출됩니다.

목차

매개변수

z - 복소 인수

반환값

오류가 발생하지 않으면, z 의 위상각을 [−π; π] 구간에서 반환합니다.

오류 및 특수한 경우들은 이 함수가 다음과 같이 구현된 것처럼 처리됩니다: atan2 ( cimag ( z ) , creal ( z ) )

예제

#include <stdio.h>
#include <complex.h>
int main(void) 
{
    double complex z1 = 1.0+0.0*I;
    printf("phase angle of %.1f%+.1fi is %f\n", creal(z1), cimag(z1), carg(z1));
    double complex z2 = 0.0+1.0*I;
    printf("phase angle of %.1f%+.1fi is %f\n", creal(z2), cimag(z2), carg(z2));
    double complex z3 = -1.0+0.0*I;
    printf("phase angle of %.1f%+.1fi is %f\n", creal(z3), cimag(z3), carg(z3));
    double complex z4 = conj(z3); // or CMPLX(-1, -0.0)
    printf("phase angle of %.1f%+.1fi (the other side of the cut) is %f\n",
             creal(z4), cimag(z4), carg(z4));
}

출력:

phase angle of 1.0+0.0i is 0.000000
phase angle of 0.0+1.0i is 1.570796
phase angle of -1.0+0.0i is 3.141593
phase angle of -1.0-0.0i (the other side of the cut) is -3.141593

참고문헌

  • C11 표준 (ISO/IEC 9899:2011):
  • 7.3.9.1 carg 함수들 (p: 196)
  • 7.25 타입-제네릭 수학 <tgmath.h> (p: 373-375)
  • G.7 타입-제네릭 수학 <tgmath.h> (p: 545)
  • C99 표준 (ISO/IEC 9899:1999):
  • 7.3.9.1 carg 함수들 (p: 178)
  • 7.22 타입-제네릭 수학 <tgmath.h> (p: 335-337)
  • G.7 타입-제네릭 수학 <tgmath.h> (p: 480)

참고 항목

(C99) (C99) (C99)
복소수의 크기를 계산함
(함수)
사분면을 결정하기 위해 부호를 사용하여 아크 탄젠트를 계산함
(함수)
C++ 문서 for arg