Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      cprojf, cproj, cprojl

      From cppreference.com
      <c‎ |numeric‎ |complex
       
       
       
      Complex number arithmetic
      Types and the imaginary constant
      (C99)
      (C99)    
      (C11)
      (C99)
      Manipulation
      (C99)
      (C99)
      (C99)
      (C99)
      (C99)
      cproj
      (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>
      floatcomplex       cprojf(floatcomplex z);
      (1)(since C99)
      doublecomplex      cproj(doublecomplex z);
      (2)(since C99)
      longdoublecomplex cprojl(longdoublecomplex z);
      (3)(since C99)
      Defined in header<tgmath.h>
      #define cproj( z )
      (4)(since C99)
      1-3) Computes the projection ofz on the Riemann sphere.
      4) Type-generic macro: ifz has typelongdoublecomplex,longdoubleimaginary, orlongdouble,cprojl is called. Ifz has typefloatcomplex,floatimaginary, orfloat,cprojf is called. Ifz has typedoublecomplex,doubleimaginary,double, or any integer type,cproj is called.

      For mostz,cproj(z)==z, but all complex infinities, even the numbers where one component is infinite and the other is NaN, become positive real infinity,INFINITY+0.0*I orINFINITY-0.0*I. The sign of the imaginary (zero) component is the sign ofcimag(z).

      Contents

      [edit]Parameters

      z - complex argument

      [edit]Return value

      The projection ofz on the Riemann sphere.

      This function is fully specified for all possible inputs and is not subject to any errors described inmath_errhandling

      [edit]Notes

      Thecproj function helps model the Riemann sphere by mapping all infinities to one (give or take the sign of the imaginary zero), and should be used just before any operation, especially comparisons, that might give spurious results for any of the other infinities.

      [edit]Example

      Run this code
      #include <stdio.h>#include <complex.h>#include <math.h> int main(void){doublecomplex z1= cproj(1+2*I);printf("cproj(1+2i) = %.1f%+.1fi\n",creal(z1),cimag(z1)); doublecomplex z2= cproj(INFINITY+2.0*I);printf("cproj(Inf+2i) = %.1f%+.1fi\n",creal(z2),cimag(z2)); doublecomplex z3= cproj(INFINITY-2.0*I);printf("cproj(Inf-2i) = %.1f%+.1fi\n",creal(z3),cimag(z3));}

      Output:

      cproj(1+2i) = 1.0+2.0icproj(Inf+2i) = inf+0.0icproj(Inf-2i) = inf-0.0i

      [edit]References

      • C11 standard (ISO/IEC 9899:2011):
      • 7.3.9.5 The cproj functions (p: 198)
      • 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.4 The cproj functions (p: 179)
      • 7.22 Type-generic math <tgmath.h> (p: 335-337)
      • G.7 Type-generic math <tgmath.h> (p: 480)

      [edit]See also

      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=c/numeric/complex/cproj&oldid=119329"

      [8]ページ先頭

      ©2009-2025 Movatter.jp