static void init_base_types(void) { base[0] = bool_type(&types); // bool base[1] = bv_type(&types, 5); // bv5 base[2] = new_scalar_type(&types, 3); // scalar3 base[3] = new_scalar_type(&types, 1); // scalar1 base[4] = pair_type(base[0], base[2]); // bool x scalar3 base[5] = pair_type(base[3], base[0]); // scalar1 x bool base[6] = fun_type1(base[0], base[2]); // [bool -> scalar3] base[7] = fun_type1(base[0], base[3]); // [bool -> scalar1] base[8] = fun_type1(base[2], base[0]); // [scalar3 -> bool] base[9] = fun_type1(base[3], base[0]); // [scalar1 -> bool] base[10] = fun_type1(base[0], base[0]); // [bool -> bool] base[11] = fun_type1(base[10], base[0]); // [[bool -> bool] -> bool] // some infinite types base[12] = new_uninterpreted_type(&types); base[13] = real_type(&types); base[14] = int_type(&types); base[15] = fun_type1(base[14], base[0]); // [int -> bool] base[16] = fun_type2(base[0], base[0], base[14]); // [bool, bool -> int] // larger finite types base[17] = pair_type(base[1], base[1]); // bv5 x bv5 base[18] = bv_type(&types, 40); // bv40 // infinite domain, unit range base[19] = fun_type1(base[13], base[3]); // [real -> scalar1] }
pair_type RLEVector::Iterator::valueBefore(usint value) { const RLEVector& par = (const RLEVector&)(this->parent); if(value >= par.size) { return pair_type(par.size, par.items); } this->getSample(this->sampleForValue(value)); if(this->val > value) { return pair_type(par.size, par.items); } this->run = 0; while(this->cur < this->block_items && this->val < value) { usint temp = this->buffer.readDeltaCode(value - this->val); if(temp == 0) { break; } this->val += temp; temp = this->buffer.readDeltaCode(); this->cur += temp; this->val += temp - 1; } if(this->val > value) { this->run = this->val - value; this->val = value; this->cur -= this->run; } return pair_type(this->val, this->sample.first + this->cur); }
pair_type SuccinctVector::Iterator::valueAfter(usint value) { const SuccinctVector& par = (const SuccinctVector&)(this->parent); if(value >= par.size) { return pair_type(par.size, par.items); } if(value == 0) { return pair_type(this->select(0), 0); } usint temp = this->rank(value - 1); return pair_type(this->select(temp), temp); }
pair_type SuccinctVector::Iterator::valueBefore(usint value) { const SuccinctVector& par = (const SuccinctVector&)(this->parent); if(value >= par.size) { return pair_type(par.size, par.items); } usint temp = this->rank(value); if(temp == 0) { return pair_type(par.size, par.items); } return pair_type(this->select(temp - 1), temp - 1); }
int main(void) { type_t tau; init_type_table(&types, 0); init_variables(); init_types(); // pair(A) = (tuple A A) tau = pair_type(var[0], var[0]); test_macro("pair", 1, var, tau); // triple(B) = (tuple B B B) tau = triple_type(var[1], var[1], var[1]); test_macro("triple", 1, var+1, tau); // test(C, D) = bool test_macro("test", 2, var+2, base[0]); // fun(E, F) = (-> (tuple E E) F) tau = pair_type(var[4], var[4]); tau = function_type(&types, var[5], 1, &tau); test_macro("fun", 2, var+4, tau); // two constructors test_constructor("mk_type2", 2); test_constructor("mk_type3", 3); printf("\n====== TYPES ========\n"); print_type_table(stdout, &types); printf("\n===== MACROS ========\n"); print_type_macros(stdout, &types); printf("===\n\n"); // creation after remove // vector[G] = (-> int G) tau = int_type(&types); tau = function_type(&types, var[6], 1, &tau); test_macro("vector", 1, var+6, tau); // matrix[H] = (-> int int H) tau = int_type(&types); tau = binary_ftype(tau, tau, var[7]); test_macro("matrix", 1, var+7, tau); printf("\n====== TYPES ========\n"); print_type_table(stdout, &types); printf("\n===== MACROS ========\n"); print_type_macros(stdout, &types); printf("===\n\n"); delete_type_table(&types); return 0; }
static void init_base_types(void) { base[0] = bool_type(&types); // bool base[1] = bv_type(&types, 5); // bv5 base[2] = new_scalar_type(&types, 3); // scalar3 base[3] = new_scalar_type(&types, 1); // scalar1 base[4] = pair_type(base[0], base[2]); // bool x scalar3 base[5] = pair_type(base[3], base[0]); // scalar1 x bool base[6] = fun_type1(base[0], base[2]); // [bool -> scalar3] base[7] = fun_type1(base[0], base[3]); // [bool -> scalar1] base[8] = fun_type1(base[2], base[0]); // [scalar3 -> bool] base[9] = fun_type1(base[3], base[0]); // [scalar1 -> bool] }
pair_type NibbleVector::Iterator::valueAfter(usint value) { const NibbleVector& par = (const NibbleVector&)(this->parent); if(value >= par.size) { return pair_type(par.size, par.items); } this->valueLoop(value); if(this->val < value) { this->getSample(this->block + 1); } return pair_type(this->val, this->sample.first + this->cur); }
SuffixArray::SuffixArray(uchar* _data, usint* ra, uint bytes, uint threads) : ok(false), data(_data), sa(0), original_sa(0), ranks(ra), data_size(bytes), sequences(0) { if(_data == 0 || ra == 0 || bytes == 0) { std::cerr << "Error: No input data given for suffix array construction!" << std::endl; return; } for(uint i = 0; i < this->data_size; i++) { if(this->data[i] == '\0') { this->sequences++; } } if(this->data[this->data_size - 1] != '\0') { std::cerr << "Error: Input data must end with \\0!" << std::endl; return; } pair_type* pairs = new pair_type[this->data_size]; for(usint i = 0; i < this->data_size; i++) { pairs[i] = pair_type(this->ranks[i], i); } #ifdef MULTITHREAD_SUPPORT omp_set_num_threads(threads); #endif parallelSort(pairs, pairs + this->data_size); this->sa = new uint[this->data_size]; for(uint i = 0; i < this->data_size; i++) { this->sa[i] = pairs[i].second; } delete[] pairs; this->original_sa = this->sa; this->sa += this->sequences; this->ok = true; }
// Add a JetCorrectorParameter object, possibly with flavor. void JetCorrectorParametersCollection::push_back( key_type i, value_type const & j, label_type const & flav) { std::cout << "i = " << i << std::endl; std::cout << "flav = " << flav << std::endl; if ( isL5(i) ) { std::cout << "This is L5, getL5Bin = " << getL5Bin(flav) << std::endl; correctionsL5_.push_back( pair_type(getL5Bin(flav),j) ); } else if ( isL7(i) ) { std::cout << "This is L7, getL7Bin = " << getL7Bin(flav) << std::endl; correctionsL7_.push_back( pair_type(getL7Bin(flav),j) ); } else if ( flav == "" ) { corrections_.push_back( pair_type(i,j) ); } else { std::cout << "***** NOT ADDING " << flav << ", corresponding position in JetCorrectorParameters is not found." << std::endl; } }
void RLEEncoder::addRun(usint start, usint len) { if(this->run.second == 0) { this->run = pair_type(start, len); } else if(start == this->run.first + this->run.second) { this->run.second += len; } else { this->setRun(this->run.first, this->run.second); this->run = pair_type(start, len); } }
pair_type NibbleVector::Iterator::selectRun(usint index, usint max_length) { usint value = this->select(index); usint len = std::min(max_length, this->run); this->run -= len; this->cur += len; this->val += len; return pair_type(value, len); }
pair_type RLEVector::Iterator::selectNextRun(usint max_length) { usint value = this->selectNext(); usint len = std::min(max_length, this->run); this->run -= len; this->cur += len; this->val += len; return pair_type(value, len); }
/* * Create some types: this must be called after init_variables */ static void init_types(void) { base[0] = bool_type(&types); base[1] = int_type(&types); base[2] = real_type(&types); base[3] = var[0]; base[4] = var[1]; base[5] = var[2]; base[6] = pair_type(base[1], base[1]); base[7] = triple_type(var[3], base[0], var[3]); base[8] = binary_ftype(base[2], base[2], base[0]); base[9] = binary_ftype(var[4], var[5], base[0]); base[10] = ternary_ftype(base[1], base[1], base[1], base[2]); base[11] = ternary_ftype(base[2], base[2], base[2], base[0]); }
pair_type NibbleVector::Iterator::nextValue() { if(this->cur >= this->block_items) { this->getSample(this->block + 1); return pair_type(this->val, this->sample.first); } this->cur++; if(this->run > 0) { this->val++; this->run--; } else { this->val += this->buffer.readNibbleCode(); this->run = this->buffer.readNibbleCode() - 1; } return pair_type(this->val, this->sample.first + this->cur); }
/* * TEST2: pairs of base types * - skip any pair type of cardinaly >= threshold */ static void test_pairs(uint32_t threshold) { uint32_t i, j; type_t tau; printf("*****************\n" "* PAIR TYPES *\n" "*****************\n" "\n"); for (i=0; i<NUM_BASE_TYPES; i++) { for (j=0; j<NUM_BASE_TYPES; j++) { tau = pair_type(base[i], base[j]); if (type_card(&types, tau) < threshold) { test_enum_type(tau); } } } }
void Alphabet::initialize(const std::map<usint, usint>& counts) { if(counts.empty()) { return; } this->size = 0; this->chars = 0; for(std::map<usint, usint>::const_iterator mapiter = counts.begin(); mapiter != counts.end(); ++mapiter) { this->index_ranges[mapiter->first] = ((mapiter->second > 0 || this->size > 0) ? pair_type(this->size, this->size + mapiter->second - 1) : EMPTY_PAIR); if(mapiter->second > 0) { this->text_chars[this->chars] = mapiter->first; this->chars++; } size += mapiter->second; } this->index_rate = 1;//std::max((this->size + counts.size() - 1) / counts.size(), (usint)1); //FIXME std::cout << "Alphabet::index_rate: " << this->index_rate << std::endl; usint current = 0; for(usint c = 0, i = 0; c < this->chars; c++) { pair_type range = this->index_ranges[this->text_chars[c]]; while(current <= range.second) { this->index_pointers[i] = c; current += this->index_rate; i++; } } this->ok = true; }
pair_type SuccinctVector::Iterator::selectRun(usint index, usint max_length) { return pair_type(this->select(index), 0); }
pair_type SuccinctVector::Iterator::nextValue() { usint temp = this->cur + 1; return pair_type(this->select(temp), temp); }
void DeltaMultiArray::Iterator::goToItem(usint array, usint index) { this->pos = std::min(this->array_iter.select(array) + index, this->parent.getSize()); this->buffer = pair_type(this->pos, this->delta_iter.readItem(this->pos)); }
expr apply(expr const & a) { bool sh = false; if (is_shared(a)) { auto r = m_cache.find(a.raw()); if (r != m_cache.end()) return r->second; sh = true; } switch (a.kind()) { case expr_kind::Var: case expr_kind::Constant: case expr_kind::Type: case expr_kind::Value: return save_result(a, copy(a), sh); case expr_kind::App: { buffer<expr> new_args; for (expr const & old_arg : args(a)) new_args.push_back(apply(old_arg)); return save_result(a, mk_app(new_args), sh); } case expr_kind::HEq: return save_result(a, mk_heq(apply(heq_lhs(a)), apply(heq_rhs(a))), sh); case expr_kind::Pair: return save_result(a, mk_pair(apply(pair_first(a)), apply(pair_second(a)), apply(pair_type(a))), sh); case expr_kind::Proj: return save_result(a, mk_proj(proj_first(a), apply(proj_arg(a))), sh); case expr_kind::Lambda: return save_result(a, mk_lambda(abst_name(a), apply(abst_domain(a)), apply(abst_body(a))), sh); case expr_kind::Pi: return save_result(a, mk_pi(abst_name(a), apply(abst_domain(a)), apply(abst_body(a))), sh); case expr_kind::Sigma: return save_result(a, mk_sigma(abst_name(a), apply(abst_domain(a)), apply(abst_body(a))), sh); case expr_kind::Let: return save_result(a, mk_let(let_name(a), apply(let_type(a)), apply(let_value(a)), apply(let_body(a))), sh); case expr_kind::MetaVar: return save_result(a, update_metavar(a, [&](local_entry const & e) -> local_entry { if (e.is_inst()) return mk_inst(e.s(), apply(e.v())); else return e; }), sh); } lean_unreachable(); // LCOV_EXCL_LINE }
pair_type SuccinctVector::Iterator::selectNextRun(usint max_length) { return pair_type(this->select(this->cur + 1), 0); }