void UpdateIndexUtility(storage::DataTable* table, const std::vector<sample_frequency_map_entry>& list) { oid_t index_count = table->GetIndexCount(); for (oid_t index_itr = 0; index_itr < index_count; index_itr++) { // Get index auto index = table->GetIndex(index_itr); auto index_metadata = index->GetMetadata(); auto index_key_attrs = index_metadata->GetKeyAttrs(); std::set<oid_t> index_set(index_key_attrs.begin(), index_key_attrs.end()); // Get current index utility auto current_index_utility = GetCurrentIndexUtility(index_set, list); auto average_index_utility = index_metadata->GetUtility(); LOG_TRACE("Average index utility %5.2lf", average_index_utility); LOG_TRACE("Current index utility %5.2lf", current_index_utility); // alpha (weight for old samples) double alpha = 0.2; // Update index utility auto updated_average_index_utility = alpha * current_index_utility + (1 - alpha) * average_index_utility; index_metadata->SetUtility(updated_average_index_utility); LOG_TRACE("Updated index utility %5.2lf :: %s", updated_average_index_utility, index_metadata->GetInfo().c_str()); } }
handle_t alloc_record(ALLOC * a, table_t * t, record_t * r) { unsigned char *buf, *p; handle_t h = 0; if (_validate_record(a, t, r) < 0 || _validate_unique(a, t, r) < 0) return 0; if ((buf = buf_get(a, _sizeof_record(t, r))) == NULL) return 0; r->prev = t->tail; r->next = 0; p = record2b(buf, t, r); h = alloc_blk(a, buf, p - buf); buf_put(a, buf); if (h == 0) return 0; r->self = h; if (_list_add_record(a, t, r) < 0) return 0; for (int i = 0; i < t->ncols; i++) if (t->cols[i].index != 0) index_set(t->cols[i].idx, r, i); return h; }
Stokhos::TensorProductBasis<ordinal_type, value_type, ordering_type>:: TensorProductBasis( const Teuchos::Array< Teuchos::RCP<const OneDOrthogPolyBasis<ordinal_type, value_type> > >& bases_, const value_type& sparse_tol_, const Stokhos::MultiIndex<ordinal_type>& index, const ordering_type& coeff_compare) : p(0), d(bases_.size()), sz(0), bases(bases_), sparse_tol(sparse_tol_), max_orders(d), basis_set(coeff_compare), norms() { // Resize bases for given index if necessary if (index.dimension() > 0) { for (ordinal_type i=0; i<d; i++) { if (index[i] != bases[i]->order()) bases[i] = bases[i]->cloneWithOrder(index[i]); } } // Compute largest order for (ordinal_type i=0; i<d; i++) { max_orders[i] = bases[i]->order(); if (max_orders[i] > p) p = max_orders[i]; } // Compute basis terms MultiIndex<ordinal_type> orders(d); for (ordinal_type i=0; i<d; ++i) orders[i] = bases[i]->order(); TensorProductIndexSet<ordinal_type> index_set(orders); ProductBasisUtils::buildProductBasis(index_set, basis_set, basis_map); sz = basis_map.size(); // Compute norms norms.resize(sz); value_type nrm; for (ordinal_type k=0; k<sz; k++) { nrm = value_type(1.0); for (ordinal_type i=0; i<d; i++) nrm = nrm * bases[i]->norm_squared(basis_map[k][i]); norms[k] = nrm; } // Create name name = "Tensor product basis ("; for (ordinal_type i=0; i<d-1; i++) name += bases[i]->getName() + ", "; name += bases[d-1]->getName() + ")"; // Allocate array for basis evaluation basis_eval_tmp.resize(d); for (ordinal_type j=0; j<d; j++) basis_eval_tmp[j].resize(max_orders[j]+1); }
void *index_new(t_symbol *s, long chan) { t_index *x = object_alloc(index_class); dsp_setup((t_pxobject *)x, 1); intin((t_object *)x,1); outlet_new((t_object *)x, "signal"); index_set(x, s); index_in1(x,chan); return (x); }
void print_pairs(size_t point_count) { pair_index_set index_set(point_count); auto interaction_count = index_set.count(); // Determine column_width based on what takes more space // to write out of the largest k and the pairs (i, j) size_t column_width = 2 + std::max( count_digits_base10(interaction_count), 4 + 2 * count_digits_base10(point_count)); std::streamsize old_width = std::cout.width(); // Lambda function to return a string of column width given data to contain auto col = [column_width] (auto data) { std::stringstream ss; ss << std::left << std::setw(column_width) << data; return ss.str(); }; // Print header std::cout << "N = " << point_count << " points" << std::endl << "K = " << interaction_count << " interactions" << std::endl << col("k") << col("(i, j)") << std::endl; // Print separator std::cout << std::string(2 * column_width, '-') << std::endl; // Print indices and pairs for (index_type k = 1; k <= interaction_count; ++k) { auto pair = index_set.map_to_pair(k); auto i = pair.first; auto j = pair.second; std::cout << col(k) << col(string_from_pair(i, j)) << std::endl; } std::cout.width(old_width); }
void index_dsp(t_index *x, t_signal **sp) { index_set(x,x->l_sym); dsp_add(index_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); }