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