OLD | NEW |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * This program is free software; you can redistribute it and/or modify | 3 * This program is free software; you can redistribute it and/or modify |
4 * it under the terms of the GNU General Public License version 2 as | 4 * it under the terms of the GNU General Public License version 2 as |
5 * published by the Free Software Foundation; | 5 * published by the Free Software Foundation; |
6 * | 6 * |
7 * This program is distributed in the hope that it will be useful, | 7 * This program is distributed in the hope that it will be useful, |
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
10 * GNU General Public License for more details. | 10 * GNU General Public License for more details. |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 *· | 352 *· |
353 * For simplicity, we'll use the first two terms | 353 * For simplicity, we'll use the first two terms |
354 * of the second form. | 354 * of the second form. |
355 */ | 355 */ |
356 void ReportExpectedCollisions () const | 356 void ReportExpectedCollisions () const |
357 { | 357 { |
358 // Expected number of collisions | 358 // Expected number of collisions |
359 // | 359 // |
360 // Number of buckets = k = 2^bits | 360 // Number of buckets = k = 2^bits |
361 long double k32 = 0xFFFFFFFF; | 361 long double k32 = 0xFFFFFFFF; |
362 long double k64 = 0xFFFFFFFFFFFFFFFFULL; | 362 long double k64 = static_cast<long double> (0xFFFFFFFFFFFFFFFFULL); |
363 | 363 |
364 long double n = m_nphrases; | 364 long double n = m_nphrases; |
365 long double Ec32 = n * (n - 1) / ( 2 * k32) * (1 - (n - 2)/(3 * k32)); | 365 long double Ec32 = n * (n - 1) / ( 2 * k32) * (1 - (n - 2)/(3 * k32)); |
366 long double Ec64 = n * (n - 1) / ( 2 * k64) * (1 - (n - 2)/(3 * k64)); | 366 long double Ec64 = n * (n - 1) / ( 2 * k64) * (1 - (n - 2)/(3 * k64)); |
367 ······ | 367 ······ |
368 // Output collisions | 368 // Output collisions |
369 std::cout << "" << std::endl; | 369 std::cout << "" << std::endl; |
370 std::cout << "Number of words or phrases: " << n << std::endl; | 370 std::cout << "Number of words or phrases: " << n << std::endl; |
371 std::cout << "Expected number of collisions: (32-bit table) " << Ec32 | 371 std::cout << "Expected number of collisions: (32-bit table) " << Ec32 |
372 << std::endl; | 372 << std::endl; |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 ·· | 574 ·· |
575 dict.Report (); | 575 dict.Report (); |
576 ·· | 576 ·· |
577 if (timing) | 577 if (timing) |
578 { | 578 { |
579 dict.Time (); | 579 dict.Time (); |
580 } // if (timing) | 580 } // if (timing) |
581 | 581 |
582 | 582 |
583 } // main | 583 } // main |
OLD | NEW |