glue_relational_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 glue_relational
00018 //! @{
00019 
00020 
00021 
00022 template<typename T1, typename T2>
00023 inline
00024 void
00025 glue_rel_lt::apply
00026   (
00027         Mat   <u32>& out,
00028   const mtGlue<u32, T1, T2, glue_rel_lt>& X
00029   )
00030   {
00031   arma_extra_debug_sigprint();
00032   
00033   const Proxy<T1> A(X.A);
00034   const Proxy<T2> B(X.B);
00035   
00036   arma_debug_assert_same_size(A, B, "operator<");
00037   
00038   out.set_size(A.n_rows, A.n_cols);
00039   
00040   const u32  n_elem  = A.n_elem;
00041         u32* out_mem = out.memptr();
00042   
00043   for(u32 i=0; i<n_elem; ++i)
00044     {
00045     out_mem[i] = (A[i] < B[i]) ? u32(1) : u32(0);
00046     }
00047   
00048   }
00049 
00050 
00051 
00052 template<typename T1, typename T2>
00053 inline
00054 void
00055 glue_rel_gt::apply
00056   (
00057         Mat   <u32>& out,
00058   const mtGlue<u32, T1, T2, glue_rel_gt>& X
00059   )
00060   {
00061   arma_extra_debug_sigprint();
00062   
00063   const Proxy<T1> A(X.A);
00064   const Proxy<T2> B(X.B);
00065   
00066   arma_debug_assert_same_size(A, B, "operator>");
00067   
00068   out.set_size(A.n_rows, A.n_cols);
00069   
00070   const u32  n_elem  = A.n_elem;
00071         u32* out_mem = out.memptr();
00072   
00073   for(u32 i=0; i<n_elem; ++i)
00074     {
00075     out_mem[i] = (A[i] > B[i]) ? u32(1) : u32(0);
00076     }
00077   
00078   }
00079 
00080 
00081 
00082 template<typename T1, typename T2>
00083 inline
00084 void
00085 glue_rel_lteq::apply
00086   (
00087         Mat   <u32>& out,
00088   const mtGlue<u32, T1, T2, glue_rel_lteq>& X
00089   )
00090   {
00091   arma_extra_debug_sigprint();
00092   
00093   const Proxy<T1> A(X.A);
00094   const Proxy<T2> B(X.B);
00095   
00096   arma_debug_assert_same_size(A, B, "operator<=");
00097   
00098   out.set_size(A.n_rows, A.n_cols);
00099   
00100   const u32  n_elem  = A.n_elem;
00101         u32* out_mem = out.memptr();
00102   
00103   for(u32 i=0; i<n_elem; ++i)
00104     {
00105     out_mem[i] = (A[i] <= B[i]) ? u32(1) : u32(0);
00106     }
00107   
00108   }
00109 
00110 
00111 
00112 template<typename T1, typename T2>
00113 inline
00114 void
00115 glue_rel_gteq::apply
00116   (
00117         Mat   <u32>& out,
00118   const mtGlue<u32, T1, T2, glue_rel_gteq>& X
00119   )
00120   {
00121   arma_extra_debug_sigprint();
00122   
00123   const Proxy<T1> A(X.A);
00124   const Proxy<T2> B(X.B);
00125   
00126   arma_debug_assert_same_size(A, B, "operator>=");
00127   
00128   out.set_size(A.n_rows, A.n_cols);
00129   
00130   const u32  n_elem  = A.n_elem;
00131         u32* out_mem = out.memptr();
00132   
00133   for(u32 i=0; i<n_elem; ++i)
00134     {
00135     out_mem[i] = (A[i] >= B[i]) ? u32(1) : u32(0);
00136     }
00137   
00138   }
00139 
00140 
00141 
00142 template<typename T1, typename T2>
00143 inline
00144 void
00145 glue_rel_eq::apply
00146   (
00147         Mat   <u32>& out,
00148   const mtGlue<u32, T1, T2, glue_rel_eq>& X
00149   )
00150   {
00151   arma_extra_debug_sigprint();
00152   
00153   const Proxy<T1> A(X.A);
00154   const Proxy<T2> B(X.B);
00155   
00156   arma_debug_assert_same_size(A, B, "operator==");
00157   
00158   out.set_size(A.n_rows, A.n_cols);
00159   
00160   const u32  n_elem  = A.n_elem;
00161         u32* out_mem = out.memptr();
00162   
00163   for(u32 i=0; i<n_elem; ++i)
00164     {
00165     out_mem[i] = (A[i] == B[i]) ? u32(1) : u32(0);
00166     }
00167   
00168   }
00169 
00170 
00171 
00172 template<typename T1, typename T2>
00173 inline
00174 void
00175 glue_rel_noteq::apply
00176   (
00177         Mat   <u32>& out,
00178   const mtGlue<u32, T1, T2, glue_rel_noteq>& X
00179   )
00180   {
00181   arma_extra_debug_sigprint();
00182   
00183   const Proxy<T1> A(X.A);
00184   const Proxy<T2> B(X.B);
00185   
00186   arma_debug_assert_same_size(A, B, "operator!=");
00187   
00188   out.set_size(A.n_rows, A.n_cols);
00189   
00190   const u32  n_elem  = A.n_elem;
00191         u32* out_mem = out.memptr();
00192   
00193   for(u32 i=0; i<n_elem; ++i)
00194     {
00195     out_mem[i] = (A[i] != B[i]) ? u32(1) : u32(0);
00196     }
00197   
00198   }
00199 
00200 
00201 
00202 //! @}