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