void TextureManager::registerTexture(Texture* target) { // FIXME: If the script specifies a file with extension, we should // prioritize that and avoid doing any operations here. if (!target->hasResource()) { // We attempt loading the resource with automatically generated filenames char fileToLoad[kMaxFileLength]; if (config.bundleEnabled) { // Attempt loading the bundle snprintf(fileToLoad, kMaxFileLength, "%s.%s", target->name().c_str(), config.texExtension().c_str()); } else { // Attempt loading individual file with generated index and default extension snprintf(fileToLoad, kMaxFileLength, "%s%0" in_between(kFileSeqDigits) "d.%s", target->name().c_str(), target->indexInBundle() + kFileSeqStart, config.texExtension().c_str()); } target->setResource(config.path(kPathResources, fileToLoad, kObjectNode).c_str()); } _arrayOfTextures.push_back(target); // Nothing to do for now // It's the responsibility of another module to generate the res path accordingly }
void set_num_threads(int threads) { #ifdef _OPENMP threads_ = in_between(1, threads, omp_get_max_threads()); primesieve::set_num_threads(threads_); #else unused_param(threads); #endif }
int S2Status::skewed_percent(maxint_t n, maxint_t limit) const { double exp = 0.96; double percent = get_percent((double) n, (double) limit); double base = exp + percent / (101 / (1 - exp)); double min = pow(base, 100.0); percent = 100 - in_between(0, 100 * (pow(base, percent) - min) / (1 - min), 100); return max(old_, (int) percent); }
/// Calculate the Lagarias-Miller-Odlyzko alpha tuning factor. /// alpha = a log(x)^2 + b log(x) + c /// a, b and c are constants that should be determined empirically. /// @see ../doc/alpha-factor-tuning.pdf /// double get_alpha_lmo(int128_t x) { double alpha = get_alpha(); // use default alpha if no command-line alpha provided if (alpha < 1) { double a = 0.00156512; double b = -0.0261411; double c = 0.990948; double logx = log((double) x); alpha = a * pow(logx, 2) + b * logx + c; } return in_between(1, alpha, iroot<6>(x)); }
void S2Status::print(maxint_t n, maxint_t limit, double rsd) { double t2 = get_wtime(); if (old_ >= 0 && (t2 - time_) < 0.01) return; time_ = t2; int percent = skewed_percent(n, limit); int load_balance = (int) in_between(0, 100 - rsd + 0.5, 100); old_ = percent; ostringstream oss; oss << "\r" << string(40,' '); oss << "\rStatus: " << percent << "%, "; oss << "Load balance: " << load_balance << "%"; cout << oss.str() << flush; }
/// Calculate the Deleglise-Rivat alpha tuning factor. /// alpha = a log(x)^3 + b log(x)^2 + c log(x) + d /// a, b, c and d are constants that should be determined empirically. /// @see ../doc/alpha-tuning-factor.pdf /// double get_alpha_deleglise_rivat(int128_t x) { double alpha = get_alpha(); double x2 = (double) x; // use default alpha if no command-line alpha provided if (alpha < 1) { double a = 0.000356618; double b = 0.00263762; double c = -0.125227; double d = 1.39952; double logx = log(x2); alpha = a * pow(logx, 3) + b * pow(logx, 2) + c * logx + d; } return in_between(1, alpha, iroot<6>(x)); }
void set_status_precision(int precision) { status_precision_ = in_between(0, precision, 5); }