-
Notifications
You must be signed in to change notification settings - Fork 370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace NAN & std::isnan by numerics::nan & numerics::isnan #127
Conversation
* In configure tests check for all variations of nan/std::nan, isnan/std::isnan * Depending on what is available, use it in numerics.h/.cpp ; prefer c++ versions. * If non is available, use own implementation. * If IS_K is defined, a handwritten isnan will be used, that compares bytewise to the defined numerics::nan
@tammoippen I assume the #if defined( IS_K )
#undef HAVE_STD_ISNAN
#undef HAVE_ISNAN
#endif will not be needed. When I applied the fix proprosed in #123 the connections were build correctly. This was confirmed by running your sli test script successfully and by running the reproducer from trac#961, which works fine as well. So I guess there is no need to force K to use the handwritten |
@tammoippen Good work! But can we trust the handwritten version under all circumstances? I am afraid that weird things may happen on weird systems, and we currently have no tests to check that |
When I first encountered this issue I spent some time trying to figure out how to solve this in the correct way. I went as far as emailing a friend that develops in C++ for a living. The consensus seems to be that short of requiring a sufficiently recent version of the C++ standard, there is no general solution that is guaranteed to work in all cases. |
@JanneM I suspected as much. Therefore my proposal to use the NaN support from either cmath or math.h combined with a test that our isnan based on those really works. In that way, we will cover, as far as I can see, all systems that we currently work with and be alerted to problems when porting to systems without proper NaN support. That seems safer to me than solutions relying on specific bit patterns. |
@tammoippen The K compiler confuses the new function template < class T >
bool
isnan( T f ) with the C macro and stops with an "expected identifier" error. Therefore the function needs another name. @heplesser suggested I compiled NEST on K with the fixes of this pull request combined with pull request #130 and this works fine (after changing the function name to @heplesser Wouldn't the test @tammoippen send me be sufficient to confirm that the employed isnan really works (at least in the context it is used for)?
|
|
@heplesser I have run the manual check: template < typename T >
bool
is_nan( T f )
{
return true;
} gives you
and template < typename T >
bool
is_nan( T f )
{
return false;
} results in
|
👍 for merge. |
Very nice work indeed. I'm all 👍 for merging. Many thanks for all your valuable contributions. |
Replace NAN and std::isnan by numerics::nan and numerics::isnan
* master: Use NewConnect instead of DivergentConnect and remove non-default weight in favor of higher rate. Fixed error message and reporting in case CSA is not available. Make wording more consistent with respect to active and passive speech. improvements as discussed in PR nest#127 Added reference Updated CSA examples to new documentation guidelines. Replace NAN, std::isnan by numerics::nan, numerics::isnan
# Conflicts: # libnestutil/numerics.cpp # libnestutil/numerics.h # nestkernel/connector_model.h # nestkernel/connector_model_impl.h
In response to trac#961 and #123.
We use
NAN
as a default argument in connect functions for weight and delay, as one can use both default delay and default weight, default delay and set a weight, default weight and set a delay or set a weight and a delay. Checking forisnan
seems problematic on K. Hence, I implemented them in thenumerics
namespace to have more control over them:nan
/std::nan
,isnan
/std::isnan
.IS_K
is defined, use a handwrittenisnan
, that compares byte-wise to the defined numerics::nan. See StackOverflow for this.