Mercurial > hg > segmenter-vamp-plugin
comparison armadillo-3.900.4/include/armadillo_bits/fn_randu.hpp @ 49:1ec0e2823891
Switch to using subrepo copies of qm-dsp, nnls-chroma, vamp-plugin-sdk; update Armadillo version; assume build without external BLAS/LAPACK
author | Chris Cannam |
---|---|
date | Thu, 13 Jun 2013 10:25:24 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
48:69251e11a913 | 49:1ec0e2823891 |
---|---|
1 // Copyright (C) 2008-2012 NICTA (www.nicta.com.au) | |
2 // Copyright (C) 2008-2012 Conrad Sanderson | |
3 // | |
4 // This Source Code Form is subject to the terms of the Mozilla Public | |
5 // License, v. 2.0. If a copy of the MPL was not distributed with this | |
6 // file, You can obtain one at http://mozilla.org/MPL/2.0/. | |
7 | |
8 | |
9 //! \addtogroup fn_randu | |
10 //! @{ | |
11 | |
12 | |
13 inline | |
14 double | |
15 randu() | |
16 { | |
17 return double(eop_aux_randu<double>()); | |
18 } | |
19 | |
20 | |
21 template<typename eT> | |
22 inline | |
23 typename arma_scalar_only<eT>::result | |
24 randu() | |
25 { | |
26 return eT(eop_aux_randu<eT>()); | |
27 } | |
28 | |
29 | |
30 | |
31 //! Generate a vector with all elements set to random values in the [0,1] interval (uniform distribution) | |
32 arma_inline | |
33 const Gen<vec, gen_randu> | |
34 randu(const uword n_elem) | |
35 { | |
36 arma_extra_debug_sigprint(); | |
37 | |
38 return Gen<vec, gen_randu>(n_elem, 1); | |
39 } | |
40 | |
41 | |
42 | |
43 template<typename obj_type> | |
44 arma_inline | |
45 const Gen<obj_type, gen_randu> | |
46 randu(const uword n_elem, const arma_empty_class junk1 = arma_empty_class(), const typename arma_Mat_Col_Row_only<obj_type>::result* junk2 = 0) | |
47 { | |
48 arma_extra_debug_sigprint(); | |
49 arma_ignore(junk1); | |
50 arma_ignore(junk2); | |
51 | |
52 if(is_Row<obj_type>::value == true) | |
53 { | |
54 return Gen<obj_type, gen_randu>(1, n_elem); | |
55 } | |
56 else | |
57 { | |
58 return Gen<obj_type, gen_randu>(n_elem, 1); | |
59 } | |
60 } | |
61 | |
62 | |
63 | |
64 //! Generate a dense matrix with all elements set to random values in the [0,1] interval (uniform distribution) | |
65 arma_inline | |
66 const Gen<mat, gen_randu> | |
67 randu(const uword n_rows, const uword n_cols) | |
68 { | |
69 arma_extra_debug_sigprint(); | |
70 | |
71 return Gen<mat, gen_randu>(n_rows, n_cols); | |
72 } | |
73 | |
74 | |
75 | |
76 template<typename obj_type> | |
77 arma_inline | |
78 const Gen<obj_type, gen_randu> | |
79 randu(const uword n_rows, const uword n_cols, const typename arma_Mat_Col_Row_only<obj_type>::result* junk = 0) | |
80 { | |
81 arma_extra_debug_sigprint(); | |
82 arma_ignore(junk); | |
83 | |
84 if(is_Col<obj_type>::value == true) | |
85 { | |
86 arma_debug_check( (n_cols != 1), "randu(): incompatible size" ); | |
87 } | |
88 else | |
89 if(is_Row<obj_type>::value == true) | |
90 { | |
91 arma_debug_check( (n_rows != 1), "randu(): incompatible size" ); | |
92 } | |
93 | |
94 return Gen<obj_type, gen_randu>(n_rows, n_cols); | |
95 } | |
96 | |
97 | |
98 | |
99 arma_inline | |
100 const GenCube<cube::elem_type, gen_randu> | |
101 randu(const uword n_rows, const uword n_cols, const uword n_slices) | |
102 { | |
103 arma_extra_debug_sigprint(); | |
104 | |
105 return GenCube<cube::elem_type, gen_randu>(n_rows, n_cols, n_slices); | |
106 } | |
107 | |
108 | |
109 | |
110 template<typename cube_type> | |
111 arma_inline | |
112 const GenCube<typename cube_type::elem_type, gen_randu> | |
113 randu(const uword n_rows, const uword n_cols, const uword n_slices, const typename arma_Cube_only<cube_type>::result* junk = 0) | |
114 { | |
115 arma_extra_debug_sigprint(); | |
116 arma_ignore(junk); | |
117 | |
118 return GenCube<typename cube_type::elem_type, gen_randu>(n_rows, n_cols, n_slices); | |
119 } | |
120 | |
121 | |
122 | |
123 //! @} |