max@0: // Copyright (C) 2008-2011 NICTA (www.nicta.com.au) max@0: // Copyright (C) 2008-2011 Conrad Sanderson max@0: // max@0: // This file is part of the Armadillo C++ library. max@0: // It is provided without any warranty of fitness max@0: // for any purpose. You can redistribute this file max@0: // and/or modify it under the terms of the GNU max@0: // Lesser General Public License (LGPL) as published max@0: // by the Free Software Foundation, either version 3 max@0: // of the License or (at your option) any later version. max@0: // (see http://www.opensource.org/licenses for more info) max@0: max@0: max@0: //! \addtogroup fn_randu max@0: //! @{ max@0: max@0: max@0: inline max@0: double max@0: randu() max@0: { max@0: return double(eop_aux_randu()); max@0: } max@0: max@0: max@0: template max@0: inline max@0: typename arma_scalar_only::result max@0: randu() max@0: { max@0: return eT(eop_aux_randu()); max@0: } max@0: max@0: max@0: max@0: //! Generate a vector with all elements set to random values in the [0,1] interval (uniform distribution) max@0: arma_inline max@0: const Gen max@0: randu(const uword n_elem) max@0: { max@0: arma_extra_debug_sigprint(); max@0: max@0: return Gen(n_elem, 1); max@0: } max@0: max@0: max@0: max@0: template max@0: arma_inline max@0: const Gen max@0: randu(const uword n_elem, const arma_empty_class junk1 = arma_empty_class(), const typename arma_Mat_Col_Row_only::result* junk2 = 0) max@0: { max@0: arma_extra_debug_sigprint(); max@0: arma_ignore(junk1); max@0: arma_ignore(junk2); max@0: max@0: if(is_Row::value == true) max@0: { max@0: return Gen(1, n_elem); max@0: } max@0: else max@0: { max@0: return Gen(n_elem, 1); max@0: } max@0: } max@0: max@0: max@0: max@0: //! Generate a dense matrix with all elements set to random values in the [0,1] interval (uniform distribution) max@0: arma_inline max@0: const Gen max@0: randu(const uword n_rows, const uword n_cols) max@0: { max@0: arma_extra_debug_sigprint(); max@0: max@0: return Gen(n_rows, n_cols); max@0: } max@0: max@0: max@0: max@0: template max@0: arma_inline max@0: const Gen max@0: randu(const uword n_rows, const uword n_cols, const typename arma_Mat_Col_Row_only::result* junk = 0) max@0: { max@0: arma_extra_debug_sigprint(); max@0: arma_ignore(junk); max@0: max@0: return Gen(n_rows, n_cols); max@0: } max@0: max@0: max@0: max@0: arma_inline max@0: const GenCube max@0: randu(const uword n_rows, const uword n_cols, const uword n_slices) max@0: { max@0: arma_extra_debug_sigprint(); max@0: max@0: return GenCube(n_rows, n_cols, n_slices); max@0: } max@0: max@0: max@0: max@0: template max@0: arma_inline max@0: const GenCube max@0: randu(const uword n_rows, const uword n_cols, const uword n_slices, const typename arma_Cube_only::result* junk = 0) max@0: { max@0: arma_extra_debug_sigprint(); max@0: arma_ignore(junk); max@0: max@0: return GenCube(n_rows, n_cols, n_slices); max@0: } max@0: max@0: max@0: max@0: //! @}