op_misc_meat.hpp

Go to the documentation of this file.
00001 // Copyright (C) 2010 NICTA and the authors listed below
00002 // http://nicta.com.au
00003 // 
00004 // Authors:
00005 // - Conrad Sanderson (conradsand at ieee dot org)
00006 // 
00007 // This file is part of the Armadillo C++ library.
00008 // It is provided without any warranty of fitness
00009 // for any purpose. You can redistribute this file
00010 // and/or modify it under the terms of the GNU
00011 // Lesser General Public License (LGPL) as published
00012 // by the Free Software Foundation, either version 3
00013 // of the License or (at your option) any later version.
00014 // (see http://www.opensource.org/licenses for more info)
00015 
00016 
00017 //! \addtogroup op_misc
00018 //! @{
00019 
00020 
00021 
00022 template<typename T1>
00023 inline void
00024 op_real::apply( Mat<typename T1::pod_type>& out, const mtOp<typename T1::pod_type, T1, op_real>& X)
00025   {
00026   arma_extra_debug_sigprint();
00027   
00028   typedef typename T1::pod_type T;
00029   
00030   const Proxy<T1> A(X.m);
00031   
00032   out.set_size(A.n_rows, A.n_cols);
00033   
00034   const u32 n_elem  = A.n_elem;
00035         T*  out_mem = out.memptr();
00036   
00037   for(u32 i=0; i<n_elem; ++i)
00038     {
00039     out_mem[i] = std::real(A[i]);
00040     }
00041   }
00042 
00043 
00044 
00045 template<typename T1>
00046 inline void
00047 op_imag::apply( Mat<typename T1::pod_type>& out, const mtOp<typename T1::pod_type, T1, op_imag>& X)
00048   {
00049   arma_extra_debug_sigprint();
00050   
00051   typedef typename T1::pod_type T;
00052   
00053   const Proxy<T1> A(X.m);
00054   
00055   out.set_size(A.n_rows, A.n_cols);
00056   
00057   const u32 n_elem  = A.n_elem;
00058         T*  out_mem = out.memptr();
00059   
00060   for(u32 i=0; i<n_elem; ++i)
00061     {
00062     out_mem[i] = std::imag(A[i]);
00063     }
00064   }
00065 
00066 
00067 
00068 template<typename T1>
00069 inline void
00070 op_abs::apply( Mat<typename T1::pod_type>& out, const mtOp<typename T1::pod_type, T1, op_abs>& X)
00071   {
00072   arma_extra_debug_sigprint();
00073   
00074   typedef typename T1::pod_type T;
00075   
00076   const Proxy<T1> A(X.m);
00077   
00078   out.set_size(A.n_rows, A.n_cols);
00079   
00080   const u32 n_elem  = A.n_elem;
00081         T*  out_mem = out.memptr();
00082   
00083   for(u32 i=0; i<n_elem; ++i)
00084     {
00085     out_mem[i] = std::abs(A[i]);
00086     }
00087   }
00088 
00089 
00090 
00091 //! @}