operator_times.hpp
Go to the documentation of this file.
00001 // Copyright (C) 2008-2010 NICTA (www.nicta.com.au)
00002 // Copyright (C) 2008-2010 Conrad Sanderson
00003 // 
00004 // This file is part of the Armadillo C++ library.
00005 // It is provided without any warranty of fitness
00006 // for any purpose. You can redistribute this file
00007 // and/or modify it under the terms of the GNU
00008 // Lesser General Public License (LGPL) as published
00009 // by the Free Software Foundation, either version 3
00010 // of the License or (at your option) any later version.
00011 // (see http://www.opensource.org/licenses for more info)
00012 
00013 
00014 
00017 
00018 
00019 
00021 template<typename T1>
00022 arma_inline
00023 const eOp<T1, eop_scalar_times>
00024 operator*
00025 (const Base<typename T1::elem_type,T1>& X, const typename T1::elem_type k)
00026   {
00027   arma_extra_debug_sigprint();
00028   
00029   return eOp<T1, eop_scalar_times>(X.get_ref(),k);
00030   }
00031 
00032 
00033 
00035 template<typename T1>
00036 arma_inline
00037 const eOp<T1, eop_scalar_times>
00038 operator*
00039 (const typename T1::elem_type k, const Base<typename T1::elem_type,T1>& X)
00040   {
00041   arma_extra_debug_sigprint();
00042   
00043   return eOp<T1, eop_scalar_times>(X.get_ref(),k);  // NOTE: order is swapped
00044   }
00045 
00046 
00047 
00049 template<typename T1>
00050 arma_inline
00051 const mtOp<typename std::complex<typename T1::pod_type>, T1, op_cx_scalar_times>
00052 operator*
00053   (
00054   const Base<typename T1::pod_type, T1>&     X,
00055   const std::complex<typename T1::pod_type>& k
00056   )
00057   {
00058   arma_extra_debug_sigprint();
00059   
00060   return mtOp<typename std::complex<typename T1::pod_type>, T1, op_cx_scalar_times>('j', X.get_ref(), k);
00061   }
00062 
00063 
00064 
00066 template<typename T1>
00067 arma_inline
00068 const mtOp<typename std::complex<typename T1::pod_type>, T1, op_cx_scalar_times>
00069 operator*
00070   (
00071   const std::complex<typename T1::pod_type>& k,
00072   const Base<typename T1::pod_type, T1>&     X
00073   )
00074   {
00075   arma_extra_debug_sigprint();
00076   
00077   return mtOp<typename std::complex<typename T1::pod_type>, T1, op_cx_scalar_times>('j', X.get_ref(), k);
00078   }
00079 
00080 
00081 
00083 template<typename T1>
00084 arma_inline
00085 const Op<T1, op_htrans2>
00086 operator*
00087 (const typename T1::elem_type k, const Op<T1, op_htrans>& X)
00088   {
00089   arma_extra_debug_sigprint();
00090   
00091   return Op<T1, op_htrans2>(X.m, k);
00092   }
00093 
00094 
00095 
00097 template<typename T1>
00098 arma_inline
00099 const Op<T1, op_htrans2>
00100 operator*
00101 (const Op<T1, op_htrans>& X, const typename T1::elem_type k)
00102   {
00103   arma_extra_debug_sigprint();
00104   
00105   return Op<T1, op_htrans2>(X.m, k);
00106   }
00107 
00108 
00109 
00111 template<typename T1, typename T2>
00112 arma_inline
00113 const Glue<T1, Op<T2, op_diagmat>, glue_times_diag>
00114 operator*
00115 (const Base<typename T2::elem_type,T1>& X, const Op<T2, op_diagmat>& Y)
00116   {
00117   arma_extra_debug_sigprint();
00118   
00119   return Glue<T1, Op<T2, op_diagmat>, glue_times_diag>(X.get_ref(), Y);
00120   }
00121 
00122 
00123 
00125 template<typename T1, typename T2>
00126 arma_inline
00127 const Glue<Op<T1, op_diagmat>, T2, glue_times_diag>
00128 operator*
00129 (const Op<T1, op_diagmat>& X, const Base<typename T1::elem_type,T2>& Y)
00130   {
00131   arma_extra_debug_sigprint();
00132   
00133   return Glue<Op<T1, op_diagmat>, T2, glue_times_diag>(X, Y.get_ref());
00134   }
00135 
00136 
00137 
00139 template<typename T1, typename T2>
00140 arma_inline
00141 Mat< typename promote_type<typename T1::elem_type, typename T2::elem_type>::result >
00142 operator*
00143 (const Op<T1, op_diagmat>& X, const Op<T2, op_diagmat>& Y)
00144   {
00145   arma_extra_debug_sigprint();
00146   
00147   typedef typename T1::elem_type eT1;
00148   typedef typename T2::elem_type eT2;
00149   
00150   typedef typename promote_type<eT1,eT2>::result out_eT;
00151   
00152   promote_type<eT1,eT2>::check();
00153   
00154   const diagmat_proxy<T1> A(X.m);
00155   const diagmat_proxy<T2> B(Y.m);
00156   
00157   arma_debug_assert_mul_size(A.n_elem, A.n_elem, B.n_elem, B.n_elem, "matrix multiply");
00158   
00159   const uword N = A.n_elem;
00160   
00161   Mat<out_eT> out(N,N);
00162   
00163   out.zeros();
00164   
00165   for(uword i=0; i<N; ++i)
00166     {
00167     out.at(i,i) = upgrade_val<eT1,eT2>::apply( A[i] ) * upgrade_val<eT1,eT2>::apply( B[i] );
00168     }
00169   
00170   return out;
00171   }
00172 
00173 
00174 
00176 template<typename T1, typename T2>
00177 arma_inline
00178 const Glue<T1, T2, glue_times>
00179 operator*
00180 (const Base<typename T1::elem_type,T1>& X, const Base<typename T1::elem_type,T2>& Y)
00181   {
00182   arma_extra_debug_sigprint();
00183   
00184   return Glue<T1, T2, glue_times>(X.get_ref(), Y.get_ref());
00185   }
00186 
00187 
00188 
00190 template<typename T1, typename T2>
00191 inline
00192 const mtGlue< typename promote_type<typename T1::elem_type, typename T2::elem_type>::result, T1, T2, glue_mixed_times >
00193 operator*
00194   (
00195   const Base< typename force_different_type<typename T1::elem_type, typename T2::elem_type>::T1_result, T1>& X,
00196   const Base< typename force_different_type<typename T1::elem_type, typename T2::elem_type>::T2_result, T2>& Y
00197   )
00198   {
00199   arma_extra_debug_sigprint();
00200   
00201   typedef typename T1::elem_type eT1;
00202   typedef typename T2::elem_type eT2;
00203   
00204   typedef typename promote_type<eT1,eT2>::result out_eT;
00205   
00206   promote_type<eT1,eT2>::check();
00207   
00208   return mtGlue<out_eT, T1, T2, glue_mixed_times>( X.get_ref(), Y.get_ref() );
00209   }
00210 
00211 
00212 


armadillo_matrix
Author(s): Conrad Sanderson - NICTA (www.nicta.com.au), (Wrapper by Sjoerd van den Dries)
autogenerated on Tue Jan 7 2014 11:42:05