@@ -108,50 +108,3 @@ ::std::vector<T> DuplicateFreeMixIn(const T* x_begin, const T* x_end, const T* y
108108 reservoirsampling (result.data () + howmanyx, howmanyy, y_begin, y_end, &seed);
109109 return result;
110110}
111-
112-
113-
114- /* *********************************************
115- ** WARNING: MixIn and MixInFast can generate duplicates!!!! Use SimpleMixIn and SlowishSimpleMixIn
116- ** instead.
117- *******************************************/
118- // Using two pointer ranges for sequences x and y, create a vector clone of x but for
119- // y_probability y's mixed in.
120- template <typename T>
121- ::std::vector<T> MixIn (const T* x_begin, const T* x_end, const T* y_begin, const T* y_end,
122- double y_probability) {
123- const size_t x_size = x_end - x_begin, y_size = y_end - y_begin;
124- if (y_size > (1ull << 32 )) throw ::std::length_error (" y is too long" );
125- ::std::vector<T> result (x_begin, x_end);
126- ::std::random_device random;
127- auto genrand = [&random, y_size]() {
128- return (static_cast <size_t >(random ()) * y_size) >> 32 ;
129- };
130- for (size_t i = 0 ; i < y_probability * x_size; ++i) {
131- result[i] = *(y_begin + genrand ());
132- }
133- ::std::shuffle (result.begin(), result.end(), random);
134- return result;
135- }
136-
137- template <typename T>
138- ::std::vector<T> MixInFast (const T* x_begin, const T* x_end, const T* y_begin, const T* y_end,
139- double y_probability, uint64_t start) {
140- const size_t x_size = x_end - x_begin, y_size = y_end - y_begin;
141- if (y_size > (1ull << 32 )) throw ::std::length_error (" y is too long" );
142- ::std::vector<T> result (x_begin, x_end);
143- uint64_t index = start;
144- auto genrand = [&index, y_size]() {
145- // mix64
146- uint64_t x = index++;
147- x = (x ^ (x >> 30 )) * 0xbf58476d1ce4e5b9L ;
148- x = (x ^ (x >> 27 )) * 0x94d049bb133111ebL ;
149- x = x ^ (x >> 31 );
150- return static_cast <size_t >((((uint32_t ) x) * (uint64_t ) y_size) >> 32 );
151- };
152- for (size_t i = 0 ; i < y_probability * x_size; ++i) {
153- result[i] = *(y_begin + genrand ());
154- }
155- ::std::shuffle (result.begin(), result.end(), std::default_random_engine(start));
156- return result;
157- }
0 commit comments