@@ -59,6 +59,7 @@ namespace turi {
59
59
return distribution_type (min, max)(m_rng);
60
60
}
61
61
};
62
+
62
63
template <>
63
64
struct uniform <double > {
64
65
typedef std::uniform_real_distribution<double > distribution_type;
@@ -132,7 +133,7 @@ namespace turi {
132
133
* Generate a random number in the uniform real with range [min,
133
134
* max) or [min, max] if the number type is discrete.
134
135
*/
135
- template <typename NumType>
136
+ template <typename NumType = uint32_t >
136
137
inline NumType uniform (const NumType min, const NumType max,
137
138
typename std::enable_if<std::is_integral<NumType>::value>::type* = nullptr ) {
138
139
@@ -144,7 +145,7 @@ namespace turi {
144
145
/* *
145
146
* Generate a random number in the uniform real with range [min,
146
147
* max) or [min, max] if the number type is discrete.
147
- * [Double overload]
148
+ * [Float overload]
148
149
*/
149
150
template <typename NumType>
150
151
inline NumType uniform (const NumType min, const NumType max,
@@ -155,14 +156,6 @@ namespace turi {
155
156
return d (m_rng);
156
157
} // end of uniform
157
158
158
- /* *
159
- * Generate a random number in the uniform real with range [min,
160
- * max) or [min, max] if the number type is discrete.
161
- */
162
- template <typename NumType>
163
- inline NumType fast_uniform (const NumType min, const NumType max) {
164
- return uniform<NumType>(min, max);
165
- }
166
159
167
160
/* *
168
161
* Generate a random number in the uniform real with range [min,
@@ -379,18 +372,6 @@ namespace turi {
379
372
return get_source ().uniform <NumType>(min, max);
380
373
} // end of uniform
381
374
382
- /* *
383
- * \ingroup random
384
- * Generate a random number in the uniform real with range [min,
385
- * max) or [min, max] if the number type is discrete.
386
- */
387
- template <typename NumType>
388
- inline NumType fast_uniform (const NumType min, const NumType max) {
389
- if (min == max) return min;
390
- return get_source ().fast_uniform <NumType>(min, max);
391
- } // end of uniform
392
-
393
-
394
375
/* *
395
376
* \ingroup random
396
377
* Generate a random number between 0 and 1
@@ -401,7 +382,7 @@ namespace turi {
401
382
* \ingroup random
402
383
* Simulates the standard rand function as defined in cstdlib
403
384
*/
404
- inline int rand () { return uniform (0 , RAND_MAX); }
385
+ inline int rand () { return uniform< int > (0 , RAND_MAX); }
405
386
406
387
407
388
/* *
0 commit comments