eglue_core_meat.hpp
Go to the documentation of this file.
00001 // Copyright (C) 2010-2011 NICTA (www.nicta.com.au)
00002 // Copyright (C) 2010-2011 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 
00016 
00017 
00018 
00019 class eglue_plus : public eglue_core<eglue_plus>
00020   {
00021   public:
00022   
00023   inline static const char* text() { return "addition"; }
00024   };
00025 
00026 
00027 
00028 class eglue_minus : public eglue_core<eglue_minus>
00029   {
00030   public:
00031   
00032   inline static const char* text() { return "subtraction"; }
00033   };
00034 
00035 
00036 
00037 class eglue_div : public eglue_core<eglue_div>
00038   {
00039   public:
00040   
00041   inline static const char* text() { return "element-wise division"; }
00042   };
00043 
00044 
00045 
00046 class eglue_schur : public eglue_core<eglue_schur>
00047   {
00048   public:
00049   
00050   inline static const char* text() { return "element-wise multiplication"; }
00051   };
00052 
00053 
00054 
00055 #undef arma_applier_1
00056 #undef arma_applier_2
00057 #undef arma_applier_3
00058 #undef operatorA
00059 #undef operatorB
00060 
00061 #define arma_applier_1(operatorA, operatorB) \
00062   {\
00063   uword i,j;\
00064   \
00065   for(i=0, j=1; j<n_elem; i+=2, j+=2)\
00066     {\
00067     eT tmp_i = P1[i];\
00068     eT tmp_j = P1[j];\
00069     \
00070     tmp_i operatorB##= P2[i];\
00071     tmp_j operatorB##= P2[j];\
00072     \
00073     out_mem[i] operatorA tmp_i;\
00074     out_mem[j] operatorA tmp_j;\
00075     }\
00076   \
00077   if(i < n_elem)\
00078     {\
00079     out_mem[i] operatorA P1[i] operatorB P2[i];\
00080     }\
00081   }
00082   
00083 
00084 
00085 #define arma_applier_2(operatorA, operatorB) \
00086   {\
00087   uword count = 0;\
00088   \
00089   for(uword col=0; col<n_cols; ++col)\
00090     {\
00091     uword i,j;\
00092     \
00093     for(i=0, j=1; j<n_rows; i+=2, j+=2, count+=2)\
00094       {\
00095       eT tmp_i = P1.at(i,col);\
00096       eT tmp_j = P1.at(j,col);\
00097       \
00098       tmp_i operatorB##= P2.at(i,col);\
00099       tmp_j operatorB##= P2.at(j,col);\
00100       \
00101       out_mem[count  ] operatorA tmp_i;\
00102       out_mem[count+1] operatorA tmp_j;\
00103       }\
00104     \
00105     if(i < n_rows)\
00106       {\
00107       out_mem[count] operatorA P1.at(i,col) operatorB P2.at(i,col);\
00108       ++count;\
00109       }\
00110     }\
00111   }
00112 
00113 
00114 
00115 #define arma_applier_3(operatorA, operatorB) \
00116   {\
00117   uword count = 0;\
00118   \
00119   for(uword slice=0; slice<n_slices; ++slice)\
00120     {\
00121     for(uword col=0; col<n_cols; ++col)\
00122       {\
00123       uword i,j;\
00124       \
00125       for(i=0, j=1; j<n_rows; i+=2, j+=2, count+=2)\
00126         {\
00127         eT tmp_i = P1.at(i,col,slice);\
00128         eT tmp_j = P1.at(j,col,slice);\
00129         \
00130         tmp_i operatorB##= P2.at(i,col,slice);\
00131         tmp_j operatorB##= P2.at(j,col,slice);\
00132         \
00133         out_mem[count  ] operatorA tmp_i;\
00134         out_mem[count+1] operatorA tmp_j;\
00135         }\
00136       \
00137       if(i < n_rows)\
00138         {\
00139         out_mem[count] operatorA P1.at(i,col,slice) operatorB P2.at(i,col,slice);\
00140         ++count;\
00141         }\
00142       }\
00143     }\
00144   }
00145 
00146 
00147 
00148 //
00149 // matrices
00150 
00151 
00152 
00153 template<typename eglue_type>
00154 template<typename T1, typename T2>
00155 arma_hot
00156 inline
00157 void
00158 eglue_core<eglue_type>::apply(Mat<typename T1::elem_type>& out, const eGlue<T1, T2, eglue_type>& x)
00159   {
00160   arma_extra_debug_sigprint();
00161   
00162   typedef typename T1::elem_type eT;
00163   
00164   const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor || Proxy<T2>::prefer_at_accessor);
00165   
00166   // NOTE: we're assuming that the matrix has already been set to the correct size and there is no aliasing;
00167   // size setting and alias checking is done by either the Mat contructor or operator=()
00168   
00169   eT* out_mem = out.memptr();
00170   
00171   if(prefer_at_accessor == false)
00172     {
00173     const uword n_elem = out.n_elem;
00174     
00175     typename Proxy<T1>::ea_type P1 = x.P1.get_ea();
00176     typename Proxy<T2>::ea_type P2 = x.P2.get_ea();
00177   
00178          if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_applier_1(=, +); }
00179     else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_applier_1(=, -); }
00180     else if(is_same_type<eglue_type, eglue_div  >::value == true) { arma_applier_1(=, /); }
00181     else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_applier_1(=, *); }
00182     }
00183   else
00184     {
00185     const uword n_rows = out.n_rows;
00186     const uword n_cols = out.n_cols;
00187   
00188     const Proxy<T1>& P1 = x.P1;
00189     const Proxy<T2>& P2 = x.P2;
00190     
00191          if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_applier_2(=, +); }
00192     else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_applier_2(=, -); }
00193     else if(is_same_type<eglue_type, eglue_div  >::value == true) { arma_applier_2(=, /); }
00194     else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_applier_2(=, *); }
00195     }
00196   }
00197 
00198 
00199 
00200 template<typename eglue_type>
00201 template<typename T1, typename T2>
00202 arma_hot
00203 inline
00204 void
00205 eglue_core<eglue_type>::apply_inplace_plus(Mat<typename T1::elem_type>& out, const eGlue<T1, T2, eglue_type>& x)
00206   {
00207   arma_extra_debug_sigprint();
00208   
00209   arma_debug_assert_same_size(out, x.P1, "addition");
00210   
00211   typedef typename T1::elem_type eT;
00212   
00213   eT* out_mem = out.memptr();
00214   
00215   const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor || Proxy<T2>::prefer_at_accessor);
00216   
00217   if(prefer_at_accessor == false)
00218     {
00219     const uword n_elem = out.n_elem;
00220     
00221     typename Proxy<T1>::ea_type P1 = x.P1.get_ea();
00222     typename Proxy<T2>::ea_type P2 = x.P2.get_ea();
00223     
00224          if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_applier_1(+=, +); }
00225     else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_applier_1(+=, -); }
00226     else if(is_same_type<eglue_type, eglue_div  >::value == true) { arma_applier_1(+=, /); }
00227     else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_applier_1(+=, *); }
00228     }
00229   else
00230     {
00231     const uword n_rows = out.n_rows;
00232     const uword n_cols = out.n_cols;
00233     
00234     const Proxy<T1>& P1 = x.P1;
00235     const Proxy<T2>& P2 = x.P2;
00236     
00237          if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_applier_2(+=, +); }
00238     else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_applier_2(+=, -); }
00239     else if(is_same_type<eglue_type, eglue_div  >::value == true) { arma_applier_2(+=, /); }
00240     else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_applier_2(+=, *); }
00241     }
00242   }
00243 
00244 
00245 
00246 template<typename eglue_type>
00247 template<typename T1, typename T2>
00248 arma_hot
00249 inline
00250 void
00251 eglue_core<eglue_type>::apply_inplace_minus(Mat<typename T1::elem_type>& out, const eGlue<T1, T2, eglue_type>& x)
00252   {
00253   arma_extra_debug_sigprint();
00254   
00255   arma_debug_assert_same_size(out, x.P1, "subtraction");
00256   
00257   typedef typename T1::elem_type eT;
00258   
00259   eT* out_mem = out.memptr();
00260   
00261   const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor || Proxy<T2>::prefer_at_accessor);
00262   
00263   if(prefer_at_accessor == false)
00264     {
00265     const uword n_elem = out.n_elem;
00266     
00267     typename Proxy<T1>::ea_type P1 = x.P1.get_ea();
00268     typename Proxy<T2>::ea_type P2 = x.P2.get_ea();
00269     
00270          if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_applier_1(-=, +); }
00271     else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_applier_1(-=, -); }
00272     else if(is_same_type<eglue_type, eglue_div  >::value == true) { arma_applier_1(-=, /); }
00273     else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_applier_1(-=, *); }
00274     }
00275   else
00276     {
00277     const uword n_rows = out.n_rows;
00278     const uword n_cols = out.n_cols;
00279     
00280     const Proxy<T1>& P1 = x.P1;
00281     const Proxy<T2>& P2 = x.P2;
00282     
00283          if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_applier_2(-=, +); }
00284     else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_applier_2(-=, -); }
00285     else if(is_same_type<eglue_type, eglue_div  >::value == true) { arma_applier_2(-=, /); }
00286     else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_applier_2(-=, *); }
00287     }
00288   }
00289 
00290 
00291 
00292 template<typename eglue_type>
00293 template<typename T1, typename T2>
00294 arma_hot
00295 inline
00296 void
00297 eglue_core<eglue_type>::apply_inplace_schur(Mat<typename T1::elem_type>& out, const eGlue<T1, T2, eglue_type>& x)
00298   {
00299   arma_extra_debug_sigprint();
00300   
00301   arma_debug_assert_same_size(out, x.P1, "element-wise multiplication");
00302   
00303   typedef typename T1::elem_type eT;
00304   
00305   eT* out_mem = out.memptr();
00306   
00307   const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor || Proxy<T2>::prefer_at_accessor);
00308   
00309   if(prefer_at_accessor == false)
00310     {
00311     const uword n_elem = out.n_elem;
00312     
00313     typename Proxy<T1>::ea_type P1 = x.P1.get_ea();
00314     typename Proxy<T2>::ea_type P2 = x.P2.get_ea();
00315     
00316          if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_applier_1(*=, +); }
00317     else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_applier_1(*=, -); }
00318     else if(is_same_type<eglue_type, eglue_div  >::value == true) { arma_applier_1(*=, /); }
00319     else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_applier_1(*=, *); }
00320     }
00321   else
00322     {
00323     const uword n_rows = out.n_rows;
00324     const uword n_cols = out.n_cols;
00325     
00326     const Proxy<T1>& P1 = x.P1;
00327     const Proxy<T2>& P2 = x.P2;
00328     
00329          if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_applier_2(*=, +); }
00330     else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_applier_2(*=, -); }
00331     else if(is_same_type<eglue_type, eglue_div  >::value == true) { arma_applier_2(*=, /); }
00332     else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_applier_2(*=, *); }
00333     }
00334   }
00335 
00336 
00337 
00338 template<typename eglue_type>
00339 template<typename T1, typename T2>
00340 arma_hot
00341 inline
00342 void
00343 eglue_core<eglue_type>::apply_inplace_div(Mat<typename T1::elem_type>& out, const eGlue<T1, T2, eglue_type>& x)
00344   {
00345   arma_extra_debug_sigprint();
00346   
00347   arma_debug_assert_same_size(out, x.P1, "element-wise division");
00348   
00349   typedef typename T1::elem_type eT;
00350   
00351   eT* out_mem = out.memptr();
00352   
00353   const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor || Proxy<T2>::prefer_at_accessor);
00354   
00355   if(prefer_at_accessor == false)
00356     {
00357     const uword n_elem = out.n_elem;
00358     
00359     typename Proxy<T1>::ea_type P1 = x.P1.get_ea();
00360     typename Proxy<T2>::ea_type P2 = x.P2.get_ea();
00361   
00362          if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_applier_1(/=, +); }
00363     else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_applier_1(/=, -); }
00364     else if(is_same_type<eglue_type, eglue_div  >::value == true) { arma_applier_1(/=, /); }
00365     else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_applier_1(/=, *); }
00366     }
00367   else
00368     {
00369     const uword n_rows = out.n_rows;
00370     const uword n_cols = out.n_cols;
00371     
00372     const Proxy<T1>& P1 = x.P1;
00373     const Proxy<T2>& P2 = x.P2;
00374     
00375          if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_applier_2(*=, +); }
00376     else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_applier_2(*=, -); }
00377     else if(is_same_type<eglue_type, eglue_div  >::value == true) { arma_applier_2(*=, /); }
00378     else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_applier_2(*=, *); }
00379     }
00380   }
00381 
00382 
00383 
00384 //
00385 // cubes
00386 
00387 
00388 
00389 template<typename eglue_type>
00390 template<typename T1, typename T2>
00391 arma_hot
00392 inline
00393 void
00394 eglue_core<eglue_type>::apply(Cube<typename T1::elem_type>& out, const eGlueCube<T1, T2, eglue_type>& x)
00395   {
00396   arma_extra_debug_sigprint();
00397   
00398   typedef typename T1::elem_type eT;
00399   
00400   const bool prefer_at_accessor = (ProxyCube<T1>::prefer_at_accessor || ProxyCube<T2>::prefer_at_accessor);
00401   
00402   // NOTE: we're assuming that the cube has already been set to the correct size and there is no aliasing;
00403   // size setting and alias checking is done by either the Cube contructor or operator=()
00404   
00405   
00406   eT* out_mem = out.memptr();
00407   
00408   if(prefer_at_accessor == false)
00409     {
00410     const uword n_elem = out.n_elem;
00411     
00412     typename ProxyCube<T1>::ea_type P1 = x.P1.get_ea();
00413     typename ProxyCube<T2>::ea_type P2 = x.P2.get_ea();
00414   
00415          if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_applier_1(=, +); }
00416     else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_applier_1(=, -); }
00417     else if(is_same_type<eglue_type, eglue_div  >::value == true) { arma_applier_1(=, /); }
00418     else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_applier_1(=, *); }
00419     }
00420   else
00421     {
00422     const uword n_rows   = x.get_n_rows();
00423     const uword n_cols   = x.get_n_cols();
00424     const uword n_slices = x.get_n_slices();
00425   
00426     const ProxyCube<T1>& P1 = x.P1;
00427     const ProxyCube<T2>& P2 = x.P2;
00428     
00429          if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_applier_3(=, +); }
00430     else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_applier_3(=, -); }
00431     else if(is_same_type<eglue_type, eglue_div  >::value == true) { arma_applier_3(=, /); }
00432     else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_applier_3(=, *); }
00433     }
00434   }
00435 
00436 
00437 
00438 template<typename eglue_type>
00439 template<typename T1, typename T2>
00440 arma_hot
00441 inline
00442 void
00443 eglue_core<eglue_type>::apply_inplace_plus(Cube<typename T1::elem_type>& out, const eGlueCube<T1, T2, eglue_type>& x)
00444   {
00445   arma_extra_debug_sigprint();
00446   
00447   const uword n_rows   = x.get_n_rows();
00448   const uword n_cols   = x.get_n_cols();
00449   const uword n_slices = x.get_n_slices();
00450   
00451   arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows, n_cols, n_slices, "addition");
00452   
00453   typedef typename T1::elem_type eT;
00454   
00455   eT* out_mem = out.memptr();
00456   
00457   const bool prefer_at_accessor = (ProxyCube<T1>::prefer_at_accessor || ProxyCube<T2>::prefer_at_accessor);
00458   
00459   if(prefer_at_accessor == false)
00460     {
00461     const uword n_elem  = out.n_elem;
00462     
00463     typename ProxyCube<T1>::ea_type P1 = x.P1.get_ea();
00464     typename ProxyCube<T2>::ea_type P2 = x.P2.get_ea();
00465     
00466          if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_applier_1(+=, +); }
00467     else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_applier_1(+=, -); }
00468     else if(is_same_type<eglue_type, eglue_div  >::value == true) { arma_applier_1(+=, /); }
00469     else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_applier_1(+=, *); }
00470     }
00471   else
00472     {
00473     const ProxyCube<T1>& P1 = x.P1;
00474     const ProxyCube<T2>& P2 = x.P2;
00475     
00476          if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_applier_3(+=, +); }
00477     else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_applier_3(+=, -); }
00478     else if(is_same_type<eglue_type, eglue_div  >::value == true) { arma_applier_3(+=, /); }
00479     else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_applier_3(+=, *); }
00480     }
00481   }
00482 
00483 
00484 
00485 template<typename eglue_type>
00486 template<typename T1, typename T2>
00487 arma_hot
00488 inline
00489 void
00490 eglue_core<eglue_type>::apply_inplace_minus(Cube<typename T1::elem_type>& out, const eGlueCube<T1, T2, eglue_type>& x)
00491   {
00492   arma_extra_debug_sigprint();
00493   
00494   const uword n_rows   = x.get_n_rows();
00495   const uword n_cols   = x.get_n_cols();
00496   const uword n_slices = x.get_n_slices();
00497   
00498   arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows, n_cols, n_slices, "subtraction");
00499   
00500   typedef typename T1::elem_type eT;
00501   
00502   eT* out_mem = out.memptr();
00503   
00504   const bool prefer_at_accessor = (ProxyCube<T1>::prefer_at_accessor || ProxyCube<T2>::prefer_at_accessor);
00505   
00506   if(prefer_at_accessor == false)
00507     {
00508     const uword n_elem  = out.n_elem;
00509     
00510     typename ProxyCube<T1>::ea_type P1 = x.P1.get_ea();
00511     typename ProxyCube<T2>::ea_type P2 = x.P2.get_ea();
00512     
00513          if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_applier_1(-=, +); }
00514     else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_applier_1(-=, -); }
00515     else if(is_same_type<eglue_type, eglue_div  >::value == true) { arma_applier_1(-=, /); }
00516     else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_applier_1(-=, *); }
00517     }
00518   else
00519     {
00520     const ProxyCube<T1>& P1 = x.P1;
00521     const ProxyCube<T2>& P2 = x.P2;
00522     
00523          if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_applier_3(-=, +); }
00524     else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_applier_3(-=, -); }
00525     else if(is_same_type<eglue_type, eglue_div  >::value == true) { arma_applier_3(-=, /); }
00526     else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_applier_3(-=, *); }
00527     }
00528   }
00529 
00530 
00531 
00532 template<typename eglue_type>
00533 template<typename T1, typename T2>
00534 arma_hot
00535 inline
00536 void
00537 eglue_core<eglue_type>::apply_inplace_schur(Cube<typename T1::elem_type>& out, const eGlueCube<T1, T2, eglue_type>& x)
00538   {
00539   arma_extra_debug_sigprint();
00540   
00541   const uword n_rows   = x.get_n_rows();
00542   const uword n_cols   = x.get_n_cols();
00543   const uword n_slices = x.get_n_slices();
00544   
00545   arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows, n_cols, n_slices, "element-wise multiplication");
00546   
00547   typedef typename T1::elem_type eT;
00548   
00549   eT* out_mem = out.memptr();
00550   
00551   const bool prefer_at_accessor = (ProxyCube<T1>::prefer_at_accessor || ProxyCube<T2>::prefer_at_accessor);
00552   
00553   if(prefer_at_accessor == false)
00554     {
00555     const uword n_elem  = out.n_elem;
00556     
00557     typename ProxyCube<T1>::ea_type P1 = x.P1.get_ea();
00558     typename ProxyCube<T2>::ea_type P2 = x.P2.get_ea();
00559     
00560          if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_applier_1(*=, +); }
00561     else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_applier_1(*=, -); }
00562     else if(is_same_type<eglue_type, eglue_div  >::value == true) { arma_applier_1(*=, /); }
00563     else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_applier_1(*=, *); }
00564     }
00565   else
00566     {
00567     const ProxyCube<T1>& P1 = x.P1;
00568     const ProxyCube<T2>& P2 = x.P2;
00569     
00570          if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_applier_3(*=, +); }
00571     else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_applier_3(*=, -); }
00572     else if(is_same_type<eglue_type, eglue_div  >::value == true) { arma_applier_3(*=, /); }
00573     else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_applier_3(*=, *); }
00574     }
00575   }
00576 
00577 
00578 
00579 template<typename eglue_type>
00580 template<typename T1, typename T2>
00581 arma_hot
00582 inline
00583 void
00584 eglue_core<eglue_type>::apply_inplace_div(Cube<typename T1::elem_type>& out, const eGlueCube<T1, T2, eglue_type>& x)
00585   {
00586   arma_extra_debug_sigprint();
00587   
00588   const uword n_rows   = x.get_n_rows();
00589   const uword n_cols   = x.get_n_cols();
00590   const uword n_slices = x.get_n_slices();
00591   
00592   arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows, n_cols, n_slices, "element-wise division");
00593   
00594   typedef typename T1::elem_type eT;
00595   
00596   eT* out_mem = out.memptr();
00597   
00598   const bool prefer_at_accessor = (ProxyCube<T1>::prefer_at_accessor || ProxyCube<T2>::prefer_at_accessor);
00599   
00600   if(prefer_at_accessor == false)
00601     {
00602     const uword n_elem  = out.n_elem;
00603     
00604     typename ProxyCube<T1>::ea_type P1 = x.P1.get_ea();
00605     typename ProxyCube<T2>::ea_type P2 = x.P2.get_ea();
00606     
00607          if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_applier_1(/=, +); }
00608     else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_applier_1(/=, -); }
00609     else if(is_same_type<eglue_type, eglue_div  >::value == true) { arma_applier_1(/=, /); }
00610     else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_applier_1(/=, *); }
00611     }
00612   else
00613     {
00614     const ProxyCube<T1>& P1 = x.P1;
00615     const ProxyCube<T2>& P2 = x.P2;
00616     
00617          if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_applier_3(/=, +); }
00618     else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_applier_3(/=, -); }
00619     else if(is_same_type<eglue_type, eglue_div  >::value == true) { arma_applier_3(/=, /); }
00620     else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_applier_3(/=, *); }
00621     }
00622   }
00623 
00624 
00625 
00626 #undef arma_applier_1
00627 #undef arma_applier_2
00628 #undef arma_applier_3
00629 
00630 
00631 


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:03