operator_div.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 operator_div
00018 //! @{
00019 
00020 
00021 
00022 //! Base / scalar
00023 template<typename T1>
00024 arma_inline
00025 const eOp<T1, eop_scalar_div_post>
00026 operator/
00027   (
00028   const Base<typename T1::elem_type,T1>& X,
00029   const typename T1::elem_type           k
00030   )
00031   {
00032   arma_extra_debug_sigprint();
00033   
00034   return eOp<T1, eop_scalar_div_post>(X.get_ref(), k);
00035   }
00036 
00037 
00038 
00039 //! scalar / Base
00040 template<typename T1>
00041 arma_inline
00042 const eOp<T1, eop_scalar_div_pre>
00043 operator/
00044   (
00045   const typename T1::elem_type           k,
00046   const Base<typename T1::elem_type,T1>& X
00047   )
00048   {
00049   arma_extra_debug_sigprint();
00050   
00051   return eOp<T1, eop_scalar_div_pre>(X.get_ref(), k);
00052   }
00053 
00054 
00055 
00056 //! complex scalar / non-complex Base (experimental)
00057 template<typename T1>
00058 arma_inline
00059 const mtOp<typename std::complex<typename T1::pod_type>, T1, op_cx_scalar_div_pre>
00060 operator/
00061   (
00062   const std::complex<typename T1::pod_type>& k,
00063   const Base<typename T1::pod_type, T1>&     X
00064   )
00065   {
00066   arma_extra_debug_sigprint();
00067   
00068   return mtOp<typename std::complex<typename T1::pod_type>, T1, op_cx_scalar_div_pre>('j', X.get_ref(), k);
00069   }
00070 
00071 
00072 
00073 //! non-complex Base / complex scalar (experimental)
00074 template<typename T1>
00075 arma_inline
00076 const mtOp<typename std::complex<typename T1::pod_type>, T1, op_cx_scalar_div_post>
00077 operator/
00078   (
00079   const Base<typename T1::pod_type, T1>&     X,
00080   const std::complex<typename T1::pod_type>& k
00081   )
00082   {
00083   arma_extra_debug_sigprint();
00084   
00085   return mtOp<typename std::complex<typename T1::pod_type>, T1, op_cx_scalar_div_post>('j', X.get_ref(), k);
00086   }
00087 
00088 
00089 
00090 //! element-wise division of Base objects with same element type
00091 template<typename T1, typename T2>
00092 arma_inline
00093 const eGlue<T1, T2, eglue_div>
00094 operator/
00095   (
00096   const Base<typename T1::elem_type,T1>& X,
00097   const Base<typename T1::elem_type,T2>& Y
00098   )
00099   {
00100   arma_extra_debug_sigprint();
00101   
00102   return eGlue<T1, T2, eglue_div>(X.get_ref(), Y.get_ref());
00103   }
00104 
00105 
00106 
00107 //! element-wise division of Base objects with different element types
00108 template<typename T1, typename T2>
00109 inline
00110 const mtGlue<typename promote_type<typename T1::elem_type, typename T2::elem_type>::result, T1, T2, glue_mixed_div>
00111 operator/
00112   (
00113   const Base< typename force_different_type<typename T1::elem_type, typename T2::elem_type>::T1_result, T1>& X,
00114   const Base< typename force_different_type<typename T1::elem_type, typename T2::elem_type>::T2_result, T2>& Y
00115   )
00116   {
00117   arma_extra_debug_sigprint();
00118   
00119   typedef typename T1::elem_type eT1;
00120   typedef typename T2::elem_type eT2;
00121   
00122   typedef typename promote_type<eT1,eT2>::result out_eT;
00123   
00124   promote_type<eT1,eT2>::check();
00125   
00126   return mtGlue<out_eT, T1, T2, glue_mixed_div>( X.get_ref(), Y.get_ref() );
00127   }
00128 
00129 
00130 
00131 //! @}