void ScreenLensDistortionOperation::executePixel(float output[4], int x, int y, void *data) { MemoryBuffer *buffer = (MemoryBuffer *)data; float xy[2] = { (float)x, (float)y }; float uv[2]; get_uv(xy, uv); float uv_dot = len_squared_v2(uv); int count[3] = { 0, 0, 0 }; float delta[3][2]; float sum[4] = { 0, 0, 0, 0 }; bool valid_r = get_delta(uv_dot, m_k4[0], uv, delta[0]); bool valid_g = get_delta(uv_dot, m_k4[1], uv, delta[1]); bool valid_b = get_delta(uv_dot, m_k4[2], uv, delta[2]); if (valid_r && valid_g && valid_b) { accumulate(buffer, 0, 1, uv_dot, uv, delta, sum, count); accumulate(buffer, 1, 2, uv_dot, uv, delta, sum, count); if (count[0]) output[0] = 2.0f * sum[0] / (float)count[0]; if (count[1]) output[1] = 2.0f * sum[1] / (float)count[1]; if (count[2]) output[2] = 2.0f * sum[2] / (float)count[2]; /* set alpha */ output[3] = 1.0f; } else { zero_v4(output); } }
void ScreenLensDistortionOperation::determineUV(float result[6], float x, float y) const { const float xy[2] = {x, y}; float uv[2]; get_uv(xy, uv); float uv_dot = len_squared_v2(uv); copy_v2_v2(result + 0, xy); copy_v2_v2(result + 2, xy); copy_v2_v2(result + 4, xy); get_delta(uv_dot, m_k4[0], uv, result + 0); get_delta(uv_dot, m_k4[1], uv, result + 2); get_delta(uv_dot, m_k4[2], uv, result + 4); }
/*-----------------------------------------------------------*/ bool NOMAD::SMesh::check_min_mesh_size_criterion ( ) const { if ( !_delta_min.is_defined() ) return false; NOMAD::Point delta; return get_delta ( delta ); }
bool Soldier::update_location() { Cart_Vector vect; vect = (get_destination() - location); if (fabs(vect.x) <= fabs((get_delta()).x) && fabs(vect.y) <= fabs((get_delta()).y)) { location = get_destination(); cout << display_code << get_id() << ": I'm there!" << endl; return true; } else location.x = location.x + ((get_delta()).x); location.y = location.y + ((get_delta()).y); cout << display_code << get_id() << ": step..." << endl; return false; }
/* * Synchronize ar.itc of the current (slave) CPU with the ar.itc of the MASTER CPU * (normally the time-keeper CPU). We use a closed loop to eliminate the possibility of * unaccounted-for errors (such as getting a machine check in the middle of a calibration * step). The basic idea is for the slave to ask the master what itc value it has and to * read its own itc before and after the master responds. Each iteration gives us three * timestamps: * * slave master * * t0 ---\ * ---\ * ---> * tm * /--- * /--- * t1 <--- * * * The goal is to adjust the slave's ar.itc such that tm falls exactly half-way between t0 * and t1. If we achieve this, the clocks are synchronized provided the interconnect * between the slave and the master is symmetric. Even if the interconnect were * asymmetric, we would still know that the synchronization error is smaller than the * roundtrip latency (t0 - t1). * * When the interconnect is quiet and symmetric, this lets us synchronize the itc to * within one or two cycles. However, we can only *guarantee* that the synchronization is * accurate to within a round-trip time, which is typically in the range of several * hundred cycles (e.g., ~500 cycles). In practice, this means that the itc's are usually * almost perfectly synchronized, but we shouldn't assume that the accuracy is much better * than half a micro second or so. */ void ia64_sync_itc (unsigned int master) { long i, delta, adj, adjust_latency = 0, done = 0; unsigned long flags, rt, master_time_stamp, bound; #if DEBUG_ITC_SYNC struct { long rt; /* roundtrip time */ long master; /* master's timestamp */ long diff; /* difference between midpoint and master's timestamp */ long lat; /* estimate of itc adjustment latency */ } t[NUM_ROUNDS]; #endif go[MASTER] = 1; if (smp_call_function_single(master, sync_master, NULL, 1, 0) < 0) { printk("sync_itc: failed to get attention of CPU %u!\n", master); return; } while (go[MASTER]); /* wait for master to be ready */ spin_lock_irqsave(&itc_sync_lock, flags); { for (i = 0; i < NUM_ROUNDS; ++i) { delta = get_delta(&rt, &master_time_stamp); if (delta == 0) { done = 1; /* let's lock on to this... */ bound = rt; } if (!done) { if (i > 0) { adjust_latency += -delta; adj = -delta + adjust_latency/4; } else adj = -delta; ia64_set_itc(ia64_get_itc() + adj); } #if DEBUG_ITC_SYNC t[i].rt = rt; t[i].master = master_time_stamp; t[i].diff = delta; t[i].lat = adjust_latency/4; #endif } } spin_unlock_irqrestore(&itc_sync_lock, flags); #if DEBUG_ITC_SYNC for (i = 0; i < NUM_ROUNDS; ++i) printk("rt=%5ld master=%5ld diff=%5ld adjlat=%5ld\n", t[i].rt, t[i].master, t[i].diff, t[i].lat); #endif printk("CPU %d: synchronized ITC with CPU %u (last diff %ld cycles, maxerr %lu cycles)\n", smp_processor_id(), master, delta, rt); }
tree composite_box_rep::action (tree t, SI x, SI y, SI delta) { int m= find_child (x, y, delta, true); if (m == -1) return ""; else return bs[m]->action (t, x- sx(m), y- sy(m), delta + get_delta (x, x1, x2)); }
path composite_box_rep::find_box_path (SI x, SI y, SI delta, bool force) { int m= find_child (x, y, delta, force); if (m==-1) return box_rep::find_box_path (x, y, delta, force); else { SI xx= x- sx(m), yy= y- sy(m); SI dd= delta + get_delta (xx, bs[m]->x1, bs[m]->x2); return path (m, bs[m]->find_box_path (xx, yy, dd, force)); } }
path find_scrolled_box_path (box b, path sp, SI x, SI y, SI delta) { if (is_nil (sp)) return b->find_box_path (x, y, delta, false); else { int m= sp->item; SI xx= x - b->sx (m), yy= y - b->sy (m); SI dd= delta + get_delta (xx, b[m]->x1, b[m]->x2); return path (m, find_scrolled_box_path (b[m], sp->next, xx, yy, dd)); } }
void composite_box_rep::loci (SI x, SI y, SI delta, list<string>& ids, rectangles& rs) { int m= find_child (x, y, delta, true); if (m == -1) box_rep::loci (x, y, delta, ids, rs); else { bs[m]->loci (x- sx(m), y- sy(m), delta + get_delta (x, x1, x2), ids, rs); rs= translate (rs, sx(m), sy(m)); } }
cursor composite_box_rep::find_cursor (path bp) { if (is_atom (bp)) return box_rep::find_cursor (bp); else { int i= bp->item; cursor cu= bs[i]->find_cursor (bp->next); cu->delta -= get_delta (cu->ox, bs[i]->x1, bs[i]->x2); cu->ox += sx(i); cu->oy += sy(i); return cu; } }
Ref<InputEvent> InputEventPanGesture::xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs) const { Ref<InputEventPanGesture> ev; ev.instance(); ev->set_device(get_device()); ev->set_modifiers_from_event(this); ev->set_position(p_xform.xform(get_position() + p_local_ofs)); ev->set_delta(get_delta()); return ev; }
path composite_box_rep::find_box_path (SI x, SI y, SI delta, bool force, bool& found) { int i, n= subnr(), m= find_child (x, y, delta, force); if (m != -1) for (i=0; i<=n; i++) { int c= (m+i) % n; SI xx= x- sx(c), yy= y- sy(c); SI dd= delta + get_delta (xx, bs[c]->x1, bs[c]->x2); path r= path (c, bs[c]->find_box_path (xx, yy, dd, force, found)); if (found || i == n) return r; } return box_rep::find_box_path (x, y, delta, force, found); }
static void update_info(int zone) { ENTER("update_info(int zone)"); int s, h, m; get_delta(zone, &s, &h, &m); delta = h*60*60 + m*60; if(s==-1) delta = -delta; sprintf(zone_info, delta==0 ? "[GMT]" : m ? "[GMT%c%d:%02d]" : "[GMT%c%d]", s==-1 ? '-' : s==1 ? '+' : '?', h, m); LEAVE; }
NOMAD::Double NOMAD::SMesh::scale_and_project(int i, NOMAD::Double l) const { NOMAD::Point delta; NOMAD::Point Delta; get_delta ( delta ); get_Delta ( Delta ); if ( delta.is_defined() && Delta.is_defined() && i <= _n) { NOMAD::Double d= Delta[i] / delta[i] * l; return d.NOMAD::Double::round()*delta[i]; } else throw NOMAD::Exception ( "SMesh.cpp" , __LINE__ , "Mesh scaling and projection cannot be performed!" ); }
static int schedule_renewal(glite_renewal_core_context ctx, time_t end_time_x509, time_t end_time_voms, proxy_record *record) { time_t end_time, delta, now; char *s, *c; s = ctime(&end_time_x509); if ((c = strchr(s, '\n'))) *c = '\0'; edg_wlpr_Log(ctx, LOG_DEBUG, "X.509 proxy credential expires on %s", s); if (end_time_voms > 0) { s = ctime(&end_time_voms); if ((c = strchr(s, '\n'))) *c = '\0'; edg_wlpr_Log(ctx, LOG_DEBUG, "The shortest VOMS cert expires on %s", s); } end_time = (end_time_x509 < end_time_voms || end_time_voms == 0) ? end_time_x509 : end_time_voms; now = time(NULL); if (now + condor_limit > end_time_x509) { edg_wlpr_Log(ctx, LOG_WARNING, "Remaining proxy lifetime fell below the value of the Condor limit!"); delta = 0; } else delta = get_delta(ctx, now, end_time); record->next_renewal = now + delta; record->end_time = end_time_x509; s = ctime(&record->next_renewal); if ((c = strchr(s, '\n'))) *c = '\0'; edg_wlpr_Log(ctx, LOG_DEBUG, "Next renewal will be attempted on %s", s); return 0; }
void test_aritificial_neural_network(void){ u32 i; double fan_in; boolean successed = FALSE; initiate_neural_network(); for (i = 0; i < MAX_LOOP_TIMES; i++){ train_neural_network(); if (sum_of_error_per_round < TARGET_ERROR_VALUE){ successed = TRUE; break; } if ((i & 2047) == 0) printf("Variance of diff between real and desired : %f\n", sum_of_error_per_round); get_delta(); modify_network_weight(); } if (successed){ while (TRUE){ printf("Input the number to be calculated. "); printf("0 for terminated, number should between 0 and 1.\n"); scanf("%lf", &fan_in); if (fan_in){ if ((fan_in > 0) && (fan_in < 1)) printf("Input: %f, desired: %f, real: %f\n", fan_in, proceed(fan_in), cos(fan_in)); else printf("Invalid input, should between 0 and 1.\n"); } else break; } } else { printf("Error! Difference between real output and desired: %f\n", sum_of_error_per_round); } }
/* * Synchronize ar.itc of the current (slave) CPU with the ar.itc of the MASTER CPU * (normally the time-keeper CPU). We use a closed loop to eliminate the possibility of * unaccounted-for errors (such as getting a machine check in the middle of a calibration * step). The basic idea is for the slave to ask the master what itc value it has and to * read its own itc before and after the master responds. Each iteration gives us three * timestamps: * * slave master * * t0 ---\ * ---\ * ---> * tm * /--- * /--- * t1 <--- * * * The goal is to adjust the slave's ar.itc such that tm falls exactly half-way between t0 * and t1. If we achieve this, the clocks are synchronized provided the interconnect * between the slave and the master is symmetric. Even if the interconnect were * asymmetric, we would still know that the synchronization error is smaller than the * roundtrip latency (t0 - t1). * * When the interconnect is quiet and symmetric, this lets us synchronize the itc to * within one or two cycles. However, we can only *guarantee* that the synchronization is * accurate to within a round-trip time, which is typically in the range of several * hundred cycles (e.g., ~500 cycles). In practice, this means that the itc's are usually * almost perfectly synchronized, but we shouldn't assume that the accuracy is much better * than half a micro second or so. */ void ia64_sync_itc (unsigned int master) { long i, delta, adj, adjust_latency = 0, done = 0; unsigned long flags, rt, master_time_stamp, bound; #if DEBUG_ITC_SYNC struct { long rt; /* roundtrip time */ long master; /* master's timestamp */ long diff; /* difference between midpoint and master's timestamp */ long lat; /* estimate of itc adjustment latency */ } t[NUM_ROUNDS]; #endif /* * Make sure local timer ticks are disabled while we sync. If * they were enabled, we'd have to worry about nasty issues * like setting the ITC ahead of (or a long time before) the * next scheduled tick. */ BUG_ON((ia64_get_itv() & (1 << 16)) == 0); go[MASTER] = 1; if (smp_call_function_single(master, sync_master, NULL, 1, 0) < 0) { printk(KERN_ERR "sync_itc: failed to get attention of CPU %u!\n", master); return; } while (go[MASTER]) cpu_relax(); /* wait for master to be ready */ spin_lock_irqsave(&itc_sync_lock, flags); { for (i = 0; i < NUM_ROUNDS; ++i) { delta = get_delta(&rt, &master_time_stamp); if (delta == 0) { done = 1; /* let's lock on to this... */ bound = rt; } if (!done) { if (i > 0) { adjust_latency += -delta; adj = -delta + adjust_latency/4; } else adj = -delta; ia64_set_itc(ia64_get_itc() + adj); } #if DEBUG_ITC_SYNC t[i].rt = rt; t[i].master = master_time_stamp; t[i].diff = delta; t[i].lat = adjust_latency/4; #endif } } spin_unlock_irqrestore(&itc_sync_lock, flags); #if DEBUG_ITC_SYNC for (i = 0; i < NUM_ROUNDS; ++i) printk("rt=%5ld master=%5ld diff=%5ld adjlat=%5ld\n", t[i].rt, t[i].master, t[i].diff, t[i].lat); #endif printk(KERN_INFO "CPU %d: synchronized ITC with CPU %u (last diff %ld cycles, " "maxerr %lu cycles)\n", smp_processor_id(), master, delta, rt); }
void Best::localSearch( const std::vector<Graph> &graphs, Solution &solution ) { size_t m = solution.alignment.size1(); size_t n = solution.alignment.size2(); // Create reverse alignment mapping std::vector<std::vector<size_t>> map; create_map(graphs, solution, map); // Count number of graphs each edge is covered in edge_count_matrix edges; count_edges(graphs, map, solution, edges); // Build neighbor lists std::vector<neighbor_list> neighbors; create_neighbor_lists(graphs, map, solution, neighbors); // Active index map std::vector<int> active(m, 0); std::random_device rd; std::minstd_rand rand_gen(rd()); int iteration = 0; bool repeat; do { repeat = false; for(size_t g = 0; g < n-1; ++g) { int best_delta = 0; size_t best_i = 0; size_t best_j = 0; #pragma omp parallel { int prv_best_delta = 0; size_t prv_best_i = 0; size_t prv_best_j = 0; #pragma omp for schedule(static, 1) for(size_t i = 0; i < m; ++i) { for(size_t j = i+1; j < m; ++j) { if(active[i] < iteration && active[j] < iteration) continue; int delta = get_delta(i, j, g, neighbors, edges); if(delta > 0) { active[i] = iteration+1; active[j] = iteration+1; } if(delta > prv_best_delta) { prv_best_delta = delta; prv_best_i = i; prv_best_j = j; } } } #pragma omp critical { if(prv_best_delta > best_delta) { best_delta = prv_best_delta; best_i = prv_best_i; best_j = prv_best_j; } } } if(best_delta > 0) { repeat = true; swap(best_i, best_j, g, iteration, neighbors, edges, solution, active); } } iteration++; } while(repeat); // Extract LCS and solution quality finalize(edges, solution); }
/** * @brief Reads monitoring event data from given core * * @param p pointer to monitoring structure * * @return Operation status * @retval PQOS_RETVAL_OK on success */ static int pqos_core_poll(struct pqos_mon_data *p) { struct pqos_event_values *pv = &p->values; int retval = PQOS_RETVAL_OK; unsigned i; if (p->event & PQOS_MON_EVENT_L3_OCCUP) { uint64_t total = 0; for (i = 0; i < p->num_poll_ctx; i++) { uint64_t tmp = 0; int ret; ret = mon_read(p->poll_ctx[i].lcore, p->poll_ctx[i].rmid, get_event_id(PQOS_MON_EVENT_L3_OCCUP), &tmp); if (ret != PQOS_RETVAL_OK) { retval = PQOS_RETVAL_ERROR; goto pqos_core_poll__exit; } total += tmp; } pv->llc = total; } if (p->event & (PQOS_MON_EVENT_LMEM_BW | PQOS_MON_EVENT_RMEM_BW)) { uint64_t total = 0, old_value = pv->mbm_local; for (i = 0; i < p->num_poll_ctx; i++) { uint64_t tmp = 0; int ret; ret = mon_read(p->poll_ctx[i].lcore, p->poll_ctx[i].rmid, get_event_id(PQOS_MON_EVENT_LMEM_BW), &tmp); if (ret != PQOS_RETVAL_OK) { retval = PQOS_RETVAL_ERROR; goto pqos_core_poll__exit; } total += tmp; } pv->mbm_local = total; pv->mbm_local_delta = get_delta(old_value, pv->mbm_local); } if (p->event & (PQOS_MON_EVENT_TMEM_BW | PQOS_MON_EVENT_RMEM_BW)) { uint64_t total = 0, old_value = pv->mbm_total; for (i = 0; i < p->num_poll_ctx; i++) { uint64_t tmp = 0; int ret; ret = mon_read(p->poll_ctx[i].lcore, p->poll_ctx[i].rmid, get_event_id(PQOS_MON_EVENT_TMEM_BW), &tmp); if (ret != PQOS_RETVAL_OK) { retval = PQOS_RETVAL_ERROR; goto pqos_core_poll__exit; } total += tmp; } pv->mbm_total = total; pv->mbm_total_delta = get_delta(old_value, pv->mbm_total); } if (p->event & PQOS_MON_EVENT_RMEM_BW) { pv->mbm_remote = 0; if (pv->mbm_total > pv->mbm_local) pv->mbm_remote = pv->mbm_total - pv->mbm_local; pv->mbm_remote_delta = 0; if (pv->mbm_total_delta > pv->mbm_local_delta) pv->mbm_remote_delta = pv->mbm_total_delta - pv->mbm_local_delta; } if (p->event & PQOS_PERF_EVENT_IPC) { /** * If multiple cores monitored in one group * then we have to accumulate the values in the group. */ uint64_t unhalted = 0, retired = 0; unsigned n; for (n = 0; n < p->num_cores; n++) { uint64_t tmp = 0; int ret = msr_read(p->cores[n], IA32_MSR_INST_RETIRED_ANY, &tmp); if (ret != MACHINE_RETVAL_OK) { retval = PQOS_RETVAL_ERROR; goto pqos_core_poll__exit; } retired += tmp; ret = msr_read(p->cores[n], IA32_MSR_CPU_UNHALTED_THREAD, &tmp); if (ret != MACHINE_RETVAL_OK) { retval = PQOS_RETVAL_ERROR; goto pqos_core_poll__exit; } unhalted += tmp; } pv->ipc_unhalted_delta = unhalted - pv->ipc_unhalted; pv->ipc_retired_delta = retired - pv->ipc_retired; pv->ipc_unhalted = unhalted; pv->ipc_retired = retired; if (pv->ipc_unhalted_delta == 0) pv->ipc = 0.0; else pv->ipc = (double) pv->ipc_retired_delta / (double) pv->ipc_unhalted_delta; } if (p->event & PQOS_PERF_EVENT_LLC_MISS) { /** * If multiple cores monitored in one group * then we have to accumulate the values in the group. */ uint64_t missed = 0; unsigned n; for (n = 0; n < p->num_cores; n++) { uint64_t tmp = 0; int ret = msr_read(p->cores[n], IA32_MSR_PMC0, &tmp); if (ret != MACHINE_RETVAL_OK) { retval = PQOS_RETVAL_ERROR; goto pqos_core_poll__exit; } missed += tmp; } pv->llc_misses_delta = missed - pv->llc_misses; pv->llc_misses = missed; } pqos_core_poll__exit: return retval; }
double viewing_step::get_interpolated_total_time_passed_in_seconds() const { return cosm.get_total_time_passed_in_seconds() + get_delta().view_interpolation_ratio() * get_delta().in_seconds(); }
String InputEventPanGesture::as_text() const { return "InputEventPanGesture : delta=(" + String(get_delta()) + "), position=(" + String(get_position()) + ")"; }
int main(int argc,char **argv) { int curr_arg; bool bVerbose; FILE *fptr; int line_len; int line_no; struct tournament_info tournament; int place; int delta; if ((argc < 3) || (argc > 4)) { printf(usage); return 1; } bVerbose = false; for (curr_arg = 1; curr_arg < argc; curr_arg++) { if (!strcmp(argv[curr_arg],"-verbose")) bVerbose = true; else break; } if (argc - curr_arg != 2) { printf(usage); return 2; } if ((fptr = fopen(argv[curr_arg],"r")) == NULL) { printf(couldnt_open,argv[curr_arg]); return 3; } fscanf(fptr,"%d",&tournament.buy_in); fscanf(fptr,"%d",&tournament.entry_fee); fscanf(fptr,"%d",&tournament.first_place_prize); fscanf(fptr,"%d",&tournament.second_place_prize); fclose(fptr); if ((fptr = fopen(argv[curr_arg+1],"r")) == NULL) { printf(couldnt_open,argv[curr_arg+1]); return 4; } line_no = 0; for ( ; ; ) { GetLine(fptr,line,&line_len,MAX_LINE_LEN); if (feof(fptr)) break; line_no++; sscanf(line,"%d",&place); delta = get_delta(&tournament,place); if (!bVerbose) printf("%d %d\n",delta,place); else printf("%d %s\n",delta,line); } fclose(fptr); return 0; }
int cmd_main(int argc, const char **argv) { struct transfer_request *request; struct transfer_request *next_request; int nr_refspec = 0; const char **refspec = NULL; struct remote_lock *ref_lock = NULL; struct remote_lock *info_ref_lock = NULL; struct rev_info revs; int delete_branch = 0; int force_delete = 0; int objects_to_send; int rc = 0; int i; int new_refs; struct ref *ref, *local_refs; repo = xcalloc(1, sizeof(*repo)); argv++; for (i = 1; i < argc; i++, argv++) { const char *arg = *argv; if (*arg == '-') { if (!strcmp(arg, "--all")) { push_all = MATCH_REFS_ALL; continue; } if (!strcmp(arg, "--force")) { force_all = 1; continue; } if (!strcmp(arg, "--dry-run")) { dry_run = 1; continue; } if (!strcmp(arg, "--helper-status")) { helper_status = 1; continue; } if (!strcmp(arg, "--verbose")) { push_verbosely = 1; http_is_verbose = 1; continue; } if (!strcmp(arg, "-d")) { delete_branch = 1; continue; } if (!strcmp(arg, "-D")) { delete_branch = 1; force_delete = 1; continue; } if (!strcmp(arg, "-h")) usage(http_push_usage); } if (!repo->url) { char *path = strstr(arg, "//"); str_end_url_with_slash(arg, &repo->url); repo->path_len = strlen(repo->url); if (path) { repo->path = strchr(path+2, '/'); if (repo->path) repo->path_len = strlen(repo->path); } continue; } refspec = argv; nr_refspec = argc - i; break; } #ifndef USE_CURL_MULTI die("git-push is not available for http/https repository when not compiled with USE_CURL_MULTI"); #endif if (!repo->url) usage(http_push_usage); if (delete_branch && nr_refspec != 1) die("You must specify only one branch name when deleting a remote branch"); setup_git_directory(); memset(remote_dir_exists, -1, 256); http_init(NULL, repo->url, 1); #ifdef USE_CURL_MULTI is_running_queue = 0; #endif /* Verify DAV compliance/lock support */ if (!locking_available()) { rc = 1; goto cleanup; } sigchain_push_common(remove_locks_on_signal); /* Check whether the remote has server info files */ repo->can_update_info_refs = 0; repo->has_info_refs = remote_exists("info/refs"); repo->has_info_packs = remote_exists("objects/info/packs"); if (repo->has_info_refs) { info_ref_lock = lock_remote("info/refs", LOCK_TIME); if (info_ref_lock) repo->can_update_info_refs = 1; else { error("cannot lock existing info/refs"); rc = 1; goto cleanup; } } if (repo->has_info_packs) fetch_indices(); /* Get a list of all local and remote heads to validate refspecs */ local_refs = get_local_heads(); fprintf(stderr, "Fetching remote heads...\n"); get_dav_remote_heads(); run_request_queue(); /* Remove a remote branch if -d or -D was specified */ if (delete_branch) { if (delete_remote_branch(refspec[0], force_delete) == -1) { fprintf(stderr, "Unable to delete remote branch %s\n", refspec[0]); if (helper_status) printf("error %s cannot remove\n", refspec[0]); } goto cleanup; } /* match them up */ if (match_push_refs(local_refs, &remote_refs, nr_refspec, (const char **) refspec, push_all)) { rc = -1; goto cleanup; } if (!remote_refs) { fprintf(stderr, "No refs in common and none specified; doing nothing.\n"); if (helper_status) printf("error null no match\n"); rc = 0; goto cleanup; } new_refs = 0; for (ref = remote_refs; ref; ref = ref->next) { struct argv_array commit_argv = ARGV_ARRAY_INIT; if (!ref->peer_ref) continue; if (is_null_oid(&ref->peer_ref->new_oid)) { if (delete_remote_branch(ref->name, 1) == -1) { error("Could not remove %s", ref->name); if (helper_status) printf("error %s cannot remove\n", ref->name); rc = -4; } else if (helper_status) printf("ok %s\n", ref->name); new_refs++; continue; } if (!oidcmp(&ref->old_oid, &ref->peer_ref->new_oid)) { if (push_verbosely) fprintf(stderr, "'%s': up-to-date\n", ref->name); if (helper_status) printf("ok %s up to date\n", ref->name); continue; } if (!force_all && !is_null_oid(&ref->old_oid) && !ref->force) { if (!has_object_file(&ref->old_oid) || !ref_newer(&ref->peer_ref->new_oid, &ref->old_oid)) { /* * We do not have the remote ref, or * we know that the remote ref is not * an ancestor of what we are trying to * push. Either way this can be losing * commits at the remote end and likely * we were not up to date to begin with. */ error("remote '%s' is not an ancestor of\n" "local '%s'.\n" "Maybe you are not up-to-date and " "need to pull first?", ref->name, ref->peer_ref->name); if (helper_status) printf("error %s non-fast forward\n", ref->name); rc = -2; continue; } } oidcpy(&ref->new_oid, &ref->peer_ref->new_oid); new_refs++; fprintf(stderr, "updating '%s'", ref->name); if (strcmp(ref->name, ref->peer_ref->name)) fprintf(stderr, " using '%s'", ref->peer_ref->name); fprintf(stderr, "\n from %s\n to %s\n", oid_to_hex(&ref->old_oid), oid_to_hex(&ref->new_oid)); if (dry_run) { if (helper_status) printf("ok %s\n", ref->name); continue; } /* Lock remote branch ref */ ref_lock = lock_remote(ref->name, LOCK_TIME); if (ref_lock == NULL) { fprintf(stderr, "Unable to lock remote branch %s\n", ref->name); if (helper_status) printf("error %s lock error\n", ref->name); rc = 1; continue; } /* Set up revision info for this refspec */ argv_array_push(&commit_argv, ""); /* ignored */ argv_array_push(&commit_argv, "--objects"); argv_array_push(&commit_argv, oid_to_hex(&ref->new_oid)); if (!push_all && !is_null_oid(&ref->old_oid)) argv_array_pushf(&commit_argv, "^%s", oid_to_hex(&ref->old_oid)); init_revisions(&revs, setup_git_directory()); setup_revisions(commit_argv.argc, commit_argv.argv, &revs, NULL); revs.edge_hint = 0; /* just in case */ /* Generate a list of objects that need to be pushed */ pushing = 0; if (prepare_revision_walk(&revs)) die("revision walk setup failed"); mark_edges_uninteresting(&revs, NULL); objects_to_send = get_delta(&revs, ref_lock); finish_all_active_slots(); /* Push missing objects to remote, this would be a convenient time to pack them first if appropriate. */ pushing = 1; if (objects_to_send) fprintf(stderr, " sending %d objects\n", objects_to_send); run_request_queue(); /* Update the remote branch if all went well */ if (aborted || !update_remote(ref->new_oid.hash, ref_lock)) rc = 1; if (!rc) fprintf(stderr, " done\n"); if (helper_status) printf("%s %s\n", !rc ? "ok" : "error", ref->name); unlock_remote(ref_lock); check_locks(); argv_array_clear(&commit_argv); } /* Update remote server info if appropriate */ if (repo->has_info_refs && new_refs) { if (info_ref_lock && repo->can_update_info_refs) { fprintf(stderr, "Updating remote server info\n"); if (!dry_run) update_remote_info_refs(info_ref_lock); } else { fprintf(stderr, "Unable to update server info\n"); } } cleanup: if (info_ref_lock) unlock_remote(info_ref_lock); free(repo); http_cleanup(); request = request_queue_head; while (request != NULL) { next_request = request->next; release_request(request); request = next_request; } return rc; }
/* * Actually process a block. Return the number of bytes written to block->var */ static int do_block(const U16 *data, /* data to compress */ int ndata, /* number of pixels to process */ RICE_BLOCK *block, /* block to set */ int blen, /* length of compressed data stream (in bits) */ unsigned int nbit, /* number of bits of noise */ unsigned int data_mask) /* mask to remove nbit */ { unsigned int delta; /* mapped difference of two pixels */ int i; int len; /* length of compressed data in bytes*/ int nleft; /* how many more bits fit in word */ U16 noise[RICE_J]; /* buffer for noise bits */ #define DEBUG 0 #if DEBUG U16 darray[RICE_J]; /* array of values of delta */ #endif const unsigned int noise_mask = ~data_mask; /* mask to isolate nbit */ int pred; /* predicted value */ int skip_words = 0; /* how many 0 U16 words to skip over */ U16 *vptr; /* FS coded (trimmed) values of data */ len = blen/BITS_PER_BYTE; if(blen != len*BITS_PER_BYTE) len++; if(blen > (ndata - 1)*U16LEN) { nbit = 16; } if(nbit <= 13) { block->option = RICE_OPTION_FS + nbit; } else if(nbit == 16) { block->option = RICE_OPTION_DEF; } else { shFatal("do_block: impossible value of nbit %d", nbit); } block->reference = data[0]; if(block->option == RICE_OPTION_DEF) { len = (ndata - 1)*sizeof(U16); /* ndata-1 => not the reference value*/ memcpy(block->var, &data[1], len); swap2((void *)&block->reference, sizeof(U16)); swap2((void *)block->var, len); return(len); } /* * OK, now do the clipping and encoding of the non-noise bits. * * Note that FS(0) == 0x1, requiring us to write 1 bit, * so (delta + 1) is the number of bits required */ memset(block->var, '\0', len); pred = data[0]; vptr = block->var; nleft = U16LEN; for(i = 0;i < ndata - 1;i++) { delta = get_delta(pred, data[i+1]); #if DEBUG if(unget_delta(pred, delta) != data[i + 1]) { fprintf(stderr,"Problem with delta: %d %d %d\n", pred, delta, data[i + 1]); } #endif pred = PREDICT(data, i + 1); #if DEBUG darray[i] = delta; #endif noise[i] = delta & noise_mask; delta = (delta & data_mask) >> nbit; if(delta + 1 > nleft) { /* it won't all fit in this word */ delta -= nleft; vptr++; nleft = U16LEN; skip_words = delta/U16LEN; vptr += skip_words; delta -= skip_words*U16LEN; } shAssert(delta + 1 <= nleft); *vptr |= (1 << (nleft - (delta + 1))); nleft -= delta + 1; shAssert(nleft >= 0); if(nleft == 0) { vptr++; nleft = U16LEN; } } shAssert(vptr - block->var < sizeof(block->var)); /* * and now the noise bits, if any */ if(nbit > 0) { U16 n; /* == noise[] */ int nb; /* number of bits still to write */ for(i = 0;i < ndata - 1;i++) { n = noise[i]; nb = nbit; if(nb > nleft) { /* won't all fit in this word */ *vptr++ |= (n >> (nb - nleft)); nb -= nleft; nleft = U16LEN; } *vptr |= n << (nleft - nb); nleft -= nb; }
/** \return delta The mesh size parameter delta^k -- \b OUT. */ NOMAD::Point get_delta ( void ) const { NOMAD::Point delta; get_delta(delta); return delta; }
int main(int argc, char* argv[]) { // Crear una ventana de 500x500 pixels: int cw = 640; int ch = 480; cg_init(cw, ch, NULL); init_cggl(cw, ch); Model* model = model_new("knight"); int done = 0; while (!done) { SDL_Event event; while(SDL_PollEvent(&event)) { switch (event.type) { case SDL_KEYDOWN: switch(event.key.keysym.sym) { case SDLK_ESCAPE: done = 1; break; case SDLK_UP: rot_speed += 5.0f; break; case SDLK_DOWN: rot_speed -= 5.0f; break; case SDLK_RIGHT: frame += 1; if (frame >= model->md2_model->header.num_frames) frame = 0; break; case SDLK_LEFT: frame -= 1; if (frame < 0) frame = model->md2_model->header.num_frames - 1; break; case SDLK_m: if (mode == CG_TRIANGLES) mode = CG_LINES; else mode = CG_TRIANGLES; break; default: break; } break; case SDL_QUIT : done = 1; break; default: break; } } cg_clear(); paint_model(model); // Actualizar la pantalla: cg_repaint(); double delta = get_delta(); rot_x += rot_speed*delta; rot_y += rot_speed*delta; rot_z += rot_speed*delta; } // Liberar recursos: model_free(model); cgCloseCGGL(); cg_close(); return 0; }