Skip to content
This repository was archived by the owner on Dec 21, 2023. It is now read-only.

Commit af22629

Browse files
author
Hoyt Koepke
committed
Changed fast_uniform to uniform (as uniform was faster).
1 parent 374cc26 commit af22629

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+177
-180
lines changed

src/core/logging/table_printer/table_printer.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ struct progress_time {
156156
*
157157
* for(size_t i = 0; i < 50000; ++i) {
158158
* table.print_progress_row(proc, proc, progress_time(), i);
159-
* proc += random::fast_uniform<size_t>(0, 100);
159+
* proc += random::uniform<size_t>(0, 100);
160160
* usleep(100); // sleep for 200 microseconds
161161
* }
162162
*

src/core/logging/table_printer/table_printer_examples.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ int main(int argc, char **argv) {
5959

6060
for(size_t i = 0; i < 50000; ++i) {
6161
table.print_progress_row(proc, proc, progress_time(), i);
62-
proc += random::fast_uniform<size_t>(0, 100);
62+
proc += random::uniform<size_t>(0, 100);
6363
usleep(100); // sleep for 200 microseconds
6464
}
6565

src/core/random/alias.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ alias_sampler::alias_sampler(const std::vector<double>& p) {
5656
}
5757

5858
size_t alias_sampler::sample() {
59-
size_t k = random::fast_uniform<size_t>(0, K - 1);
60-
if (q[k] > random::fast_uniform<double>(0, 1)) {
59+
size_t k = random::uniform<size_t>(0, K - 1);
60+
if (q[k] > random::uniform<double>(0, 1)) {
6161
return k;
6262
} else {
6363
return J[k];

src/core/random/random.hpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ namespace turi {
144144
/**
145145
* Generate a random number in the uniform real with range [min,
146146
* max) or [min, max] if the number type is discrete.
147-
* [Double overload]
147+
* [Float overload]
148148
*/
149149
template <typename NumType>
150150
inline NumType uniform(const NumType min, const NumType max,
@@ -155,14 +155,6 @@ namespace turi {
155155
return d(m_rng);
156156
} // end of uniform
157157

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-
}
166158

167159
/**
168160
* Generate a random number in the uniform real with range [min,
@@ -385,11 +377,16 @@ namespace turi {
385377
* max) or [min, max] if the number type is discrete.
386378
*/
387379
template<typename NumType>
388-
inline NumType fast_uniform(const NumType min, const NumType max) {
380+
inline NumType uniform(const NumType min, const NumType max) {
389381
if (min == max) return min;
382+
<<<<<<< Updated upstream
390383
return get_source().fast_uniform<NumType>(min, max);
391384
} // end of uniform
392385

386+
=======
387+
return get_source().uniform<NumType>(min, max);
388+
} // end of uniform
389+
>>>>>>> Stashed changes
393390

394391
/**
395392
* \ingroup random

src/core/storage/serialization/dir_archive.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ size_t get_next_random_number() {
278278
gen.nondet_seed();
279279
initialized = true;
280280
}
281-
return gen.fast_uniform<size_t>(0, std::numeric_limits<size_t>::max());
281+
return gen.uniform<size_t>(0, std::numeric_limits<size_t>::max());
282282
}
283283

284284

src/core/storage/sframe_data/sarray_file_format_v2.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ class sarray_format_reader_v2: public sarray_format_reader<T> {
314314
* (looping around).
315315
*/
316316
void try_evict_something_from_cache() {
317-
size_t b = turi::random::fast_uniform<size_t>(0, m_cache.size() - 1);
317+
size_t b = turi::random::uniform<size_t>(0, m_cache.size() - 1);
318318
/*
319319
* if the current bit is not 1, try to find the next one bit
320320
* if there is no bit after that, loop around, reset and 0 and try the bit

src/core/util/testing_utils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ std::string _get_unique_directory(const std::string& file, size_t line) {
5656

5757
ss << "t" << thread::thread_id() << "__";
5858

59-
ss << random::fast_uniform<size_t>(0, size_t(-1));
59+
ss << random::uniform<size_t>(0, size_t(-1));
6060

6161
return ss.str();
6262
}

src/core/util/testing_utils.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ void _save_and_load_object(T& dest, const U& src, std::string dir) {
4848

4949
std::string arc_name = dir + "/test_archive";
5050

51-
uint64_t random_number = hash64(random::fast_uniform<size_t>(0,size_t(-1)));
51+
uint64_t random_number = hash64(random::uniform<size_t>(0,size_t(-1)));
5252

5353
// Save it
5454
dir_archive archive_write;

src/ml/ml_data/ml_data.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@ ml_data ml_data::create_subsampled_copy(size_t n_rows, size_t random_seed) const
746746
for(size_t i = 0; i < n_rows; ++i) {
747747
size_t lb = (i > 0) ? (samples[i - 1] + 1) : 0;
748748
size_t ub = (i < n_rows - 1) ? (samples[i + 1] - 1) : data_size - 1;
749-
samples[i] = random::fast_uniform<size_t>(lb, ub);
749+
samples[i] = random::uniform<size_t>(lb, ub);
750750
}
751751

752752
// Break them up into groups

src/ml/sketches/countmin.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class countmin {
6969
gen.seed(seed);
7070
// Initialize hash functions and count matrix
7171
for (size_t j = 0; j < num_hash; ++j) {
72-
seeds.push_back(gen.fast_uniform<size_t>(0, std::numeric_limits<size_t>::max()));
72+
seeds.push_back(gen.uniform<size_t>(0, std::numeric_limits<size_t>::max()));
7373
counts.push_back(std::vector<size_t>(num_bins));
7474
}
7575
}

0 commit comments

Comments
 (0)