| 422 | K real_kernel; |
| 423 | |
| 424 | void build_cache ( |
| 425 | ) const |
| 426 | { |
| 427 | std::sort(cache->frequency_of_use.rbegin(), cache->frequency_of_use.rend()); |
| 428 | counter = 0; |
| 429 | |
| 430 | |
| 431 | cache->kernel.set_size(cache_size, samples->size()); |
| 432 | cache->sample_location.assign(samples->size(), -1); |
| 433 | |
| 434 | // loop over all the samples in the cache |
| 435 | for (long i = 0; i < cache_size; ++i) |
| 436 | { |
| 437 | const long cur = cache->frequency_of_use[i].second; |
| 438 | cache->sample_location[cur] = i; |
| 439 | |
| 440 | // now populate all possible kernel products with the current sample |
| 441 | for (long j = 0; j < samples->size(); ++j) |
| 442 | { |
| 443 | cache->kernel(i, j) = real_kernel((*samples)(cur), (*samples)(j)); |
| 444 | } |
| 445 | |
| 446 | } |
| 447 | |
| 448 | // reset the frequency of use metrics |
| 449 | for (long i = 0; i < samples->size(); ++i) |
| 450 | cache->frequency_of_use[i] = std::make_pair(0, i); |
| 451 | } |
| 452 | |
| 453 | |
| 454 | struct cache_type |