Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > isnan() for complex data

Reply
Thread Tools

isnan() for complex data

 
 
jacob navia
Guest
Posts: n/a
 
      02-04-2008
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
http://www.cs.virginia.edu/~lcc-win32
 
Reply With Quote
 
 
 
 
Barry
Guest
Posts: n/a
 
      02-04-2008
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
 
Reply With Quote
 
 
 
 
jacob navia
Guest
Posts: n/a
 
      02-04-2008
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
http://www.cs.virginia.edu/~lcc-win32
 
Reply With Quote
 
jacob navia
Guest
Posts: n/a
 
      02-04-2008
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
http://www.cs.virginia.edu/~lcc-win32
 
Reply With Quote
 
ciccio
Guest
Posts: n/a
 
      02-05-2008
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
 
Reply With Quote
 
Barry
Guest
Posts: n/a
 
      02-05-2008
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++?
>>
>> 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))
>
>
>

I think C++ will expand nothing but syntactic sugar(template function).

According to C++0x draft (here, N2315).

26.7 [c.math]

12
The templates defined in <cmath> replace the C99 macros with the same
names. The templates have the following
declarations:

....

template <class T> bool isnan(T x);

....

13
The templates behave the same as the C99 macros with corresponding names
defined in C99 subclause 7.12.3, Classification macros, and C99
subclause 7.12.14, Comparison macros.
SEE ALSO: ISO C subclauses 7.5, 7.10.2, 7.10.6.


--
Best Regards
Barry


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How complex is complex? Kottiyath Python 22 03-28-2009 10:11 PM
Accessing complex data from a linked list based data structure.. Ram C Programming 3 03-24-2009 02:15 AM
wsdl2java: method parameter a complex type that extends another complex type Robert Mark Bram Java 0 02-04-2007 10:06 AM
[XML Schema] Content type of complex type definition with complex content Stanimir Stamenkov XML 2 10-25-2005 10:16 AM
For expert on complex loops (reposted) - complex looping problem news.amnet.net.au Java 1 04-13-2004 07:10 AM



Advertisments