Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      cargf, carg, cargl

      From cppreference.com
      <c‎ |numeric‎ |complex
       
       
       
      Complex number arithmetic
      Types and the imaginary constant
      (C99)
      (C99)    
      (C11)
      (C99)
      Manipulation
      (C99)
      (C99)
      carg
      (C99)
      (C99)
      (C99)
      (C99)
      Power and exponential functions
      (C99)
      (C99)
      (C99)
      (C99)
      Trigonometric functions
      (C99)
      (C99)
      (C99)
      (C99)
      (C99)
      (C99)
      Hyperbolic functions
      (C99)
      (C99)
      (C99)
      (C99)
      (C99)
      (C99)
       
      Defined in header<complex.h>
      float       cargf(floatcomplex z);
      (1)(since C99)
      double      carg(doublecomplex z);
      (2)(since C99)
      longdouble cargl(longdoublecomplex z);
      (3)(since C99)
      Defined in header<tgmath.h>
      #define carg( z )
      (4)(since C99)
      1-3) Computes the argument (also called phase angle) ofz, with a branch cut along the negative real axis.
      4) Type-generic macro: ifz has typelongdoublecomplex,longdoubleimaginary, orlongdouble,cargl is called. Ifz has typefloatcomplex,floatimaginary, orfloat,cargf is called. Ifz has typedoublecomplex,doubleimaginary,double, or any integer type,carg is called.

      Contents

      [edit]Parameters

      z - complex argument

      [edit]Return value

      If no errors occur, returns the phase angle ofz in the interval[−π; π].

      Errors and special cases are handled as if the function is implemented asatan2(cimag(z),creal(z))

      [edit]Example

      Run this code
      #include <stdio.h>#include <complex.h> int main(void){doublecomplex z1=1.0+0.0*I;printf("phase angle of %.1f%+.1fi is %f\n",creal(z1),cimag(z1), carg(z1)); doublecomplex z2=0.0+1.0*I;printf("phase angle of %.1f%+.1fi is %f\n",creal(z2),cimag(z2), carg(z2)); doublecomplex z3=-1.0+0.0*I;printf("phase angle of %.1f%+.1fi is %f\n",creal(z3),cimag(z3), carg(z3)); doublecomplex 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));}

      Output:

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

      [edit]References

      • C11 standard (ISO/IEC 9899:2011):
      • 7.3.9.1 The carg functions (p: 196)
      • 7.25 Type-generic math <tgmath.h> (p: 373-375)
      • G.7 Type-generic math <tgmath.h> (p: 545)
      • C99 standard (ISO/IEC 9899:1999):
      • 7.3.9.1 The carg functions (p: 178)
      • 7.22 Type-generic math <tgmath.h> (p: 335-337)
      • G.7 Type-generic math <tgmath.h> (p: 480)

      [edit]See also

      (C99)(C99)(C99)
      computes the magnitude of a complex number
      (function)[edit]
      computes arc tangent, using signs to determine quadrants
      (function)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=c/numeric/complex/carg&oldid=95595"

      [8]ページ先頭

      ©2009-2025 Movatter.jp