isnan() for complex data

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jacob navia

    isnan() for complex data

    Hi

    Has C++ defined the function
    isnan() for complex numbers?
    What is the definition?

    Thanks in advance
    --
    jacob navia
    jacob at jacob point remcomp point fr
    logiciels/informatique

  • Barry

    #2
    Re: isnan() for complex data

    jacob navia wrote:
    Hi
    >
    Has C++ defined the function
    isnan() for complex numbers?
    What is the definition?
    >
    Thanks in advance
    /isnan/ is a macro in C99, still not in the current C++03 standard.

    Synopsis:
    #include <math.h>
    int isnan(real-floating x);

    --
    Best Regards
    Barry

    Comment

    • jacob navia

      #3
      Re: isnan() for complex data

      Barry wrote:
      jacob navia wrote:
      >Hi
      >>
      >Has C++ defined the function
      >isnan() for complex numbers?
      >What is the definition?
      >>
      >Thanks in advance
      >
      /isnan/ is a macro in C99, still not in the current C++03 standard.
      >
      Synopsis:
      #include <math.h>
      int isnan(real-floating x);
      >
      In C99 this is ONLY defined for real types. No definition for
      complex types. What is the definition in C++?

      is it

      insan(z) --isnan(real(z) || isnan(imag(z)

      or

      insan(z) --isnan(real(z) && isnan(imag(z)

      ???

      The same problem appears for

      isinf()


      --
      jacob navia
      jacob at jacob point remcomp point fr
      logiciels/informatique

      Comment

      • jacob navia

        #4
        Re: isnan() for complex data

        jacob navia wrote:
        >
        In C99 this is ONLY defined for real types. No definition for
        complex types. What is the definition in C++?
        >
        is it
        >
        insan(z) --isnan(real(z) || isnan(imag(z)
        excuse me that should have been
        insan(z) --isnan(real(z)) || isnan(imag(z))
        with correctly matched parentheses!


        >
        or
        >
        insan(z) --isnan(real(z) && isnan(imag(z)
        The same
        insan(z) --isnan(real(z)) && isnan(imag(z))



        --
        jacob navia
        jacob at jacob point remcomp point fr
        logiciels/informatique

        Comment

        • ciccio

          #5
          Re: isnan() for complex data

          jacob navia wrote:
          jacob navia wrote:
          >>
          >In C99 this is ONLY defined for real types. No definition for
          >complex types. What is the definition in C++?
          >insan(z) --isnan(real(z)) || isnan(imag(z))
          If you want to program an "isnan" function for std::complex<T> , then I
          suggest you to use the above function.

          If one of the parts is an invalid real number then your whole complex
          number should be invalid.

          The same reasoning goes for isinf. If one of your complex numbers is
          infinite, then your complex number is one of the many representations of
          infinite.

          Klaas

          Comment

          Working...