Commit 0eff2f63 authored by Tomáš Oberhuber's avatar Tomáš Oberhuber
Browse files

Fixed problem with std::isnan on older g++.

parent 0da92ca5
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -168,6 +168,24 @@ T sign( const T& a )
   return ( T ) 1;
}

template< class T >
__cuda_callable__
bool isNan( const T& v )
{
#if defined HAVE_CUDA
   #if defined(__CUDA_ARCH__)
      return isnan( v );
   #else
      #if defined (__GNUC__) && ( __GNUC__  < 5 )
         return false;
      #else
         return std::isnan( v );
      #endif
   #endif
#else
   return std::isnan( v );
#endif
}
template< typename Real >
__cuda_callable__
bool isSmall( const Real& v,
+2 −2
Original line number Diff line number Diff line
@@ -107,7 +107,7 @@ bool IterativeSolver< Real, Index> :: checkNextIteration()
{
   this->refreshSolverMonitor();

   if( std::isnan( this->getResidue() ) ||
   if( isNan( this->getResidue() ) ||
       this->getIterations() > this->getMaxIterations()  ||
       ( this->getResidue() > this->getDivergenceResidue() && this->getIterations() >= this->getMinIterations() ) ||
       ( this->getResidue() < this->getConvergenceResidue() && this->getIterations() >= this->getMinIterations() ) )
@@ -120,7 +120,7 @@ bool
IterativeSolver< Real, Index>::
checkConvergence()
{
   if( std::isnan( this->getResidue() ) )
   if( isNan( this->getResidue() ) )
   {
      std::cerr << std::endl << "The residue is NaN." << std::endl;
      return false;
+1 −1
Original line number Diff line number Diff line
@@ -87,7 +87,7 @@ BICGStabL< Matrix >::solve( ConstVectorViewType b, VectorViewType x )
   }

   sigma[ 0 ] = r_0.lpNorm( 2.0 );
   if( std::isnan( sigma[ 0 ] ) )
   if( isNan( sigma[ 0 ] ) )
      throw std::runtime_error( "BiCGstab(ell): initial residue is NAN" );

   r_ast = r_0;