comparison armadillo-2.4.4/include/armadillo_bits/fn_trunc_exp.hpp @ 0:8b6102e2a9b0

Armadillo Library
author maxzanoni76 <max.zanoni@eecs.qmul.ac.uk>
date Wed, 11 Apr 2012 09:27:06 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:8b6102e2a9b0
1 // Copyright (C) 2008-2010 NICTA (www.nicta.com.au)
2 // Copyright (C) 2008-2010 Conrad Sanderson
3 //
4 // This file is part of the Armadillo C++ library.
5 // It is provided without any warranty of fitness
6 // for any purpose. You can redistribute this file
7 // and/or modify it under the terms of the GNU
8 // Lesser General Public License (LGPL) as published
9 // by the Free Software Foundation, either version 3
10 // of the License or (at your option) any later version.
11 // (see http://www.opensource.org/licenses for more info)
12
13
14
15 //! \addtogroup fn_trunc_exp
16 //! @{
17
18
19
20 template<typename eT>
21 inline
22 static
23 typename arma_float_only<eT>::result
24 trunc_exp(const eT x)
25 {
26 if(std::numeric_limits<eT>::is_iec559 && (x >= Math<eT>::log_max() ))
27 {
28 return std::numeric_limits<eT>::max();
29 }
30 else
31 {
32 return std::exp(x);
33 }
34 }
35
36
37
38 template<typename eT>
39 inline
40 static
41 typename arma_integral_only<eT>::result
42 trunc_exp(const eT x)
43 {
44 return eT( trunc_exp( double(x) ) );
45 }
46
47
48
49 template<typename T>
50 arma_inline
51 static
52 std::complex<T>
53 trunc_exp(const std::complex<T>& x)
54 {
55 return std::exp(x);
56 }
57
58
59
60 template<typename T1>
61 arma_inline
62 const eOp<T1, eop_trunc_exp>
63 trunc_exp(const Base<typename T1::elem_type,T1>& A)
64 {
65 arma_extra_debug_sigprint();
66
67 return eOp<T1, eop_trunc_exp>(A.get_ref());
68 }
69
70
71
72 template<typename T1>
73 arma_inline
74 const eOpCube<T1, eop_trunc_exp>
75 trunc_exp(const BaseCube<typename T1::elem_type,T1>& A)
76 {
77 arma_extra_debug_sigprint();
78
79 return eOpCube<T1, eop_trunc_exp>(A.get_ref());
80 }
81
82
83
84 //! @}