Commit 6e543d20 authored by Peter Eastman's avatar Peter Eastman
Browse files

Fixed compilation errors

parent 9904545a
...@@ -44,11 +44,7 @@ ...@@ -44,11 +44,7 @@
#include <sstream> #include <sstream>
#include <typeinfo> #include <typeinfo>
#ifdef _MSC_VER #include <limits>
#include <limits>
#define isinf !_finite
#define isnan _isnan
#endif
namespace OpenMM { namespace OpenMM {
...@@ -111,14 +107,14 @@ public: ...@@ -111,14 +107,14 @@ public:
static const std::string CUSTOM_NONBONDED_FORCE; static const std::string CUSTOM_NONBONDED_FORCE;
/** /**
* Return true if input number is nan * Return true if input number is nan or infinity
* *
* @param number number to test * @param number number to test
* *
* @return true if number is nan * @return true if number is nan or infinity
*/ */
static int isNan( double number ); static int isNanOrInfinity( double number );
/** /**
* Get force name * Get force name
......
...@@ -78,8 +78,8 @@ ValidateOpenMM::~ValidateOpenMM() { ...@@ -78,8 +78,8 @@ ValidateOpenMM::~ValidateOpenMM() {
} }
int ValidateOpenMM::isNan( double number ){ int ValidateOpenMM::isNanOrInfinity( double number ){
return isinf( number ) || isnan( number ) ? 1 : 0; return (number != number || number == std::numeric_limits<double>::infinity() || number == -std::numeric_limits<double>::infinity()) ? 1 : 0;
} }
FILE* ValidateOpenMM::getLog( void ) const { FILE* ValidateOpenMM::getLog( void ) const {
......
...@@ -46,7 +46,7 @@ ForceValidationResult::ForceValidationResult( const Context& context1, const Con ...@@ -46,7 +46,7 @@ ForceValidationResult::ForceValidationResult( const Context& context1, const Con
_potentialEnergies[0] = state1.getPotentialEnergy(); _potentialEnergies[0] = state1.getPotentialEnergy();
_potentialEnergies[1] = state2.getPotentialEnergy(); _potentialEnergies[1] = state2.getPotentialEnergy();
if( ValidateOpenMM::isNan( _potentialEnergies[0] ) || ValidateOpenMM::isNan( _potentialEnergies[1] ) ){ if( ValidateOpenMM::isNanOrInfinity( _potentialEnergies[0] ) || ValidateOpenMM::isNanOrInfinity( _potentialEnergies[1] ) ){
_nansDetected++; _nansDetected++;
} }
...@@ -154,7 +154,7 @@ void ForceValidationResult::_calculateNormOfForceVector( int forceIndex ){ ...@@ -154,7 +154,7 @@ void ForceValidationResult::_calculateNormOfForceVector( int forceIndex ){
for( unsigned int ii = 0; ii < _forces[forceIndex].size(); ii++ ){ for( unsigned int ii = 0; ii < _forces[forceIndex].size(); ii++ ){
Vec3 f1 = _forces[forceIndex][ii]; Vec3 f1 = _forces[forceIndex][ii];
_norms[forceIndex].push_back( std::sqrt( (f1[0]*f1[0]) + (f1[1]*f1[1]) + (f1[2]*f1[2]) ) ); _norms[forceIndex].push_back( std::sqrt( (f1[0]*f1[0]) + (f1[1]*f1[1]) + (f1[2]*f1[2]) ) );
if( ValidateOpenMM::isNan( f1[0] ) || ValidateOpenMM::isNan( f1[1] ) || ValidateOpenMM::isNan( f1[2] ) ){ if( ValidateOpenMM::isNanOrInfinity( f1[0] ) || ValidateOpenMM::isNanOrInfinity( f1[1] ) || ValidateOpenMM::isNanOrInfinity( f1[2] ) ){
_nansDetected++; _nansDetected++;
} }
} }
...@@ -375,7 +375,7 @@ void ForceValidationResult::compareForces( double tolerance ){ ...@@ -375,7 +375,7 @@ void ForceValidationResult::compareForces( double tolerance ){
clearInconsistentForceIndexList( ); clearInconsistentForceIndexList( );
for( unsigned int jj = 0; jj < forces1.size(); jj++ ){ for( unsigned int jj = 0; jj < forces1.size(); jj++ ){
if( ValidateOpenMM::isNan( forceNorms1[jj] ) || ValidateOpenMM::isNan( forceNorms2[jj] ) ){ if( ValidateOpenMM::isNanOrInfinity( forceNorms1[jj] ) || ValidateOpenMM::isNanOrInfinity( forceNorms2[jj] ) ){
registerInconsistentForceIndex( jj ); registerInconsistentForceIndex( jj );
} else { } else {
double delta = std::sqrt( (forces1[jj][0]-forces2[jj][0])*(forces1[jj][0]-forces2[jj][0]) + double delta = std::sqrt( (forces1[jj][0]-forces2[jj][0])*(forces1[jj][0]-forces2[jj][0]) +
...@@ -405,7 +405,7 @@ void ForceValidationResult::compareForceNorms( double tolerance ){ ...@@ -405,7 +405,7 @@ void ForceValidationResult::compareForceNorms( double tolerance ){
clearInconsistentForceIndexList( ); clearInconsistentForceIndexList( );
for( unsigned int jj = 0; jj < forceNorms0.size(); jj++ ){ for( unsigned int jj = 0; jj < forceNorms0.size(); jj++ ){
if( ValidateOpenMM::isNan( forceNorms0[jj] ) || ValidateOpenMM::isNan( forceNorms1[jj] ) ){ if( ValidateOpenMM::isNanOrInfinity( forceNorms0[jj] ) || ValidateOpenMM::isNanOrInfinity( forceNorms1[jj] ) ){
registerInconsistentForceIndex( jj ); registerInconsistentForceIndex( jj );
} else { } else {
double sum = 0.5*( fabs( forceNorms0[jj] ) + fabs( forceNorms1[jj] ) ); double sum = 0.5*( fabs( forceNorms0[jj] ) + fabs( forceNorms1[jj] ) );
...@@ -829,7 +829,7 @@ std::string ValidateOpenMMForces::getSummary( std::vector<ForceValidationResult* ...@@ -829,7 +829,7 @@ std::string ValidateOpenMMForces::getSummary( std::vector<ForceValidationResult*
std::vector<double> forceNorms2 = forceValidationResults[ii]->getForceNorms( 1 ); std::vector<double> forceNorms2 = forceValidationResults[ii]->getForceNorms( 1 );
for( unsigned int kk = 0; kk < inconsistentIndices.size() && kk < maxMissesToPrint; kk++ ){ for( unsigned int kk = 0; kk < inconsistentIndices.size() && kk < maxMissesToPrint; kk++ ){
int jj = inconsistentIndices[kk]; int jj = inconsistentIndices[kk];
if( isNan( forceNorms1[jj] ) || isNan( forceNorms2[jj] ) ){ if( isNanOrInfinity( forceNorms1[jj] ) || isNanOrInfinity( forceNorms2[jj] ) ){
(void) LOCAL_SPRINTF5( value, " nan at index %6d norms: [%12.5e %12.5e]", jj, forceNorms1[jj], forceNorms2[jj] ); (void) LOCAL_SPRINTF5( value, " nan at index %6d norms: [%12.5e %12.5e]", jj, forceNorms1[jj], forceNorms2[jj] );
summary << _getLine( tab, "Error", value ); summary << _getLine( tab, "Error", value );
} else { } else {
......
...@@ -66,10 +66,6 @@ protected: ...@@ -66,10 +66,6 @@ protected:
* The ForceImpl will be deleted automatically when the Context is deleted. * The ForceImpl will be deleted automatically when the Context is deleted.
*/ */
virtual ForceImpl* createImpl() = 0; virtual ForceImpl* createImpl() = 0;
private:
Force& operator=(const Force& rhs);
Force(const Force& rhs);
}; };
} // namespace OpenMM } // namespace OpenMM
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment