Row_meat.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 Row
00017 //! @{
00018 
00019 template<typename eT>
00020 inline
00021 Row<eT>::Row()
00022   : Mat<eT>()
00023   {
00024   arma_extra_debug_sigprint();
00025   }
00026 
00027 
00028 
00029 template<typename eT>
00030 inline
00031 Row<eT>::Row(const u32 in_n_elem)
00032   : Mat<eT>(1,in_n_elem)
00033   {
00034   arma_extra_debug_sigprint();
00035   }
00036 
00037 
00038 
00039 template<typename eT>
00040 inline
00041 Row<eT>::Row(const char* text)
00042   : Mat<eT>(text)
00043   {
00044   arma_extra_debug_sigprint();
00045   
00046   arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" );
00047   }
00048   
00049 
00050 
00051 template<typename eT>
00052 inline
00053 const Row<eT>&
00054 Row<eT>::operator=(const char* text)
00055   {
00056   arma_extra_debug_sigprint();
00057   
00058   Mat<eT>::operator=(text);
00059   arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" );
00060   return *this;
00061   }
00062 
00063 
00064 
00065 template<typename eT>
00066 inline
00067 Row<eT>::Row(const Row<eT>& X)
00068   : Mat<eT>(X)
00069   {
00070   arma_extra_debug_sigprint();
00071   }
00072 
00073 
00074 
00075 template<typename eT>
00076 inline
00077 const Row<eT>&
00078 Row<eT>::operator=(const Row<eT>& X)
00079   {
00080   arma_extra_debug_sigprint();
00081   
00082   Mat<eT>::operator=(X);
00083   return *this;
00084   }
00085 
00086 
00087 
00088 template<typename eT>
00089 inline Row<eT>::Row(const Mat<eT>& X)
00090   : Mat<eT>(X)
00091   {
00092   arma_extra_debug_sigprint();
00093   
00094   arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" );
00095   }
00096 
00097 
00098 
00099 template<typename eT>
00100 inline
00101 const Row<eT>&
00102 Row<eT>::operator=(const Mat<eT>& X)
00103   {
00104   arma_extra_debug_sigprint();
00105   
00106   Mat<eT>::operator=(X);
00107   arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" );
00108   return *this;
00109   }
00110 
00111 
00112 
00113 template<typename eT>
00114 inline
00115 const Row<eT>&
00116 Row<eT>::operator*=(const Mat<eT>& X)
00117   {
00118   arma_extra_debug_sigprint();
00119   
00120   Mat<eT>::operator*=(X);
00121   arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" );
00122   return *this;
00123   }
00124 
00125 
00126 
00127 //! construct a row vector from a given auxillary array
00128 template<typename eT>
00129 inline
00130 Row<eT>::Row(const eT* aux_mem, const u32 aux_length)
00131   {
00132   arma_extra_debug_sigprint();
00133   
00134   Mat<eT>::set_size(1, aux_length);
00135   arma_check( (Mat<eT>::n_elem != aux_length), "Row(): don't know how to handle the given array" );
00136 
00137   syslib::copy_elem( Mat<eT>::memptr(), aux_mem, Mat<eT>::n_elem );
00138   }
00139 
00140 
00141 
00142 template<typename eT>
00143 template<typename T1, typename T2>
00144 inline
00145 Row<eT>::Row
00146   (
00147   const Base<typename Row<eT>::pod_type, T1>& A,
00148   const Base<typename Row<eT>::pod_type, T2>& B
00149   )
00150   : Mat<eT>(A,B)
00151   {
00152   arma_extra_debug_sigprint();
00153   
00154   arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" );
00155   }
00156 
00157 
00158 
00159 template<typename eT>
00160 inline
00161 Row<eT>::Row(const subview<eT>& X)
00162   : Mat<eT>(X)
00163   {
00164   arma_extra_debug_sigprint();
00165   
00166   arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" );
00167   }
00168 
00169 
00170 
00171 template<typename eT>
00172 inline
00173 const Row<eT>&
00174 Row<eT>::operator=(const subview<eT>& X)
00175   {
00176   arma_extra_debug_sigprint();
00177   
00178   Mat<eT>::operator=(X);
00179   arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" );
00180   return *this;
00181   }
00182 
00183 
00184 
00185 template<typename eT>
00186 inline
00187 const Row<eT>&
00188 Row<eT>::operator*=(const subview<eT>& X)
00189   {
00190   arma_extra_debug_sigprint();
00191   
00192   Mat<eT>::operator*=(X);
00193   arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" );
00194   return *this;
00195   }
00196 
00197 
00198 
00199 //! construct a row vector from given a diagview
00200 template<typename eT>
00201 inline Row<eT>::Row(const diagview<eT>& X)
00202   : Mat<eT>(X)
00203   {
00204   arma_extra_debug_sigprint();
00205   
00206   std::swap( access::rw(Mat<eT>::n_rows), access::rw(Mat<eT>::n_cols) );
00207   arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" );
00208   }
00209 
00210 
00211 
00212 //! construct a row vector from given a diagview
00213 template<typename eT>
00214 inline
00215 const Row<eT>&
00216 Row<eT>::operator=(const diagview<eT>& X)
00217   {
00218   arma_extra_debug_sigprint();
00219   
00220   Mat<eT>::operator=(X);
00221   
00222   //std::swap( access::rw(Mat<eT>::n_rows), access::rw(Mat<eT>::n_cols) );
00223   arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" );
00224   
00225   return *this;
00226   }
00227 
00228 
00229 
00230 template<typename eT>
00231 inline
00232 const Row<eT>&
00233 Row<eT>::operator*=(const diagview<eT>& X)
00234   {
00235   arma_extra_debug_sigprint();
00236   
00237   Mat<eT>::operator*=(X);
00238   
00239   arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" );
00240   
00241   return *this;
00242   }
00243 
00244 
00245 
00246 template<typename eT>
00247 template<typename T1, typename op_type>
00248 inline
00249 Row<eT>::Row(const Op<T1, op_type>& X)
00250   : Mat<eT>(X)
00251   {
00252   arma_extra_debug_sigprint();
00253   
00254   arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" );
00255   }
00256 
00257 
00258 
00259 template<typename eT>
00260 template<typename T1, typename op_type>
00261 inline
00262 const Row<eT>&
00263 Row<eT>::operator=(const Op<T1, op_type>& X)
00264   {
00265   arma_extra_debug_sigprint();
00266   
00267   Mat<eT>::operator=(X);
00268   arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" );
00269   return *this;
00270   }
00271 
00272 
00273 
00274 template<typename eT>
00275 template<typename T1, typename op_type>
00276 inline
00277 const Row<eT>&
00278 Row<eT>::operator*=(const Op<T1, op_type>& X)
00279   {
00280   arma_extra_debug_sigprint();
00281   
00282   Mat<eT>::operator*=(X);
00283   arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" );
00284   return *this;
00285   }
00286 
00287 
00288 
00289 template<typename eT>
00290 template<typename T1, typename T2, typename glue_type>
00291 inline
00292 Row<eT>::Row(const Glue<T1, T2, glue_type>& X)
00293   : Mat<eT>(X)
00294   {
00295   arma_extra_debug_sigprint();
00296   
00297   arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" );
00298   }
00299 
00300 
00301 
00302 template<typename eT>
00303 template<typename T1, typename T2, typename glue_type>
00304 inline
00305 const Row<eT>&
00306 Row<eT>::operator=(const Glue<T1, T2, glue_type>& X)
00307   {
00308   arma_extra_debug_sigprint();
00309   
00310   Mat<eT>::operator=(X);
00311   arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" );
00312   return *this;
00313   }
00314 
00315 
00316 
00317 template<typename eT>
00318 template<typename T1, typename T2, typename glue_type>
00319 inline
00320 const Row<eT>&
00321 Row<eT>::operator*=(const Glue<T1, T2, glue_type>& X)
00322   {
00323   arma_extra_debug_sigprint();
00324   
00325   Mat<eT>::operator*=(X);
00326   arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" );
00327   return *this;
00328   }
00329 
00330 
00331 
00332 template<typename eT>
00333 inline
00334 void
00335 Row<eT>::set_size(const u32 in_n_elem)
00336   {
00337   arma_extra_debug_sigprint();
00338   
00339   Mat<eT>::set_size(1,in_n_elem);
00340   }
00341 
00342 
00343 
00344 template<typename eT>
00345 inline
00346 void
00347 Row<eT>::set_size(const u32 in_n_rows, const u32 in_n_cols)
00348   {
00349   arma_extra_debug_sigprint();
00350   
00351   Mat<eT>::set_size( (std::min)( u32(1), in_n_rows), in_n_cols );
00352   
00353   arma_debug_check( (in_n_rows > 1), "Row::set_size(): incompatible dimensions" );
00354   }
00355 
00356 
00357 
00358 template<typename eT>
00359 inline
00360 void
00361 Row<eT>::zeros()
00362   {
00363   arma_extra_debug_sigprint();
00364   
00365   Mat<eT>::zeros();
00366   }
00367 
00368 
00369 
00370 template<typename eT>
00371 inline
00372 void
00373 Row<eT>::zeros(const u32 in_n_elem)
00374   {
00375   arma_extra_debug_sigprint();
00376   
00377   Mat<eT>::zeros(1,in_n_elem);
00378   }
00379 
00380 
00381 
00382 template<typename eT>
00383 inline
00384 void
00385 Row<eT>::zeros(const u32 in_n_rows, const u32 in_n_cols)
00386   {
00387   arma_extra_debug_sigprint();
00388   
00389   Mat<eT>::zeros( (std::min)( u32(1), in_n_rows), in_n_cols );
00390   arma_debug_check( (in_n_rows > 1), "Row<eT>::zeros(): incompatible dimensions" );
00391   }
00392 
00393 
00394 
00395 template<typename eT>
00396 inline
00397 void
00398 Row<eT>::load(const std::string name, const file_type type)
00399   {
00400   arma_extra_debug_sigprint();
00401   
00402   Mat<eT>::load(name,type);
00403   arma_debug_check( (Mat<eT>::n_rows > 1), "Row(): incompatible dimensions" );
00404   }
00405 
00406 
00407 
00408 //! @}