void RStarTreeNode::reinsert_elements(RStarTreePtr tree, const BoundedObjectPtr element, BoundedObjectPtrVector &reinsert) { Uint32 i, reinsert_count; assert(get_count() == get_max_count()); reinsert_count = static_cast<Sint32>(get_max_count() * tree->get_reinsert_factor()); assert(reinsert_count < get_count()); reinsert.reserve(reinsert_count + 1); for (i = 0; i < reinsert_count; i++) { reinsert.push_back(get_element(i)); } for (i = 0; i < reinsert_count; i++) { assert(get_index(reinsert[i]) == i); remove_element(i); } reinsert.push_back(element); assert(get_count() > 0); }
void zdd_count(mpz_ptr z) { uint32_t r = zdd_root(), s = zdd_size(); mpz_ptr *count = malloc(sizeof(*count) * s); for(int i = 0; i < s; i++) count[i] = NULL; // Count elements in ZDD rooted at node n. mpz_ptr get_count(uint32_t n) { if (count[n]) return count[n]; count[n] = malloc(sizeof(mpz_t)); mpz_init(count[n]); if (n <= 1) { mpz_set_ui(count[n], n); return count[n]; } uint32_t x = pool[n]->lo; uint32_t y = pool[n]->hi; x = 1 >= x ? x : x - r + 2; y = 1 >= y ? y : y - r + 2; mpz_add(count[n], get_count(x), get_count(y)); return count[n]; } r = 1 >= r ? r : 2; mpz_set(z, get_count(r)); for(int i = 0; i < s; i++) { if (count[i]) { mpz_clear(count[i]); free(count[i]); } } }
void delay(u32 ms) { int overflow_times; u32 aim_count; u32 old_count, new_count; old_count = get_count(); if(ms >= (60 * 60 * 1000)) { ms = 36000000; early_printf("to long time to delay (>1 hour), delay 1 hours\n"); } overflow_times = ms / ms_overflow; ms = ms % ms_overflow; aim_count = ms * cycle_per_ms + old_count; if(aim_count < old_count) overflow_times++; // here overflow refer to 0xffffffff -> 0 while(overflow_times > 0){ new_count = get_count(); if(new_count < old_count) overflow_times--; old_count = new_count; } do { new_count = get_count(); if(new_count < old_count) // this code is useful when aim_count is near 0xffffffff return ; old_count = new_count; } while(new_count < aim_count); }
RStarTreeNodePtr RStarTreeNode::find_small_leaf( const Uint32 minimum_load, RStarTreeNodePtrStack &path_buffer) { RStarTreeNodePtr found; Uint32 i; if (get_leaf()) { if (get_count() < minimum_load) { return this; } else { return 0; } } path_buffer.push(this); for (i = 0; i < get_count(); i++) { found = get_node(i)->find_small_leaf(minimum_load, path_buffer); if (found) { return found; } } path_buffer.pop(); return 0; }
void udelay(u32 us) { u32 aim_count; u32 old_count, new_count; old_count = get_count(); if(us > ms_overflow * 1000) delay(us / 1000 + 1); aim_count = us * cycle_per_us + old_count; // us * cycle_per_us is not bigger than 0xffffffff if(aim_count < old_count) { while(1){ new_count = get_count(); if(new_count < old_count) break; old_count = new_count; } } do { new_count = get_count(); if(new_count < old_count) // this code is useful when aim_count is near 0xffffffff return ; old_count = new_count; } while(new_count < aim_count); }
RStarTreeNodePtr RStarTreeNode::find_least_enlargement( const BoundingBox &bounding_box) const { float enlargement, min_enlargement, v; Uint32 i, index; assert(!get_leaf()); assert(get_count() > 0); min_enlargement = std::numeric_limits<float>::max(); index = std::numeric_limits<Uint32>::max(); for (i = 0; i < get_count(); i++) { v = get_element_bounding_box(i).get_volume(); enlargement = enclose(bounding_box, get_element_bounding_box(i)).get_volume() - v; if (enlargement < min_enlargement) { if (enlargement <= 0.0f) { return get_node(i); } min_enlargement = enlargement; index = i; } } return get_node(index); }
// Incoming output data for a block void flow_t::process_output(Array<Vector<super_t,2>>* buffer, MPI_Status* status) { { // How many elements did we receive? const int tag = status->MPI_TAG; const local_id_t local_block_id = request_block_id(tag); const uint8_t dimension = request_dimension(tag); const auto event = output_blocks.local_block_line_event(local_block_id,dimension); thread_time_t time(output_recv_kind,event); if (PENTAGO_MPI_COMPRESS_OUTPUTS) { const int count = get_count(status,MPI_BYTE); PENTAGO_MPI_TRACE("process output block: source %d, local block id %d, dimension %d, count %d, tag %d, event 0x%llx",status->MPI_SOURCE,local_block_id.id,dimension,count,tag,event); const auto compressed = char_view_own(*buffer).slice_own(0,count); // Schedule an accumulate as soon as possible to conserve memory threads_schedule(CPU,curry(absorb_compressed_output,&output_blocks,local_block_id,dimension,compressed,*buffer),true); } else { const int count = get_count(status,MPI_LONG_LONG_INT); PENTAGO_MPI_TRACE("process output block: source %d, local block id %d, dimension %d, count %g, tag %d, event 0x%llx",status->MPI_SOURCE,local_block_id.id,dimension,count/8.,tag,event); GEODE_ASSERT(!(count&7)); const auto block_data = buffer->slice_own(0,count/8); // Schedule an accumulate as soon as possible to conserve memory threads_schedule(CPU,curry(&accumulating_block_store_t::accumulate,&output_blocks,local_block_id,dimension,block_data),true); } buffer->clean_memory(); } // One step closer... progress.progress(); countdown.decrement(); post_output_recv(buffer); }
/*RETURN TRUE/FALSE MESSAGE ON SCREEN IF STRING MATCHES OR NOT RESPECTIVELY*/ void cmp_str(char a[],char b[]) { int i,j; int cnt; cnt = Lexicon.count; i = get_count(a); j = get_count(b); if(i > cnt || j > cnt) { printf("\nERROR :- ONE OF THE VAR NOT DECLARED\n"); } else if(Lexicon.Entry[i].str == NULL || Lexicon.Entry[j].str ==NULL) { puts("\nERROR:- VAR NOT DECLARED\n"); } else { if(strcmp(Lexicon.Entry[i].str,Lexicon.Entry[j].str)==0) { printf("\nMATCHING\n"); } else { printf("\nNOT MATCHING\n"); } } }
// Remove a value from list void ValueList::remove(ReferenceImpl* value) { STD_ASSERT(("Value is not in this list.", value->owner == this)); #if USE_LIST_IN_VALUE_LIST m_container.remove_node(value); #elif USE_VECTOR_IN_VALUE_LIST STD_ASSERT(("Value offset is invalid.", value->offset < get_count())); STD_ASSERT(("Value is not in the specified offset.", m_container[value->offset] == value)); // Replace with tail element & shrink auto value_offset = value->offset; auto tail_offset = get_count() - 1; m_container[value_offset] = m_container[tail_offset]; m_container[value_offset]->offset = value_offset; m_container[tail_offset] = 0; m_container.shrink(tail_offset); #else // Replace with tail element & shrink m_container.erase(value); #endif // Remove owner value->owner = 0; }
OutputIterator transform(ExecutionPolicy &sep, Iterator b, Iterator e, OutputIterator out, UnaryOperation op) { { cl::sycl::queue q(sep.get_queue()); auto device = q.get_device(); size_t local = device.get_info<cl::sycl::info::device::max_work_group_size>(); auto bufI = sycl::helpers::make_const_buffer(b, e); auto bufO = sycl::helpers::make_buffer(out, out + bufI.get_count()); auto vectorSize = bufI.get_count(); size_t global = sep.calculateGlobalSize(vectorSize, local); auto f = [vectorSize, local, global, &bufI, &bufO, op]( cl::sycl::handler &h) mutable { cl::sycl::nd_range<3> r{cl::sycl::range<3>{std::max(global, local), 1, 1}, cl::sycl::range<3>{local, 1, 1}}; auto aI = bufI.template get_access<cl::sycl::access::mode::read>(h); auto aO = bufO.template get_access<cl::sycl::access::mode::write>(h); h.parallel_for<typename ExecutionPolicy::kernelName>( r, [aI, aO, op, vectorSize](cl::sycl::nd_item<3> id) { if ((id.get_global(0) < vectorSize)) { aO[id.get_global(0)] = op(aI[id.get_global(0)]); } }); }; q.submit(f); } return out; }
static void static_test () { static_assert(get_count(_state(0, 1234)) == 1234, "fail"); static_assert(get_count(_state(1, 1234)) == 1234, "fail"); static_assert(get_count(_state(2, 1234)) == 1234, "fail"); static_assert(get_count(_state(3, 1234)) == 1234, "fail"); static_assert(get_count(_state(4, 1234)) == 1234, "fail"); static_assert(get_stage(_state(0, 1234)) == get_stage(_state(0, 5679)), "fail"); static_assert(get_stage(_state(1, 1234)) == get_stage(_state(1, 5679)), "fail"); static_assert(get_stage(_state(2, 1234)) == get_stage(_state(2, 5679)), "fail"); static_assert(get_stage(_state(3, 1234)) == get_stage(_state(3, 5679)), "fail"); static_assert(_state(0, 1234) != _state(1, 1234), "fail"); static_assert(_state(0, 1234) != _state(2, 1234), "fail"); static_assert(_state(0, 1234) != _state(3, 1234), "fail"); static_assert(_state(0, 1234) != _state(4, 1234), "fail"); static_assert(_state(1, 1234) != _state(2, 1234), "fail"); static_assert(_state(1, 1234) != _state(3, 1234), "fail"); static_assert(_state(1, 1234) != _state(4, 1234), "fail"); static_assert(_state(2, 1234) != _state(3, 1234), "fail"); static_assert(_state(2, 1234) != _state(4, 1234), "fail"); static_assert(_state(3, 1234) != _state(4, 1234), "fail"); }
void metadb_handle_list::delete_all() { if (get_count()>0) { metadb::get()->handle_release_multi(get_ptr(),get_count()); remove_all(); } }
int read_test2(TEST_DATA *data, IO_BUFFER *iobuf) { IO_ITEM_HEADER item_header; int i; item_header.type = 99; /* test data */ if ( get_item_begin(iobuf,&item_header) < 0 ) { Warning("Missing or invalid test data block."); return -4; } get_vector_of_long(data->lvar,2,iobuf); data->ilvar[0] = get_long(iobuf); data->ilvar[1] = get_long(iobuf); get_vector_of_int(data->isvar,2,iobuf); get_vector_of_short(data->svar,3,iobuf); get_vector_of_real(data->fvar,2,iobuf); get_vector_of_double(data->dvar,2,iobuf); data->hvar[0] = get_sfloat(iobuf); data->hvar[1] = get_sfloat(iobuf); get_vector_of_byte((uint8_t *)data->i8var,2,iobuf); get_vector_of_byte(data->u8var,2,iobuf); get_vector_of_short(data->i16var,2,iobuf); get_vector_of_short((int16_t *)data->u16var,2,iobuf); get_vector_of_int32(data->i32var,2,iobuf); get_vector_of_uint32(data->u32var,2,iobuf); #ifdef HAVE_64BIT_INT get_vector_of_int64(data->i64var,2,iobuf); get_vector_of_uint64(data->u64var,2,iobuf); #endif data->nbvar = get_count(iobuf); get_vector_of_byte(data->bvar,2,iobuf); for (i=0; i<4; i++) data->cnt16var[i] = get_count(iobuf); for (i=0; i<6; i++) data->cnt32var[i] = get_count(iobuf); for (i=0; i<6; i++) data->cntzvar[i] = get_count(iobuf); for (i=0; i<8; i++) data->cntvar[i] = get_count(iobuf); for (i=0; i<10; i++) data->scnt16var[i] = get_scount16(iobuf); for (i=0; i<12; i++) data->scnt32var[i] = get_scount32(iobuf); for (i=0; i<12; i++) data->scntzvar[i] = get_scount(iobuf); for (i=0; i<14; i++) data->scntvar[i] = get_scount(iobuf); get_string(data->str16var,sizeof(data->str16var),iobuf); get_long_string(data->str32var,sizeof(data->str32var),iobuf); get_var_string(data->strvvar,sizeof(data->strvvar),iobuf); return(get_item_end(iobuf,&item_header)); }
void AnimatedSprite::set_index_value( int &value_loc, int value ) { if ( value < 0 || value >= get_count() ) { value_loc = get_count() - 1; } else { value_loc = value; } }
void __attribute__((interrupt, no_auto_psv)) _U2TXInterrupt(void) { static uint8_t i = 0; U2TX_Clear_Intr_Status_Bit; if (get_count(&tx_queue)) { while (U2STAbits.UTXBF == 0 && get_count(&tx_queue)) { dequeue(&tx_queue, &i); U2TXREG = i; } } }
/* * Write the table to a file. */ void CVmMetaTable::write_to_file(CVmFile *fp) { size_t i; /* write the number of entries */ fp->write_int2(get_count()); /* write each entry */ for (i = 0 ; i < get_count() ; ++i) { const char *nm; const vm_meta_entry_t *entry; ushort j; /* get the entry */ entry = get_entry(i); /* get this entry's name */ nm = entry->image_meta_name_; /* write the length of the name, followed by the name */ fp->write_int2(strlen(nm)); fp->write_bytes(nm, strlen(nm)); /* write our associated IntrinsicClass object's ID */ fp->write_int4(entry->class_obj_); /* * Write the property table information - write the number of * function entries, and the minimum and maximum property ID's. */ fp->write_int2(entry->func_xlat_cnt_); fp->write_int2(entry->min_prop_); fp->write_int2(entry->min_prop_ + entry->prop_xlat_cnt_); /* * Write out the property translation table. The function * translation table will always be smaller than (at worst, it * will be the same size as) the property translation table; * both tables contain the same information, so since we only * need to write out one or the other, write out the smaller of * the two. * * Note that xlat_func() requires a 1-based function index, so * run our counter from 1 to the function table count. */ for (j = 1 ; j <= entry->func_xlat_cnt_ ; ++j) fp->write_int2(entry->xlat_func(j)); } }
void RStarTreeNode::remove_element(const Uint32 index) { Uint32 end; assert(check_index(index)); end = get_count() - 1; if ((index != (get_count() - 1)) && (get_count() > 1)) { set_element(get_element(end), index); } m_count--; }
int is_badpass_ip(MYSQL *mysql,unsigned int ip) { int cnt; cnt=get_count(mysql,ip,60); if (cnt>3) return 1; cnt=get_count(mysql,ip,60*60); if (cnt>8) return 1; cnt=get_count(mysql,ip,60*60*24); if (cnt>25) return 1; return 0; }
void enqueue(queue_t *q, unsigned int val) { std::string str1("enqueue"); //ANNOTATION function_call(str1, INVOCATION, val); //ANNOTATION int success = 0; unsigned int node; pointer tail; pointer next; pointer tmp; node = new_node(); store_32(&q->nodes[node].value, val); tmp = atomic_load_explicit(&q->nodes[node].next, memory_order_seq_cst); set_ptr(&tmp, 0); // NULL atomic_store_explicit(&q->nodes[node].next, tmp, memory_order_seq_cst); while (!success) { tail = atomic_load_explicit(&q->tail, memory_order_seq_cst); next = atomic_load_explicit(&q->nodes[get_ptr(tail)].next, memory_order_seq_cst); if (tail == atomic_load_explicit(&q->tail, memory_order_seq_cst)) { /* Check for uninitialized 'next' */ MODEL_ASSERT(get_ptr(next) != POISON_IDX); if (get_ptr(next) == 0) { // == NULL pointer value = MAKE_POINTER(node, get_count(next) + 1); success = atomic_compare_exchange_strong_explicit(&q->nodes[get_ptr(tail)].next, &next, value, memory_order_seq_cst, memory_order_seq_cst); } if (!success) { unsigned int ptr = get_ptr(atomic_load_explicit(&q->nodes[get_ptr(tail)].next, memory_order_seq_cst)); pointer value = MAKE_POINTER(ptr, get_count(tail) + 1); atomic_compare_exchange_strong_explicit(&q->tail, &tail, value, memory_order_seq_cst, memory_order_seq_cst); thrd_yield(); } } } atomic_compare_exchange_strong_explicit(&q->tail, &tail, MAKE_POINTER(node, get_count(tail) + 1), memory_order_seq_cst, memory_order_seq_cst); function_call(str1, RESPONSE); //ANNOTATION }
void RStarTreeNode::split(RStarTreePtr tree, const BoundedObjectPtr element, RStarTreeNodePtr new_node) { BoundedObjectPtrArray9 split_data; Sint32 i, node_spf, new_size, split_point; Uint32 j; assert(get_count() == get_max_count()); assert(new_node); assert(element); assert(tree); new_size = get_max_count() + 1; node_spf = boost::numeric_cast<Sint32>(new_size * tree->m_split_distribution_factor); for (j = 0; j < get_max_count(); j++) { split_data[j] = get_element(j); } split_data[get_max_count()] = element; split_point = split_array9(split_data, node_spf); assert(split_point > 0); assert(split_point < static_cast<Sint32>(get_max_count())); clear(); for (i = 0; i < split_point; i++) { new_node->add_element(split_data[i]); } for (i = split_point; i < new_size; i++) { add_element(split_data[i]); } update_enclosing_bounding_box(); new_node->update_enclosing_bounding_box(); assert(new_node->get_count() > 0); assert(get_count() > 0); }
double equi_width_histo::get_skew() const { double count = get_count(); if (count == 0) return 0; double skew_min = m_histo[0]; double skew_max = m_histo[0]; for (int i = 0; i < m_nmb_buckets; i++){ if (m_histo[i] < skew_min) skew_min = m_histo[i]; if (m_histo[i] > skew_max) skew_max = m_histo[i]; } for (unsigned int i = 0; i < m_histo_min.size(); i++){ if (m_histo_min[i] < skew_min) skew_min = m_histo_min[i]; if (m_histo_min[i] > skew_max) skew_max = m_histo_min[i]; } for (unsigned int i = 0; i < m_histo_max.size(); i++){ if (m_histo_max[i] < skew_min) skew_min = m_histo_max[i]; if (m_histo_max[i] > skew_max) skew_max = m_histo_max[i]; } return ((skew_max - skew_min) / count); }
lld get_count(lld n){ if(debug)printf("called on %lld\n",n); if(n/m==0){ return 0; } return n/m + get_count(n%m + n/m); }
/// Returns True if the compasses have been configured (i.e. offsets saved) /// /// @returns True if compass has been configured /// bool Compass::configured(uint8_t i) { // exit immediately if instance is beyond the number of compasses we have available if (i > get_count()) { return false; } // exit immediately if all offsets are zero if (get_offsets(i).length() == 0.0f) { return false; } #if COMPASS_MAX_INSTANCES > 1 // backup detected dev_id int32_t dev_id_orig = _dev_id[i]; // load dev_id from eeprom _dev_id[i].load(); // if different then the device has not been configured if (_dev_id[i] != dev_id_orig) { // restore device id _dev_id[i] = dev_id_orig; // return failure return false; } #endif // if we got here then it must be configured return true; }
Buffer Collection::encode() const { // Inner types are always encoded using the v3+ (int32_t) encoding Buffer buf(sizeof(int32_t) + get_items_size(sizeof(int32_t))); size_t pos = buf.encode_int32(0, get_count()); encode_items_int32(buf.data() + pos); return buf; }
bool Tab::add_profile(QString * profile_name, QString * image_path, QWidget * parent){ (void)parent; bool add_profile = false; if(get_count()<MAX_PROFILE){ //Create button & insert in the list QIcon *icon = new QIcon(*image_path); QPushButton *button = new QPushButton(*icon,*profile_name); button->setMinimumSize(130,50); button->setIconSize(QSize(45,45)); button->setCheckable(true); //Add button to the group of buttons Tab::group->addButton(button); v_layout->addWidget(button); list.insert(profile_name, image_path); //Increase the count count++; add_profile = true; } return add_profile; }
OutputIterator transform(ExecutionPolicy &sep, InputIterator first1, InputIterator last1, InputIterator first2, OutputIterator result, BinaryOperation op) { cl::sycl::queue q(sep.get_queue()); auto device = q.get_device(); size_t local = device.get_info<cl::sycl::info::device::max_work_group_size>(); auto buf1 = sycl::helpers::make_const_buffer(first1, last1); auto n = buf1.get_count(); auto buf2 = sycl::helpers::make_const_buffer(first2, first2 + n); auto res = sycl::helpers::make_buffer(result, result + n); size_t global = sep.calculateGlobalSize(n, local); auto f = [n, local, global, &buf1, &buf2, &res, op](cl::sycl::handler &h) mutable { cl::sycl::nd_range<3> r{cl::sycl::range<3>{std::max(global, local), 1, 1}, cl::sycl::range<3>{local, 1, 1}}; auto a1 = buf1.template get_access<cl::sycl::access::mode::read>(h); auto a2 = buf2.template get_access<cl::sycl::access::mode::read>(h); auto aO = res.template get_access<cl::sycl::access::mode::write>(h); h.parallel_for<typename ExecutionPolicy::kernelName>( r, [a1, a2, aO, op, n](cl::sycl::nd_item<3> id) { if (id.get_global(0) < n) { aO[id.get_global(0)] = op(a1[id.get_global(0)], a2[id.get_global(0)]); } }); }; q.submit(f); return first2 + n; }
::flx::gc::generic::pointer_data_t flx_collector_t::get_pointer_data (void *p) { ::flx::gc::generic::pointer_data_t pdat; pdat.head = NULL; pdat.max_elements = 0ul; pdat.used_elements = 0ul; pdat.shape = NULL; pdat.pointer = p; Word_t cand = (Word_t)p; Word_t head = cand; Word_t *ppshape = (Word_t*)JudyLLast(j_shape,&head, &je); if(ppshape==(Word_t*)PPJERR)judyerror("get_pointer_data"); if(ppshape == NULL) return pdat; // no lower object gc_shape_t *pshape = (gc_shape_t*)(*ppshape & ~1UL); unsigned long max_slots = get_count((void*)head); unsigned long used_slots = get_used((void*)head); unsigned long n = max_slots * pshape->count * pshape->amt; if(cand >= (Word_t)(void*)((unsigned char*)(void*)head+n)) return pdat; // not interior pdat.head = (void*)head; pdat.max_elements = max_slots; pdat.used_elements = used_slots; pdat.shape = pshape; return pdat; }
void playlist_oper::remove_sel(bool crop) { bit_array_bittable mask(get_count()); get_sel_mask(mask); if (crop) remove_mask(bit_array_not(mask)); else remove_mask(mask); }
/// Returns True if the compasses have been configured (i.e. offsets saved) /// /// @returns True if compass has been configured /// bool Compass::configured(uint8_t i) { // exit immediately if instance is beyond the number of compasses we have available if (i > get_count()) { return false; } // exit immediately if all offsets are zero if (is_zero(get_offsets(i).length())) { return false; } // exit immediately if all offsets (mG) are zero if (is_zero(get_offsets(i).length())) { return false; } // backup detected dev_id int32_t dev_id_orig = _state[i].dev_id; // load dev_id from eeprom _state[i].dev_id.load(); // if different then the device has not been configured if (_state[i].dev_id != dev_id_orig) { // restore device id _state[i].dev_id = dev_id_orig; // return failure return false; } // if we got here then it must be configured return true; }
void equi_width_histo::print() const { // print min_histogram std::cout.precision(3); if (m_histo_min.size() > 0){ for (unsigned int i = m_histo_min.size(); i > 0; i--){ std::cout << "[" << m_min - i * m_bucket_size << "\t" << m_min - (i-1) * m_bucket_size << "] : " << m_histo_min[i-1] << "\n"; } } // print original histogram for (int i = 0; i < m_nmb_buckets; i++){ std::cout << "[" << m_min + i * m_bucket_size << "\t" << m_min + (i+1) * m_bucket_size << "] : " << m_histo[i] << "\n"; } // print min_histogram if (m_histo_max.size() > 0){ for (unsigned int i = 0; i < m_histo_max.size(); i++){ std::cout << "[" << m_max + i * m_bucket_size << "\t" << m_max + (i+1) * m_bucket_size << "] : " << m_histo[i] << "\n"; } } std::cout << std::endl; std::cout << "Count: " << " " << get_count() << std::endl; std::cout << "Median: " << " " << get_median() << std::endl; std::cout << "Skew: " << " " << get_skew() << std::endl; }