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
00023 template<typename eT>
00024 arma_inline
00025 bool
00026 arma_isfinite(eT val)
00027 {
00028 return true;
00029 }
00030
00031
00032
00033 template<>
00034 arma_inline
00035 bool
00036 arma_isfinite(float x)
00037 {
00038 #if defined(ARMA_HAVE_STD_ISFINITE)
00039 {
00040 return (std::isfinite(x) != 0);
00041 }
00042 #else
00043 {
00044 const bool x_is_inf = ( (x == x) && ((x - x) != float(0)) );
00045 const bool x_is_nan = (x != x);
00046
00047 return ( (x_is_inf == false) && (x_is_nan == false) );
00048 }
00049 #endif
00050 }
00051
00052
00053
00054 template<>
00055 arma_inline
00056 bool
00057 arma_isfinite(double x)
00058 {
00059 #if defined(ARMA_HAVE_STD_ISFINITE)
00060 {
00061 return (std::isfinite(x) != 0);
00062 }
00063 #else
00064 {
00065 const bool x_is_inf = ( (x == x) && ((x - x) != double(0)) );
00066 const bool x_is_nan = (x != x);
00067
00068 return ( (x_is_inf == false) && (x_is_nan == false) );
00069 }
00070 #endif
00071 }
00072
00073
00074
00075 template<typename T>
00076 arma_inline
00077 bool
00078 arma_isfinite(const std::complex<T>& x)
00079 {
00080 if( (arma_isfinite(x.real()) == false) || (arma_isfinite(x.imag()) == false) )
00081 {
00082 return false;
00083 }
00084 else
00085 {
00086 return true;
00087 }
00088 }
00089
00090
00091
00092