Leptonica  1.77.0
Image processing and image analysis suite
dnafunc1.c File Reference
#include "allheaders.h"

Go to the source code of this file.

Functions

l_ok l_dnaJoin (L_DNA *dad, L_DNA *das, l_int32 istart, l_int32 iend)
 
L_DNAl_dnaaFlattenToDna (L_DNAA *daa)
 
NUMAl_dnaConvertToNuma (L_DNA *da)
 
L_DNAnumaConvertToDna (NUMA *na)
 
L_DNAl_dnaUnionByAset (L_DNA *da1, L_DNA *da2)
 
L_DNAl_dnaRemoveDupsByAset (L_DNA *das)
 
L_DNAl_dnaIntersectionByAset (L_DNA *da1, L_DNA *da2)
 
L_ASETl_asetCreateFromDna (L_DNA *da)
 
L_DNAl_dnaDiffAdjValues (L_DNA *das)
 

Detailed Description

 Rearrangements
     l_int32     *l_dnaJoin()
     l_int32     *l_dnaaFlattenToDna()

 Conversion between numa and dna
     NUMA        *l_dnaConvertToNuma()
     L_DNA       *numaConvertToDna()

 Set operations using aset (rbtree)
     L_DNA       *l_dnaUnionByAset()
     L_DNA       *l_dnaRemoveDupsByAset()
     L_DNA       *l_dnaIntersectionByAset()
     L_ASET      *l_asetCreateFromDna()

 Miscellaneous operations
     L_DNA       *l_dnaDiffAdjValues()
This file contains an implementation on sets of doubles (or integers)
that uses an underlying tree (rbtree).  The keys stored in the tree
are simply the double array values in the dna.  Use of a DnaHash
is typically more efficient, with O(1) in lookup and insertion.
 

Definition in file dnafunc1.c.

Function Documentation

◆ l_asetCreateFromDna()

L_ASET* l_asetCreateFromDna ( L_DNA da)

l_asetCreateFromDna()

Parameters
[in]dasource dna
Returns
set using the doubles in da as keys

Definition at line 350 of file dnafunc1.c.

Referenced by l_dnaIntersectionByAset().

◆ l_dnaaFlattenToDna()

L_DNA* l_dnaaFlattenToDna ( L_DNAA daa)

l_dnaaFlattenToDna()

Parameters
[in]daa
Returns
dad, or NULL on error
Notes:
     (1) This 'flattens' the dnaa to a dna, by joining successively
         each dna in the dnaa.
     (2) It leaves the input dnaa unchanged.

Definition at line 125 of file dnafunc1.c.

References L_Dnaa::dna, l_dnaCreate(), l_dnaJoin(), and L_Dnaa::nalloc.

◆ l_dnaConvertToNuma()

NUMA* l_dnaConvertToNuma ( L_DNA da)

l_dnaConvertToNuma()

Parameters
[in]da
Returns
na, or NULL on error

Definition at line 159 of file dnafunc1.c.

References l_dnaGetCount(), l_dnaGetDValue(), numaAddNumber(), and numaCreate().

◆ l_dnaDiffAdjValues()

L_DNA* l_dnaDiffAdjValues ( L_DNA das)

l_dnaDiffAdjValues()

Parameters
[in]dasinput l_dna
Returns
dad of difference values val[i+1] - val[i], or NULL on error

Definition at line 385 of file dnafunc1.c.

References l_dnaAddNumber(), l_dnaCreate(), l_dnaGetCount(), and l_dnaGetIValue().

◆ l_dnaIntersectionByAset()

L_DNA* l_dnaIntersectionByAset ( L_DNA da1,
L_DNA da2 
)

l_dnaIntersectionByAset()

Parameters
[in]da1,da2
Returns
dad with the intersection of the two arrays, or NULL on error
Notes:
     (1) See sarrayIntersection() for the approach.
     (2) Here, the key in building the sorted tree is the number itself.
     (3) Operations using an underlying tree are O(nlogn), which is
         typically less efficient than hashing, which is O(n).

Definition at line 301 of file dnafunc1.c.

References l_asetCreateFromDna(), l_dnaCreate(), and l_dnaGetCount().

◆ l_dnaJoin()

l_ok l_dnaJoin ( L_DNA dad,
L_DNA das,
l_int32  istart,
l_int32  iend 
)

l_dnaJoin()

Parameters
[in]daddest dna; add to this one
[in]das[optional] source dna; add from this one
[in]istartstarting index in das
[in]iendending index in das; use -1 to cat all
Returns
0 if OK, 1 on error
Notes:
     (1) istart < 0 is taken to mean 'read from the start' (istart = 0)
     (2) iend < 0 means 'read to the end'
     (3) if das == NULL, this is a no-op

Definition at line 79 of file dnafunc1.c.

References l_dnaAddNumber(), l_dnaGetCount(), and l_dnaGetDValue().

Referenced by l_dnaaFlattenToDna(), and l_dnaUnionByAset().

◆ l_dnaRemoveDupsByAset()

L_DNA* l_dnaRemoveDupsByAset ( L_DNA das)

l_dnaRemoveDupsByAset()

Parameters
[in]das
Returns
dad with duplicates removed, or NULL on error

Definition at line 256 of file dnafunc1.c.

Referenced by l_dnaUnionByAset().

◆ l_dnaUnionByAset()

L_DNA* l_dnaUnionByAset ( L_DNA da1,
L_DNA da2 
)

l_dnaUnionByAset()

Parameters
[in]da1,da2
Returns
dad with the union of the set of numbers, or NULL on error
Notes:
     (1) See sarrayUnionByAset() for the approach.
     (2) Here, the key in building the sorted tree is the number itself.
     (3) Operations using an underlying tree are O(nlogn), which is
         typically less efficient than hashing, which is O(n).

Definition at line 226 of file dnafunc1.c.

References l_dnaCopy(), l_dnaDestroy(), l_dnaJoin(), and l_dnaRemoveDupsByAset().

◆ numaConvertToDna()

L_DNA* numaConvertToDna ( NUMA na)

numaConvertToDna

Parameters
[in]na
Returns
da, or NULL on error

Definition at line 187 of file dnafunc1.c.

References l_dnaAddNumber(), l_dnaCreate(), numaGetCount(), and numaGetFValue().