Functions

Cmath_wrap

//! More...

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)

Detailed Description

//!


Function Documentation

template<typename eT >
arma_inline bool arma_isfinite ( eT  val  ) 

Definition at line 32 of file cmath_wrap.hpp.

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

  {
  return true;
  }

template<>
arma_inline bool arma_isfinite ( float  x  ) 

Definition at line 42 of file cmath_wrap.hpp.

  {
  #if defined(ARMA_HAVE_STD_ISFINITE)
    {
    return (std::isfinite(x) != 0);
    }
  #else
    {
    const bool x_is_inf = ( (x == x) && ((x - x) != float(0)) );
    const bool x_is_nan = (x != x);

    return ( (x_is_inf == false) && (x_is_nan == false) );
    }
  #endif
  }

template<>
arma_inline bool arma_isfinite ( double  x  ) 

Definition at line 63 of file cmath_wrap.hpp.

  {
  #if defined(ARMA_HAVE_STD_ISFINITE)
    {
    return (std::isfinite(x) != 0);
    }
  #else
    {
    const bool x_is_inf = ( (x == x) && ((x - x) != double(0)) );
    const bool x_is_nan = (x != x);

    return ( (x_is_inf == false) && (x_is_nan == false) );
    }
  #endif
  }

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

Definition at line 84 of file cmath_wrap.hpp.

References arma_isfinite().

  {
  if( (arma_isfinite(x.real()) == false) || (arma_isfinite(x.imag()) == false) )
    {
    return false;
    }
  else
    {
    return true;
    }
  }

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

Definition at line 139 of file cmath_wrap.hpp.

References acos().

Referenced by eop_aux::acos().

  {
  #if defined(ARMA_HAVE_STD_TR1)
    {
    return std::tr1::acos(x);
    }
  #else
    {
    return arma_boost_wrap(acos, x);
    }
  #endif
  }

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

Definition at line 157 of file cmath_wrap.hpp.

References asin().

Referenced by eop_aux::asin().

  {
  #if defined(ARMA_HAVE_STD_TR1)
    {
    return std::tr1::asin(x);
    }
  #else
    {
    return arma_boost_wrap(asin, x);
    }
  #endif
  }

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

Definition at line 175 of file cmath_wrap.hpp.

References atan().

Referenced by eop_aux::atan().

  {
  #if defined(ARMA_HAVE_STD_TR1)
    {
    return std::tr1::atan(x);
    }
  #else
    {
    return arma_boost_wrap(atan, x);
    }
  #endif
  }

template<typename eT >
arma_inline eT arma_acosh ( const eT  x  ) 

Definition at line 193 of file cmath_wrap.hpp.

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

Referenced by eop_aux::acosh().

  {
  #if defined(ARMA_HAVE_STD_TR1)
    {
    return std::tr1::acosh(x);
    }
  #elif defined(ARMA_USE_BOOST)
    {
    return boost::math::acosh(x);
    }
  #else
    {
    if(x >= eT(1))
      {
      // http://functions.wolfram.com/ElementaryFunctions/ArcCosh/02/
      return std::log( x + std::sqrt(x*x - eT(1)) );
      }
    else
      {
      if(std::numeric_limits<eT>::has_quiet_NaN == true)
        {
        return -(std::numeric_limits<eT>::quiet_NaN());
        }
      else
        {
        return eT(0);
        }
      }
    }
  #endif
  }

template<typename eT >
arma_inline eT arma_asinh ( const eT  x  ) 

Definition at line 230 of file cmath_wrap.hpp.

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

Referenced by eop_aux::asinh().

  {
  #if defined(ARMA_HAVE_STD_TR1)
    {
    return std::tr1::asinh(x);
    }
  #elif defined(ARMA_USE_BOOST)
    {
    return boost::math::asinh(x);
    }
  #else
    {
    // http://functions.wolfram.com/ElementaryFunctions/ArcSinh/02/
    return std::log( x + std::sqrt(x*x + eT(1)) );
    }
  #endif
  }

template<typename eT >
arma_inline eT arma_atanh ( const eT  x  ) 

Definition at line 253 of file cmath_wrap.hpp.

References atanh(), and log().

Referenced by eop_aux::atanh().

  {
  #if defined(ARMA_HAVE_STD_TR1)
    {
    return std::tr1::atanh(x);
    }
  #elif defined(ARMA_USE_BOOST)
    {
    return boost::math::atanh(x);
    }
  #else
    {
    if( (x >= eT(-1)) && (x <= eT(+1)) )
      {
      // http://functions.wolfram.com/ElementaryFunctions/ArcTanh/02/
      return std::log( ( eT(1)+x ) / ( eT(1)-x ) ) / eT(2);
      }
    else
      {
      if(std::numeric_limits<eT>::has_quiet_NaN == true)
        {
        return -(std::numeric_limits<eT>::quiet_NaN());
        }
      else
        {
        return eT(0);
        }
      }
    }
  #endif
  }

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

Definition at line 290 of file cmath_wrap.hpp.

References acosh().

  {
  #if defined(ARMA_HAVE_STD_TR1)
    {
    return std::tr1::acosh(x);
    }
  #else
    {
    return arma_boost_wrap(acosh, x);
    }
  #endif
  }

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

Definition at line 308 of file cmath_wrap.hpp.

References asinh().

  {
  #if defined(ARMA_HAVE_STD_TR1)
    {
    return std::tr1::asinh(x);
    }
  #else
    {
    return arma_boost_wrap(asinh, x);
    }
  #endif
  }

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

Definition at line 326 of file cmath_wrap.hpp.

References atanh().

  {
  #if defined(ARMA_HAVE_STD_TR1)
    {
    return std::tr1::atanh(x);
    }
  #else
    {
    return arma_boost_wrap(atanh, x);
    }
  #endif
  }