Cmath_wrap

Functions

template<typename eT >
arma_inline bool arma_isfinite (eT val)
template<>
arma_inline bool arma_isfinite (float x)
template<>
arma_inline bool arma_isfinite (double x)
template<typename T >
arma_inline bool arma_isfinite (const std::complex< T > &x)
template<typename T >
arma_inline std::complex< T > arma_acos (const std::complex< T > &x)
template<typename T >
arma_inline std::complex< T > arma_asin (const std::complex< T > &x)
template<typename T >
arma_inline std::complex< T > arma_atan (const std::complex< T > &x)
template<typename eT >
arma_inline eT arma_acosh (const eT x)
template<typename eT >
arma_inline eT arma_asinh (const eT x)
template<typename eT >
arma_inline eT arma_atanh (const eT x)
template<typename T >
arma_inline std::complex< T > arma_acosh (const std::complex< T > &x)
template<typename T >
arma_inline std::complex< T > arma_asinh (const std::complex< T > &x)
template<typename T >
arma_inline std::complex< T > arma_atanh (const std::complex< T > &x)

Function Documentation

template<typename eT >
arma_inline bool arma_isfinite ( eT  val  )  [inline]

Definition at line 32 of file cmath_wrap.hpp.

Referenced by arma_isfinite(), Mat< eT >::is_finite(), Cube< eT >::is_finite(), log_add(), and running_stat< eT >::operator()().

00033   {
00034   return true;
00035   }

template<>
arma_inline bool arma_isfinite ( float  x  )  [inline]

Definition at line 42 of file cmath_wrap.hpp.

00043   {
00044   #if defined(ARMA_HAVE_STD_ISFINITE)
00045     {
00046     return (std::isfinite(x) != 0);
00047     }
00048   #else
00049     {
00050     const bool x_is_inf = ( (x == x) && ((x - x) != float(0)) );
00051     const bool x_is_nan = (x != x);
00052 
00053     return ( (x_is_inf == false) && (x_is_nan == false) );
00054     }
00055   #endif
00056   }

template<>
arma_inline bool arma_isfinite ( double  x  )  [inline]

Definition at line 63 of file cmath_wrap.hpp.

00064   {
00065   #if defined(ARMA_HAVE_STD_ISFINITE)
00066     {
00067     return (std::isfinite(x) != 0);
00068     }
00069   #else
00070     {
00071     const bool x_is_inf = ( (x == x) && ((x - x) != double(0)) );
00072     const bool x_is_nan = (x != x);
00073 
00074     return ( (x_is_inf == false) && (x_is_nan == false) );
00075     }
00076   #endif
00077   }

template<typename T >
arma_inline bool arma_isfinite ( const std::complex< T > &  x  )  [inline]

Definition at line 84 of file cmath_wrap.hpp.

References arma_isfinite().

00085   {
00086   if( (arma_isfinite(x.real()) == false) || (arma_isfinite(x.imag()) == false) )
00087     {
00088     return false;
00089     }
00090   else
00091     {
00092     return true;
00093     }
00094   }

template<typename T >
arma_inline std::complex<T> arma_acos ( const std::complex< T > &  x  )  [inline]

Definition at line 139 of file cmath_wrap.hpp.

References acos().

Referenced by eop_aux::acos().

00140   {
00141   #if defined(ARMA_HAVE_STD_TR1)
00142     {
00143     return std::tr1::acos(x);
00144     }
00145   #else
00146     {
00147     return arma_boost_wrap(acos, x);
00148     }
00149   #endif
00150   }

template<typename T >
arma_inline std::complex<T> arma_asin ( const std::complex< T > &  x  )  [inline]

Definition at line 157 of file cmath_wrap.hpp.

References asin().

Referenced by eop_aux::asin().

00158   {
00159   #if defined(ARMA_HAVE_STD_TR1)
00160     {
00161     return std::tr1::asin(x);
00162     }
00163   #else
00164     {
00165     return arma_boost_wrap(asin, x);
00166     }
00167   #endif
00168   }

template<typename T >
arma_inline std::complex<T> arma_atan ( const std::complex< T > &  x  )  [inline]

Definition at line 175 of file cmath_wrap.hpp.

References atan().

Referenced by eop_aux::atan().

00176   {
00177   #if defined(ARMA_HAVE_STD_TR1)
00178     {
00179     return std::tr1::atan(x);
00180     }
00181   #else
00182     {
00183     return arma_boost_wrap(atan, x);
00184     }
00185   #endif
00186   }

template<typename eT >
arma_inline eT arma_acosh ( const eT  x  )  [inline]

Definition at line 193 of file cmath_wrap.hpp.

References acosh(), log(), and sqrt().

Referenced by eop_aux::acosh().

00194   {
00195   #if defined(ARMA_HAVE_STD_TR1)
00196     {
00197     return std::tr1::acosh(x);
00198     }
00199   #elif defined(ARMA_USE_BOOST)
00200     {
00201     return boost::math::acosh(x);
00202     }
00203   #else
00204     {
00205     if(x >= eT(1))
00206       {
00207       // http://functions.wolfram.com/ElementaryFunctions/ArcCosh/02/
00208       return std::log( x + std::sqrt(x*x - eT(1)) );
00209       }
00210     else
00211       {
00212       if(std::numeric_limits<eT>::has_quiet_NaN == true)
00213         {
00214         return -(std::numeric_limits<eT>::quiet_NaN());
00215         }
00216       else
00217         {
00218         return eT(0);
00219         }
00220       }
00221     }
00222   #endif
00223   }

template<typename eT >
arma_inline eT arma_asinh ( const eT  x  )  [inline]

Definition at line 230 of file cmath_wrap.hpp.

References asinh(), log(), and sqrt().

Referenced by eop_aux::asinh().

00231   {
00232   #if defined(ARMA_HAVE_STD_TR1)
00233     {
00234     return std::tr1::asinh(x);
00235     }
00236   #elif defined(ARMA_USE_BOOST)
00237     {
00238     return boost::math::asinh(x);
00239     }
00240   #else
00241     {
00242     // http://functions.wolfram.com/ElementaryFunctions/ArcSinh/02/
00243     return std::log( x + std::sqrt(x*x + eT(1)) );
00244     }
00245   #endif
00246   }

template<typename eT >
arma_inline eT arma_atanh ( const eT  x  )  [inline]

Definition at line 253 of file cmath_wrap.hpp.

References atanh(), and log().

Referenced by eop_aux::atanh().

00254   {
00255   #if defined(ARMA_HAVE_STD_TR1)
00256     {
00257     return std::tr1::atanh(x);
00258     }
00259   #elif defined(ARMA_USE_BOOST)
00260     {
00261     return boost::math::atanh(x);
00262     }
00263   #else
00264     {
00265     if( (x >= eT(-1)) && (x <= eT(+1)) )
00266       {
00267       // http://functions.wolfram.com/ElementaryFunctions/ArcTanh/02/
00268       return std::log( ( eT(1)+x ) / ( eT(1)-x ) ) / eT(2);
00269       }
00270     else
00271       {
00272       if(std::numeric_limits<eT>::has_quiet_NaN == true)
00273         {
00274         return -(std::numeric_limits<eT>::quiet_NaN());
00275         }
00276       else
00277         {
00278         return eT(0);
00279         }
00280       }
00281     }
00282   #endif
00283   }

template<typename T >
arma_inline std::complex<T> arma_acosh ( const std::complex< T > &  x  )  [inline]

Definition at line 290 of file cmath_wrap.hpp.

References acosh().

00291   {
00292   #if defined(ARMA_HAVE_STD_TR1)
00293     {
00294     return std::tr1::acosh(x);
00295     }
00296   #else
00297     {
00298     return arma_boost_wrap(acosh, x);
00299     }
00300   #endif
00301   }

template<typename T >
arma_inline std::complex<T> arma_asinh ( const std::complex< T > &  x  )  [inline]

Definition at line 308 of file cmath_wrap.hpp.

References asinh().

00309   {
00310   #if defined(ARMA_HAVE_STD_TR1)
00311     {
00312     return std::tr1::asinh(x);
00313     }
00314   #else
00315     {
00316     return arma_boost_wrap(asinh, x);
00317     }
00318   #endif
00319   }

template<typename T >
arma_inline std::complex<T> arma_atanh ( const std::complex< T > &  x  )  [inline]

Definition at line 326 of file cmath_wrap.hpp.

References atanh().

00327   {
00328   #if defined(ARMA_HAVE_STD_TR1)
00329     {
00330     return std::tr1::atanh(x);
00331     }
00332   #else
00333     {
00334     return arma_boost_wrap(atanh, x);
00335     }
00336   #endif
00337   }