72 #include "allheaders.h" 99 if (pnaindex) *pnaindex = NULL;
101 return (
PTA *)ERROR_PTR(
"ptas not defined", procName, NULL);
103 return (
PTA *)ERROR_PTR(
"invalid sort type", procName, NULL);
105 return (
PTA *)ERROR_PTR(
"invalid sort order", procName, NULL);
108 return (
PTA *)ERROR_PTR(
"naindex not made", procName, NULL);
116 return (
PTA *)ERROR_PTR(
"ptad not made", procName, NULL);
141 PROCNAME(
"ptaGetSortIndex");
144 return ERROR_INT(
"&naindex not defined", procName, 1);
147 return ERROR_INT(
"ptas not defined", procName, 1);
149 return ERROR_INT(
"invalid sort type", procName, 1);
151 return ERROR_INT(
"invalid sort order", procName, 1);
156 return ERROR_INT(
"na not made", procName, 1);
157 for (i = 0; i < n; i++) {
169 return ERROR_INT(
"naindex not made", procName, 1);
189 PROCNAME(
"ptaSortByIndex");
192 return (
PTA *)ERROR_PTR(
"ptas not defined", procName, NULL);
194 return (
PTA *)ERROR_PTR(
"naindex not defined", procName, NULL);
199 return (
PTA *)ERROR_PTR(
"ptad not made", procName, NULL);
200 for (i = 0; i < n; i++) {
225 PROCNAME(
"ptaaSortByIndex");
228 return (
PTAA *)ERROR_PTR(
"ptaas not defined", procName, NULL);
230 return (
PTAA *)ERROR_PTR(
"naindex not defined", procName, NULL);
234 return (
PTAA *)ERROR_PTR(
"numa and ptaa sizes differ", procName, NULL);
236 for (i = 0; i < n; i++) {
266 PROCNAME(
"ptaGetRankValue");
269 return ERROR_INT(
"&val not defined", procName, 1);
272 return ERROR_INT(
"pta not defined", procName, 1);
274 return ERROR_INT(
"invalid sort type", procName, 1);
275 if (fract < 0.0 || fract > 1.0)
276 return ERROR_INT(
"fract not in [0.0 ... 1.0]", procName, 1);
278 return ERROR_INT(
"pta empty", procName, 1);
285 index = (l_int32)(fract * (l_float32)(n - 1) + 0.5);
322 PROCNAME(
"ptaUnionByAset");
325 return (
PTA *)ERROR_PTR(
"pta1 not defined", procName, NULL);
327 return (
PTA *)ERROR_PTR(
"pta2 not defined", procName, NULL);
362 PROCNAME(
"ptaRemoveDupsByAset");
365 return (
PTA *)ERROR_PTR(
"ptas not defined", procName, NULL);
367 set = l_asetCreate(L_UINT_TYPE);
370 for (i = 0; i < n; i++) {
374 if (!l_asetFind(
set, key)) {
376 l_asetInsert(
set, key);
404 l_int32 n1, n2, i, n, x, y;
408 PTA *pta_small, *pta_big, *ptad;
410 PROCNAME(
"ptaIntersectionByAset");
413 return (
PTA *)ERROR_PTR(
"pta1 not defined", procName, NULL);
415 return (
PTA *)ERROR_PTR(
"pta2 not defined", procName, NULL);
420 pta_small = (n1 < n2) ? pta1 : pta2;
421 pta_big = (n1 < n2) ? pta2 : pta1;
427 set2 = l_asetCreate(L_UINT_TYPE);
428 for (i = 0; i < n; i++) {
432 if (l_asetFind(set1, key) && !l_asetFind(set2, key)) {
434 l_asetInsert(set2, key);
438 l_asetDestroy(&set1);
439 l_asetDestroy(&set2);
458 PROCNAME(
"l_asetCreateFromPta");
461 return (
L_ASET *)ERROR_PTR(
"pta not defined", procName, NULL);
463 set = l_asetCreate(L_UINT_TYPE);
465 for (i = 0; i < n; i++) {
469 l_asetInsert(
set, key);
498 PROCNAME(
"ptaUnionByHash");
501 return (
PTA *)ERROR_PTR(
"pta1 not defined", procName, NULL);
503 return (
PTA *)ERROR_PTR(
"pta2 not defined", procName, NULL);
547 l_int32 i, n, index, items, x, y;
553 PROCNAME(
"ptaRemoveDupsByHash");
555 if (pdahash) *pdahash = NULL;
557 return ERROR_INT(
"&ptad not defined", procName, 1);
560 return ERROR_INT(
"ptas not defined", procName, 1);
567 for (i = 0, items = 0; i < n; i++) {
603 l_int32 n1, n2, nsmall, i, x, y, index1, index2;
607 PTA *pta_small, *pta_big, *ptad;
609 PROCNAME(
"ptaIntersectionByHash");
612 return (
PTA *)ERROR_PTR(
"pta1 not defined", procName, NULL);
614 return (
PTA *)ERROR_PTR(
"pta2 not defined", procName, NULL);
619 pta_small = (n1 < n2) ? pta1 : pta2;
620 pta_big = (n1 < n2) ? pta2 : pta1;
630 for (i = 0; i < nsmall; i++) {
680 l_int32 i, nvals, index, xi, yi;
684 PROCNAME(
"ptaFindPtByHash");
687 return ERROR_INT(
"&index not defined", procName, 1);
690 return ERROR_INT(
"pta not defined", procName, 1);
692 return ERROR_INT(
"dahash not defined", procName, 1);
700 for (i = 0; i < nvals; i++) {
703 if (x == xi && y == yi) {
727 PROCNAME(
"l_dnaHashCreateFromPta");
730 return (
L_DNAHASH *)ERROR_PTR(
"pta not defined", procName, NULL);
744 for (i = 0; i < n; i++) {
l_int32 ptaaAddPta(PTAA *ptaa, PTA *pta, l_int32 copyflag)
ptaaAddPta()
L_DNA * l_dnaHashGetDna(L_DNAHASH *dahash, l_uint64 key, l_int32 copyflag)
l_dnaHashGetDna()
l_int32 numaAddNumber(NUMA *na, l_float32 val)
numaAddNumber()
NUMA * numaGetSortIndex(NUMA *na, l_int32 sortorder)
numaGetSortIndex()
l_int32 l_dnaGetCount(L_DNA *da)
l_dnaGetCount()
l_int32 ptaFindPtByHash(PTA *pta, L_DNAHASH *dahash, l_int32 x, l_int32 y, l_int32 *pindex)
ptaFindPtByHash()
l_int32 ptaAddPt(PTA *pta, l_float32 x, l_float32 y)
ptaAddPt()
l_int32 ptaRemoveDupsByHash(PTA *ptas, PTA **pptad, L_DNAHASH **pdahash)
ptaRemoveDupsByHash()
l_int32 ptaGetPt(PTA *pta, l_int32 index, l_float32 *px, l_float32 *py)
ptaGetPt()
void l_dnaHashDestroy(L_DNAHASH **pdahash)
l_dnaHashDestroy()
PTA * ptaCreate(l_int32 n)
ptaCreate()
NUMA * numaCreate(l_int32 n)
numaCreate()
l_int32 ptaGetCount(PTA *pta)
ptaGetCount()
PTA * ptaSort(PTA *ptas, l_int32 sorttype, l_int32 sortorder, NUMA **pnaindex)
ptaSort()
PTA * ptaRemoveDupsByAset(PTA *ptas)
ptaRemoveDupsByAset()
l_int32 ptaGetSortIndex(PTA *ptas, l_int32 sorttype, l_int32 sortorder, NUMA **pnaindex)
ptaGetSortIndex()
l_int32 l_hashPtToUint64(l_int32 x, l_int32 y, l_uint64 *phash)
l_hashPtToUint64()
l_int32 l_dnaGetIValue(L_DNA *da, l_int32 index, l_int32 *pival)
l_dnaGetIValue()
PTAA * ptaaSortByIndex(PTAA *ptaas, NUMA *naindex)
ptaaSortByIndex()
l_int32 findNextLargerPrime(l_int32 start, l_uint32 *pprime)
findNextLargerPrime()
PTA * ptaaGetPta(PTAA *ptaa, l_int32 index, l_int32 accessflag)
ptaaGetPta()
static const l_int32 L_INSERT
l_int32 ptaJoin(PTA *ptad, PTA *ptas, l_int32 istart, l_int32 iend)
ptaJoin()
l_int32 numaGetCount(NUMA *na)
numaGetCount()
PTA * ptaUnionByAset(PTA *pta1, PTA *pta2)
ptaUnionByAset()
l_int32 l_dnaHashAdd(L_DNAHASH *dahash, l_uint64 key, l_float64 value)
l_dnaHashAdd()
l_int32 ptaGetRankValue(PTA *pta, l_float32 fract, PTA *ptasort, l_int32 sorttype, l_float32 *pval)
ptaGetRankValue()
PTA * ptaCopy(PTA *pta)
ptaCopy()
void numaDestroy(NUMA **pna)
numaDestroy()
PTA * ptaIntersectionByHash(PTA *pta1, PTA *pta2)
ptaIntersectionByHash()
PTA * ptaIntersectionByAset(PTA *pta1, PTA *pta2)
ptaIntersectionByAset()
L_ASET * l_asetCreateFromPta(PTA *pta)
l_asetCreateFromPta()
l_int32 ptaGetIPt(PTA *pta, l_int32 index, l_int32 *px, l_int32 *py)
ptaGetIPt()
l_int32 ptaaGetCount(PTAA *ptaa)
ptaaGetCount()
void ptaDestroy(PTA **ppta)
ptaDestroy()
L_DNAHASH * l_dnaHashCreateFromPta(PTA *pta)
l_dnaHashCreateFromPta()
l_int32 numaGetIValue(NUMA *na, l_int32 index, l_int32 *pival)
numaGetIValue()
L_DNAHASH * l_dnaHashCreate(l_int32 nbuckets, l_int32 initsize)
l_dnaHashCreate()
PTAA * ptaaCreate(l_int32 n)
ptaaCreate()
PTA * ptaSortByIndex(PTA *ptas, NUMA *naindex)
ptaSortByIndex()
PTA * ptaUnionByHash(PTA *pta1, PTA *pta2)
ptaUnionByHash()