145 #include <config_auto.h>
149 #include "allheaders.h"
179 l_float32 val1, val2;
181 PROCNAME(
"numaArithOp");
184 return (
NUMA *)ERROR_PTR(
"na1, na2 not both defined", procName, nad);
187 return (
NUMA *)ERROR_PTR(
"na1, na2 sizes differ", procName, nad);
188 if (nad && nad != na1)
189 return (
NUMA *)ERROR_PTR(
"nad defined but not in-place", procName, nad);
190 if (op != L_ARITH_ADD && op != L_ARITH_SUBTRACT &&
191 op != L_ARITH_MULTIPLY && op != L_ARITH_DIVIDE)
192 return (
NUMA *)ERROR_PTR(
"invalid op", procName, nad);
193 if (op == L_ARITH_DIVIDE) {
194 for (i = 0; i < n; i++) {
197 return (
NUMA *)ERROR_PTR(
"na2 has 0 element", procName, nad);
205 for (i = 0; i < n; i++) {
212 case L_ARITH_SUBTRACT:
215 case L_ARITH_MULTIPLY:
258 l_int32 i, n, val1, val2, val;
260 PROCNAME(
"numaLogicalOp");
263 return (
NUMA *)ERROR_PTR(
"na1, na2 not both defined", procName, nad);
266 return (
NUMA *)ERROR_PTR(
"na1, na2 sizes differ", procName, nad);
267 if (nad && nad != na1)
268 return (
NUMA *)ERROR_PTR(
"nad defined; not in-place", procName, nad);
269 if (op != L_UNION && op != L_INTERSECTION &&
270 op != L_SUBTRACTION && op != L_EXCLUSIVE_OR)
271 return (
NUMA *)ERROR_PTR(
"invalid op", procName, nad);
277 for (i = 0; i < n; i++) {
280 val1 = (val1 == 0) ? 0 : 1;
281 val2 = (val2 == 0) ? 0 : 1;
284 val = (val1 || val2) ? 1 : 0;
288 val = (val1 && val2) ? 1 : 0;
292 val = (val1 && !val2) ? 1 : 0;
296 val = (val1 != val2) ? 1 : 0;
331 PROCNAME(
"numaInvert");
334 return (
NUMA *)ERROR_PTR(
"nas not defined", procName, nad);
335 if (nad && nad != nas)
336 return (
NUMA *)ERROR_PTR(
"nad defined; not in-place", procName, nad);
341 for (i = 0; i < n; i++) {
376 l_float32 val1, val2;
378 PROCNAME(
"numaSimilar");
381 return ERROR_INT(
"&similar not defined", procName, 1);
384 return ERROR_INT(
"na1 and na2 not both defined", procName, 1);
385 maxdiff = L_ABS(maxdiff);
390 for (i = 0; i < n; i++) {
393 if (L_ABS(val1 - val2) > maxdiff)
return 0;
425 PROCNAME(
"numaAddToNumber");
428 return ERROR_INT(
"na not defined", procName, 1);
430 return ERROR_INT(
"na is empty", procName, 1);
431 if (index < 0 || index >= n) {
432 L_ERROR(
"index %d not in [0,...,%d]\n", procName, index, n - 1);
436 na->
array[index] += val;
457 l_int32 i, n, iminloc;
458 l_float32 val, minval;
460 PROCNAME(
"numaGetMin");
462 if (!pminval && !piminloc)
463 return ERROR_INT(
"nothing to do", procName, 1);
464 if (pminval) *pminval = 0.0;
465 if (piminloc) *piminloc = 0;
467 return ERROR_INT(
"na not defined", procName, 1);
469 return ERROR_INT(
"na is empty", procName, 1);
471 minval = +1000000000.;
473 for (i = 0; i < n; i++) {
481 if (pminval) *pminval = minval;
482 if (piminloc) *piminloc = iminloc;
500 l_int32 i, n, imaxloc;
501 l_float32 val, maxval;
503 PROCNAME(
"numaGetMax");
505 if (!pmaxval && !pimaxloc)
506 return ERROR_INT(
"nothing to do", procName, 1);
507 if (pmaxval) *pmaxval = 0.0;
508 if (pimaxloc) *pimaxloc = 0;
510 return ERROR_INT(
"na not defined", procName, 1);
512 return ERROR_INT(
"na is empty", procName, 1);
514 maxval = -1000000000.;
516 for (i = 0; i < n; i++) {
524 if (pmaxval) *pmaxval = maxval;
525 if (pimaxloc) *pimaxloc = imaxloc;
544 PROCNAME(
"numaGetSum");
547 return ERROR_INT(
"&sum not defined", procName, 1);
550 return ERROR_INT(
"na not defined", procName, 1);
553 return ERROR_INT(
"na is empty", procName, 1);
555 for (i = 0; i < n; i++) {
585 PROCNAME(
"numaGetPartialSums");
588 return (
NUMA *)ERROR_PTR(
"na not defined", procName, NULL);
591 L_WARNING(
"na is empty\n", procName);
594 for (i = 0; i < n; i++) {
621 PROCNAME(
"numaGetSumOnInterval");
624 return ERROR_INT(
"&sum not defined", procName, 1);
627 return ERROR_INT(
"na not defined", procName, 1);
631 return ERROR_INT(
"na is empty", procName, 1);
632 if (first < 0) first = 0;
633 if (first >= n || last < -1)
637 last = L_MIN(last, n - 1);
639 for (i = first; i <= last; i++) {
662 PROCNAME(
"numaHasOnlyIntegers");
665 return ERROR_INT(
"&allints not defined", procName, 1);
668 return ERROR_INT(
"na not defined", procName, 1);
671 return ERROR_INT(
"na is empty", procName, 1);
672 for (i = 0; i < n; i ++) {
674 if (val != (l_int32)val) {
697 PROCNAME(
"numaGetMean");
700 return ERROR_INT(
"&ave not defined", procName, 1);
703 return ERROR_INT(
"na not defined", procName, 1);
705 return ERROR_INT(
"na is empty", procName, 1);
726 PROCNAME(
"numaGetMeanAbsval");
729 return ERROR_INT(
"&aveabs not defined", procName, 1);
732 return ERROR_INT(
"na not defined", procName, 1);
734 return ERROR_INT(
"na is empty", procName, 1);
758 PROCNAME(
"numaSubsample");
761 return (
NUMA *)ERROR_PTR(
"nas not defined", procName, NULL);
763 return (
NUMA *)ERROR_PTR(
"subfactor < 1", procName, NULL);
767 L_WARNING(
"nas is empty\n", procName);
768 for (i = 0; i < n; i++) {
769 if (i % subfactor != 0)
continue;
792 PROCNAME(
"numaMakeDelta");
795 return (
NUMA *)ERROR_PTR(
"nas not defined", procName, NULL);
797 L_WARNING(
"n < 2; returning empty numa\n", procName);
803 for (i = 1; i < n; i++) {
829 PROCNAME(
"numaMakeSequence");
832 return (
NUMA *)ERROR_PTR(
"na not made", procName, NULL);
834 for (i = 0; i < size; i++) {
835 val = startval + i * increment;
873 PROCNAME(
"numaMakeAbsval");
876 return (
NUMA *)ERROR_PTR(
"nas not defined", procName, NULL);
877 if (nad && nad != nas)
878 return (
NUMA *)ERROR_PTR(
"nad and not in-place", procName, NULL);
883 for (i = 0; i < n; i++) {
885 nad->
array[i] = L_ABS(val);
908 l_float32 startx, delx;
909 l_float32 *fas, *fad;
912 PROCNAME(
"numaAddBorder");
915 return (
NUMA *)ERROR_PTR(
"nas not defined", procName, NULL);
916 if (left < 0) left = 0;
917 if (right < 0) right = 0;
918 if (left == 0 && right == 0)
922 len = n + left + right;
928 for (i = 0; i < n; i++)
929 fad[left + i] = fas[i];
954 PROCNAME(
"numaAddSpecifiedBorder");
957 return (
NUMA *)ERROR_PTR(
"nas not defined", procName, NULL);
958 if (left < 0) left = 0;
959 if (right < 0) right = 0;
960 if (left == 0 && right == 0)
963 return (
NUMA *)ERROR_PTR(
"invalid type", procName, NULL);
966 return (
NUMA *)ERROR_PTR(
"border too large", procName, NULL);
972 for (i = 0; i < left; i++)
974 for (i = n - right; i < n; i++)
975 fa[i] = fa[n - right - 1];
977 for (i = 0; i < left; i++)
978 fa[i] = fa[2 * left - 1 - i];
979 for (i = 0; i < right; i++)
980 fa[n - right + i] = fa[n - right - i - 1];
1001 l_float32 startx, delx;
1002 l_float32 *fas, *fad;
1005 PROCNAME(
"numaRemoveBorder");
1008 return (
NUMA *)ERROR_PTR(
"nas not defined", procName, NULL);
1009 if (left < 0) left = 0;
1010 if (right < 0) right = 0;
1011 if (left == 0 && right == 0)
1015 if ((len = n - left - right) < 0)
1016 return (
NUMA *)ERROR_PTR(
"len < 0 after removal", procName, NULL);
1022 for (i = 0; i < len; i++)
1023 fad[i] = fas[left + i];
1040 l_int32 n, i, val, count, inrun;
1042 PROCNAME(
"numaCountNonzeroRuns");
1045 return ERROR_INT(
"&count not defined", procName, 1);
1048 return ERROR_INT(
"na not defined", procName, 1);
1050 return ERROR_INT(
"na is empty", procName, 1);
1054 for (i = 0; i < n; i++) {
1056 if (!inrun && val > 0) {
1059 }
else if (inrun && val == 0) {
1083 l_int32 n, i, found;
1086 PROCNAME(
"numaGetNonzeroRange");
1088 if (pfirst) *pfirst = 0;
1089 if (plast) *plast = 0;
1090 if (!pfirst || !plast)
1091 return ERROR_INT(
"pfirst and plast not both defined", procName, 1);
1093 return ERROR_INT(
"na not defined", procName, 1);
1095 return ERROR_INT(
"na is empty", procName, 1);
1098 for (i = 0; i < n; i++) {
1112 for (i = n - 1; i >= 0; i--) {
1135 l_int32 n, i, count;
1138 PROCNAME(
"numaGetCountRelativeToZero");
1141 return ERROR_INT(
"&count not defined", procName, 1);
1144 return ERROR_INT(
"na not defined", procName, 1);
1146 return ERROR_INT(
"na is empty", procName, 1);
1148 for (i = 0, count = 0; i < n; i++) {
1187 l_float32 val, startx, delx;
1190 PROCNAME(
"numaClipToInterval");
1193 return (
NUMA *)ERROR_PTR(
"nas not defined", procName, NULL);
1195 return (
NUMA *)ERROR_PTR(
"nas is empty", procName, NULL);
1196 if (first < 0 || first > last)
1197 return (
NUMA *)ERROR_PTR(
"range not valid", procName, NULL);
1199 return (
NUMA *)ERROR_PTR(
"no elements in range", procName, NULL);
1201 last = L_MIN(last, n - 1);
1202 if ((nad =
numaCreate(last - first + 1)) == NULL)
1203 return (
NUMA *)ERROR_PTR(
"nad not made", procName, NULL);
1204 for (i = first; i <= last; i++) {
1239 PROCNAME(
"numaMakeThresholdIndicator");
1242 return (
NUMA *)ERROR_PTR(
"nas not defined", procName, NULL);
1244 return (
NUMA *)ERROR_PTR(
"nas is empty", procName, NULL);
1247 for (i = 0; i < n; i++) {
1253 if (fval < thresh) ival = 1;
1256 if (fval > thresh) ival = 1;
1259 if (fval <= thresh) ival = 1;
1262 if (fval >= thresh) ival = 1;
1266 return (
NUMA *)ERROR_PTR(
"invalid type", procName, NULL);
1292 l_int32 n, i, j, ileft, iright;
1293 l_float32 left, right, binsize, lfract, rfract, sum, startx, delx;
1297 PROCNAME(
"numaUniformSampling");
1300 return (
NUMA *)ERROR_PTR(
"nas not defined", procName, NULL);
1302 return (
NUMA *)ERROR_PTR(
"nas is empty", procName, NULL);
1304 return (
NUMA *)ERROR_PTR(
"nsamp must be > 0", procName, NULL);
1308 binsize = (l_float32)n / (l_float32)nsamp;
1312 for (i = 0; i < nsamp; i++) {
1314 right = left + binsize;
1315 ileft = (l_int32)left;
1316 lfract = 1.0 - left + ileft;
1319 iright = (l_int32)right;
1320 rfract = right - iright;
1321 iright = L_MIN(iright, n - 1);
1322 if (ileft == iright) {
1323 sum += (lfract + rfract - 1.0) * array[ileft];
1325 if (lfract > 0.0001)
1326 sum += lfract * array[ileft];
1327 if (rfract > 0.0001)
1328 sum += rfract * array[iright];
1329 for (j = ileft + 1; j < iright; j++)
1359 l_float32 val1, val2;
1361 PROCNAME(
"numaReverse");
1364 return (
NUMA *)ERROR_PTR(
"nas not defined", procName, NULL);
1365 if (nad && nas != nad)
1366 return (
NUMA *)ERROR_PTR(
"nad defined but != nas", procName, NULL);
1370 for (i = 0; i < n / 2; i++) {
1378 for (i = n - 1; i >= 0; i--) {
1414 l_int32 n, i, inrun;
1415 l_float32 maxval, threshval, fval, startx, delx, x0, x1;
1418 PROCNAME(
"numaLowPassIntervals");
1421 return (
NUMA *)ERROR_PTR(
"nas not defined", procName, NULL);
1423 return (
NUMA *)ERROR_PTR(
"nas is empty", procName, NULL);
1424 if (thresh < 0.0 || thresh > 1.0)
1425 return (
NUMA *)ERROR_PTR(
"invalid thresh", procName, NULL);
1434 threshval = thresh * maxval;
1440 for (i = 0; i < n; i++) {
1442 if (fval < threshval && inrun == FALSE) {
1444 x0 = startx + i * delx;
1445 }
else if (fval > threshval && inrun == TRUE) {
1447 x1 = startx + i * delx;
1452 if (inrun == TRUE) {
1453 x1 = startx + (n - 1) * delx;
1492 l_int32 n, i, istart, inband, output, sign;
1493 l_int32 startbelow, below, above, belowlast, abovelast;
1494 l_float32 maxval, threshval1, threshval2, fval, startx, delx, x0, x1;
1497 PROCNAME(
"numaThresholdEdges");
1500 return (
NUMA *)ERROR_PTR(
"nas not defined", procName, NULL);
1502 return (
NUMA *)ERROR_PTR(
"nas is empty", procName, NULL);
1503 if (thresh1 < 0.0 || thresh1 > 1.0 || thresh2 < 0.0 || thresh2 > 1.0)
1504 return (
NUMA *)ERROR_PTR(
"invalid thresholds", procName, NULL);
1505 if (thresh2 < thresh1)
1506 return (
NUMA *)ERROR_PTR(
"thresh2 < thresh1", procName, NULL);
1517 threshval1 = thresh1 * maxval;
1518 threshval2 = thresh2 * maxval;
1525 for (i = 0; i < n; i++) {
1528 belowlast = (fval < threshval1) ? TRUE : FALSE;
1529 abovelast = (fval > threshval2) ? TRUE : FALSE;
1530 if (belowlast == TRUE || abovelast == TRUE)
1541 startbelow = belowlast;
1543 x0 = startx + istart * delx;
1544 for (i = istart + 1; i < n; i++) {
1546 below = (fval < threshval1) ? TRUE : FALSE;
1547 above = (fval > threshval2) ? TRUE : FALSE;
1548 if (!inband && belowlast && above) {
1549 x1 = startx + i * delx;
1553 }
else if (!inband && abovelast && below) {
1554 x1 = startx + i * delx;
1558 }
else if (inband && startbelow && above) {
1559 x1 = startx + i * delx;
1564 }
else if (inband && !startbelow && below) {
1566 x1 = startx + i * delx;
1571 }
else if (inband && !startbelow && above) {
1572 x0 = startx + i * delx;
1574 }
else if (inband && startbelow && below) {
1575 x0 = startx + i * delx;
1577 }
else if (!inband && !above && !below) {
1579 startbelow = belowlast;
1580 }
else if (!inband && (above || below)) {
1581 x0 = startx + i * delx;
1590 x0 = startx + i * delx;
1615 PROCNAME(
"numaGetSpanValues");
1618 return ERROR_INT(
"na not defined", procName, 1);
1620 return ERROR_INT(
"na is empty", procName, 1);
1622 return ERROR_INT(
"n is not odd", procName, 1);
1624 if (nspans < 0 || span >= nspans)
1625 return ERROR_INT(
"invalid span", procName, 1);
1653 PROCNAME(
"numaGetEdgeValues");
1656 return ERROR_INT(
"na not defined", procName, 1);
1658 return ERROR_INT(
"na is empty", procName, 1);
1660 return ERROR_INT(
"n % 3 is not 1", procName, 1);
1661 nedges = (n - 1) / 3;
1662 if (edge < 0 || edge >= nedges)
1663 return ERROR_INT(
"invalid edge", procName, 1);
1710 l_int32 i, n, i1, i2, i3;
1711 l_float32 x1, x2, x3, fy1, fy2, fy3, d1, d2, d3, del, fi, maxx;
1714 PROCNAME(
"numaInterpolateEqxVal");
1717 return ERROR_INT(
"&yval not defined", procName, 1);
1720 return ERROR_INT(
"nay not defined", procName, 1);
1722 return ERROR_INT(
"deltax not > 0", procName, 1);
1724 return ERROR_INT(
"invalid interp type", procName, 1);
1726 return ERROR_INT(
"not enough points", procName, 1);
1729 L_WARNING(
"only 2 points; using linear interp\n", procName);
1731 maxx = startx + deltax * (n - 1);
1732 if (xval < startx || xval > maxx)
1733 return ERROR_INT(
"xval is out of bounds", procName, 1);
1736 fi = (xval - startx) / deltax;
1745 *pyval = fa[i] + del * (fa[i + 1] - fa[i]);
1750 d1 = d3 = 0.5 / (deltax * deltax);
1761 x1 = startx + i1 * deltax;
1762 x2 = startx + i2 * deltax;
1763 x3 = startx + i3 * deltax;
1767 *pyval = fy1 * (xval - x2) * (xval - x3) +
1768 fy2 * (xval - x1) * (xval - x3) +
1769 fy3 * (xval - x1) * (xval - x2);
1801 l_int32 i, im, nx, ny, i1, i2, i3;
1802 l_float32 delu, dell, fract, d1, d2, d3;
1803 l_float32 minx, maxx;
1804 l_float32 *fax, *fay;
1806 PROCNAME(
"numaInterpolateArbxVal");
1809 return ERROR_INT(
"&yval not defined", procName, 1);
1812 return ERROR_INT(
"nax not defined", procName, 1);
1814 return ERROR_INT(
"nay not defined", procName, 1);
1816 return ERROR_INT(
"invalid interp type", procName, 1);
1820 return ERROR_INT(
"nax and nay not same size arrays", procName, 1);
1822 return ERROR_INT(
"not enough points", procName, 1);
1825 L_WARNING(
"only 2 points; using linear interp\n", procName);
1829 if (xval < minx || xval > maxx)
1830 return ERROR_INT(
"xval is out of bounds", procName, 1);
1838 if (xval == fax[0]) {
1844 for (i = 1; i < nx; i++) {
1845 delu = fax[i] - xval;
1852 dell = xval - fax[im];
1856 fract = dell / (fax[i] - fax[im]);
1859 *pyval = fay[i] + fract * (fay[i + 1] - fay[i]);
1873 d1 = (fax[i1] - fax[i2]) * (fax[i1] - fax[i3]);
1874 d2 = (fax[i2] - fax[i1]) * (fax[i2] - fax[i3]);
1875 d3 = (fax[i3] - fax[i1]) * (fax[i3] - fax[i2]);
1876 *pyval = fay[i1] * (xval - fax[i2]) * (xval - fax[i3]) / d1 +
1877 fay[i2] * (xval - fax[i1]) * (xval - fax[i3]) / d2 +
1878 fay[i3] * (xval - fax[i1]) * (xval - fax[i2]) / d3;
1923 l_float32 x, yval, maxx, delx;
1926 PROCNAME(
"numaInterpolateEqxInterval");
1928 if (pnax) *pnax = NULL;
1930 return ERROR_INT(
"&nay not defined", procName, 1);
1933 return ERROR_INT(
"nasy not defined", procName, 1);
1935 return ERROR_INT(
"n < 2", procName, 1);
1937 return ERROR_INT(
"deltax not > 0", procName, 1);
1939 return ERROR_INT(
"invalid interp type", procName, 1);
1942 L_WARNING(
"only 2 points; using linear interp\n", procName);
1944 maxx = startx + deltax * (n - 1);
1945 if (x0 < startx || x1 > maxx || x1 <= x0)
1946 return ERROR_INT(
"[x0 ... x1] is not valid", procName, 1);
1948 return ERROR_INT(
"npts < 3", procName, 1);
1949 delx = (x1 - x0) / (l_float32)(npts - 1);
1952 return ERROR_INT(
"nay not made", procName, 1);
1960 for (i = 0; i < npts; i++) {
2010 l_int32 i, im, j, nx, ny, i1, i2, i3, sorted;
2012 l_float32 del, xval, yval, excess, fract, minx, maxx, d1, d2, d3;
2013 l_float32 *fax, *fay;
2014 NUMA *nasx, *nasy, *nadx, *nady;
2016 PROCNAME(
"numaInterpolateArbxInterval");
2018 if (pnadx) *pnadx = NULL;
2020 return ERROR_INT(
"&nady not defined", procName, 1);
2023 return ERROR_INT(
"nay not defined", procName, 1);
2025 return ERROR_INT(
"nax not defined", procName, 1);
2027 return ERROR_INT(
"invalid interp type", procName, 1);
2029 return ERROR_INT(
"x0 > x1", procName, 1);
2033 return ERROR_INT(
"nax and nay not same size arrays", procName, 1);
2035 return ERROR_INT(
"not enough points", procName, 1);
2038 L_WARNING(
"only 2 points; using linear interp\n", procName);
2042 if (x0 < minx || x1 > maxx)
2043 return ERROR_INT(
"xval is out of bounds", procName, 1);
2048 L_WARNING(
"we are sorting nax in increasing order\n", procName);
2059 if ((index = (l_int32 *)LEPT_CALLOC(npts,
sizeof(l_int32))) == NULL) {
2062 return ERROR_INT(
"ind not made", procName, 1);
2064 del = (x1 - x0) / (npts - 1.0);
2065 for (i = 0, j = 0; j < nx && i < npts; i++) {
2066 xval = x0 + i * del;
2067 while (j < nx - 1 && xval > fax[j])
2070 index[i] = L_MIN(j, nx - 1);
2072 index[i] = L_MAX(j - 1, 0);
2082 for (i = 0; i < npts; i++) {
2083 xval = x0 + i * del;
2087 excess = xval - fax[im];
2088 if (excess == 0.0) {
2092 fract = excess / (fax[im + 1] - fax[im]);
2095 yval = fay[im] + fract * (fay[im + 1] - fay[im]);
2110 d1 = (fax[i1] - fax[i2]) * (fax[i1] - fax[i3]);
2111 d2 = (fax[i2] - fax[i1]) * (fax[i2] - fax[i3]);
2112 d3 = (fax[i3] - fax[i1]) * (fax[i3] - fax[i2]);
2113 yval = fay[i1] * (xval - fax[i2]) * (xval - fax[i3]) / d1 +
2114 fay[i2] * (xval - fax[i1]) * (xval - fax[i3]) / d2 +
2115 fay[i3] * (xval - fax[i1]) * (xval - fax[i2]) / d3;
2170 l_float32 x1, x2, x3, y1, y2, y3, c1, c2, c3, a, b, xmax, ymax;
2172 PROCNAME(
"numaFitMax");
2174 if (pmaxval) *pmaxval = 0.0;
2175 if (pmaxloc) *pmaxloc = 0.0;
2177 return ERROR_INT(
"na not defined", procName, 1);
2179 return ERROR_INT(
"na is empty", procName, 1);
2181 return ERROR_INT(
"&maxval not defined", procName, 1);
2183 return ERROR_INT(
"&maxloc not defined", procName, 1);
2186 return ERROR_INT(
"na and naloc of unequal size", procName, 1);
2192 if (imaxloc == 0 || imaxloc == n - 1) {
2224 if (x1 == x2 || x1 == x3 || x2 == x3) {
2231 c1 = y1 / ((x1 - x2) * (x1 - x3));
2232 c2 = y2 / ((x2 - x1) * (x2 - x3));
2233 c3 = y3 / ((x3 - x1) * (x3 - x2));
2235 b = c1 * (x2 + x3) + c2 * (x1 + x3) + c3 * (x1 + x2);
2237 ymax = c1 * (xmax - x2) * (xmax - x3) +
2238 c2 * (xmax - x1) * (xmax - x3) +
2239 c3 * (xmax - x1) * (xmax - x2);
2277 l_float32 minx, maxx, der, invdel;
2281 PROCNAME(
"numaDifferentiateInterval");
2283 if (pnadx) *pnadx = NULL;
2285 return ERROR_INT(
"&nady not defined", procName, 1);
2288 return ERROR_INT(
"nay not defined", procName, 1);
2290 return ERROR_INT(
"nax not defined", procName, 1);
2292 return ERROR_INT(
"x0 > x1", procName, 1);
2296 return ERROR_INT(
"nax and nay not same size arrays", procName, 1);
2298 return ERROR_INT(
"not enough points", procName, 1);
2301 if (x0 < minx || x1 > maxx)
2302 return ERROR_INT(
"xval is out of bounds", procName, 1);
2304 return ERROR_INT(
"npts < 2", procName, 1);
2308 npts, pnadx, &naiy))
2309 return ERROR_INT(
"interpolation failed", procName, 1);
2313 invdel = 0.5 * ((l_float32)npts - 1.0) / (x1 - x0);
2317 der = 0.5 * invdel * (fay[1] - fay[0]);
2319 for (i = 1; i < npts - 1; i++) {
2320 der = invdel * (fay[i + 1] - fay[i - 1]);
2323 der = 0.5 * invdel * (fay[npts - 1] - fay[npts - 2]);
2359 l_float32 minx, maxx, sum, del;
2363 PROCNAME(
"numaIntegrateInterval");
2366 return ERROR_INT(
"&sum not defined", procName, 1);
2369 return ERROR_INT(
"nay not defined", procName, 1);
2371 return ERROR_INT(
"nax not defined", procName, 1);
2373 return ERROR_INT(
"x0 > x1", procName, 1);
2375 return ERROR_INT(
"npts < 2", procName, 1);
2379 return ERROR_INT(
"nax and nay not same size arrays", procName, 1);
2381 return ERROR_INT(
"not enough points", procName, 1);
2384 if (x0 < minx || x1 > maxx)
2385 return ERROR_INT(
"xval is out of bounds", procName, 1);
2390 return ERROR_INT(
"interpolation failed", procName, 1);
2392 del = (x1 - x0) / ((l_float32)npts - 1.0);
2396 sum = 0.5 * (fay[0] + fay[npts - 1]);
2397 for (i = 1; i < npts - 1; i++)
2465 NUMA *naindex = NULL;
2467 PROCNAME(
"numaSortGeneral");
2469 if (pnasort) *pnasort = NULL;
2470 if (pnaindex) *pnaindex = NULL;
2471 if (pnainvert) *pnainvert = NULL;
2473 return ERROR_INT(
"na not defined", procName, 1);
2475 return ERROR_INT(
"invalid sort order", procName, 1);
2477 return ERROR_INT(
"invalid sort type", procName, 1);
2478 if (!pnasort && !pnaindex && !pnainvert)
2479 return ERROR_INT(
"nothing to do", procName, 1);
2483 isize = (l_int32)size;
2484 if (isize > MaxInitPtraSize - 1) {
2485 L_WARNING(
"array too large; using shell sort\n", procName);
2500 *pnaindex = naindex;
2526 PROCNAME(
"numaSortAutoSelect");
2529 return (
NUMA *)ERROR_PTR(
"nas not defined", procName, NULL);
2531 L_WARNING(
"nas is empty; returning copy\n", procName);
2535 return (
NUMA *)ERROR_PTR(
"invalid sort order", procName, NULL);
2539 return (
NUMA *)ERROR_PTR(
"invalid sort type", procName, NULL);
2544 return numaSort(NULL, nas, sortorder);
2567 PROCNAME(
"numaSortIndexAutoSelect");
2570 return (
NUMA *)ERROR_PTR(
"nas not defined", procName, NULL);
2572 L_WARNING(
"nas is empty; returning copy\n", procName);
2576 return (
NUMA *)ERROR_PTR(
"invalid sort order", procName, NULL);
2579 return (
NUMA *)ERROR_PTR(
"invalid sort type", procName, NULL);
2605 l_float32 minval, maxval;
2607 PROCNAME(
"numaChooseSortType");
2610 return ERROR_INT(
"nas not defined", procName, UNDEF);
2615 if (minval < 0.0 || n < 200)
2620 if (maxval > MaxInitPtraSize - 1)
2627 if (n * log((l_float32)n) < 0.003 * maxval)
2654 l_int32 i, n, gap, j;
2658 PROCNAME(
"numaSort");
2661 return (
NUMA *)ERROR_PTR(
"nain not defined", procName, NULL);
2663 return (
NUMA *)ERROR_PTR(
"invalid sort order", procName, NULL);
2668 else if (nain != naout)
2669 return (
NUMA *)ERROR_PTR(
"invalid: not in-place", procName, NULL);
2671 L_WARNING(
"naout is empty\n", procName);
2674 array = naout->
array;
2678 for (gap = n/2; gap > 0; gap = gap / 2) {
2679 for (i = gap; i < n; i++) {
2680 for (j = i - gap; j >= 0; j -= gap) {
2682 array[j] > array[j + gap]) ||
2684 array[j] < array[j + gap]))
2687 array[j] = array[j + gap];
2688 array[j + gap] = tmp;
2723 PROCNAME(
"numaBinSort");
2726 return (
NUMA *)ERROR_PTR(
"nas not defined", procName, NULL);
2728 L_WARNING(
"nas is empty; returning copy\n", procName);
2732 return (
NUMA *)ERROR_PTR(
"invalid sort order", procName, NULL);
2735 return (
NUMA *)ERROR_PTR(
"bin sort failed", procName, NULL);
2754 l_int32 i, n, gap, j;
2760 PROCNAME(
"numaGetSortIndex");
2763 return (
NUMA *)ERROR_PTR(
"na not defined", procName, NULL);
2765 L_WARNING(
"na is empty\n", procName);
2769 return (
NUMA *)ERROR_PTR(
"invalid sortorder", procName, NULL);
2773 return (
NUMA *)ERROR_PTR(
"array not made", procName, NULL);
2774 if ((iarray = (l_float32 *)LEPT_CALLOC(n,
sizeof(l_float32))) == NULL) {
2776 return (
NUMA *)ERROR_PTR(
"iarray not made", procName, NULL);
2778 for (i = 0; i < n; i++)
2782 for (gap = n/2; gap > 0; gap = gap / 2) {
2783 for (i = gap; i < n; i++) {
2784 for (j = i - gap; j >= 0; j -= gap) {
2786 array[j] > array[j + gap]) ||
2788 array[j] < array[j + gap]))
2791 array[j] = array[j + gap];
2792 array[j + gap] = tmp;
2794 iarray[j] = iarray[j + gap];
2795 iarray[j + gap] = tmp;
2802 for (i = 0; i < n; i++)
2836 l_int32 i, n, isize, ival, imax;
2837 l_float32 minsize, size;
2838 NUMA *na, *nai, *nad;
2841 PROCNAME(
"numaGetBinSortIndex");
2844 return (
NUMA *)ERROR_PTR(
"nas not defined", procName, NULL);
2846 L_WARNING(
"nas is empty\n", procName);
2850 return (
NUMA *)ERROR_PTR(
"invalid sort order", procName, NULL);
2853 return (
NUMA *)ERROR_PTR(
"nas has negative numbers", procName, NULL);
2855 isize = (l_int32)size;
2856 if (isize > MaxInitPtraSize - 1) {
2857 L_ERROR(
"array too large: %d elements > max size = %d\n",
2858 procName, isize, MaxInitPtraSize - 1);
2872 for (i = 0; i < n; i++) {
2888 for (i = 0; i <= imax; i++) {
2895 for (i = imax; i >= 0; i--) {
2919 l_int32 i, n, ni, index;
2923 PROCNAME(
"numaSortByIndex");
2926 return (
NUMA *)ERROR_PTR(
"nas not defined", procName, NULL);
2928 return (
NUMA *)ERROR_PTR(
"naindex not defined", procName, NULL);
2932 return (
NUMA *)ERROR_PTR(
"numa sizes differ", procName, NULL);
2934 L_WARNING(
"nas is empty\n", procName);
2939 for (i = 0; i < n; i++) {
2970 l_float32 prevval, val;
2972 PROCNAME(
"numaIsSorted");
2975 return ERROR_INT(
"&sorted not defined", procName, 1);
2978 return ERROR_INT(
"nas not defined", procName, 1);
2980 L_WARNING(
"nas is empty\n", procName);
2985 return ERROR_INT(
"invalid sortorder", procName, 1);
2989 for (i = 1; i < n; i++) {
3026 PROCNAME(
"numaSortPair");
3028 if (pnasx) *pnasx = NULL;
3029 if (pnasy) *pnasy = NULL;
3030 if (!pnasx || !pnasy)
3031 return ERROR_INT(
"&nasx and/or &nasy not defined", procName, 1);
3033 return ERROR_INT(
"nax not defined", procName, 1);
3035 return ERROR_INT(
"nay not defined", procName, 1);
3037 return ERROR_INT(
"invalid sortorder", procName, 1);
3040 if (sorted == TRUE) {
3070 l_int32 i, n, val, error;
3074 PROCNAME(
"numaInvertMap");
3077 return (
NUMA *)ERROR_PTR(
"nas not defined", procName, NULL);
3079 L_WARNING(
"nas is empty\n", procName);
3084 test = (l_int32 *)LEPT_CALLOC(n,
sizeof(l_int32));
3086 for (i = 0; i < n; i++) {
3093 if (test[val] == 0) {
3104 return (
NUMA *)ERROR_PTR(
"nas not invertible", procName, NULL);
3129 PROCNAME(
"numaAddSorted");
3132 return ERROR_INT(
"na not defined", procName, 1);
3135 return ERROR_INT(
"insert failure", procName, 1);
3168 l_int32 n, increasing, lindex, rindex, midindex;
3169 l_float32 val0, valn, valmid;
3171 PROCNAME(
"numaFindSortedLoc");
3174 return ERROR_INT(
"&index not defined", procName, 1);
3177 return ERROR_INT(
"na not defined", procName, 1);
3180 if (n == 0)
return 0;
3190 increasing = (valn >= val0) ? 1 : 0;
3197 }
else if (val > valn) {
3205 }
else if (val < valn) {
3215 midindex = (lindex + rindex) / 2;
3216 if (midindex == lindex || midindex == rindex)
break;
3257 l_int32 i, index, temp;
3261 PROCNAME(
"numaPseudorandomSequence");
3264 return (
NUMA *)ERROR_PTR(
"size <= 0", procName, NULL);
3266 if ((array = (l_int32 *)LEPT_CALLOC(size,
sizeof(l_int32))) == NULL)
3267 return (
NUMA *)ERROR_PTR(
"array not made", procName, NULL);
3268 for (i = 0; i < size; i++)
3271 for (i = size - 1; i > 0; i--) {
3272 index = (l_int32)((i + 1) * ((l_float64)rand() / (l_float64)RAND_MAX));
3273 index = L_MIN(index, i);
3275 array[i] = array[index];
3276 array[index] = temp;
3296 l_int32 i, index, size;
3298 NUMA *naindex, *nad;
3300 PROCNAME(
"numaRandomPermutation");
3303 return (
NUMA *)ERROR_PTR(
"nas not defined", procName, NULL);
3305 L_WARNING(
"nas is empty\n", procName);
3311 for (i = 0; i < size; i++) {
3361 PROCNAME(
"numaGetRankValue");
3364 return ERROR_INT(
"&val not defined", procName, 1);
3367 return ERROR_INT(
"na not defined", procName, 1);
3369 return ERROR_INT(
"na empty", procName, 1);
3370 if (fract < 0.0 || fract > 1.0)
3371 return ERROR_INT(
"fract not in [0.0 ... 1.0]", procName, 1);
3381 return ERROR_INT(
"nas not made", procName, 1);
3383 index = (l_int32)(fract * (l_float32)(n - 1) + 0.5);
3408 PROCNAME(
"numaGetMedian");
3411 return ERROR_INT(
"&val not defined", procName, 1);
3414 return ERROR_INT(
"na not defined or empty", procName, 1);
3442 PROCNAME(
"numaGetBinnedMedian");
3445 return ERROR_INT(
"&val not defined", procName, 1);
3448 return ERROR_INT(
"na not defined or empty", procName, 1);
3472 PROCNAME(
"numaGetMeanDevFromMedian");
3475 return ERROR_INT(
"&dev not defined", procName, 1);
3478 return ERROR_INT(
"na not defined", procName, 1);
3480 return ERROR_INT(
"na is empty", procName, 1);
3483 for (i = 0; i < n; i++) {
3485 dev += L_ABS(val - med);
3487 *pdev = dev / (l_float32)n;
3519 PROCNAME(
"numaGetMedianDevFromMedian");
3521 if (pmed) *pmed = 0.0;
3523 return ERROR_INT(
"&dev not defined", procName, 1);
3526 return ERROR_INT(
"na not defined or empty", procName, 1);
3529 if (pmed) *pmed = med;
3532 for (i = 0; i < n; i++) {
3564 l_int32 i, n, maxcount, prevcount;
3565 l_float32 val, maxval, prevval;
3569 PROCNAME(
"numaGetMode");
3571 if (pcount) *pcount = 0;
3573 return ERROR_INT(
"&val not defined", procName, 1);
3576 return ERROR_INT(
"na not defined", procName, 1);
3578 return ERROR_INT(
"na is empty", procName, 1);
3581 return ERROR_INT(
"nas not made", procName, 1);
3588 maxcount = prevcount;
3591 for (i = 1; i < n; i++) {
3593 if (val == prevval) {
3596 if (prevcount > maxcount) {
3597 maxcount = prevcount;
3606 if (prevcount > maxcount) {
3607 maxcount = prevcount;
3648 PROCNAME(
"numaJoin");
3651 return ERROR_INT(
"nad not defined", procName, 1);
3658 if (iend < 0 || iend >= n)
3661 return ERROR_INT(
"istart > iend; nothing to add", procName, 1);
3663 for (i = istart; i <= iend; i++) {
3697 PROCNAME(
"numaaJoin");
3700 return ERROR_INT(
"naad not defined", procName, 1);
3707 if (iend < 0 || iend >= n)
3710 return ERROR_INT(
"istart > iend; nothing to add", procName, 1);
3712 for (i = istart; i <= iend; i++) {
3743 PROCNAME(
"numaaFlattenToNuma");
3746 return (
NUMA *)ERROR_PTR(
"naa not defined", procName, NULL);
3751 for (i = 0; i < nalloc; i++) {
l_ok numaAddNumber(NUMA *na, l_float32 val)
numaAddNumber()
l_ok numaReplaceNumber(NUMA *na, l_int32 index, l_float32 val)
numaReplaceNumber()
l_ok numaGetFValue(NUMA *na, l_int32 index, l_float32 *pval)
numaGetFValue()
NUMA ** numaaGetPtrArray(NUMAA *naa)
numaaGetPtrArray()
NUMA * numaCreate(l_int32 n)
numaCreate()
l_int32 numaaGetCount(NUMAA *naa)
numaaGetCount()
l_ok numaInsertNumber(NUMA *na, l_int32 index, l_float32 val)
numaInsertNumber()
NUMA * numaaGetNuma(NUMAA *naa, l_int32 index, l_int32 accessflag)
numaaGetNuma()
NUMA * numaClone(NUMA *na)
numaClone()
void numaDestroy(NUMA **pna)
numaDestroy()
l_ok numaSetValue(NUMA *na, l_int32 index, l_float32 val)
numaSetValue()
l_int32 numaGetCount(NUMA *na)
numaGetCount()
l_ok numaGetIValue(NUMA *na, l_int32 index, l_int32 *pival)
numaGetIValue()
l_ok numaaAddNuma(NUMAA *naa, NUMA *na, l_int32 copyflag)
numaaAddNuma()
NUMA * numaCopy(NUMA *na)
numaCopy()
l_ok numaGetParameters(NUMA *na, l_float32 *pstartx, l_float32 *pdelx)
numaGetParameters()
NUMA * numaCreateFromIArray(l_int32 *iarray, l_int32 size)
numaCreateFromIArray()
l_ok numaSetParameters(NUMA *na, l_float32 startx, l_float32 delx)
numaSetParameters()
l_float32 * numaGetFArray(NUMA *na, l_int32 copyflag)
numaGetFArray()
NUMA * numaInvert(NUMA *nad, NUMA *nas)
numaInvert()
NUMA * numaMakeThresholdIndicator(NUMA *nas, l_float32 thresh, l_int32 type)
numaMakeThresholdIndicator()
NUMA * numaPseudorandomSequence(l_int32 size, l_int32 seed)
numaPseudorandomSequence()
NUMA * numaSort(NUMA *naout, NUMA *nain, l_int32 sortorder)
numaSort()
l_ok numaaJoin(NUMAA *naad, NUMAA *naas, l_int32 istart, l_int32 iend)
numaaJoin()
l_ok numaGetMode(NUMA *na, l_float32 *pval, l_int32 *pcount)
numaGetMode()
l_ok numaInterpolateArbxVal(NUMA *nax, NUMA *nay, l_int32 type, l_float32 xval, l_float32 *pyval)
numaInterpolateArbxVal()
l_ok numaGetMeanAbsval(NUMA *na, l_float32 *paveabs)
numaGetMeanAbsval()
NUMA * numaMakeDelta(NUMA *nas)
numaMakeDelta()
NUMA * numaReverse(NUMA *nad, NUMA *nas)
numaReverse()
l_int32 numaGetEdgeValues(NUMA *na, l_int32 edge, l_int32 *pstart, l_int32 *pend, l_int32 *psign)
numaGetEdgeValues()
l_ok numaGetMedianDevFromMedian(NUMA *na, l_float32 *pmed, l_float32 *pdev)
numaGetMedianDevFromMedian()
l_int32 numaSimilar(NUMA *na1, NUMA *na2, l_float32 maxdiff, l_int32 *psimilar)
numaSimilar()
NUMA * numaLogicalOp(NUMA *nad, NUMA *na1, NUMA *na2, l_int32 op)
numaLogicalOp()
NUMA * numaAddBorder(NUMA *nas, l_int32 left, l_int32 right, l_float32 val)
numaAddBorder()
l_ok numaHasOnlyIntegers(NUMA *na, l_int32 *pallints)
numaHasOnlyIntegers()
l_ok numaGetMedian(NUMA *na, l_float32 *pval)
numaGetMedian()
NUMA * numaaFlattenToNuma(NUMAA *naa)
numaaFlattenToNuma()
l_ok numaGetMean(NUMA *na, l_float32 *pave)
numaGetMean()
NUMA * numaGetSortIndex(NUMA *na, l_int32 sortorder)
numaGetSortIndex()
l_ok numaSortPair(NUMA *nax, NUMA *nay, l_int32 sortorder, NUMA **pnasx, NUMA **pnasy)
numaSortPair()
l_ok numaFindSortedLoc(NUMA *na, l_float32 val, l_int32 *pindex)
numaFindSortedLoc()
NUMA * numaMakeAbsval(NUMA *nad, NUMA *nas)
numaMakeAbsval()
l_ok numaInterpolateEqxVal(l_float32 startx, l_float32 deltax, NUMA *nay, l_int32 type, l_float32 xval, l_float32 *pyval)
numaInterpolateEqxVal()
l_ok numaAddToNumber(NUMA *na, l_int32 index, l_float32 val)
numaAddToNumber()
NUMA * numaUniformSampling(NUMA *nas, l_int32 nsamp)
numaUniformSampling()
l_int32 numaIsSorted(NUMA *nas, l_int32 sortorder, l_int32 *psorted)
numaIsSorted()
l_ok numaGetSumOnInterval(NUMA *na, l_int32 first, l_int32 last, l_float32 *psum)
numaGetSumOnInterval()
NUMA * numaRemoveBorder(NUMA *nas, l_int32 left, l_int32 right)
numaRemoveBorder()
NUMA * numaSortAutoSelect(NUMA *nas, l_int32 sortorder)
numaSortAutoSelect()
l_ok numaGetCountRelativeToZero(NUMA *na, l_int32 type, l_int32 *pcount)
numaGetCountRelativeToZero()
l_ok numaInterpolateEqxInterval(l_float32 startx, l_float32 deltax, NUMA *nasy, l_int32 type, l_float32 x0, l_float32 x1, l_int32 npts, NUMA **pnax, NUMA **pnay)
numaInterpolateEqxInterval()
l_ok numaInterpolateArbxInterval(NUMA *nax, NUMA *nay, l_int32 type, l_float32 x0, l_float32 x1, l_int32 npts, NUMA **pnadx, NUMA **pnady)
numaInterpolateArbxInterval()
l_ok numaGetMeanDevFromMedian(NUMA *na, l_float32 med, l_float32 *pdev)
numaGetMeanDevFromMedian()
NUMA * numaRandomPermutation(NUMA *nas, l_int32 seed)
numaRandomPermutation()
l_ok numaJoin(NUMA *nad, NUMA *nas, l_int32 istart, l_int32 iend)
numaJoin()
l_ok numaGetRankValue(NUMA *na, l_float32 fract, NUMA *nasort, l_int32 usebins, l_float32 *pval)
numaGetRankValue()
l_ok numaGetMin(NUMA *na, l_float32 *pminval, l_int32 *piminloc)
numaGetMin()
NUMA * numaBinSort(NUMA *nas, l_int32 sortorder)
numaBinSort()
NUMA * numaSortIndexAutoSelect(NUMA *nas, l_int32 sortorder)
numaSortIndexAutoSelect()
NUMA * numaLowPassIntervals(NUMA *nas, l_float32 thresh, l_float32 maxn)
numaLowPassIntervals()
l_ok numaGetBinnedMedian(NUMA *na, l_int32 *pval)
numaGetBinnedMedian()
NUMA * numaInvertMap(NUMA *nas)
numaInvertMap()
l_ok numaAddSorted(NUMA *na, l_float32 val)
numaAddSorted()
NUMA * numaMakeConstant(l_float32 val, l_int32 size)
numaMakeConstant()
NUMA * numaClipToInterval(NUMA *nas, l_int32 first, l_int32 last)
numaClipToInterval()
NUMA * numaSubsample(NUMA *nas, l_int32 subfactor)
numaSubsample()
l_ok numaGetMax(NUMA *na, l_float32 *pmaxval, l_int32 *pimaxloc)
numaGetMax()
NUMA * numaGetPartialSums(NUMA *na)
numaGetPartialSums()
NUMA * numaThresholdEdges(NUMA *nas, l_float32 thresh1, l_float32 thresh2, l_float32 maxn)
numaThresholdEdges()
NUMA * numaArithOp(NUMA *nad, NUMA *na1, NUMA *na2, l_int32 op)
numaArithOp()
l_int32 numaChooseSortType(NUMA *nas)
numaChooseSortType()
l_int32 numaGetSpanValues(NUMA *na, l_int32 span, l_int32 *pstart, l_int32 *pend)
numaGetSpanValues()
NUMA * numaSortByIndex(NUMA *nas, NUMA *naindex)
numaSortByIndex()
NUMA * numaAddSpecifiedBorder(NUMA *nas, l_int32 left, l_int32 right, l_int32 type)
numaAddSpecifiedBorder()
l_ok numaSortGeneral(NUMA *na, NUMA **pnasort, NUMA **pnaindex, NUMA **pnainvert, l_int32 sortorder, l_int32 sorttype)
numaSortGeneral()
l_ok numaGetNonzeroRange(NUMA *na, l_float32 eps, l_int32 *pfirst, l_int32 *plast)
numaGetNonzeroRange()
NUMA * numaMakeSequence(l_float32 startval, l_float32 increment, l_int32 size)
numaMakeSequence()
l_ok numaFitMax(NUMA *na, l_float32 *pmaxval, NUMA *naloc, l_float32 *pmaxloc)
numaFitMax()
NUMA * numaGetBinSortIndex(NUMA *nas, l_int32 sortorder)
numaGetBinSortIndex()
l_ok numaCountNonzeroRuns(NUMA *na, l_int32 *pcount)
numaCountNonzeroRuns()
l_ok numaDifferentiateInterval(NUMA *nax, NUMA *nay, l_float32 x0, l_float32 x1, l_int32 npts, NUMA **pnadx, NUMA **pnady)
numaDifferentiateInterval()
l_ok numaGetSum(NUMA *na, l_float32 *psum)
numaGetSum()
l_ok numaIntegrateInterval(NUMA *nax, NUMA *nay, l_float32 x0, l_float32 x1, l_int32 npts, l_float32 *psum)
numaIntegrateInterval()
l_ok ptraInsert(L_PTRA *pa, l_int32 index, void *item, l_int32 shiftflag)
ptraInsert()
L_PTRA * ptraCreate(l_int32 n)
ptraCreate()
l_ok ptraGetMaxIndex(L_PTRA *pa, l_int32 *pmaxindex)
ptraGetMaxIndex()
void ptraDestroy(L_PTRA **ppa, l_int32 freeflag, l_int32 warnflag)
ptraDestroy()
void * ptraRemove(L_PTRA *pa, l_int32 index, l_int32 flag)
ptraRemove()
void * ptraGetPtrToItem(L_PTRA *pa, l_int32 index)
ptraGetPtrToItem()
void * ptraRemoveLast(L_PTRA *pa)
ptraRemoveLast()
void lept_stderr(const char *fmt,...)
lept_stderr()
l_int32 lept_roundftoi(l_float32 fval)
lept_roundftoi()