void maybe_expand_axis_limits( double *farr, int size, axis *ax ) { if ( size >= 1 ) { ax->lowest_val = real_min(ax->lowest_val,doubles_min(farr,size)); ax->highest_val = real_max(ax->highest_val,doubles_max(farr,size)); } }
static void adapt_summary(struct mesh* m) { unsigned long total_elems = comm_add_ulong(mesh_count(m, mesh_dim(m))); double minqual = comm_min_double(mesh_min_quality(m)); unsigned nedges = mesh_count(m, 1); double* edge_sizes = mesh_measure_edges_for_adapt(m); double min = comm_min_double(doubles_min(edge_sizes, nedges)); double max = comm_max_double(doubles_max(edge_sizes, nedges)); loop_free(edge_sizes); if (comm_rank() == 0) printf("%10lu elements, min quality %.0f%%, metric range %.2f - %.2f\n", total_elems, minqual * 100.0, min, max); }
void compute_axis_limits( double *farr, int size, axis *ax ) { if ( size < 1 ) printf("compute_axis_limits: no way dude. Axis is empty!\n"); else { ax->lowest_val = doubles_min(farr,size); ax->highest_val = doubles_max(farr,size); } if ( Verbosity > 10.0 ) printf("%s axis limits: (%g , %g)\n", (ax->vertical) ? "Vertical" : "Horizontal", ax->lowest_val, ax->highest_val ); }
void ongr_basic_histogram( frame *fr, double *x, int size ) { double rough_num_cols = int_min(MAX_BARS/6-1,(int) ceil(sqrt((double) size))); double xlo,xhi,delta; int bars; double freq[MAX_BARS],bases[MAX_BARS]; int i; ongr on; sensible_limits(doubles_min(x,size),doubles_max(x,size),&xlo,&xhi,&delta); /* &&& */ /* xlo = 0.0; xhi = 10.0; delta = 0.2; */ bars = (int) ceil((xhi - xlo) / delta); while ( bars < rough_num_cols ) { bars *= 2; if ( bars < rough_num_cols ) { bars /= 2; bars *= 5; } if ( bars < rough_num_cols ) bars *= 2; } if ( bars > MAX_BARS ) my_error("MAX_BARS too small"); delta = (xhi - xlo) / bars; bars += 3; xhi += delta; xlo -= delta; set_realnums_constant(freq,bars,0.0); printf("delta = %g, bars = %d\n",delta,bars); for ( i = 0 ; i < size ; i++ ) { int bar_num = (int) floor(0.5 + (x[i] - xlo)/delta); if ( bar_num < 0 || bar_num >= bars ) my_error("oisdncoisna"); freq[bar_num] += 1.0; } for ( i = 0 ; i < bars ; i++ ) bases[i] = xlo + i * (xhi - xlo) / (bars-1); clear_ongr(&on); compute_axis_limits(bases,bars,&on.x_axis); compute_axis_limits(freq,bars,&on.y_axis); sprintf(on.y_axis.label,"Histogram Frequency"); on.y_axis.lowest_val = 0.0; compute_axes_details(&on,fr); draw_axes(fr,&on); plot_graphic_in_frame(fr,&on,bases,freq,bars,"NN",delta,AG_PURPLE); if ( size < MAX_X_ARR_SIZE ) { double fake_y[MAX_X_ARR_SIZE]; double v = 0.5; set_realnums_constant(fake_y,size,v); plot_in_frame(fr,&on,x,fake_y,size,"ND"); } }