glue_relational_meat.hpp
Go to the documentation of this file.
00001 // Copyright (C) 2009-2011 NICTA (www.nicta.com.au)
00002 // Copyright (C) 2009-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 #undef operator_rel
00020 #undef operator_str
00021 
00022 #undef arma_applier_mat
00023 #undef arma_applier_cube
00024 
00025 
00026 #define arma_applier_mat(operator_rel, operator_str) \
00027   {\
00028   const Proxy<T1> P1(X.A);\
00029   const Proxy<T2> P2(X.B);\
00030   \
00031   arma_debug_assert_same_size(P1, P2, operator_str);\
00032   \
00033   const uword n_rows = P1.get_n_rows();\
00034   const uword n_cols = P1.get_n_cols();\
00035   \
00036   out.set_size(n_rows, n_cols);\
00037   \
00038   uword* out_mem = out.memptr();\
00039   \
00040   const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor || Proxy<T2>::prefer_at_accessor);\
00041   \
00042   if(prefer_at_accessor == false)\
00043     {\
00044     typename Proxy<T1>::ea_type A = P1.get_ea();\
00045     typename Proxy<T2>::ea_type B = P2.get_ea();\
00046     \
00047     const uword n_elem = out.n_elem;\
00048     \
00049     for(uword i=0; i<n_elem; ++i)\
00050       {\
00051       out_mem[i] = (A[i] operator_rel B[i]) ? uword(1) : uword(0);\
00052       }\
00053     }\
00054   else\
00055     {\
00056     uword count = 0;\
00057     \
00058     for(uword col=0; col<n_cols; ++col)\
00059       {\
00060       for(uword row=0; row<n_rows; ++row, ++count)\
00061         {\
00062         out_mem[count] = (P1.at(row,col) operator_rel P2.at(row,col)) ? uword(1) : uword(0);\
00063         }\
00064       }\
00065     }\
00066   }
00067 
00068 
00069 
00070 
00071 #define arma_applier_cube(operator_rel, operator_str) \
00072   {\
00073   const ProxyCube<T1> P1(X.A);\
00074   const ProxyCube<T2> P2(X.B);\
00075   \
00076   arma_debug_assert_same_size(P1, P2, operator_str);\
00077   \
00078   const uword n_rows   = P1.get_n_rows();\
00079   const uword n_cols   = P1.get_n_cols();\
00080   const uword n_slices = P1.get_n_slices();\
00081   \
00082   out.set_size(n_rows, n_cols, n_slices);\
00083   \
00084   uword* out_mem = out.memptr();\
00085   \
00086   const bool prefer_at_accessor = (ProxyCube<T1>::prefer_at_accessor || ProxyCube<T2>::prefer_at_accessor);\
00087   \
00088   if(prefer_at_accessor == false)\
00089     {\
00090     typename ProxyCube<T1>::ea_type A = P1.get_ea();\
00091     typename ProxyCube<T2>::ea_type B = P2.get_ea();\
00092     \
00093     const uword n_elem = out.n_elem;\
00094     \
00095     for(uword i=0; i<n_elem; ++i)\
00096       {\
00097       out_mem[i] = (A[i] operator_rel B[i]) ? uword(1) : uword(0);\
00098       }\
00099     }\
00100   else\
00101     {\
00102     uword count = 0;\
00103     \
00104     for(uword slice = 0; slice < n_slices; ++slice)\
00105     for(uword col   = 0; col   < n_cols;   ++col)\
00106     for(uword row   = 0; row   < n_rows;   ++row, ++count)\
00107       {\
00108       out_mem[count] = (P1.at(row,col,slice) operator_rel P2.at(row,col,slice)) ? uword(1) : uword(0);\
00109       }\
00110     }\
00111   }
00112 
00113 
00114 
00115 template<typename T1, typename T2>
00116 inline
00117 void
00118 glue_rel_lt::apply
00119   (
00120         Mat   <uword>& out,
00121   const mtGlue<uword, T1, T2, glue_rel_lt>& X
00122   )
00123   {
00124   arma_extra_debug_sigprint();
00125   
00126   arma_applier_mat(<, "operator<");
00127   }
00128 
00129 
00130 
00131 template<typename T1, typename T2>
00132 inline
00133 void
00134 glue_rel_gt::apply
00135   (
00136         Mat   <uword>& out,
00137   const mtGlue<uword, T1, T2, glue_rel_gt>& X
00138   )
00139   {
00140   arma_extra_debug_sigprint();
00141   
00142   arma_applier_mat(>, "operator>");
00143   }
00144 
00145 
00146 
00147 template<typename T1, typename T2>
00148 inline
00149 void
00150 glue_rel_lteq::apply
00151   (
00152         Mat   <uword>& out,
00153   const mtGlue<uword, T1, T2, glue_rel_lteq>& X
00154   )
00155   {
00156   arma_extra_debug_sigprint();
00157   
00158   arma_applier_mat(<=, "operator<=");
00159   }
00160 
00161 
00162 
00163 template<typename T1, typename T2>
00164 inline
00165 void
00166 glue_rel_gteq::apply
00167   (
00168         Mat   <uword>& out,
00169   const mtGlue<uword, T1, T2, glue_rel_gteq>& X
00170   )
00171   {
00172   arma_extra_debug_sigprint();
00173   
00174   arma_applier_mat(>=, "operator>=");
00175   }
00176 
00177 
00178 
00179 template<typename T1, typename T2>
00180 inline
00181 void
00182 glue_rel_eq::apply
00183   (
00184         Mat   <uword>& out,
00185   const mtGlue<uword, T1, T2, glue_rel_eq>& X
00186   )
00187   {
00188   arma_extra_debug_sigprint();
00189   
00190   arma_applier_mat(==, "operator==");
00191   }
00192 
00193 
00194 
00195 template<typename T1, typename T2>
00196 inline
00197 void
00198 glue_rel_noteq::apply
00199   (
00200         Mat   <uword>& out,
00201   const mtGlue<uword, T1, T2, glue_rel_noteq>& X
00202   )
00203   {
00204   arma_extra_debug_sigprint();
00205   
00206   arma_applier_mat(!=, "operator!=");
00207   }
00208 
00209 
00210 
00211 //
00212 //
00213 //
00214 
00215 
00216 
00217 template<typename T1, typename T2>
00218 inline
00219 void
00220 glue_rel_lt::apply
00221   (
00222         Cube      <uword>& out,
00223   const mtGlueCube<uword, T1, T2, glue_rel_lt>& X
00224   )
00225   {
00226   arma_extra_debug_sigprint();
00227   
00228   arma_applier_cube(<, "operator<");
00229   }
00230 
00231 
00232 
00233 template<typename T1, typename T2>
00234 inline
00235 void
00236 glue_rel_gt::apply
00237   (
00238         Cube      <uword>& out,
00239   const mtGlueCube<uword, T1, T2, glue_rel_gt>& X
00240   )
00241   {
00242   arma_extra_debug_sigprint();
00243   
00244   arma_applier_cube(>, "operator>");
00245   }
00246 
00247 
00248 
00249 template<typename T1, typename T2>
00250 inline
00251 void
00252 glue_rel_lteq::apply
00253   (
00254         Cube      <uword>& out,
00255   const mtGlueCube<uword, T1, T2, glue_rel_lteq>& X
00256   )
00257   {
00258   arma_extra_debug_sigprint();
00259   
00260   arma_applier_cube(<=, "operator<=");
00261   }
00262 
00263 
00264 
00265 template<typename T1, typename T2>
00266 inline
00267 void
00268 glue_rel_gteq::apply
00269   (
00270         Cube      <uword>& out,
00271   const mtGlueCube<uword, T1, T2, glue_rel_gteq>& X
00272   )
00273   {
00274   arma_extra_debug_sigprint();
00275   
00276   arma_applier_cube(>=, "operator>=");
00277   }
00278 
00279 
00280 
00281 template<typename T1, typename T2>
00282 inline
00283 void
00284 glue_rel_eq::apply
00285   (
00286         Cube      <uword>& out,
00287   const mtGlueCube<uword, T1, T2, glue_rel_eq>& X
00288   )
00289   {
00290   arma_extra_debug_sigprint();
00291   
00292   arma_applier_cube(==, "operator==");
00293   }
00294 
00295 
00296 
00297 template<typename T1, typename T2>
00298 inline
00299 void
00300 glue_rel_noteq::apply
00301   (
00302         Cube      <uword>& out,
00303   const mtGlueCube<uword, T1, T2, glue_rel_noteq>& X
00304   )
00305   {
00306   arma_extra_debug_sigprint();
00307   
00308   arma_applier_cube(!=, "operator!=");
00309   }
00310 
00311 
00312 
00313 #undef arma_applier_mat
00314 #undef arma_applier_cube
00315 
00316 
00317 


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