1 // SPDX-License-Identifier: Apache-2.0
2 //
3 // Copyright 2008-2016 Conrad Sanderson (http://conradsanderson.id.au)
4 // Copyright 2008-2016 National ICT Australia (NICTA)
5 //
6 // Licensed under the Apache License, Version 2.0 (the "License");
7 // you may not use this file except in compliance with the License.
8 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 // ------------------------------------------------------------------------
17 
18 
19 
20 //! \addtogroup fn_eps
21 //! @{
22 
23 
24 
25 template<typename T1>
26 arma_warn_unused
27 inline
28 const eOp<T1, eop_eps>
eps(const Base<typename T1::elem_type,T1> & X,const typename arma_not_cx<typename T1::elem_type>::result * junk=nullptr)29 eps(const Base<typename T1::elem_type, T1>& X, const typename arma_not_cx<typename T1::elem_type>::result* junk = nullptr)
30   {
31   arma_extra_debug_sigprint();
32   arma_ignore(junk);
33 
34   return eOp<T1, eop_eps>(X.get_ref());
35   }
36 
37 
38 
39 template<typename T1>
40 arma_warn_unused
41 inline
42 Mat< typename T1::pod_type >
eps(const Base<std::complex<typename T1::pod_type>,T1> & X,const typename arma_cx_only<typename T1::elem_type>::result * junk=nullptr)43 eps(const Base< std::complex<typename T1::pod_type>, T1>& X, const typename arma_cx_only<typename T1::elem_type>::result* junk = nullptr)
44   {
45   arma_extra_debug_sigprint();
46   arma_ignore(junk);
47 
48   typedef typename T1::pod_type   T;
49   typedef typename T1::elem_type eT;
50 
51   const unwrap<T1>   tmp(X.get_ref());
52   const Mat<eT>& A = tmp.M;
53 
54   Mat<T> out(A.n_rows, A.n_cols, arma_nozeros_indicator());
55 
56          T* out_mem = out.memptr();
57   const eT*   A_mem =   A.memptr();
58 
59   const uword n_elem = A.n_elem;
60 
61   for(uword i=0; i<n_elem; ++i)
62     {
63     out_mem[i] = eop_aux::direct_eps( A_mem[i] );
64     }
65 
66   return out;
67   }
68 
69 
70 
71 template<typename eT>
72 arma_warn_unused
73 arma_inline
74 typename arma_integral_only<eT>::result
eps(const eT & x)75 eps(const eT& x)
76   {
77   arma_ignore(x);
78 
79   return eT(0);
80   }
81 
82 
83 
84 template<typename eT>
85 arma_warn_unused
86 arma_inline
87 typename arma_real_only<eT>::result
eps(const eT & x)88 eps(const eT& x)
89   {
90   return eop_aux::direct_eps(x);
91   }
92 
93 
94 
95 template<typename T>
96 arma_warn_unused
97 arma_inline
98 typename arma_real_only<T>::result
eps(const std::complex<T> & x)99 eps(const std::complex<T>& x)
100   {
101   return eop_aux::direct_eps(x);
102   }
103 
104 
105 
106 //! @}
107