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 00018 //! \addtogroup fn_trunc_exp 00019 //! @{ 00020 00021 00022 00023 template<typename eT> 00024 inline 00025 static 00026 typename arma_float_only<eT>::result 00027 trunc_exp(const eT x) 00028 { 00029 if(std::numeric_limits<eT>::is_iec559 && (x >= Math<eT>::log_max() )) 00030 { 00031 return std::numeric_limits<eT>::max(); 00032 } 00033 else 00034 { 00035 return std::exp(x); 00036 } 00037 } 00038 00039 00040 00041 template<typename eT> 00042 inline 00043 static 00044 typename arma_integral_only<eT>::result 00045 trunc_exp(const eT x) 00046 { 00047 return eT( trunc_exp( double(x) ) ); 00048 } 00049 00050 00051 00052 template<typename T> 00053 arma_inline 00054 static 00055 std::complex<T> 00056 trunc_exp(const std::complex<T>& x) 00057 { 00058 return std::exp(x); 00059 } 00060 00061 00062 00063 template<typename T1> 00064 arma_inline 00065 const eOp<T1, eop_trunc_exp> 00066 trunc_exp(const Base<typename T1::elem_type,T1>& A) 00067 { 00068 arma_extra_debug_sigprint(); 00069 00070 return eOp<T1, eop_trunc_exp>(A.get_ref()); 00071 } 00072 00073 00074 00075 template<typename T1> 00076 arma_inline 00077 const eOpCube<T1, eop_cube_trunc_exp> 00078 trunc_exp(const BaseCube<typename T1::elem_type,T1>& A) 00079 { 00080 arma_extra_debug_sigprint(); 00081 00082 return eOpCube<T1, eop_cube_trunc_exp>(A.get_ref()); 00083 } 00084 00085 00086 00087 //! @}