void priority_queue_assign( priority_queue_t* pt_pqueuedest, const priority_queue_t* cpt_pqueuesrc) { assert(pt_pqueuedest != NULL && cpt_pqueuesrc != NULL); vector_assign(&pt_pqueuedest->_t_vector, &cpt_pqueuesrc->_t_vector); pt_pqueuedest->_t_binary_op = cpt_pqueuesrc->_t_binary_op; }
template<class R> void reshape(const R& newSeqShap) { if (depth) { vector_assign(newSeqShap, this->shape); this->shape += depth; this->resize_data(); } }
//functions CoordIterator (const R& shap, const vector<int>& dirs = list_of<int>(), bool reverse = false): directions(dirs), pt(boost::size(shap)), end(false) { vector_assign(shap, shape); directions.resize(shape.size(), 1); if (reverse) { range_multiply_val(directions, -1); } begin(); }
/** * Assign stack element with an exist stack adaptor. */ void stack_assign(cstl_stack_t* psk_dest, const cstl_stack_t* cpsk_src) { assert(psk_dest != NULL); assert(cpsk_src != NULL); #if defined (CSTL_STACK_VECTOR_SEQUENCE) vector_assign(&psk_dest->_t_sequence, &cpsk_src->_t_sequence); #elif defined (CSTL_STACK_LIST_SEQUENCE) list_assign(&psk_dest->_t_sequence, &cpsk_src->_t_sequence); #else deque_assign(&psk_dest->_t_sequence, &cpsk_src->_t_sequence); #endif }
/* * Computes clusters' centroids. */ static void compute_centroids(void) { int i, j; /* Loop indexes. */ int population; /* Centroid population. */ start = timer_get(); memcpy(lcentroids, CENTROID(rank*(ncentroids/nprocs)), lncentroids[rank]*dimension*sizeof(float)); memset(&has_changed[rank*NUM_THREADS], 0, NUM_THREADS*sizeof(int)); memset(centroids, 0, (ncentroids + DELTA*nprocs)*dimension*sizeof(float)); memset(ppopulation, 0, (ncentroids + nprocs*DELTA)*sizeof(int)); /* Compute partial centroids. */ #pragma omp parallel for schedule(static) default(shared) private(i, j) for (i = 0; i < lnpoints; i++) { j = map[i]%NUM_THREADS; omp_set_lock(&lock[j]); vector_add(CENTROID(map[i]), POINT(i)); ppopulation[map[i]]++; omp_unset_lock(&lock[j]); } end = timer_get(); total += timer_diff(start, end); sync_pcentroids(); sync_ppopulation(); start = timer_get(); /* Compute centroids. */ #pragma omp parallel for schedule(static) default(shared) private(i, j, population) for (j = 0; j < lncentroids[rank]; j++) { population = 0; for (i = 0; i < nprocs; i++) { if (*POPULATION(i, j) == 0) continue; population += *POPULATION(i, j); if (i == rank) continue; vector_add(PCENTROID(rank, j), PCENTROID(i, j)); } if (population > 1) vector_mult(PCENTROID(rank, j), 1.0/population); /* Cluster mean has changed. */ if (!vector_equal(PCENTROID(rank, j), LCENTROID(j))) { has_changed[rank*NUM_THREADS + omp_get_thread_num()] = 1; vector_assign(LCENTROID(j), PCENTROID(rank, j)); } } end = timer_get(); total += timer_diff(start, end); sync_centroids(); sync_status(); }
void _type_copy_vector(const void* cpv_first, const void* cpv_second, void* pv_output) { assert(cpv_first != NULL && cpv_second != NULL && pv_output != NULL); vector_assign((vector_t*)cpv_first, (vector_t*)cpv_second); *(bool_t*)pv_output = true; }
int t_vector() { c_vector vt; __c_vector(&vt, int_comparer); printf("1.test create vector\n"); create_with_push_back(&vt); print_vector(&vt); reverse_print_vector(&vt); clear_vector(&vt); printf("\n\n2.test vector assign\n"); create_with_push_back(&vt); vector_assign(&vt); clear_vector(&vt); printf("\n\n3.test erase vector\n"); erase_vector(); printf("\n\n4.test reserve vector\n"); create_with_push_back(&vt); vector_reserve(&vt); clear_vector(&vt); printf("\n\n5.test front back\n"); create_with_push_back(&vt); vector_front_back(&vt); clear_vector(&vt); printf("\n\n6.test swap\n"); create_with_push_back(&vt); vector_swap(&vt); clear_vector(&vt); printf("\n\n7.test insert\n"); vector_insert(&vt); clear_vector(&vt); printf("\n\n8.test insert2\n"); create_with_push_back(&vt); vector_insert2(&vt); clear_vector(&vt); printf("\n\n9.test fill insert\n"); create_with_push_back(&vt); vector_fill_insert(&vt); clear_vector(&vt); printf("\n\n10.test resize\n"); create_with_push_back(&vt); vector_resize(&vt); clear_vector(&vt); printf("\n\n11.test equal\n"); create_with_push_back(&vt); vector_equal(&vt); clear_vector(&vt); printf("\n\n12.test less\n"); create_with_push_back(&vt); vector_less(&vt); clear_vector(&vt); __c_rotcev(&vt); printf("\n\nfinish testing vector!\n"); return 0; }