double cal_angle(const C &c, const P &a, const P &b) { double k = dmul(c.mid, a, b) / SQR(c.r); get_min(k, 1.0); get_max(k, -1.0); return acos(k); }
int main() { int itr; int nCount; /* 문제의 테스트 케이스 */ scanf("%d", &nCount); /* 테스트 케이스 입력 */ for(itr=0; itr<nCount; itr++) { printf("#testcase%d\n",itr+1); top = -1; int count; scanf("%d",&count); char tmp[100][100]; char input[100]; for(int i = 0; i < count; i++){ scanf("%s",input); // *tmp[i] = *input; if(input[1] == 'u'){ int new_input; scanf("%d", &new_input); push(new_input); } else if(input[0] == 'M'){ if(empty()){ printf("Empty\n"); continue; } printf("Min %d\n", get_min()); } else if(input[1] == 'o'){ if(empty()){ printf("Empty\n"); continue; } printf("Pop %d\n", pop()); } } // for(int i = 0; i <= top; i++){ // printf("%d\n", stack[i]); // } // for(int i = 0; i < count; i++){ // if(tmp[i][1] == 'u'){ // push(tmp[i][5]); // } // else if(tmp[i][0] == 'M'){ // printf("Min %c\n", get_min()); // } // else if(tmp[i][1] == 'O'){ // if(!empty()){ // printf("Pop %c\n", pop()); // } // else{ // printf("Empty\n"); // } // } // } } return 0; /* 반드시 return 0으로 해주셔야합니다. */ }
int main() { int arr_1[] = {1, 2, 3, 4, 5}; int arr_2[] = {6, 7, 8}; int lenght_1 = LENGHT_ARRAY(arr_1); int lenght_2 = LENGHT_ARRAY(arr_2); int min = get_min(arr_1, lenght_1); printf("min = %d\n", min); int min_2 = get_min(arr_2, lenght_2); printf("min_2 = %d\n", min_2); int max = get_max(arr_1, lenght_1); printf("max = %d\n", max); int max_2 = get_max(arr_2, lenght_2); printf("max_2 = %d\n", max_2); double average = get_avg(arr_1, lenght_1); printf("average = %f\n", average); double average_2 = get_avg(arr_2, lenght_2); printf("average_2 = %f\n", average_2); int sum = get_sum(arr_1, lenght_1); printf("sum = %d\n", sum); int sum_2 = get_sum(arr_2, lenght_2); printf("sum_2 = %d\n", sum_2); bool isContain = arr_contains(arr_1, lenght_1, 5); printf("isContain 5 = %d\n", isContain); bool isContain_2 = arr_contains(arr_2, lenght_2, 5); printf("isContain_2 5 = %d\n", isContain_2); int *arrMerge; arrMerge = arr_merge(arr_1, arr_2, lenght_1, lenght_2); int i; printf("Merged: "); for (i = 0; i < (lenght_1 + lenght_2); i++) { printf("%d ", arrMerge[i]); } printf("\n"); free(arrMerge); printf("Clearing... \n"); arr_clear(arr_1, lenght_1); for (i = 0; i < lenght_1; i++) { printf("%d ", arr_1[i]); } printf("\n"); arr_clear(arr_2, lenght_2); for (i = 0; i < lenght_2; i++) { printf("%d ", arr_2[i]); } return (EXIT_SUCCESS); }
int main() { record queue[10000]; long int ele, pr; char ch; scanf("%c",&ch); getchar(); do { switch(ch) { case 'a': scanf("%ld",&ele); scanf("%ld",&pr); getchar(); if(checkNumber(ele) && checkNumber(pr) && ele >= 0 && pr >=1) { insert(queue, ele, pr); size++; } else { printf("Enter elements in given range.\n"); } break; case 'e': extract_min(queue); break; case 'g': get_min(queue); break; case 'd': scanf("%ld",&ele); scanf("%ld",&pr); getchar(); if(checkNumber(ele) && checkNumber(pr) && ele >= 0 && pr >=1) { decrease_priority(queue, ele, pr); } else { printf("Enter elements in given range.\n"); } break; case 's': printf("\n"); break; default: printf("Enter correct choice.\n"); break; } scanf("%c",&ch); getchar(); } while(ch != 's'); return 0; }
/** \brief Sweeps the pressure sensor, and compensates the results. * * If performing a calibration sweep, pass NULL for the second parameter, and * no compensation will be performed. * * When sweeping * * \param[in] buffer buffer to save the sensor sweep results * \param[in] comp_buffer compensation values to use, or NULL to not use any */ static void sweep_sensor(uint16_t buffer[NUM_PS_Y_CHANS][NUM_PS_X_CHANS], uint16_t comp_buffer[NUM_PS_Y_CHANS][NUM_PS_X_CHANS]) { uint8_t y_channel, x_channel; uint16_t oversample_buffer[OVERSAMPLE_SIZE]; uint16_t result; uint16_t comp = ZERO_THRESHOLD; uint16_t min; uint16_t max; uint8_t oversample_ndx; /* start at position 0,0 */ ADC_reset_channel(&adc0); ADC_reset_channel(&adc1); for (y_channel = 0; y_channel < NUM_PS_Y_CHANS; ++y_channel) { /* set the y channel, but don't use the conversion result */ ADC_set_output_data(&adc1, MPy_channels+y_channel); ADC_sample_once(&adc1); for (x_channel = 0; x_channel < (NUM_PS_X_CHANS / 2); ++x_channel) { /* set the x_channel, but dont use the conversion result */ ADC_set_output_data(&adc0, MPx_channels+x_channel); ADC_sample_once(&adc0); /* delay_ms(5); */ comp = ZERO_THRESHOLD; for (oversample_ndx = 0; oversample_ndx < OVERSAMPLE_SIZE; ++oversample_ndx) { oversample_buffer[oversample_ndx] = ADC_sample_once(&adc1); if (oversample_buffer[oversample_ndx] & SIGN_BIT) { oversample_buffer[oversample_ndx] = 0; } } min = get_min(oversample_buffer); max = get_max(oversample_buffer); if ((max - min > OVERSAMPLE_THRESHOLD) && (comp_buffer != NULL)) { result = 0; } else { result = (max+min)/2; } if (comp_buffer != NULL) { comp = comp_buffer[y_channel][x_channel] + ZERO_THRESHOLD; if (comp > result) { /* if comp is gt result, set to 0 */ result = 0; comp = ZERO_THRESHOLD; } } comp -=ZERO_THRESHOLD; buffer[y_channel][x_channel] = result-comp; for (oversample_ndx = 0; oversample_ndx < OVERSAMPLE_SIZE; ++oversample_ndx) { oversample_buffer[oversample_ndx] = ADC_sample_once(&adc0); if (oversample_buffer[oversample_ndx] & SIGN_BIT) { oversample_buffer[oversample_ndx] = 0; } } min = get_min(oversample_buffer); max = get_max(oversample_buffer); if ((max - min > OVERSAMPLE_THRESHOLD) && (comp_buffer != NULL)) { result = 0; } else { result = (max+min)/2; } if (comp_buffer != NULL) { comp = comp_buffer[y_channel][x_channel + (NUM_PS_X_CHANS/2)] + ZERO_THRESHOLD; if (comp > result) { /* if comp is gt result, set to 0 */ result = 0; comp = ZERO_THRESHOLD; } } if (result & SIGN_BIT) { result = 0; comp = ZERO_THRESHOLD; } comp -= ZERO_THRESHOLD; buffer[y_channel][x_channel + (NUM_PS_X_CHANS)/2] = result-comp; } } }
void Slider::_gui_input(Ref<InputEvent> p_event) { if (!editable) { return; } Ref<InputEventMouseButton> mb = p_event; if (mb.is_valid()) { if (mb->get_button_index() == BUTTON_LEFT) { if (mb->is_pressed()) { Ref<Texture> grabber = get_icon(mouse_inside || has_focus() ? "grabber_highlight" : "grabber"); grab.pos = orientation == VERTICAL ? mb->get_position().y : mb->get_position().x; double grab_width = (double)grabber->get_size().width; double grab_height = (double)grabber->get_size().height; double max = orientation == VERTICAL ? get_size().height - grab_height : get_size().width - grab_width; if (orientation == VERTICAL) set_as_ratio(1 - (((double)grab.pos - (grab_height / 2.0)) / max)); else set_as_ratio(((double)grab.pos - (grab_width / 2.0)) / max); grab.active = true; grab.uvalue = get_as_ratio(); } else { grab.active = false; } } else if (scrollable) { if (mb->is_pressed() && mb->get_button_index() == BUTTON_WHEEL_UP) { set_value(get_value() + get_step()); } else if (mb->is_pressed() && mb->get_button_index() == BUTTON_WHEEL_DOWN) { set_value(get_value() - get_step()); } } } Ref<InputEventMouseMotion> mm = p_event; if (mm.is_valid()) { if (grab.active) { Size2i size = get_size(); Ref<Texture> grabber = get_icon("grabber"); float motion = (orientation == VERTICAL ? mm->get_position().y : mm->get_position().x) - grab.pos; if (orientation == VERTICAL) motion = -motion; float areasize = orientation == VERTICAL ? size.height - grabber->get_size().height : size.width - grabber->get_size().width; if (areasize <= 0) return; float umotion = motion / float(areasize); set_as_ratio(grab.uvalue + umotion); } } if (!mm.is_valid() && !mb.is_valid()) { if (p_event->is_action("ui_left") && p_event->is_pressed()) { if (orientation != HORIZONTAL) return; set_value(get_value() - (custom_step >= 0 ? custom_step : get_step())); accept_event(); } else if (p_event->is_action("ui_right") && p_event->is_pressed()) { if (orientation != HORIZONTAL) return; set_value(get_value() + (custom_step >= 0 ? custom_step : get_step())); accept_event(); } else if (p_event->is_action("ui_up") && p_event->is_pressed()) { if (orientation != VERTICAL) return; set_value(get_value() + (custom_step >= 0 ? custom_step : get_step())); accept_event(); } else if (p_event->is_action("ui_down") && p_event->is_pressed()) { if (orientation != VERTICAL) return; set_value(get_value() - (custom_step >= 0 ? custom_step : get_step())); accept_event(); } else if (p_event->is_action("ui_home") && p_event->is_pressed()) { set_value(get_min()); accept_event(); } else if (p_event->is_action("ui_end") && p_event->is_pressed()) { set_value(get_max()); accept_event(); } } }
void Binary_search_tree::delete_min() { remove(get_min(root)->get_data()); }
void fill_csv(Image::Pointer im1, Image::Pointer im2, Image::Pointer label, const char *output_excel) { CsvWriter csv = CsvWriter(QString(output_excel)); csv.insert(2,1,QString("T1")); csv.insert(2,2,QString("WM")); csv.insert(3,2,QString("GM")); csv.insert(4,2,QString("CSF")); csv.insert(1,3,QString("Volume")); csv.insert(1,4,QString("Mean")); csv.insert(1,5,QString("Min")); csv.insert(1,6,QString("Max")); csv.insert(7,1,QString("T2")); csv.insert(7,2,QString("WM")); csv.insert(8,2,QString("GM")); csv.insert(9,2,QString("CSF")); csv.insert(6,3,QString("Volume")); csv.insert(6,4,QString("Mean")); csv.insert(6,5,QString("Min")); csv.insert(6,6,QString("Max")); // White Matter std::cout<<"White Matter statistics"<<std::endl; Image::Pointer wm1 = binary_and(im1, label2mask(label,1)); unsigned int min = get_min(wm1); unsigned int max = get_max(wm1); float mean = get_mean(wm1); unsigned int volume = get_volume(wm1); csv.insert(2,3,QString("%1").arg(volume)); csv.insert(2,4,QString("%1").arg(mean)); csv.insert(2,5,QString("%1").arg(min)); csv.insert(2,6,QString("%1").arg(max)); Image::Pointer wm2 = binary_and(im2, label2mask(label,1)); min = get_min(wm2); max = get_max(wm2); mean = get_mean(wm2); volume = get_volume(wm2); csv.insert(7,3,QString("%1").arg(volume)); csv.insert(7,4,QString("%1").arg(mean)); csv.insert(7,5,QString("%1").arg(min)); csv.insert(7,6,QString("%1").arg(max)); // Gray Matter std::cout<<"Gray Matter statistics"<<std::endl; Image::Pointer gm1 = binary_and(im1, label2mask(label,2)); min = get_min(gm1); max = get_max(gm1); mean = get_mean(gm1); volume = get_volume(gm1); csv.insert(3,3,QString("%1").arg(volume)); csv.insert(3,4,QString("%1").arg(mean)); csv.insert(3,5,QString("%1").arg(min)); csv.insert(3,6,QString("%1").arg(max)); Image::Pointer gm2 = binary_and(im2, label2mask(label,2)); min = get_min(gm2); max = get_max(gm2); mean = get_mean(gm2); volume = get_volume(gm2); csv.insert(8,3,QString("%1").arg(volume)); csv.insert(8,4,QString("%1").arg(mean)); csv.insert(8,5,QString("%1").arg(min)); csv.insert(8,6,QString("%1").arg(max)); // CSF std::cout<<"CSF statistics"<<std::endl; Image::Pointer csf1 = binary_and(im1, label2mask(label,3)); min = get_min(csf1); max = get_max(csf1); mean = get_mean(csf1); volume = get_volume(csf1); csv.insert(4,3,QString("%1").arg(volume)); csv.insert(4,4,QString("%1").arg(mean)); csv.insert(4,5,QString("%1").arg(min)); csv.insert(4,6,QString("%1").arg(max)); Image::Pointer csf2 = binary_and(im2, label2mask(label,3)); min = get_min(csf2); max = get_max(csf2); mean = get_mean(csf2); volume = get_volume(csf2); csv.insert(9,3,QString("%1").arg(volume)); csv.insert(9,4,QString("%1").arg(mean)); csv.insert(9,5,QString("%1").arg(min)); csv.insert(9,6,QString("%1").arg(max)); std::cout<<"Updating cvs file"<<std::endl; csv.update(); std::cout<<"cvs file updated"<<std::endl; }
float animated_param_t::clamp( float x) const { if( x < get_min()) return get_min(); if( x > get_max()) return get_max(); return x; }
BST_node* Binary_search_tree::get_min(BST_node* t) { if (t->get_left_child() != nullptr) get_min(t->get_left_child()); else return t; }
void ScrollBar::_input_event(InputEvent p_event) { switch(p_event.type) { case InputEvent::MOUSE_BUTTON: { const InputEventMouseButton &b=p_event.mouse_button; accept_event(); if (b.button_index==5 && b.pressed) { if (orientation==VERTICAL) set_val( get_val() + get_page() / 4.0 ); else set_val( get_val() + get_page() / 4.0 ); accept_event(); } if (b.button_index==4 && b.pressed) { if (orientation==HORIZONTAL) set_val( get_val() - get_page() / 4.0 ); else set_val( get_val() - get_page() / 4.0 ); accept_event(); } if (b.button_index!=1) return; if (b.pressed) { double ofs = orientation==VERTICAL ? b.y : b.x ; Ref<Texture> decr = get_icon("decrement"); Ref<Texture> incr = get_icon("increment"); double decr_size = orientation==VERTICAL ? decr->get_height() : decr->get_width(); double incr_size = orientation==VERTICAL ? incr->get_height() : incr->get_width(); double grabber_ofs = get_grabber_offset(); double grabber_size = get_grabber_size(); double total = orientation==VERTICAL ? get_size().height : get_size().width; if (ofs < decr_size ) { set_val( get_val() - (custom_step>=0?custom_step:get_step()) ); break; } if (ofs > total-incr_size ) { set_val( get_val() + (custom_step>=0?custom_step:get_step()) ); break; } ofs-=decr_size; if ( ofs < grabber_ofs ) { set_val( get_val() - get_page() ); break; } ofs-=grabber_ofs; if (ofs < grabber_size ) { drag.active=true; drag.pos_at_click=grabber_ofs+ofs; drag.value_at_click=get_unit_value(); update(); } else { set_val( get_val() + get_page() ); } } else { drag.active=false; update(); } } break; case InputEvent::MOUSE_MOTION: { const InputEventMouseMotion &m=p_event.mouse_motion; accept_event(); if (drag.active) { double ofs = orientation==VERTICAL ? m.y : m.x ; Ref<Texture> decr = get_icon("decrement"); double decr_size = orientation==VERTICAL ? decr->get_height() : decr->get_width(); ofs-=decr_size; double diff = (ofs-drag.pos_at_click) / get_area_size(); set_unit_value( drag.value_at_click + diff ); } else { double ofs = orientation==VERTICAL ? m.y : m.x ; Ref<Texture> decr = get_icon("decrement"); Ref<Texture> incr = get_icon("increment"); double decr_size = orientation==VERTICAL ? decr->get_height() : decr->get_width(); double incr_size = orientation==VERTICAL ? incr->get_height() : incr->get_width(); double total = orientation==VERTICAL ? get_size().height : get_size().width; HiliteStatus new_hilite; if (ofs < decr_size ) { new_hilite=HILITE_DECR; } else if (ofs > total-incr_size ) { new_hilite=HILITE_INCR; } else { new_hilite=HILITE_RANGE; } if (new_hilite!=hilite) { hilite=new_hilite; update(); } } } break; case InputEvent::KEY: { const InputEventKey &k=p_event.key; if (!k.pressed) return; switch (k.scancode) { case KEY_LEFT: { if (orientation!=HORIZONTAL) return; set_val( get_val() - (custom_step>=0?custom_step:get_step()) ); } break; case KEY_RIGHT: { if (orientation!=HORIZONTAL) return; set_val( get_val() + (custom_step>=0?custom_step:get_step()) ); } break; case KEY_UP: { if (orientation!=VERTICAL) return; set_val( get_val() - (custom_step>=0?custom_step:get_step()) ); } break; case KEY_DOWN: { if (orientation!=VERTICAL) return; set_val( get_val() + (custom_step>=0?custom_step:get_step()) ); } break; case KEY_HOME: { set_val( get_min() ); } break; case KEY_END: { set_val( get_max() ); } break; } break; } } }
TITANIUM_PROPERTY_GETTER(Slider, min) { return get_context().CreateNumber(get_min()); }
// Находим значение fris-функции, для смешанной выборки, где определёна система столпов: // s - матрица столпов. // num_cl - номер класса, для которого определен единственный столп; // smpl - единственный столп класса num_cl; // kol_ss - количество образцов в смешанной выборке; // dm_mix - матрица подобия; // cl - вектор разбиения; // kol_st - количество верифицированных образов; // n - количество классов в разбиении; // rez - переменная для формирования результата; void fris_compact_ss(int * s, int * kol_ss, int * kol_st, double * dm_mix, int * cl, int * n, int * kol_col, double * rez) { int i,j,k, count; int ss[*n+1][*kol_col+1]; int b[(*n+1) * (*kol_col+1)]; double rho_self, rho_alien, rho, max, r, f; for (i = 1; i <= *n; i++) { for (j = 1; j<= *kol_col; j++) { ss[i][j] = get_eli(s, i, j, n); } } for (k = 1; k <= *kol_ss; k++){ rho_self = 0; rho_alien = 6; //printf("%i\n", k); if (k <= *kol_st){ if(cheking(k, ss[cl[k-1]], *kol_col) == "TRUE"){ rho_self = get_min(ss[cl[k-1]], kol_col, k, dm_mix, kol_ss); count = 1; for (i=1; i<= *n; i++){ if (cl[k-1] != i){ for (j=0; j< *kol_col; j++){ b[count] = ss[i][j+1]; count ++ ; } } } count = count-1; rho = get_min(b, &count, k, dm_mix, kol_ss); if (rho_alien > rho ){ rho_alien = rho; } } }else{ count = 1; for (i=1; i<= *n; i++){ for (j=0; j< *kol_col; j++){ b[count] = ss[i][j+1]; count ++ ; } } count = count-1; if(cheking(k, b, count) == "TRUE"){ rho_self = get_min(b, &count, k, dm_mix, kol_ss); max = get_min(ss[1], kol_col, k, dm_mix, kol_ss); for (i = 1; i <= *n; i++){ rho = get_min(ss[i], kol_col, k, dm_mix, kol_ss); if(max < rho){ max = rho; } } if (rho_alien > max){ rho_alien = max; } } } if (rho_self == 0 && rho_alien ==0 ){ printf("k = %i\n", k ); } //printf("rho_self = %f\n", rho_self); //printf("rho_alien = %f\n", rho_alien); f = fris(rho_self, rho_alien); // считаем значение fris-функции для k образца //printf("f = %f\n", f); r=r+f; } *rez = r / *kol_ss; // Находим значение fris- функции, сумму значений fris-функций делим на количество образцов в смешанной выборке }
void Slider::_input_event(InputEvent p_event) { if (p_event.type==InputEvent::MOUSE_BUTTON) { InputEventMouseButton &mb = p_event.mouse_button; if (mb.button_index==BUTTON_LEFT) { if (mb.pressed) { grab.pos=orientation==VERTICAL?mb.y:mb.x; double max = orientation==VERTICAL ? get_size().height : get_size().width ; if (orientation==VERTICAL) set_unit_value( 1 - ((double)grab.pos / max) ); else set_unit_value((double)grab.pos / max); grab.active=true; grab.uvalue=get_unit_value(); } else { grab.active=false; } } else if (mb.pressed && mb.button_index==BUTTON_WHEEL_UP) { set_val( get_val() + get_step()); } else if (mb.pressed && mb.button_index==BUTTON_WHEEL_DOWN) { set_val( get_val() - get_step()); } } else if (p_event.type==InputEvent::MOUSE_MOTION) { if (grab.active) { Size2i size = get_size(); Ref<Texture> grabber = get_icon("grabber"); float motion = (orientation==VERTICAL?p_event.mouse_motion.y:p_event.mouse_motion.x) - grab.pos; if (orientation==VERTICAL) motion=-motion; float areasize = orientation==VERTICAL?size.height - grabber->get_size().height:size.width - grabber->get_size().width; if (areasize<=0) return; float umotion = motion / float(areasize); set_unit_value( grab.uvalue + umotion ); } } else { if (p_event.is_action("ui_left") && p_event.is_pressed()) { if (orientation!=HORIZONTAL) return; set_val( get_val() - (custom_step>=0?custom_step:get_step()) ); accept_event(); } else if (p_event.is_action("ui_right") && p_event.is_pressed()) { if (orientation!=HORIZONTAL) return; set_val( get_val() + (custom_step>=0?custom_step:get_step()) ); accept_event(); } else if (p_event.is_action("ui_up") && p_event.is_pressed()) { if (orientation!=VERTICAL) return; set_val( get_val() + (custom_step>=0?custom_step:get_step()) ); accept_event(); } else if (p_event.is_action("ui_down") && p_event.is_pressed()) { if (orientation!=VERTICAL) return; set_val( get_val() - (custom_step>=0?custom_step:get_step()) ); accept_event(); } else if (p_event.type==InputEvent::KEY) { const InputEventKey &k=p_event.key; if (!k.pressed) return; switch (k.scancode) { case KEY_HOME: { set_val( get_min() ); accept_event(); } break; case KEY_END: { set_val( get_max() ); accept_event(); } break; } ; } } }
void SpinBox::_gui_input(const Ref<InputEvent> &p_event) { if (!is_editable()) { return; } Ref<InputEventMouseButton> mb = p_event; if (mb.is_valid() && mb->is_pressed()) { bool up = mb->get_position().y < (get_size().height / 2); switch (mb->get_button_index()) { case BUTTON_LEFT: { set_value(get_value() + (up ? get_step() : -get_step())); range_click_timer->set_wait_time(0.6); range_click_timer->set_one_shot(true); range_click_timer->start(); line_edit->grab_focus(); } break; case BUTTON_RIGHT: { set_value((up ? get_max() : get_min())); line_edit->grab_focus(); } break; case BUTTON_WHEEL_UP: { if (line_edit->has_focus()) { set_value(get_value() + get_step() * mb->get_factor()); accept_event(); } } break; case BUTTON_WHEEL_DOWN: { if (line_edit->has_focus()) { set_value(get_value() - get_step() * mb->get_factor()); accept_event(); } } break; } } if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == 1) { //set_default_cursor_shape(CURSOR_VSIZE); Vector2 cpos = Vector2(mb->get_position().x, mb->get_position().y); drag.mouse_pos = cpos; } if (mb.is_valid() && !mb->is_pressed() && mb->get_button_index() == 1) { //set_default_cursor_shape(CURSOR_ARROW); range_click_timer->stop(); if (drag.enabled) { drag.enabled = false; Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE); warp_mouse(drag.capture_pos); } } Ref<InputEventMouseMotion> mm = p_event; if (mm.is_valid() && mm->get_button_mask() & 1) { Vector2 cpos = mm->get_position(); if (drag.enabled) { float diff_y = drag.mouse_pos.y - cpos.y; diff_y = Math::pow(ABS(diff_y), 1.8f) * SGN(diff_y); diff_y *= 0.1; drag.mouse_pos = cpos; drag.base_val = CLAMP(drag.base_val + get_step() * diff_y, get_min(), get_max()); set_value(drag.base_val); } else if (drag.mouse_pos.distance_to(cpos) > 2) { Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_CAPTURED); drag.enabled = true; drag.base_val = get_value(); drag.mouse_pos = cpos; drag.capture_pos = cpos; } } }
void calc_forcing_stats(int Nrecs, atmos_data_struct *atmos, const int NR) { /********************************************************************** calc_forcing_stats.c Keith Cherkauer November 16, 2000 This routine finds the maximum, minimum and mean values for each data type. Results are output to stdout for inclusion in screen or log file output. These statistics are meant only to help the user identify possible problems in their input forcing data and are not an exhaustive study of that data. **********************************************************************/ double *values = (double *) calloc ( Nrecs, sizeof(double) ); printf("Variable\tMean\tStd. Dev.\tSum\tMaximum\tMinimum\n"); /** Air Temperature **/ for (int rec = 0; rec < Nrecs; rec ++ ) values[rec] = atmos[rec].air_temp[NR]; printf("air temp (C):\t%f\t%f\t%f\t%f\t%f\n", get_mean(values, Nrecs, INVALID), get_stdev(values, Nrecs, get_mean(values, Nrecs, INVALID), INVALID), get_sum(values, Nrecs, INVALID), get_max(values, Nrecs, INVALID), get_min(values, Nrecs, INVALID) ); /** Density **/ for (int rec = 0; rec < Nrecs; rec ++ ) values[rec] = atmos[rec].density[NR]; printf("Density (kg/m^3):\t%f\t%f\t%f\t%f\t%f\n", get_mean(values, Nrecs, INVALID), get_stdev(values, Nrecs, get_mean(values, Nrecs, INVALID), INVALID), get_sum(values, Nrecs, INVALID), get_max(values, Nrecs, INVALID), get_min(values, Nrecs, INVALID) ); /** Longwave **/ for (int rec = 0; rec < Nrecs; rec ++ ) values[rec] = atmos[rec].longwave[NR]; printf("Longwave (W/m^2):\t%f\t%f\t%f\t%f\t%f\n", get_mean(values, Nrecs, INVALID), get_stdev(values, Nrecs, get_mean(values, Nrecs, INVALID), INVALID), get_sum(values, Nrecs, INVALID), get_max(values, Nrecs, INVALID), get_min(values, Nrecs, INVALID) ); /** Precipitation **/ for (int rec = 0; rec < Nrecs; rec ++ ) values[rec] = atmos[rec].prec[NR]; printf("Precip (mm):\t%f\t%f\t%f\t%f\t%f\n", get_mean(values, Nrecs, INVALID), get_stdev(values, Nrecs, get_mean(values, Nrecs, INVALID), INVALID), get_sum(values, Nrecs, INVALID), get_max(values, Nrecs, INVALID), get_min(values, Nrecs, INVALID) ); /** Pressure **/ for (int rec = 0; rec < Nrecs; rec ++ ) values[rec] = atmos[rec].pressure[NR]; printf("Pressure (Pa):\t%f\t%f\t%f\t%f\t%f\n", get_mean(values, Nrecs, INVALID), get_stdev(values, Nrecs, get_mean(values, Nrecs, INVALID), INVALID), get_sum(values, Nrecs, INVALID), get_max(values, Nrecs, INVALID), get_min(values, Nrecs, INVALID) ); /** Shortwave **/ for (int rec = 0; rec < Nrecs; rec ++ ) values[rec] = atmos[rec].shortwave[NR]; printf("Shortwave (W/m^2):\t%f\t%f\t%f\t%f\t%f\n", get_mean(values, Nrecs, INVALID), get_stdev(values, Nrecs, get_mean(values, Nrecs, INVALID), INVALID), get_sum(values, Nrecs, INVALID), get_max(values, Nrecs, INVALID), get_min(values, Nrecs, INVALID) ); /** Vapor Pressure **/ for (int rec = 0; rec < Nrecs; rec ++ ) values[rec] = atmos[rec].vp[NR]; printf("vp (Pa):\t%f\t%f\t%f\t%f\t%f\n", get_mean(values, Nrecs, INVALID), get_stdev(values, Nrecs, get_mean(values, Nrecs, INVALID), INVALID), get_sum(values, Nrecs, INVALID), get_max(values, Nrecs, INVALID), get_min(values, Nrecs, INVALID) ); /** Vapor Pressure Deficit **/ for (int rec = 0; rec < Nrecs; rec ++ ) values[rec] = atmos[rec].vpd[NR]; printf("vpd (Pa):\t%f\t%f\t%f\t%f\t%f\n", get_mean(values, Nrecs, INVALID), get_stdev(values, Nrecs, get_mean(values, Nrecs, INVALID), INVALID), get_sum(values, Nrecs, INVALID), get_max(values, Nrecs, INVALID), get_min(values, Nrecs, INVALID) ); /** Wind Speed **/ for (int rec = 0; rec < Nrecs; rec ++ ) values[rec] = atmos[rec].wind[NR]; printf("wind speed (m/s):\t%f\t%f\t%f\t%f\t%f\n", get_mean(values, Nrecs, INVALID), get_stdev(values, Nrecs, get_mean(values, Nrecs, INVALID), INVALID), get_sum(values, Nrecs, INVALID), get_max(values, Nrecs, INVALID), get_min(values, Nrecs, INVALID) ); fflush(stdout); free(values); }
void pop_min() { max_deleted.push(get_min()); min_heap.pop(); }