! . */
| 15510 | |
| 15511 | /*! . */ |
| 15512 | unsigned 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 | /*! . */ |
| 15548 | unsigned int gmtlib_log_array (struct GMT_CTRL *GMT, double min, double max, double delta, double **array) { |
no outgoing calls
no test coverage detected