Opened 16 years ago

Closed 16 years ago

#257 closed enhancement (fixed)

matrix does not accept "-inf"

Reported by: Peter Owned by: Jari Häkkinen
Priority: minor Milestone: yat 0.4
Component: utility Version: trunk
Keywords: Cc:


Is that a restriction created by yat or is it inherited from GSL?

If not inherited, why?

Change History (9)

comment:1 Changed 16 years ago by Peter

Summary: matrix does not accept "-Int"matrix does not accept "-inf"

comment:2 Changed 16 years ago by Markus Ringnér

You can test if your compiler supports infinity for doubles by checking the bool returned by:


comment:3 Changed 16 years ago by Markus Ringnér

Vhat is meant with does not accept -inf? If it is rad from a file to a matrix or something else?

If the problem is with reading -inf from a file, it could be a yat problem. If so could you check if one can read nan from a file?

comment:4 Changed 16 years ago by Peter

Yes I'm using istream constructor reading from file.

The exception I guess is thrown from here

    if(utility::is_double(element)) {
 	        else if (!element.size() || utility::is_nan(element)) {
 	        else {
 	          std::stringstream ss("Warning: '");
 	          ss << element << "' is not accepted as a matrix element.";
 	          throw IO_error(ss.str());

comment:5 Changed 16 years ago by Peter

Yes, I can read a nan from file, which is pretty obvious from the code above, but I tested anyway.

Should we modify is_double or shoule we add checks against -inf and inf?

comment:6 Changed 16 years ago by Markus Ringnér

Maybe nan, inf and -inf should all be fixed in is_double ? After all they are in the (IEEE whatever) double specification. This means yat would be limited to systems with numeric_limits<double>::has_infinity and then (-)inf can be generated with (-)numeric_limits<double>::infinity(). This requirement is probably minor since yat already requires systems where doubles have quiet_nan. Would changing is_double influence any other yat functionality?

Perhaps we should start using std::isnan and std::isinf. They are not strictly speaking standard C++ as they were added to C99 (after the latest C++ standard C++98), but they are in the C++0X draft.

comment:7 Changed 16 years ago by Peter

I removed is_double and re-compiled. Everything compiles except matrix and vector.

We have to document this change in the NEWS file.

comment:8 Changed 16 years ago by Peter

I have started to use std::isnan in a couple of places (mainly assertions).

For this issue it does help though because is_doubel is a function checking whether a string corresponds to a double.

comment:9 Changed 16 years ago by Peter

Resolution: fixed
Status: newclosed

fixed in [917] and [918]

Note: See TracTickets for help on using tickets.