comparison armadillo-2.4.4/include/armadillo_bits/fn_trunc_log.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 //! \addtogroup fn_trunc_log
15 //! @{
16
17
18
19 template<typename eT>
20 inline
21 static
22 typename arma_float_only<eT>::result
23 trunc_log(const eT x)
24 {
25 if(std::numeric_limits<eT>::is_iec559)
26 {
27 if(x == std::numeric_limits<eT>::infinity())
28 {
29 return Math<eT>::log_max();
30 }
31 else
32 {
33 return (x <= eT(0)) ? Math<eT>::log_min() : std::log(x);
34 }
35 }
36 else
37 {
38 return std::log(x);
39 }
40 }
41
42
43
44 template<typename eT>
45 inline
46 static
47 typename arma_integral_only<eT>::result
48 trunc_log(const eT x)
49 {
50 return eT( trunc_log( double(x) ) );
51 }
52
53
54
55 template<typename T>
56 inline
57 static
58 std::complex<T>
59 trunc_log(const std::complex<T>& x)
60 {
61 return std::log(x);
62 }
63
64
65
66 template<typename T1>
67 arma_inline
68 const eOp<T1, eop_trunc_log>
69 trunc_log(const Base<typename T1::elem_type,T1>& A)
70 {
71 arma_extra_debug_sigprint();
72
73 return eOp<T1, eop_trunc_log>(A.get_ref());
74 }
75
76
77
78 template<typename T1>
79 arma_inline
80 const eOpCube<T1, eop_trunc_log>
81 trunc_log(const BaseCube<typename T1::elem_type,T1>& A)
82 {
83 arma_extra_debug_sigprint();
84
85 return eOpCube<T1, eop_trunc_log>(A.get_ref());
86 }
87
88
89
90 //! @}