fn_ones.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 fn_ones
00018 //! @{
00019 
00020 
00021 
00022 //! Generate a vector with all elements set to one
00023 arma_inline
00024 const eOp<colvec, eop_ones_full>
00025 ones(const u32 n_elem, const arma_Mat_Col_Row_only<colvec>::result* junk = 0)
00026   {
00027   arma_extra_debug_sigprint();
00028   
00029   return eOp<colvec, eop_ones_full>(n_elem, 1);
00030   }
00031 
00032 
00033 
00034 template<typename vec_type>
00035 arma_inline
00036 const eOp<vec_type, eop_ones_full>
00037 ones(const u32 n_elem, const typename arma_Mat_Col_Row_only<vec_type>::result* junk = 0)
00038   {
00039   arma_extra_debug_sigprint();
00040   
00041   if(is_Row<vec_type>::value == true)
00042     {
00043     return eOp<vec_type, eop_ones_full>(1, n_elem);
00044     }
00045   else
00046     {
00047     return eOp<vec_type, eop_ones_full>(n_elem, 1);
00048     }
00049   }
00050 
00051 
00052 
00053 //! Delayed generation of a dense matrix with all elements set to one
00054 arma_inline
00055 const eOp<mat, eop_ones_full>
00056 ones(const u32 n_rows, const u32 n_cols, const arma_Mat_Col_Row_only<mat>::result* junk = 0)
00057   {
00058   arma_extra_debug_sigprint();
00059   
00060   return eOp<mat, eop_ones_full>(n_rows, n_cols);
00061   }
00062 
00063 
00064 
00065 template<typename mat_type>
00066 arma_inline
00067 const eOp<mat_type, eop_ones_full>
00068 ones(const u32 n_rows, const u32 n_cols, const typename arma_Mat_Col_Row_only<mat_type>::result* junk = 0)
00069   {
00070   arma_extra_debug_sigprint();
00071   
00072   arma_type_check<is_Mat<mat_type>::value == false>::apply();
00073   
00074   return eOp<mat_type, eop_ones_full>(n_rows, n_cols);
00075   }
00076 
00077 
00078 
00079 arma_inline
00080 const eOpCube<cube, eop_cube_ones_full>
00081 ones(const u32 n_rows, const u32 n_cols, const u32 n_slices, const arma_Cube_only<cube>::result* junk = 0)
00082   {
00083   arma_extra_debug_sigprint();
00084   
00085   return eOpCube<cube, eop_cube_ones_full>(n_rows, n_cols, n_slices);
00086   }
00087 
00088 
00089 
00090 template<typename cube_type>
00091 arma_inline
00092 const eOpCube<cube_type, eop_cube_ones_full>
00093 ones(const u32 n_rows, const u32 n_cols, const u32 n_slices, const typename arma_Cube_only<cube_type>::result* junk = 0)
00094   {
00095   arma_extra_debug_sigprint();
00096   
00097   arma_type_check<is_Cube<cube_type>::value == false>::apply();
00098   
00099   return eOpCube<cube_type, eop_cube_ones_full>(n_rows, n_cols, n_slices);
00100   }
00101 
00102 
00103 
00104 //! Delayed generation of a diagonal matrix with the diagonal elements set to one
00105 arma_inline
00106 const eOp<mat, eop_ones_diag>
00107 eye(const u32 n_rows, const u32 n_cols, const arma_Mat_Col_Row_only<mat>::result* junk = 0)
00108   {
00109   arma_extra_debug_sigprint();
00110   
00111   return eOp<mat, eop_ones_diag>(n_rows, n_cols);
00112   }
00113 
00114 
00115 
00116 template<typename mat_type>
00117 arma_inline
00118 const eOp<mat_type, eop_ones_diag>
00119 eye(const u32 n_rows, const u32 n_cols, const typename arma_Mat_Col_Row_only<mat_type>::result* junk = 0)
00120   {
00121   arma_extra_debug_sigprint();
00122   
00123   arma_type_check<is_Mat_only<mat_type>::value == false>::apply();
00124   
00125   return eOp<mat_type, eop_ones_diag>(n_rows, n_cols);
00126   }
00127 
00128 
00129 
00130 //! @}