fn_zeros.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 fn_zeros
00017 //! @{
00018 
00019 
00020 //! Generate a dense matrix with all elements set to zero
00021 inline
00022 const Op<mat, op_zeros>
00023 zeros(const u32 n_rows, const u32 n_cols)
00024   {
00025   arma_extra_debug_sigprint();
00026   
00027   return Op<mat, op_zeros>(n_rows, n_cols, 'j');
00028   }
00029 
00030 
00031 
00032 template<typename mat_type>
00033 inline
00034 const Op<mat_type,op_zeros>
00035 zeros(const u32 n_rows, const u32 n_cols)
00036   {
00037   arma_extra_debug_sigprint();
00038   
00039   arma_type_check<is_Mat<mat_type>::value == false>::apply();
00040   
00041   return Op<mat_type,op_zeros>(n_rows, n_cols, 'j');
00042   }
00043 
00044 
00045 
00046 //! Generate a vector with all elements set to zero
00047 inline
00048 const Op<colvec, op_zeros>
00049 zeros(const u32 n_elem)
00050   {
00051   arma_extra_debug_sigprint();
00052   
00053   return Op<colvec, op_zeros>(n_elem, 1, 'j');
00054   }
00055 
00056 
00057 
00058 template<typename vec_type>
00059 inline
00060 const Op<vec_type,op_zeros>
00061 zeros(const u32 n_elem)
00062   {
00063   arma_extra_debug_sigprint();
00064   
00065   arma_type_check< (is_Col<vec_type>::value == false) && (is_Row<vec_type>::value == false) >::apply();
00066   
00067   if(is_Row<vec_type>::value == true)
00068     {
00069     return Op<vec_type,op_zeros>(1, n_elem, 'j');
00070     }
00071   else
00072     {
00073     return Op<vec_type,op_zeros>(n_elem, 1, 'j');
00074     }
00075   }
00076 
00077 
00078 
00079 //
00080 //
00081 // handling of cubes
00082 
00083 
00084 
00085 //! Generate a dense cube with all elements set to zero
00086 inline
00087 const OpCube<cube, op_zeros>
00088 zeros(const u32 n_rows, const u32 n_cols, const u32 n_slices)
00089   {
00090   arma_extra_debug_sigprint();
00091   
00092   return OpCube<cube, op_zeros>(n_rows, n_cols, n_slices);
00093   }
00094 
00095 
00096 
00097 template<typename cube_type>
00098 inline
00099 const OpCube<cube_type,op_zeros>
00100 zeros(const u32 n_rows, const u32 n_cols, const u32 n_slices)
00101   {
00102   arma_extra_debug_sigprint();
00103   
00104   arma_type_check<is_Cube<cube_type>::value == false>::apply();
00105   
00106   return OpCube<cube_type,op_zeros>(n_rows, n_cols, n_slices);
00107   }
00108 
00109 
00110 
00111 //! @}