| 17882 | } |
| 17883 | |
| 17884 | GMT_LOCAL double *gmtsupport_unique_array (struct GMT_CTRL *GMT, double *array, uint64_t *n) { |
| 17885 | size_t k, j; |
| 17886 | /* Sort the array in case user did not enter values that were monotonically increasing */ |
| 17887 | gmt_sort_array (GMT, array, *n, GMT_DOUBLE); |
| 17888 | /* Skip any duplicates in the sorted array */ |
| 17889 | k = 0; j = 1; |
| 17890 | while (j < *n) { |
| 17891 | if (doubleAlmostEqualZero (array[j], array[k])) /* Skip repeated point */ |
| 17892 | j++; |
| 17893 | else /* Copy over unique value */ |
| 17894 | array[++k] = array[j++]; |
| 17895 | } |
| 17896 | k++; /* (new) total number of unique values */ |
| 17897 | if (k < *n) { /* Update array count */ |
| 17898 | *n = k; |
| 17899 | array = gmt_M_memory (GMT, array, *n, double); /* Reallocate exact length of array */ |
| 17900 | GMT_Report (GMT->parent, GMT_MSG_WARNING, "Eliminated %d duplicate values from the sorted array\n", (int)(j-k)); |
| 17901 | } |
| 17902 | return array; |
| 17903 | } |
| 17904 | |
| 17905 | double *gmt_list_to_array (struct GMT_CTRL *GMT, char *list, unsigned int type, bool unique, uint64_t *n) { |
| 17906 | /* Given a comma-separated string of values of type, parse and return array and its length */ |
no test coverage detected