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