fn_eps.hpp

Go to the documentation of this file.
00001 // Copyright (C) 2009 NICTA
00002 // Copyright (C) 2009 Dimitrios Bouzas
00003 // 
00004 // Authors:
00005 // - Conrad Sanderson (conradsand at ieee dot org)
00006 // - Dimitrios Bouzas (dimitris dot mpouzas at gmail dot com)
00007 // 
00008 // This file is part of the Armadillo C++ library.
00009 // It is provided without any warranty of fitness
00010 // for any purpose. You can redistribute this file
00011 // and/or modify it under the terms of the GNU
00012 // Lesser General Public License (LGPL) as published
00013 // by the Free Software Foundation, either version 3
00014 // of the License or (at your option) any later version.
00015 // (see http://www.opensource.org/licenses for more info)
00016 
00017 
00018 
00019 //! \addtogroup fn_eps
00020 //! @{
00021 
00022 
00023 
00024 //! \brief
00025 //! eps version for non-complex matrices and vectors
00026 template<typename T1>
00027 inline
00028 const Op<T1, op_eps>
00029 eps(const Base<typename T1::elem_type, T1>& X)
00030   {
00031   arma_extra_debug_sigprint();
00032   
00033   typedef typename T1::elem_type eT;
00034   
00035   isnt_fltpt<eT>::check();
00036   
00037   return Op<T1, op_eps>(X.get_ref());
00038   }
00039 
00040 
00041 
00042 //! \brief
00043 //! eps version for complex matrices and vectors
00044 template<typename T1>
00045 inline
00046 Mat< typename T1::pod_type >
00047 eps(const Base< std::complex<typename T1::pod_type>, T1>& X)
00048   {
00049   arma_extra_debug_sigprint();
00050   
00051   typedef typename T1::pod_type   T;
00052   typedef typename T1::elem_type eT;
00053   
00054   isnt_fltpt<T>::check();
00055   
00056   const unwrap<T1>   tmp(X.get_ref());
00057   const Mat<eT>& A = tmp.M;
00058   
00059   Mat<T> out;
00060   op_eps::direct_eps(out, A);
00061   
00062   return out;
00063   }
00064 
00065 
00066 
00067 //! \brief
00068 //! eps version for scalars of type float
00069 arma_inline
00070 float
00071 eps(const float x)
00072   {
00073   return op_eps::direct_eps(x);
00074   }
00075 
00076 
00077 
00078 //! \brief
00079 //! eps version for scalars of type double
00080 arma_inline
00081 double
00082 eps(const double x)
00083   {
00084   return op_eps::direct_eps(x);
00085   }
00086 
00087 
00088 
00089 //! \brief
00090 //! eps version for std::complex<float>
00091 arma_inline
00092 float
00093 eps(const std::complex<float>& x)
00094   {
00095   return op_eps::direct_eps(x);
00096   }
00097 
00098 
00099 
00100 //! \brief
00101 //! eps version for std::complex<double>
00102 arma_inline
00103 double
00104 eps(const std::complex<double>& x)
00105   {
00106   return op_eps::direct_eps(x);
00107   }
00108 
00109 
00110 
00111 //! @}