cmath_wrap.hpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 template<typename eT>
00023 arma_inline
00024 bool
00025 arma_isfinite(eT val)
00026 {
00027 return true;
00028 }
00029
00030
00031
00032 template<>
00033 arma_inline
00034 bool
00035 arma_isfinite(float x)
00036 {
00037 #if defined(ARMA_HAVE_STD_ISFINITE)
00038 {
00039 return (std::isfinite(x) != 0);
00040 }
00041 #else
00042 {
00043 const bool x_is_inf = ( (x == x) && ((x - x) != float(0)) );
00044 const bool x_is_nan = (x != x);
00045
00046 return ( (x_is_inf == false) && (x_is_nan == false) );
00047 }
00048 #endif
00049 }
00050
00051
00052
00053 template<>
00054 arma_inline
00055 bool
00056 arma_isfinite(double x)
00057 {
00058 #if defined(ARMA_HAVE_STD_ISFINITE)
00059 {
00060 return (std::isfinite(x) != 0);
00061 }
00062 #else
00063 {
00064 const bool x_is_inf = ( (x == x) && ((x - x) != double(0)) );
00065 const bool x_is_nan = (x != x);
00066
00067 return ( (x_is_inf == false) && (x_is_nan == false) );
00068 }
00069 #endif
00070 }
00071
00072
00073
00074 template<typename T>
00075 arma_inline
00076 bool
00077 arma_isfinite(const std::complex<T>& x)
00078 {
00079 if( (arma_isfinite(x.real()) == false) || (arma_isfinite(x.imag()) == false) )
00080 {
00081 return false;
00082 }
00083 else
00084 {
00085 return true;
00086 }
00087 }
00088
00089
00090
00091