comparison armadillo-2.4.4/include/armadillo_bits/fn_eps.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) 2009-2010 NICTA (www.nicta.com.au)
2 // Copyright (C) 2009-2010 Conrad Sanderson
3 // Copyright (C) 2009-2010 Dimitrios Bouzas
4 //
5 // This file is part of the Armadillo C++ library.
6 // It is provided without any warranty of fitness
7 // for any purpose. You can redistribute this file
8 // and/or modify it under the terms of the GNU
9 // Lesser General Public License (LGPL) as published
10 // by the Free Software Foundation, either version 3
11 // of the License or (at your option) any later version.
12 // (see http://www.opensource.org/licenses for more info)
13
14
15
16 //! \addtogroup fn_eps
17 //! @{
18
19
20
21 //! \brief
22 //! eps version for non-complex matrices and vectors
23 template<typename T1>
24 inline
25 const eOp<T1, eop_eps>
26 eps(const Base<typename T1::elem_type, T1>& X, const typename arma_not_cx<typename T1::elem_type>::result* junk = 0)
27 {
28 arma_extra_debug_sigprint();
29
30 arma_ignore(junk);
31
32 typedef typename T1::elem_type eT;
33
34 return eOp<T1, eop_eps>(X.get_ref());
35 }
36
37
38
39 //! \brief
40 //! eps version for complex matrices and vectors
41 template<typename T1>
42 inline
43 Mat< typename T1::pod_type >
44 eps(const Base< std::complex<typename T1::pod_type>, T1>& X, const typename arma_cx_only<typename T1::elem_type>::result* junk = 0)
45 {
46 arma_extra_debug_sigprint();
47
48 arma_ignore(junk);
49
50 typedef typename T1::pod_type T;
51 typedef typename T1::elem_type eT;
52
53 const unwrap<T1> tmp(X.get_ref());
54 const Mat<eT>& A = tmp.M;
55
56 Mat<T> out(A.n_rows, A.n_cols);
57
58 T* out_mem = out.memptr();
59 const eT* A_mem = A.memptr();
60 const uword n_elem = A.n_elem;
61
62 for(uword i=0; i<n_elem; ++i)
63 {
64 out_mem[i] = eop_aux::direct_eps( A_mem[i] );
65 }
66
67
68 return out;
69 }
70
71
72
73 template<typename eT>
74 arma_inline
75 arma_warn_unused
76 typename arma_integral_only<eT>::result
77 eps(const eT& x)
78 {
79 arma_ignore(x);
80
81 return eT(0);
82 }
83
84
85
86 template<typename eT>
87 arma_inline
88 arma_warn_unused
89 typename arma_float_only<eT>::result
90 eps(const eT& x)
91 {
92 return eop_aux::direct_eps(x);
93 }
94
95
96
97 template<typename T>
98 arma_inline
99 arma_warn_unused
100 typename arma_float_only<T>::result
101 eps(const std::complex<T>& x)
102 {
103 return eop_aux::direct_eps(x);
104 }
105
106
107
108 //! @}