/** * Optimize b with the greedy method */ template <class FT> void Pruner<FT>::greedy(evec &b) { // Do not call enforce in this function, as min_pruning_bounds may not have been set // Indeed, the min_pruning_bound should now based on greedy. if (!shape_loaded) { throw std::invalid_argument("Error: No basis shape was loaded"); } fill(min_pruning_coefficients.begin(), min_pruning_coefficients.end(), 0.); b.resize(d); fill(b.begin(), b.end(), 1.); evec new_b(d); FT nodes; for (int j = 1; j < 2 * d - 1; j += 2) { int i = j / 2; if (i > 1) { b[i] = b[i - 1] > .9 ? 1 : 1.1 * b[i - 1]; } double goal_factor = 1. / (3. * n) + 4 * j * (n - j) / (n * n * n); // Make the tree width as a parabola, with maximum at n/2 nodes = 1. + 1e10 * preproc_cost; while ((nodes > goal_factor * preproc_cost) & (b[i] > .001)) { b[i] *= .98; for (int k = 0; k < i; ++k) { b[k] = b[k] < b[i] ? b[k] : b[i]; // Enforcing decreasing by hand } nodes = relative_volume((j + 1) / 2, b); nodes *= tabulated_ball_vol[j + 1]; nodes *= pow_si(normalized_radius * sqrt(b[i]), j + 1); nodes *= ipv[j]; nodes *= symmetry_factor; } } }
/** @brief double型のべき乗 z=x^y */ void dvec_pow_si(int n, double *z, double *x, long y) { int i; for(i=0; i<n; i++){ z[i]=pow_si(x[i],y); } }