fn_trunc_log.hpp

Go to the documentation of this file.
00001 // Copyright (C) 2010 NICTA and the authors listed below
00002 // http://nicta.com.au
00003 // 
00004 // Authors:
00005 // - Conrad Sanderson (conradsand at ieee dot org)
00006 // 
00007 // This file is part of the Armadillo C++ library.
00008 // It is provided without any warranty of fitness
00009 // for any purpose. You can redistribute this file
00010 // and/or modify it under the terms of the GNU
00011 // Lesser General Public License (LGPL) as published
00012 // by the Free Software Foundation, either version 3
00013 // of the License or (at your option) any later version.
00014 // (see http://www.opensource.org/licenses for more info)
00015 
00016 
00017 //! \addtogroup fn_trunc_log
00018 //! @{
00019 
00020 
00021 
00022 template<typename eT>
00023 inline 
00024 static
00025 typename arma_float_only<eT>::result
00026 trunc_log(const eT x)
00027   {
00028   if(std::numeric_limits<eT>::is_iec559)
00029     {
00030     if(x == std::numeric_limits<eT>::infinity())
00031       {
00032       return Math<eT>::log_max();
00033       }
00034     else
00035       {
00036       return (x <= eT(0)) ? Math<eT>::log_min() : std::log(x);
00037       }
00038     }
00039   else
00040     {
00041     return std::log(x);
00042     }
00043   }
00044 
00045 
00046 
00047 template<typename eT>
00048 inline 
00049 static
00050 typename arma_integral_only<eT>::result
00051 trunc_log(const eT x)
00052   {
00053   return eT( trunc_log( double(x) ) );
00054   }
00055 
00056 
00057 
00058 template<typename T>
00059 inline 
00060 static
00061 std::complex<T>
00062 trunc_log(const std::complex<T>& x)
00063   {
00064   return std::log(x);
00065   }
00066 
00067 
00068 
00069 template<typename T1>
00070 arma_inline
00071 const eOp<T1, eop_trunc_log>
00072 trunc_log(const Base<typename T1::elem_type,T1>& A)
00073   {
00074   arma_extra_debug_sigprint();
00075   
00076   return eOp<T1, eop_trunc_log>(A.get_ref());
00077   }
00078 
00079 
00080 
00081 template<typename T1>
00082 arma_inline
00083 const eOpCube<T1, eop_cube_trunc_log>
00084 trunc_log(const BaseCube<typename T1::elem_type,T1>& A)
00085   {
00086   arma_extra_debug_sigprint();
00087   
00088   return eOpCube<T1, eop_cube_trunc_log>(A.get_ref());
00089   }
00090 
00091 
00092 
00093 //! @}