PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ rt_band_get_quantiles_stream()

rt_quantile rt_band_get_quantiles_stream ( rt_band  band,
int  exclude_nodata_value,
double  sample,
uint64_t  cov_count,
struct quantile_llist **  qlls,
uint32_t *  qlls_count,
double *  quantiles,
uint32_t  quantiles_count,
uint32_t *  rtn_count 
)

Compute the default set of or requested quantiles for a coverage.

This function is based upon the algorithm described in:

A One-Pass Space-Efficient Algorithm for Finding Quantiles (1995) by Rakesh Agrawal, Arun Swami in Proc. 7th Intl. Conf. Management of Data (COMAD-95)

http://www.almaden.ibm.com/cs/projects/iis/hdb/Publications/papers/comad95.pdf

In the future, it may be worth exploring algorithms that don't require the size of the coverage

Parameters
band: the band to include in the quantile search
exclude_nodata_value: if non-zero, ignore nodata values
sample: percentage of pixels to sample
cov_count: number of values in coverage
qlls: set of quantile_llist structures
qlls_count: the number of quantile_llist structures
quantiles: the quantiles to be computed if bot qlls and quantiles provided, qlls is used
quantiles_count: the number of quantiles to be computed
rtn_count: the number of quantiles being returned
Returns
the default set of or requested quantiles for a band or NULL

Definition at line 1011 of file rt_statistics.c.

1018 {
1019 rt_quantile rtn = NULL;
1020 int init_quantiles = 0;
1021
1022 struct quantile_llist *qll = NULL;
1023 struct quantile_llist_element *qle = NULL;
1024 struct quantile_llist_element *qls = NULL;
1025 const uint32_t MAX_VALUES = 750;
1026
1027 uint8_t *data = NULL;
1028 double value;
1029 int isnodata = 0;
1030
1031 uint32_t a = 0;
1032 uint32_t i = 0;
1033 uint32_t j = 0;
1034 uint32_t k = 0;
1035 uint32_t x = 0;
1036 int64_t y = 0;
1037 uint32_t z = 0;
1038 uint32_t idx = 0;
1039 uint32_t offset = 0;
1040 uint32_t diff = 0;
1041 uint8_t exists = 0;
1042
1043 uint32_t do_sample = 0;
1044 uint32_t sample_size = 0;
1045 uint32_t sample_per = 0;
1046 uint32_t sample_int = 0;
1047 int status;
1048
1049 RASTER_DEBUG(3, "starting");
1050
1051 assert(NULL != band);
1052 assert(cov_count > 1);
1053 assert(NULL != rtn_count);
1054 RASTER_DEBUGF(3, "cov_count = %llu", cov_count);
1055
1056 data = rt_band_get_data(band);
1057 if (data == NULL) {
1058 rterror("rt_band_get_summary_stats: Cannot get band data");
1059 return NULL;
1060 }
1061
1062 if (!rt_band_get_hasnodata_flag(band))
1063 exclude_nodata_value = 0;
1064 RASTER_DEBUGF(3, "exclude_nodata_value = %d", exclude_nodata_value);
1065
1066 /* quantile_llist not provided */
1067 if (NULL == *qlls) {
1068 /* quantiles not provided */
1069 if (NULL == quantiles) {
1070 /* quantile count not specified, default to quartiles */
1071 if (quantiles_count < 2)
1072 quantiles_count = 5;
1073
1074 quantiles = rtalloc(sizeof(double) * quantiles_count);
1075 init_quantiles = 1;
1076 if (NULL == quantiles) {
1077 rterror("rt_band_get_quantiles_stream: Could not allocate memory for quantile input");
1078 return NULL;
1079 }
1080
1081 quantiles_count--;
1082 for (i = 0; i <= quantiles_count; i++)
1083 quantiles[i] = ((double) i) / quantiles_count;
1084 quantiles_count++;
1085 }
1086
1087 /* check quantiles */
1088 for (i = 0; i < quantiles_count; i++) {
1089 if (quantiles[i] < 0. || quantiles[i] > 1.) {
1090 rterror("rt_band_get_quantiles_stream: Quantile value not between 0 and 1");
1091 if (init_quantiles) rtdealloc(quantiles);
1092 return NULL;
1093 }
1094 }
1095 quicksort(quantiles, quantiles + quantiles_count - 1);
1096
1097 /* initialize linked-list set */
1098 *qlls_count = quantiles_count * 2;
1099 RASTER_DEBUGF(4, "qlls_count = %d", *qlls_count);
1100 *qlls = rtalloc(sizeof(struct quantile_llist) * *qlls_count);
1101 if (NULL == *qlls) {
1102 rterror("rt_band_get_quantiles_stream: Could not allocate memory for quantile output");
1103 if (init_quantiles) rtdealloc(quantiles);
1104 return NULL;
1105 }
1106
1107 j = (uint32_t) floor(MAX_VALUES / 100.) + 1;
1108 for (i = 0; i < *qlls_count; i++) {
1109 qll = &((*qlls)[i]);
1110 qll->quantile = quantiles[(i * quantiles_count) / *qlls_count];
1111 qll->count = 0;
1112 qll->sum1 = 0;
1113 qll->sum2 = 0;
1114 qll->head = NULL;
1115 qll->tail = NULL;
1116
1117 /* initialize index */
1118 qll->index = rtalloc(sizeof(struct quantile_llist_index) * j);
1119 if (NULL == qll->index) {
1120 rterror("rt_band_get_quantiles_stream: Could not allocate memory for quantile output");
1121 if (init_quantiles) rtdealloc(quantiles);
1122 return NULL;
1123 }
1124 qll->index_max = j;
1126
1127 /* AL-GEQ */
1128 if (!(i % 2)) {
1129 qll->algeq = 1;
1130 qll->tau = (uint64_t) ROUND(cov_count - (cov_count * qll->quantile), 0);
1131 if (qll->tau < 1) qll->tau = 1;
1132 }
1133 /* AL-GT */
1134 else {
1135 qll->algeq = 0;
1136 qll->tau = cov_count - (*qlls)[i - 1].tau + 1;
1137 }
1138
1139 RASTER_DEBUGF(4, "qll init: (algeq, quantile, count, tau, sum1, sum2) = (%d, %f, %d, %llu, %llu, %llu)",
1140 qll->algeq, qll->quantile, qll->count, qll->tau, qll->sum1, qll->sum2);
1141 RASTER_DEBUGF(4, "qll init: (head, tail) = (%p, %p)", qll->head, qll->tail);
1142 }
1143
1144 if (init_quantiles) rtdealloc(quantiles);
1145 }
1146
1147 /* clamp percentage */
1148 if (
1149 (sample < 0 || FLT_EQ(sample, 0.0)) ||
1150 (sample > 1 || FLT_EQ(sample, 1.0))
1151 ) {
1152 do_sample = 0;
1153 sample = 1;
1154 }
1155 else
1156 do_sample = 1;
1157 RASTER_DEBUGF(3, "do_sample = %d", do_sample);
1158
1159 /* sample all pixels */
1160 if (!do_sample) {
1161 sample_size = band->width * band->height;
1162 sample_per = band->height;
1163 }
1164 /*
1165 randomly sample a percentage of available pixels
1166 sampling method is known as
1167 "systematic random sample without replacement"
1168 */
1169 else {
1170 sample_size = round((band->width * band->height) * sample);
1171 sample_per = round(sample_size / band->width);
1172 sample_int = round(band->height / sample_per);
1173 srand(time(NULL));
1174 }
1175 RASTER_DEBUGF(3, "sampling %d of %d available pixels w/ %d per set"
1176 , sample_size, (band->width * band->height), sample_per);
1177
1178 for (x = 0, j = 0, k = 0; x < band->width; x++) {
1179 y = -1;
1180 diff = 0;
1181
1182 /* exclude_nodata_value = TRUE and band is NODATA */
1183 if (exclude_nodata_value && rt_band_get_isnodata_flag(band)) {
1184 RASTER_DEBUG(3, "Skipping quantile calculation as band is NODATA");
1185 break;
1186 }
1187
1188 for (i = 0, z = 0; i < sample_per; i++) {
1189 if (do_sample != 1)
1190 y = i;
1191 else {
1192 offset = (rand() % sample_int) + 1;
1193 y += diff + offset;
1194 diff = sample_int - offset;
1195 }
1196 RASTER_DEBUGF(5, "(x, y, z) = (%u, %lld, %u)", x, y, z);
1197 if (y >= band->height || z > sample_per) break;
1198
1199 status = rt_band_get_pixel(band, x, y, &value, &isnodata);
1200
1201 j++;
1202 if (status == ES_NONE && (!exclude_nodata_value || (exclude_nodata_value && !isnodata))) {
1203
1204 /* process each quantile */
1205 for (a = 0; a < *qlls_count; a++) {
1206 qll = &((*qlls)[a]);
1207 qls = NULL;
1208 RASTER_DEBUGF(4, "%d of %d (%f)", a + 1, *qlls_count, qll->quantile);
1209 RASTER_DEBUGF(5, "qll before: (algeq, quantile, count, tau, sum1, sum2) = (%d, %f, %d, %lld, %lld, %lld)",
1210 qll->algeq, qll->quantile, qll->count, qll->tau, qll->sum1, qll->sum2);
1211 RASTER_DEBUGF(5, "qll before: (head, tail) = (%p, %p)", qll->head, qll->tail);
1212
1213 /* OPTIMIZATION: shortcuts for quantiles of zero or one */
1214 if (FLT_EQ(qll->quantile, 0.)) {
1215 if (NULL != qll->head) {
1216 if (value < qll->head->value)
1217 qll->head->value = value;
1218 }
1219 else {
1220 qle = quantile_llist_insert(qll->head, value, NULL);
1221 qll->head = qle;
1222 qll->tail = qle;
1223 qll->count = 1;
1224 }
1225
1226 RASTER_DEBUGF(4, "quantile shortcut for %f\n\n", qll->quantile);
1227 continue;
1228 }
1229 else if (FLT_EQ(qll->quantile, 1.)) {
1230 if (NULL != qll->head) {
1231 if (value > qll->head->value)
1232 qll->head->value = value;
1233 }
1234 else {
1235 qle = quantile_llist_insert(qll->head, value, NULL);
1236 qll->head = qle;
1237 qll->tail = qle;
1238 qll->count = 1;
1239 }
1240
1241 RASTER_DEBUGF(4, "quantile shortcut for %f\n\n", qll->quantile);
1242 continue;
1243 }
1244
1245 /* value exists in list */
1246 /* OPTIMIZATION: check to see if value exceeds last value */
1247 if (NULL != qll->tail && value > qll->tail->value)
1248 qle = NULL;
1249 /* OPTIMIZATION: check to see if value equals last value */
1250 else if (NULL != qll->tail && FLT_EQ(value, qll->tail->value))
1251 qle = qll->tail;
1252 /* OPTIMIZATION: use index if possible */
1253 else {
1254 qls = quantile_llist_index_search(qll, value, &idx);
1255 qle = quantile_llist_search(qls, value);
1256 }
1257
1258 /* value found */
1259 if (NULL != qle) {
1260 RASTER_DEBUGF(4, "%f found in list", value);
1261 RASTER_DEBUGF(5, "qle before: (value, count) = (%f, %d)", qle->value, qle->count);
1262
1263 qle->count++;
1264 qll->sum1++;
1265
1266 if (qll->algeq)
1267 qll->sum2 = qll->sum1 - qll->head->count;
1268 else
1269 qll->sum2 = qll->sum1 - qll->tail->count;
1270
1271 RASTER_DEBUGF(4, "qle after: (value, count) = (%f, %d)", qle->value, qle->count);
1272 }
1273 /* can still add element */
1274 else if (qll->count < MAX_VALUES) {
1275 RASTER_DEBUGF(4, "Adding %f to list", value);
1276
1277 /* insert */
1278 /* OPTIMIZATION: check to see if value exceeds last value */
1279 if (NULL != qll->tail && (value > qll->tail->value || FLT_EQ(value, qll->tail->value))) {
1280 idx = qll->count;
1281 qle = quantile_llist_insert(qll->tail, value, &idx);
1282 }
1283 /* OPTIMIZATION: use index if possible */
1284 else
1285 qle = quantile_llist_insert(qls, value, &idx);
1286 if (NULL == qle) return NULL;
1287 RASTER_DEBUGF(5, "value added at index: %d => %f", idx, value);
1288 qll->count++;
1289 qll->sum1++;
1290
1291 /* first element */
1292 if (NULL == qle->prev)
1293 qll->head = qle;
1294 /* last element */
1295 if (NULL == qle->next)
1296 qll->tail = qle;
1297
1298 if (qll->algeq)
1299 qll->sum2 = qll->sum1 - qll->head->count;
1300 else
1301 qll->sum2 = qll->sum1 - qll->tail->count;
1302
1303 /* index is only needed if there are at least 100 values */
1304 quantile_llist_index_update(qll, qle, idx);
1305
1306 RASTER_DEBUGF(5, "qle, prev, next, head, tail = %p, %p, %p, %p, %p", qle, qle->prev, qle->next, qll->head, qll->tail);
1307 }
1308 /* AL-GEQ */
1309 else if (qll->algeq) {
1310 RASTER_DEBUGF(4, "value, head->value = %f, %f", value, qll->head->value);
1311
1312 if (value < qll->head->value) {
1313 /* ignore value if test isn't true */
1314 if (qll->sum1 >= qll->tau) {
1315 RASTER_DEBUGF(4, "skipping %f", value);
1316 }
1317 else {
1318
1319 /* delete last element */
1320 RASTER_DEBUGF(4, "deleting %f from list", qll->tail->value);
1321 qle = qll->tail->prev;
1322 RASTER_DEBUGF(5, "to-be tail is %f with count %d", qle->value, qle->count);
1323 qle->count += qll->tail->count;
1326 qll->tail = qle;
1327 qll->count--;
1328 RASTER_DEBUGF(5, "tail is %f with count %d", qll->tail->value, qll->tail->count);
1329
1330 /* insert value */
1331 RASTER_DEBUGF(4, "adding %f to list", value);
1332 /* OPTIMIZATION: check to see if value exceeds last value */
1333 if (NULL != qll->tail && (value > qll->tail->value || FLT_EQ(value, qll->tail->value))) {
1334 idx = qll->count;
1335 qle = quantile_llist_insert(qll->tail, value, &idx);
1336 }
1337 /* OPTIMIZATION: use index if possible */
1338 else {
1339 qls = quantile_llist_index_search(qll, value, &idx);
1340 qle = quantile_llist_insert(qls, value, &idx);
1341 }
1342 if (NULL == qle) return NULL;
1343 RASTER_DEBUGF(5, "value added at index: %d => %f", idx, value);
1344 qll->count++;
1345 qll->sum1++;
1346
1347 /* first element */
1348 if (NULL == qle->prev)
1349 qll->head = qle;
1350 /* last element */
1351 if (NULL == qle->next)
1352 qll->tail = qle;
1353
1354 qll->sum2 = qll->sum1 - qll->head->count;
1355
1356 quantile_llist_index_update(qll, qle, idx);
1357
1358 RASTER_DEBUGF(5, "qle, head, tail = %p, %p, %p", qle, qll->head, qll->tail);
1359
1360 }
1361 }
1362 else {
1363 qle = qll->tail;
1364 while (NULL != qle) {
1365 if (qle->value < value) {
1366 qle->count++;
1367 qll->sum1++;
1368 qll->sum2 = qll->sum1 - qll->head->count;
1369 RASTER_DEBUGF(4, "incremented count of %f by 1 to %d", qle->value, qle->count);
1370 break;
1371 }
1372
1373 qle = qle->prev;
1374 }
1375 }
1376 }
1377 /* AL-GT */
1378 else {
1379 RASTER_DEBUGF(4, "value, tail->value = %f, %f", value, qll->tail->value);
1380
1381 if (value > qll->tail->value) {
1382 /* ignore value if test isn't true */
1383 if (qll->sum1 >= qll->tau) {
1384 RASTER_DEBUGF(4, "skipping %f", value);
1385 }
1386 else {
1387
1388 /* delete last element */
1389 RASTER_DEBUGF(4, "deleting %f from list", qll->head->value);
1390 qle = qll->head->next;
1391 RASTER_DEBUGF(5, "to-be tail is %f with count %d", qle->value, qle->count);
1392 qle->count += qll->head->count;
1395 qll->head = qle;
1396 qll->count--;
1397 quantile_llist_index_update(qll, NULL, 0);
1398 RASTER_DEBUGF(5, "tail is %f with count %d", qll->head->value, qll->head->count);
1399
1400 /* insert value */
1401 RASTER_DEBUGF(4, "adding %f to list", value);
1402 /* OPTIMIZATION: check to see if value exceeds last value */
1403 if (NULL != qll->tail && (value > qll->tail->value || FLT_EQ(value, qll->tail->value))) {
1404 idx = qll->count;
1405 qle = quantile_llist_insert(qll->tail, value, &idx);
1406 }
1407 /* OPTIMIZATION: use index if possible */
1408 else {
1409 qls = quantile_llist_index_search(qll, value, &idx);
1410 qle = quantile_llist_insert(qls, value, &idx);
1411 }
1412 if (NULL == qle) return NULL;
1413 RASTER_DEBUGF(5, "value added at index: %d => %f", idx, value);
1414 qll->count++;
1415 qll->sum1++;
1416
1417 /* first element */
1418 if (NULL == qle->prev)
1419 qll->head = qle;
1420 /* last element */
1421 if (NULL == qle->next)
1422 qll->tail = qle;
1423
1424 qll->sum2 = qll->sum1 - qll->tail->count;
1425
1426 quantile_llist_index_update(qll, qle, idx);
1427
1428 RASTER_DEBUGF(5, "qle, head, tail = %p, %p, %p", qle, qll->head, qll->tail);
1429
1430 }
1431 }
1432 else {
1433 qle = qll->head;
1434 while (NULL != qle) {
1435 if (qle->value > value) {
1436 qle->count++;
1437 qll->sum1++;
1438 qll->sum2 = qll->sum1 - qll->tail->count;
1439 RASTER_DEBUGF(4, "incremented count of %f by 1 to %d", qle->value, qle->count);
1440 break;
1441 }
1442
1443 qle = qle->next;
1444 }
1445 }
1446 }
1447
1448 RASTER_DEBUGF(5, "sum2, tau = %lld, %lld", qll->sum2, qll->tau);
1449 if (qll->sum2 >= qll->tau) {
1450 /* AL-GEQ */
1451 if (qll->algeq) {
1452 RASTER_DEBUGF(4, "deleting first element %f from list", qll->head->value);
1453
1454 if (NULL != qll->head->next) {
1455 qle = qll->head->next;
1456 qll->sum1 -= qll->head->count;
1457 qll->sum2 = qll->sum1 - qle->count;
1460 qll->head = qle;
1461 qll->count--;
1462
1463 quantile_llist_index_update(qll, NULL, 0);
1464 }
1465 else {
1467 qll->head = NULL;
1468 qll->tail = NULL;
1469 qll->sum1 = 0;
1470 qll->sum2 = 0;
1471 qll->count = 0;
1472
1474 }
1475 }
1476 /* AL-GT */
1477 else {
1478 RASTER_DEBUGF(4, "deleting first element %f from list", qll->tail->value);
1479
1480 if (NULL != qll->tail->prev) {
1481 qle = qll->tail->prev;
1482 qll->sum1 -= qll->tail->count;
1483 qll->sum2 = qll->sum1 - qle->count;
1486 qll->tail = qle;
1487 qll->count--;
1488 }
1489 else {
1491 qll->head = NULL;
1492 qll->tail = NULL;
1493 qll->sum1 = 0;
1494 qll->sum2 = 0;
1495 qll->count = 0;
1496
1498 }
1499 }
1500 }
1501
1502 RASTER_DEBUGF(5, "qll after: (algeq, quantile, count, tau, sum1, sum2) = (%d, %f, %d, %lld, %lld, %lld)",
1503 qll->algeq, qll->quantile, qll->count, qll->tau, qll->sum1, qll->sum2);
1504 RASTER_DEBUGF(5, "qll after: (head, tail) = (%p, %p)\n\n", qll->head, qll->tail);
1505 }
1506
1507 }
1508 else {
1509 RASTER_DEBUGF(5, "skipping value at (x, y) = (%u, %lld)", x, y);
1510 }
1511
1512 z++;
1513 }
1514 }
1515
1516 /* process quantiles */
1517 *rtn_count = *qlls_count / 2;
1518 rtn = rtalloc(sizeof(struct rt_quantile_t) * *rtn_count);
1519 if (NULL == rtn) return NULL;
1520
1521 RASTER_DEBUGF(3, "returning %d quantiles", *rtn_count);
1522 for (i = 0, k = 0; i < *qlls_count; i++) {
1523 qll = &((*qlls)[i]);
1524
1525 exists = 0;
1526 for (x = 0; x < k; x++) {
1527 if (FLT_EQ(qll->quantile, rtn[x].quantile)) {
1528 exists = 1;
1529 break;
1530 }
1531 }
1532 if (exists) continue;
1533
1534 RASTER_DEBUGF(5, "qll: (algeq, quantile, count, tau, sum1, sum2) = (%d, %f, %d, %lld, %lld, %lld)",
1535 qll->algeq, qll->quantile, qll->count, qll->tau, qll->sum1, qll->sum2);
1536 RASTER_DEBUGF(5, "qll: (head, tail) = (%p, %p)", qll->head, qll->tail);
1537
1538 rtn[k].quantile = qll->quantile;
1539 rtn[k].has_value = 0;
1540
1541 /* check that qll->head and qll->tail have value */
1542 if (qll->head == NULL || qll->tail == NULL)
1543 continue;
1544
1545 /* AL-GEQ */
1546 if (qll->algeq)
1547 qle = qll->head;
1548 /* AM-GT */
1549 else
1550 qle = qll->tail;
1551
1552 exists = 0;
1553 for (j = i + 1; j < *qlls_count; j++) {
1554 if (FLT_EQ((*qlls)[j].quantile, qll->quantile)) {
1555
1556 RASTER_DEBUGF(5, "qlls[%d]: (algeq, quantile, count, tau, sum1, sum2) = (%d, %f, %d, %lld, %lld, %lld)",
1557 j, (*qlls)[j].algeq, (*qlls)[j].quantile, (*qlls)[j].count, (*qlls)[j].tau, (*qlls)[j].sum1, (*qlls)[j].sum2);
1558 RASTER_DEBUGF(5, "qlls[%d]: (head, tail) = (%p, %p)", j, (*qlls)[j].head, (*qlls)[j].tail);
1559
1560 exists = 1;
1561 break;
1562 }
1563 }
1564
1565 /* weighted average for quantile */
1566 if (exists) {
1567 if ((*qlls)[j].algeq) {
1568 rtn[k].value = ((qle->value * qle->count) + ((*qlls)[j].head->value * (*qlls)[j].head->count)) / (qle->count + (*qlls)[j].head->count);
1569 RASTER_DEBUGF(5, "qlls[%d].head: (value, count) = (%f, %d)", j, (*qlls)[j].head->value, (*qlls)[j].head->count);
1570 }
1571 else {
1572 rtn[k].value = ((qle->value * qle->count) + ((*qlls)[j].tail->value * (*qlls)[j].tail->count)) / (qle->count + (*qlls)[j].tail->count);
1573 RASTER_DEBUGF(5, "qlls[%d].tail: (value, count) = (%f, %d)", j, (*qlls)[j].tail->value, (*qlls)[j].tail->count);
1574 }
1575 }
1576 /* straight value for quantile */
1577 else {
1578 rtn[k].value = qle->value;
1579 }
1580 rtn[k].has_value = 1;
1581 RASTER_DEBUGF(3, "(quantile, value) = (%f, %f)\n\n", rtn[k].quantile, rtn[k].value);
1582
1583 k++;
1584 }
1585
1586 RASTER_DEBUG(3, "done");
1587 return rtn;
1588}
void rterror(const char *fmt,...) __attribute__((format(printf
Wrappers used for reporting errors and info.
void * rtalloc(size_t size)
Wrappers used for managing memory.
Definition rt_context.c:191
#define RASTER_DEBUG(level, msg)
Definition librtcore.h:304
#define RASTER_DEBUGF(level, msg,...)
Definition librtcore.h:308
int rt_band_get_hasnodata_flag(rt_band band)
Get hasnodata flag value.
Definition rt_band.c:833
void * rt_band_get_data(rt_band band)
Get pointer to raster band data.
Definition rt_band.c:559
#define ROUND(x, y)
Definition librtcore.h:2443
rt_errorstate rt_band_get_pixel(rt_band band, int x, int y, double *value, int *nodata)
Get pixel value.
Definition rt_band.c:1551
int rt_band_get_isnodata_flag(rt_band band)
Get isnodata flag value.
Definition rt_band.c:873
#define FLT_EQ(x, y)
Definition librtcore.h:2436
@ ES_NONE
Definition librtcore.h:182
void rtdealloc(void *mem)
Definition rt_context.c:206
static struct quantile_llist_element * quantile_llist_index_search(struct quantile_llist *qll, double value, uint32_t *index)
static void quantile_llist_index_update(struct quantile_llist *qll, struct quantile_llist_element *qle, uint32_t idx)
static struct quantile_llist_element * quantile_llist_insert(struct quantile_llist_element *element, double value, uint32_t *idx)
static void quantile_llist_index_delete(struct quantile_llist *qll, struct quantile_llist_element *qle)
static struct quantile_llist_element * quantile_llist_search(struct quantile_llist_element *element, double needle)
static void quicksort(double *left, double *right)
static int quantile_llist_delete(struct quantile_llist_element *element)
static void quantile_llist_index_reset(struct quantile_llist *qll)
struct quantile_llist_element * prev
Definition librtcore.h:2615
struct quantile_llist_element * next
Definition librtcore.h:2616
uint32_t count
Definition librtcore.h:2601
uint64_t sum1
Definition librtcore.h:2607
uint64_t sum2
Definition librtcore.h:2608
uint32_t index_max
Definition librtcore.h:2605
struct quantile_llist_element * head
Definition librtcore.h:2599
struct quantile_llist_element * tail
Definition librtcore.h:2600
struct quantile_llist_index * index
Definition librtcore.h:2604
double quantile
Definition librtcore.h:2588
uint32_t has_value
Definition librtcore.h:2590

References quantile_llist::algeq, quantile_llist::count, quantile_llist_element::count, ES_NONE, FLT_EQ, rt_quantile_t::has_value, quantile_llist::head, quantile_llist::index, quantile_llist::index_max, quantile_llist_element::next, quantile_llist_element::prev, rt_quantile_t::quantile, quantile_llist::quantile, quantile_llist_delete(), quantile_llist_index_delete(), quantile_llist_index_reset(), quantile_llist_index_search(), quantile_llist_index_update(), quantile_llist_insert(), quantile_llist_search(), quicksort(), RASTER_DEBUG, RASTER_DEBUGF, ROUND, rt_band_get_data(), rt_band_get_hasnodata_flag(), rt_band_get_isnodata_flag(), rt_band_get_pixel(), rtalloc(), rtdealloc(), rterror(), quantile_llist::sum1, quantile_llist::sum2, quantile_llist::tail, quantile_llist::tau, rt_quantile_t::value, and quantile_llist_element::value.

Referenced by test_band_stats().

Here is the call graph for this function:
Here is the caller graph for this function: