operator_cube_plus.hpp

Go to the documentation of this file.
00001 // Copyright (C) 2009 NICTA
00002 // 
00003 // Authors:
00004 // - Conrad Sanderson (conradsand at ieee dot org)
00005 // 
00006 // This file is part of the Armadillo C++ library.
00007 // It is provided without any warranty of fitness
00008 // for any purpose. You can redistribute this file
00009 // and/or modify it under the terms of the GNU
00010 // Lesser General Public License (LGPL) as published
00011 // by the Free Software Foundation, either version 3
00012 // of the License or (at your option) any later version.
00013 // (see http://www.opensource.org/licenses for more info)
00014 
00015 
00016 //! \addtogroup operator_cube_plus
00017 //! @{
00018 
00019 
00020 
00021 //! unary plus operation (does nothing, but is required for completeness)
00022 template<typename T1>
00023 arma_inline
00024 const BaseCube<typename T1::elem_type,T1>&
00025 operator+
00026 (const BaseCube<typename T1::elem_type,T1>& X)
00027   {
00028   arma_extra_debug_sigprint();
00029   
00030   return X;
00031   }
00032 
00033 
00034 
00035 //! Base + scalar
00036 template<typename T1>
00037 arma_inline
00038 const OpCube<T1, op_scalar_plus>
00039 operator+
00040 (const BaseCube<typename T1::elem_type,T1>& X, const typename T1::elem_type k)
00041   {
00042   arma_extra_debug_sigprint();
00043   
00044   return OpCube<T1, op_scalar_plus>(X.get_ref(), k);
00045   }
00046 
00047 
00048 
00049 //! op + scalar, level 2
00050 template<typename T1>
00051 arma_inline
00052 const OpCube<T1,op_scalar_plus>
00053 operator+
00054 (const OpCube<T1,op_scalar_plus>& X, const typename T1::elem_type k)
00055   {
00056   arma_extra_debug_sigprint();
00057   
00058   return OpCube<T1, op_scalar_plus>(X.m, X.aux + k);
00059   }
00060 
00061 
00062 
00063 //! scalar + Base
00064 template<typename T1>
00065 arma_inline
00066 const OpCube<T1, op_scalar_plus>
00067 operator+
00068 (const typename T1::elem_type k, const BaseCube<typename T1::elem_type,T1>& X)
00069   {
00070   arma_extra_debug_sigprint();
00071   
00072   return OpCube<T1, op_scalar_plus>(X.get_ref(), k);  // NOTE: order is swapped
00073   }
00074 
00075 
00076 
00077 //
00078 // addition of Base objects with different element types
00079 //
00080 
00081 
00082 
00083 //! Base + Base
00084 template<typename eT1, typename T1, typename eT2, typename T2>
00085 arma_inline
00086 Cube<typename promote_type<eT1,eT2>::result>
00087 operator+
00088 (const BaseCube<eT1,T1>& X, const BaseCube<eT2,T2>& Y)
00089   {
00090   arma_extra_debug_sigprint();
00091   
00092   promote_type<eT1,eT2>::check();
00093 
00094   const unwrap_cube<T1> tmp1(X.get_ref());
00095   const unwrap_cube<T2> tmp2(Y.get_ref());
00096   
00097   const Cube<eT1>& A = tmp1.M;
00098   const Cube<eT2>& B = tmp2.M;
00099   
00100   Cube< typename promote_type<eT1,eT2>::result > out;
00101   glue_cube_plus::apply_mixed(out, A, B);
00102   
00103   return out;
00104   }
00105 
00106 
00107 
00108 //
00109 // addition of Base objects with same element types
00110 //
00111 
00112 
00113 
00114 template<typename T1, typename T2>
00115 arma_inline
00116 const GlueCube<T1, T2, glue_cube_plus>
00117 operator+
00118 (const BaseCube<std::complex<double>,T1>& X, const BaseCube<std::complex<double>,T2>& Y)
00119   {
00120   arma_extra_debug_sigprint();
00121   
00122   return GlueCube<T1, T2, glue_cube_plus>(X.get_ref(), Y.get_ref());
00123   }
00124 
00125 
00126 
00127 template<typename T1, typename T2>
00128 arma_inline
00129 const GlueCube<T1, T2, glue_cube_plus>
00130 operator+
00131 (const BaseCube<std::complex<float>,T1>& X, const BaseCube<std::complex<float>,T2>& Y)
00132   {
00133   arma_extra_debug_sigprint();
00134   
00135   return GlueCube<T1, T2, glue_cube_plus>(X.get_ref(), Y.get_ref());
00136   }
00137 
00138 
00139 
00140 template<typename T1, typename T2>
00141 arma_inline
00142 const GlueCube<T1, T2, glue_cube_plus>
00143 operator+
00144 (const BaseCube<double,T1>& X, const BaseCube<double,T2>& Y)
00145   {
00146   arma_extra_debug_sigprint();
00147   
00148   return GlueCube<T1, T2, glue_cube_plus>(X.get_ref(), Y.get_ref());
00149   }
00150 
00151 
00152 
00153 template<typename T1, typename T2>
00154 arma_inline
00155 const GlueCube<T1, T2, glue_cube_plus>
00156 operator+
00157 (const BaseCube<float,T1>& X, const BaseCube<float,T2>& Y)
00158   {
00159   arma_extra_debug_sigprint();
00160   
00161   return GlueCube<T1, T2, glue_cube_plus>(X.get_ref(), Y.get_ref());
00162   }
00163 
00164 
00165 
00166 template<typename T1, typename T2>
00167 arma_inline
00168 const GlueCube<T1, T2, glue_cube_plus>
00169 operator+
00170 (const BaseCube<s32,T1>& X, const BaseCube<s32,T2>& Y)
00171   {
00172   arma_extra_debug_sigprint();
00173   
00174   return GlueCube<T1, T2, glue_cube_plus>(X.get_ref(), Y.get_ref());
00175   }
00176 
00177 
00178 
00179 template<typename T1, typename T2>
00180 arma_inline
00181 const GlueCube<T1, T2, glue_cube_plus>
00182 operator+
00183 (const BaseCube<u32,T1>& X, const BaseCube<u32,T2>& Y)
00184   {
00185   arma_extra_debug_sigprint();
00186   
00187   return GlueCube<T1, T2, glue_cube_plus>(X.get_ref(), Y.get_ref());
00188   }
00189 
00190 
00191 
00192 template<typename T1, typename T2>
00193 arma_inline
00194 const GlueCube<T1, T2, glue_cube_plus>
00195 operator+
00196 (const BaseCube<s16,T1>& X, const BaseCube<s16,T2>& Y)
00197   {
00198   arma_extra_debug_sigprint();
00199   
00200   return GlueCube<T1, T2, glue_cube_plus>(X.get_ref(), Y.get_ref());
00201   }
00202 
00203 
00204 
00205 template<typename T1, typename T2>
00206 arma_inline
00207 const GlueCube<T1, T2, glue_cube_plus>
00208 operator+
00209 (const BaseCube<u16,T1>& X, const BaseCube<u16,T2>& Y)
00210   {
00211   arma_extra_debug_sigprint();
00212   
00213   return GlueCube<T1, T2, glue_cube_plus>(X.get_ref(), Y.get_ref());
00214   }
00215 
00216 
00217 
00218 template<typename T1, typename T2>
00219 arma_inline
00220 const GlueCube<T1, T2, glue_cube_plus>
00221 operator+
00222 (const BaseCube<s8,T1>& X, const BaseCube<s8,T2>& Y)
00223   {
00224   arma_extra_debug_sigprint();
00225   
00226   return GlueCube<T1, T2, glue_cube_plus>(X.get_ref(), Y.get_ref());
00227   }
00228 
00229 
00230 
00231 template<typename T1, typename T2>
00232 arma_inline
00233 const GlueCube<T1, T2, glue_cube_plus>
00234 operator+
00235 (const BaseCube<u8,T1>& X, const BaseCube<u8,T2>& Y)
00236   {
00237   arma_extra_debug_sigprint();
00238   
00239   return GlueCube<T1, T2, glue_cube_plus>(X.get_ref(), Y.get_ref());
00240   }
00241 
00242 
00243 
00244 //! @}