statistics.cc (7811:a8fc35183c10) statistics.cc (7831:c1e158414648)
1/*
2 * Copyright (c) 2003-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 222 unchanged lines hidden (view full) ---

231 if (subnames.size() < x)
232 subnames.resize(x);
233 if (subdescs.size() < x)
234 subdescs.resize(x);
235 if (y_subnames.size() < y)
236 y_subnames.resize(y);
237}
238
1/*
2 * Copyright (c) 2003-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 222 unchanged lines hidden (view full) ---

231 if (subnames.size() < x)
232 subnames.resize(x);
233 if (subdescs.size() < x)
234 subdescs.resize(x);
235 if (y_subnames.size() < y)
236 y_subnames.resize(y);
237}
238
239void
240HistStor::grow_out()
241{
242 int size = cvec.size();
243 int zero = size / 2; // round down!
244 int top_half = zero + (size - zero + 1) / 2; // round up!
245 int bottom_half = (size - zero) / 2; // round down!
246
247 // grow down
248 int low_pair = zero - 1;
249 for (int i = zero - 1; i >= bottom_half; i--) {
250 cvec[i] = cvec[low_pair];
251 if (low_pair - 1 >= 0)
252 cvec[i] += cvec[low_pair - 1];
253 low_pair -= 2;
254 }
255 assert(low_pair == 0 || low_pair == -1 || low_pair == -2);
256
257 for (int i = bottom_half - 1; i >= 0; i--)
258 cvec[i] = Counter();
259
260 // grow up
261 int high_pair = zero;
262 for (int i = zero; i < top_half; i++) {
263 cvec[i] = cvec[high_pair];
264 if (high_pair + 1 < size)
265 cvec[i] += cvec[high_pair + 1];
266 high_pair += 2;
267 }
268 assert(high_pair == size || high_pair == size + 1);
269
270 for (int i = top_half; i < size; i++)
271 cvec[i] = Counter();
272
273 max_bucket *= 2;
274 min_bucket *= 2;
275 bucket_size *= 2;
276}
277
278void
279HistStor::grow_convert()
280{
281 int size = cvec.size();
282 int half = (size + 1) / 2; // round up!
283 //bool even = (size & 1) == 0;
284
285 int pair = size - 1;
286 for (int i = size - 1; i >= half; --i) {
287 cvec[i] = cvec[pair];
288 if (pair - 1 >= 0)
289 cvec[i] += cvec[pair - 1];
290 pair -= 2;
291 }
292
293 for (int i = half - 1; i >= 0; i--)
294 cvec[i] = Counter();
295
296 min_bucket = -max_bucket;// - (even ? bucket_size : 0);
297 bucket_size *= 2;
298}
299
300void
301HistStor::grow_up()
302{
303 int size = cvec.size();
304 int half = (size + 1) / 2; // round up!
305
306 int pair = 0;
307 for (int i = 0; i < half; i++) {
308 cvec[i] = cvec[pair];
309 if (pair + 1 < size)
310 cvec[i] += cvec[pair + 1];
311 pair += 2;
312 }
313 assert(pair == size || pair == size + 1);
314
315 for (int i = half; i < size; i++)
316 cvec[i] = Counter();
317
318 max_bucket *= 2;
319 bucket_size *= 2;
320}
321
239Formula::Formula()
240{
241}
242
243Formula::Formula(Temp r)
244{
245 root = r;
246 setInit();

--- 134 unchanged lines hidden ---
322Formula::Formula()
323{
324}
325
326Formula::Formula(Temp r)
327{
328 root = r;
329 setInit();

--- 134 unchanged lines hidden ---