MCPcopy Create free account
hub / github.com/GenericMappingTools/gmt / gmtlib_linear_array

Function gmtlib_linear_array

src/gmt_support.c:15512–15545  ·  view source on GitHub ↗

! . */

Source from the content-addressed store, hash-verified

15510
15511/*! . */
15512unsigned int gmtlib_linear_array (struct GMT_CTRL *GMT, double min, double max, double delta, double phase, double **array) {
15513 /* Create an array of values between min and max, with steps delta and given phase.
15514 Example: min = 0, max = 9, delta = 2, phase = 1
15515 Result: 1, 3, 5, 7, 9
15516 */
15517
15518 int64_t first, last, i, n;
15519 double *val = NULL;
15520
15521 if (delta <= 0.0) return (0);
15522
15523 /* Undo the phase and scale by 1/delta */
15524 min = (min - phase) / delta;
15525 max = (max - phase) / delta;
15526
15527 /* Look for first value */
15528 first = lrint (floor (min));
15529 while (min - first > GMT_CONV4_LIMIT) first++;
15530
15531 /* Look for last value */
15532 last = lrint (ceil (max));
15533 while (last - max > GMT_CONV4_LIMIT) last--;
15534
15535 n = last - first + 1;
15536 if (n <= 0) return (0);
15537
15538 /* Create an array of n equally spaced elements */
15539 val = gmt_M_memory (GMT, NULL, n, double);
15540 for (i = 0; i < n; i++) val[i] = phase + (first + i) * delta; /* Rescale to original values */
15541
15542 *array = val;
15543
15544 return ((unsigned int)n);
15545}
15546
15547/*! . */
15548unsigned int gmtlib_log_array (struct GMT_CTRL *GMT, double min, double max, double delta, double **array) {

Callers 14

gmtplot_linearx_oblgridFunction · 0.85
gmtplot_lineary_gridFunction · 0.85
gmtplot_lineary_oblgridFunction · 0.85
gmtplot_map_gridticksFunction · 0.85
gmtplot_map_tickitemFunction · 0.85
gmtplot_map_annotateFunction · 0.85
gmtplot_draw_mag_roseFunction · 0.85
gmt_linearx_gridFunction · 0.85
gmtplot_geo_spiderFunction · 0.85
gmtlib_log_arrayFunction · 0.85
gmtlib_pow_arrayFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected