![]() |
Leptonica
1.82.0
Image processing and image analysis suite
|
#include <string.h>
#include <math.h>
#include "allheaders.h"
Go to the source code of this file.
Functions | |
static l_int32 | l_dnaExtendArray (L_DNA *da) |
static l_int32 | l_dnaaExtendArray (L_DNAA *daa) |
L_DNA * | l_dnaCreate (l_int32 n) |
L_DNA * | l_dnaCreateFromIArray (l_int32 *iarray, l_int32 size) |
L_DNA * | l_dnaCreateFromDArray (l_float64 *darray, l_int32 size, l_int32 copyflag) |
L_DNA * | l_dnaMakeSequence (l_float64 startval, l_float64 increment, l_int32 size) |
void | l_dnaDestroy (L_DNA **pda) |
L_DNA * | l_dnaCopy (L_DNA *da) |
L_DNA * | l_dnaClone (L_DNA *da) |
l_ok | l_dnaEmpty (L_DNA *da) |
l_ok | l_dnaAddNumber (L_DNA *da, l_float64 val) |
l_ok | l_dnaInsertNumber (L_DNA *da, l_int32 index, l_float64 val) |
l_ok | l_dnaRemoveNumber (L_DNA *da, l_int32 index) |
l_ok | l_dnaReplaceNumber (L_DNA *da, l_int32 index, l_float64 val) |
l_int32 | l_dnaGetCount (L_DNA *da) |
l_ok | l_dnaSetCount (L_DNA *da, l_int32 newcount) |
l_ok | l_dnaGetDValue (L_DNA *da, l_int32 index, l_float64 *pval) |
l_ok | l_dnaGetIValue (L_DNA *da, l_int32 index, l_int32 *pival) |
l_ok | l_dnaSetValue (L_DNA *da, l_int32 index, l_float64 val) |
l_ok | l_dnaShiftValue (L_DNA *da, l_int32 index, l_float64 diff) |
l_int32 * | l_dnaGetIArray (L_DNA *da) |
l_float64 * | l_dnaGetDArray (L_DNA *da, l_int32 copyflag) |
l_int32 | l_dnaGetRefcount (L_DNA *da) |
l_ok | l_dnaChangeRefcount (L_DNA *da, l_int32 delta) |
l_ok | l_dnaGetParameters (L_DNA *da, l_float64 *pstartx, l_float64 *pdelx) |
l_ok | l_dnaSetParameters (L_DNA *da, l_float64 startx, l_float64 delx) |
l_ok | l_dnaCopyParameters (L_DNA *dad, L_DNA *das) |
L_DNA * | l_dnaRead (const char *filename) |
L_DNA * | l_dnaReadStream (FILE *fp) |
L_DNA * | l_dnaReadMem (const l_uint8 *data, size_t size) |
l_ok | l_dnaWrite (const char *filename, L_DNA *da) |
l_ok | l_dnaWriteStream (FILE *fp, L_DNA *da) |
l_ok | l_dnaWriteStderr (L_DNA *da) |
l_ok | l_dnaWriteMem (l_uint8 **pdata, size_t *psize, L_DNA *da) |
L_DNAA * | l_dnaaCreate (l_int32 n) |
L_DNAA * | l_dnaaCreateFull (l_int32 nptr, l_int32 n) |
l_ok | l_dnaaTruncate (L_DNAA *daa) |
void | l_dnaaDestroy (L_DNAA **pdaa) |
l_ok | l_dnaaAddDna (L_DNAA *daa, L_DNA *da, l_int32 copyflag) |
l_int32 | l_dnaaGetCount (L_DNAA *daa) |
l_int32 | l_dnaaGetDnaCount (L_DNAA *daa, l_int32 index) |
l_int32 | l_dnaaGetNumberCount (L_DNAA *daa) |
L_DNA * | l_dnaaGetDna (L_DNAA *daa, l_int32 index, l_int32 accessflag) |
l_ok | l_dnaaReplaceDna (L_DNAA *daa, l_int32 index, L_DNA *da) |
l_ok | l_dnaaGetValue (L_DNAA *daa, l_int32 i, l_int32 j, l_float64 *pval) |
l_ok | l_dnaaAddNumber (L_DNAA *daa, l_int32 index, l_float64 val) |
L_DNAA * | l_dnaaRead (const char *filename) |
L_DNAA * | l_dnaaReadStream (FILE *fp) |
L_DNAA * | l_dnaaReadMem (const l_uint8 *data, size_t size) |
l_ok | l_dnaaWrite (const char *filename, L_DNAA *daa) |
l_ok | l_dnaaWriteStream (FILE *fp, L_DNAA *daa) |
l_ok | l_dnaaWriteMem (l_uint8 **pdata, size_t *psize, L_DNAA *daa) |
Variables | |
static const l_uint32 | MaxDoubleArraySize = 100000000 |
static const l_uint32 | MaxPtrArraySize = 1000000 |
static const l_int32 | InitialArraySize = 50 |
Dna creation, destruction, copy, clone, etc. L_DNA *l_dnaCreate() L_DNA *l_dnaCreateFromIArray() L_DNA *l_dnaCreateFromDArray() L_DNA *l_dnaMakeSequence() void *l_dnaDestroy() L_DNA *l_dnaCopy() L_DNA *l_dnaClone() l_int32 l_dnaEmpty()
Dna: add/remove number and extend array l_int32 l_dnaAddNumber() static l_int32 l_dnaExtendArray() l_int32 l_dnaInsertNumber() l_int32 l_dnaRemoveNumber() l_int32 l_dnaReplaceNumber()
Dna accessors l_int32 l_dnaGetCount() l_int32 l_dnaSetCount() l_int32 l_dnaGetIValue() l_int32 l_dnaGetDValue() l_int32 l_dnaSetValue() l_int32 l_dnaShiftValue() l_int32 *l_dnaGetIArray() l_float64 *l_dnaGetDArray() l_int32 l_dnaGetRefcount() l_int32 l_dnaChangeRefcount() l_int32 l_dnaGetParameters() l_int32 l_dnaSetParameters() l_int32 l_dnaCopyParameters()
Serialize Dna for I/O L_DNA *l_dnaRead() L_DNA *l_dnaReadStream() L_DNA *l_dnaReadMem() l_int32 l_dnaWrite() l_int32 l_dnaWriteStream() l_int32 l_dnaWriteStderr() l_int32 l_dnaWriteMem()
Dnaa creation, destruction L_DNAA *l_dnaaCreate() L_DNAA *l_dnaaCreateFull() l_int32 l_dnaaTruncate() void *l_dnaaDestroy()
Add Dna to Dnaa l_int32 l_dnaaAddDna() static l_int32 l_dnaaExtendArray()
Dnaa accessors l_int32 l_dnaaGetCount() l_int32 l_dnaaGetDnaCount() l_int32 l_dnaaGetNumberCount() L_DNA *l_dnaaGetDna() L_DNA *l_dnaaReplaceDna() l_int32 l_dnaaGetValue() l_int32 l_dnaaAddNumber()
Serialize Dnaa for I/O L_DNAA *l_dnaaRead() L_DNAA *l_dnaaReadStream() L_DNAA *l_dnaaReadMem() l_int32 l_dnaaWrite() l_int32 l_dnaaWriteStream() l_int32 l_dnaaWriteMem()
(1) The Dna is a struct holding an array of doubles. It can also be used to store l_int32 values, up to the full precision of int32. Always use it whenever integers larger than a few million need to be stored.
(2) Always use the accessors in this file, never the fields directly.
(3) Storing and retrieving numbers:
* to append a new number to the array, use l_dnaAddNumber(). If the number is an int, it will will automatically be converted to l_float64 and stored.
* to reset a value stored in the array, use l_dnaSetValue().
* to increment or decrement a value stored in the array, use l_dnaShiftValue().
* to obtain a value from the array, use either l_dnaGetIValue() or l_dnaGetDValue(), depending on whether you are retrieving an integer or a float64. This avoids doing an explicit cast, such as (a) return a l_float64 and cast it to an l_int32 (b) cast the return directly to (l_float64 *) to satisfy the function prototype, as in l_dnaGetDValue(da, index, (l_float64 *)&ival); [ugly!]
(4) int <--> double conversions:
Conversions go automatically from l_int32 --> l_float64, without loss of precision. You must cast (l_int32) to go from l_float64 --> l_int32 because you're truncating to the integer value.
(5) As with other arrays in leptonica, the l_dna has both an allocated size and a count of the stored numbers. When you add a number, it goes on the end of the array, and causes a realloc if the array is already filled. However, in situations where you want to add numbers randomly into an array, such as when you build a histogram, you must set the count of stored numbers in advance. This is done with l_dnaSetCount(). If you set a count larger than the allocated array, it does a realloc to the size requested.
(6) In situations where the data in a l_dna correspond to a function y(x), the values can be either at equal spacings in x or at arbitrary spacings. For the former, we can represent all x values by two parameters: startx (corresponding to y[0]) and delx for the change in x for adjacent values y[i] and y[i+1]. startx and delx are initialized to 0.0 and 1.0, rsp. For arbitrary spacings, we use a second l_dna, and the two l_dnas are typically denoted dnay and dnax.
Definition in file dnabasic.c.
[in] | daa | |
[in] | da | to be added |
[in] | copyflag | L_INSERT, L_COPY, L_CLONE |
Definition at line 1421 of file dnabasic.c.
References L_Dnaa::dna, L_CLONE, L_COPY, l_dnaaExtendArray(), l_dnaaGetCount(), l_dnaClone(), l_dnaCopy(), l_dnaDestroy(), L_INSERT, L_Dnaa::n, and L_Dnaa::nalloc.
Referenced by evalColorfillData(), l_dnaaCreateFull(), and ptraConcatenatePdfToData().
l_ok l_dnaaAddNumber | ( | L_DNAA * | daa, |
l_int32 | index, | ||
l_float64 | val | ||
) |
[in] | daa | |
[in] | index | of l_dna within l_dnaa |
[in] | val | number to be added; stored as a double |
Notes: (1) Adds to an existing l_dna only.
Definition at line 1684 of file dnabasic.c.
References L_CLONE, l_dnaAddNumber(), l_dnaaGetCount(), l_dnaaGetDna(), and l_dnaDestroy().
L_DNAA* l_dnaaCreate | ( | l_int32 | n | ) |
[in] | n | size of l_dna ptr array to be alloc'd 0 for default |
Definition at line 1285 of file dnabasic.c.
Referenced by l_dnaaCreateFull(), and ptraConcatenatePdfToData().
L_DNAA* l_dnaaCreateFull | ( | l_int32 | nptr, |
l_int32 | n | ||
) |
[in] | nptr | size of dna ptr array to be alloc'd |
[in] | n | size of individual dna arrays to be alloc'd 0 for default |
Notes: (1) This allocates a dnaa and fills the array with allocated dnas. In use, after calling this function, use l_dnaaAddNumber(dnaa, index, val); to add val to the index-th dna in dnaa.
Definition at line 1321 of file dnabasic.c.
References l_dnaaAddDna(), l_dnaaCreate(), l_dnaCreate(), and L_INSERT.
l_ok l_dnaAddNumber | ( | L_DNA * | da, |
l_float64 | val | ||
) |
[in] | da | |
[in] | val | float or int to be added; stored as a float |
Definition at line 448 of file dnabasic.c.
References L_Dna::array, l_dnaExtendArray(), l_dnaGetCount(), L_Dna::n, and L_Dna::nalloc.
Referenced by arrayFindEachSequence(), evalColorfillData(), l_dnaaAddNumber(), l_dnaCopy(), l_dnaCreateFromDArray(), l_dnaCreateFromIArray(), l_dnaDiffAdjValues(), l_dnaHashAdd(), l_dnaIntersectionByHmap(), l_dnaJoin(), l_dnaMakeHistoByHmap(), l_dnaMakeSequence(), l_dnaRemoveDupsByHmap(), l_dnaSelectRange(), makeColorfillTestData(), numaConvertToDna(), parseTrailerPdf(), and recogGetClassIndex().
void l_dnaaDestroy | ( | L_DNAA ** | pdaa | ) |
[in,out] | pdaa | will be set to null before returning |
Definition at line 1386 of file dnabasic.c.
References L_Dnaa::dna, l_dnaDestroy(), and L_Dnaa::n.
Referenced by l_colorfillDestroy(), and ptraConcatenatePdfToData().
|
static |
[in] | daa |
Notes: (1) Doubles the number of dna ptrs. (2) The max size of the dna array is 1M ptrs.
Definition at line 1473 of file dnabasic.c.
References L_Dnaa::nalloc.
Referenced by l_dnaaAddDna().
l_int32 l_dnaaGetCount | ( | L_DNAA * | daa | ) |
[in] | daa |
Definition at line 1507 of file dnabasic.c.
References L_Dnaa::n.
Referenced by l_dnaaAddDna(), l_dnaaAddNumber(), l_dnaaGetNumberCount(), l_dnaaGetValue(), l_dnaaReplaceDna(), l_dnaaTruncate(), and l_dnaaWriteStream().
[in] | daa | |
[in] | index | to the index-th l_dna |
[in] | accessflag | L_COPY or L_CLONE |
Definition at line 1576 of file dnabasic.c.
References L_Dnaa::dna, L_CLONE, L_COPY, l_dnaClone(), l_dnaCopy(), and L_Dnaa::n.
Referenced by l_dnaaAddNumber(), l_dnaaGetNumberCount(), l_dnaaTruncate(), l_dnaaWriteStream(), and ptraConcatenatePdfToData().
l_int32 l_dnaaGetDnaCount | ( | L_DNAA * | daa, |
l_int32 | index | ||
) |
[in] | daa | |
[in] | index | of l_dna in daa |
Definition at line 1525 of file dnabasic.c.
References L_Dnaa::dna, l_dnaGetCount(), and L_Dnaa::n.
l_int32 l_dnaaGetNumberCount | ( | L_DNAA * | daa | ) |
[in] | daa |
Definition at line 1546 of file dnabasic.c.
References L_CLONE, l_dnaaGetCount(), l_dnaaGetDna(), l_dnaDestroy(), and l_dnaGetCount().
l_ok l_dnaaGetValue | ( | L_DNAA * | daa, |
l_int32 | i, | ||
l_int32 | j, | ||
l_float64 * | pval | ||
) |
[in] | daa | |
[in] | i | index of l_dna within l_dnaa |
[in] | j | index into l_dna |
[out] | pval | double value |
Definition at line 1644 of file dnabasic.c.
References L_Dna::array, L_Dnaa::dna, l_dnaaGetCount(), and L_Dna::n.
L_DNAA* l_dnaaRead | ( | const char * | filename | ) |
[in] | filename |
Definition at line 1716 of file dnabasic.c.
References fopenReadStream(), and l_dnaaReadStream().
L_DNAA* l_dnaaReadMem | ( | const l_uint8 * | data, |
size_t | size | ||
) |
[in] | data | dnaa serialization; in ascii |
[in] | size | of data; can use strlen to get it |
Definition at line 1798 of file dnabasic.c.
References fopenReadFromMemory(), and l_dnaaReadStream().
L_DNAA* l_dnaaReadStream | ( | FILE * | fp | ) |
[in] | fp | file stream |
Notes: (1) It is OK for the dnaa to be empty.
Definition at line 1748 of file dnabasic.c.
References DNA_VERSION_NUMBER.
Referenced by l_dnaaRead(), and l_dnaaReadMem().
[in] | daa | |
[in] | index | to the index-th l_dna |
[in] | da | insert and replace any existing one |
Notes: (1) Any existing l_dna is destroyed, and the input one is inserted in its place. (2) If index is invalid, return 1 (error)
Definition at line 1612 of file dnabasic.c.
References L_Dnaa::dna, l_dnaaGetCount(), and l_dnaDestroy().
l_ok l_dnaaTruncate | ( | L_DNAA * | daa | ) |
[in] | daa |
Notes: (1) This identifies the largest index containing a dna that has any numbers within it, destroys all dna beyond that index, and resets the count.
Definition at line 1352 of file dnabasic.c.
References L_Dnaa::dna, L_CLONE, l_dnaaGetCount(), l_dnaaGetDna(), l_dnaDestroy(), l_dnaGetCount(), and L_Dnaa::n.
l_ok l_dnaaWrite | ( | const char * | filename, |
L_DNAA * | daa | ||
) |
[in] | filename | |
[in] | daa |
Definition at line 1826 of file dnabasic.c.
References fopenWriteStream(), and l_dnaaWriteStream().
l_ok l_dnaaWriteMem | ( | l_uint8 ** | pdata, |
size_t * | psize, | ||
L_DNAA * | daa | ||
) |
[out] | pdata | data of serialized dnaa; ascii |
[out] | psize | size of returned data |
[in] | daa |
Notes: (1) Serializes a dnaa in memory and puts the result in a buffer.
Definition at line 1899 of file dnabasic.c.
References fopenWriteWinTempfile(), l_binaryReadStream(), and l_dnaaWriteStream().
l_ok l_dnaaWriteStream | ( | FILE * | fp, |
L_DNAA * | daa | ||
) |
[in] | fp | file stream |
[in] | daa |
Definition at line 1857 of file dnabasic.c.
References DNA_VERSION_NUMBER, L_CLONE, l_dnaaGetCount(), l_dnaaGetDna(), l_dnaDestroy(), and l_dnaWriteStream().
Referenced by l_dnaaWrite(), and l_dnaaWriteMem().
l_ok l_dnaChangeRefcount | ( | L_DNA * | da, |
l_int32 | delta | ||
) |
l_dnaChangeRefCount()
[in] | da | |
[in] | delta | change to be applied |
Definition at line 914 of file dnabasic.c.
References L_Dna::refcount.
Referenced by l_dnaClone(), and l_dnaDestroy().
[in] | da |
Definition at line 398 of file dnabasic.c.
References l_dnaChangeRefcount().
Referenced by l_dnaaAddDna(), l_dnaaGetDna(), and l_dnaHashGetDna().
[in] | da |
Notes: (1) This removes unused ptrs above da->n.
Definition at line 369 of file dnabasic.c.
References L_Dna::array, L_Dna::delx, l_dnaAddNumber(), l_dnaCreate(), L_Dna::n, and L_Dna::startx.
Referenced by l_dnaaAddDna(), l_dnaaGetDna(), l_dnaHashGetDna(), l_dnaSelectRange(), l_dnaUnionByAset(), and l_dnaUnionByHmap().
[in] | dad | destination DNuma |
[in] | das | source DNuma |
Definition at line 988 of file dnabasic.c.
References l_dnaGetParameters(), and l_dnaSetParameters().
L_DNA* l_dnaCreate | ( | l_int32 | n | ) |
[in] | n | size of number array to be alloc'd; 0 for default |
Definition at line 180 of file dnabasic.c.
Referenced by arrayFindEachSequence(), evalColorfillData(), l_dnaaCreateFull(), l_dnaaFlattenToDna(), l_dnaCopy(), l_dnaCreateFromDArray(), l_dnaCreateFromIArray(), l_dnaDiffAdjValues(), l_dnaHashAdd(), l_dnaIntersectionByAset(), l_dnaIntersectionByHmap(), l_dnaMakeHistoByHmap(), l_dnaMakeSequence(), l_dnaRemoveDupsByHmap(), l_dnaSelectRange(), makeColorfillTestData(), numaConvertToDna(), and parseTrailerPdf().
L_DNA* l_dnaCreateFromDArray | ( | l_float64 * | darray, |
l_int32 | size, | ||
l_int32 | copyflag | ||
) |
[in] | darray | float |
[in] | size | of the array |
[in] | copyflag | L_INSERT or L_COPY |
Notes: (1) With L_INSERT, ownership of the input array is transferred to the returned l_dna, and all size elements are considered to be valid.
Definition at line 258 of file dnabasic.c.
References L_Dna::array, L_COPY, l_dnaAddNumber(), l_dnaCreate(), L_INSERT, and L_Dna::n.
L_DNA* l_dnaCreateFromIArray | ( | l_int32 * | iarray, |
l_int32 | size | ||
) |
[in] | iarray | integer array |
[in] | size | of the array |
Notes: (1) We can't insert this int array into the l_dna, because a l_dna takes a double array. So this just copies the data from the input array into the l_dna. The input array continues to be owned by the caller.
Definition at line 221 of file dnabasic.c.
References l_dnaAddNumber(), and l_dnaCreate().
void l_dnaDestroy | ( | L_DNA ** | pda | ) |
[in,out] | pda | will be set to null before returning |
Notes: (1) Decrements the ref count and, if 0, destroys the l_dna. (2) Always nulls the input ptr.
Definition at line 332 of file dnabasic.c.
References L_Dna::array, l_dnaChangeRefcount(), and l_dnaGetRefcount().
Referenced by arrayFindEachSequence(), arrayReplaceEachSequence(), l_dnaaAddDna(), l_dnaaAddNumber(), l_dnaaDestroy(), l_dnaaGetNumberCount(), l_dnaaReplaceDna(), l_dnaaTruncate(), l_dnaaWriteStream(), l_dnaHashDestroy(), l_dnaUnionByAset(), l_dnaUnionByHmap(), makeColorfillTestData(), parseTrailerPdf(), ptraConcatenatePdfToData(), recogDestroy(), and substituteObjectNumbers().
l_ok l_dnaEmpty | ( | L_DNA * | da | ) |
[in] | da |
Notes: (1) This does not change the allocation of the array. It just clears the number of stored numbers, so that the array appears to be empty.
Definition at line 424 of file dnabasic.c.
References L_Dna::n.
Referenced by parseTrailerPdf().
|
static |
[in] | da |
Notes: (1) Doubles the size of the array. (2) The max number of doubles is 100M.
Definition at line 482 of file dnabasic.c.
References L_Dna::nalloc.
Referenced by l_dnaAddNumber(), and l_dnaInsertNumber().
l_int32 l_dnaGetCount | ( | L_DNA * | da | ) |
[in] | da |
Definition at line 631 of file dnabasic.c.
References L_Dna::n.
Referenced by arrayFindEachSequence(), arrayReplaceEachSequence(), l_dnaAddNumber(), l_dnaaGetDnaCount(), l_dnaaGetNumberCount(), l_dnaaTruncate(), l_dnaConvertToNuma(), l_dnaDiffAdjValues(), l_dnaGetDArray(), l_dnaGetIArray(), l_dnaInsertNumber(), l_dnaIntersectionByAset(), l_dnaIntersectionByHmap(), l_dnaJoin(), l_dnaRemoveNumber(), l_dnaReplaceNumber(), l_dnaSelectRange(), l_dnaWriteStderr(), l_dnaWriteStream(), l_hmapCreateFromDna(), parseTrailerPdf(), ptraConcatenatePdfToData(), recogGetClassIndex(), and substituteObjectNumbers().
l_float64* l_dnaGetDArray | ( | L_DNA * | da, |
l_int32 | copyflag | ||
) |
[in] | da | |
[in] | copyflag | L_NOCOPY or L_COPY |
Notes: (1) If copyflag == L_COPY, it makes a copy which the caller is responsible for freeing. Otherwise, it operates directly on the bare array of the l_dna. (2) Very important: for L_NOCOPY, any writes to the array will be in the l_dna. Do not write beyond the size of the count field, because it will not be accessible from the l_dna! If necessary, be sure to set the count field to a larger number (such as the alloc size) BEFORE calling this function. Creating with l_dnaMakeConstant() is another way to insure full initialization.
Definition at line 864 of file dnabasic.c.
References L_Dna::array, l_dnaGetCount(), and L_NOCOPY.
l_ok l_dnaGetDValue | ( | L_DNA * | da, |
l_int32 | index, | ||
l_float64 * | pval | ||
) |
[in] | da | |
[in] | index | into l_dna |
[out] | pval | double value; 0.0 on error |
Notes: (1) Caller may need to check the function return value to decide if a 0.0 in the returned ival is valid.
Definition at line 692 of file dnabasic.c.
References L_Dna::array, and L_Dna::n.
Referenced by l_dnaConvertToNuma(), l_dnaIntersectionByHmap(), l_dnaJoin(), l_dnaMakeHistoByHmap(), l_dnaRemoveDupsByHmap(), l_dnaSelectRange(), l_hmapCreateFromDna(), and makeColorfillTestData().
l_int32* l_dnaGetIArray | ( | L_DNA * | da | ) |
[in] | da |
Notes: (1) A copy of the array is made, because we need to generate an integer array from the bare double array. The caller is responsible for freeing the array. (2) The array size is determined by the number of stored numbers, not by the size of the allocated array in the l_dna. (3) This function is provided to simplify calculations using the bare internal array, rather than continually calling accessors on the l_dna. It is typically used on an array of size 256.
Definition at line 820 of file dnabasic.c.
References l_dnaGetCount(), and l_dnaGetIValue().
Referenced by generateOutputDataPdf(), and substituteObjectNumbers().
l_ok l_dnaGetIValue | ( | L_DNA * | da, |
l_int32 | index, | ||
l_int32 * | pival | ||
) |
[in] | da | |
[in] | index | into l_dna |
[out] | pival | integer value; 0 on error |
Notes: (1) Caller may need to check the function return value to decide if a 0 in the returned ival is valid.
Definition at line 727 of file dnabasic.c.
References L_Dna::array, and L_Dna::n.
Referenced by arrayReplaceEachSequence(), l_dnaDiffAdjValues(), l_dnaGetIArray(), parseTrailerPdf(), recogGetClassIndex(), and recogShowContent().
l_ok l_dnaGetParameters | ( | L_DNA * | da, |
l_float64 * | pstartx, | ||
l_float64 * | pdelx | ||
) |
[in] | da | |
[out] | pstartx | [optional] startx |
[out] | pdelx | [optional] delx |
Definition at line 935 of file dnabasic.c.
References L_Dna::delx, and L_Dna::startx.
Referenced by l_dnaCopyParameters(), l_dnaWriteStderr(), and l_dnaWriteStream().
l_int32 l_dnaGetRefcount | ( | L_DNA * | da | ) |
l_dnaGetRefCount()
[in] | da |
Definition at line 896 of file dnabasic.c.
References L_Dna::refcount.
Referenced by l_dnaDestroy().
l_ok l_dnaInsertNumber | ( | L_DNA * | da, |
l_int32 | index, | ||
l_float64 | val | ||
) |
[in] | da | |
[in] | index | location in da to insert new value |
[in] | val | float64 or integer to be added |
Notes: (1) This shifts da[i] --> da[i + 1] for all i >= index, and then inserts val as da[index]. (2) It should not be used repeatedly on large arrays, because the function is O(n).
Definition at line 526 of file dnabasic.c.
References L_Dna::array, l_dnaExtendArray(), l_dnaGetCount(), L_Dna::n, and L_Dna::nalloc.
L_DNA* l_dnaMakeSequence | ( | l_float64 | startval, |
l_float64 | increment, | ||
l_int32 | size | ||
) |
[in] | startval | |
[in] | increment | |
[in] | size | of sequence |
Definition at line 297 of file dnabasic.c.
References l_dnaAddNumber(), and l_dnaCreate().
L_DNA* l_dnaRead | ( | const char * | filename | ) |
[in] | filename |
Definition at line 1014 of file dnabasic.c.
References fopenReadStream(), and l_dnaReadStream().
L_DNA* l_dnaReadMem | ( | const l_uint8 * | data, |
size_t | size | ||
) |
[in] | data | dna serialization; in ascii |
[in] | size | of data; can use strlen to get it |
Definition at line 1096 of file dnabasic.c.
References fopenReadFromMemory(), and l_dnaReadStream().
L_DNA* l_dnaReadStream | ( | FILE * | fp | ) |
[in] | fp | file stream |
Notes: (1) fscanf takes lf to read a double; fprintf takes f to write it. (2) It is OK for the dna to be empty.
Definition at line 1047 of file dnabasic.c.
References DNA_VERSION_NUMBER.
Referenced by l_dnaRead(), and l_dnaReadMem().
l_ok l_dnaRemoveNumber | ( | L_DNA * | da, |
l_int32 | index | ||
) |
[in] | da | |
[in] | index | element to be removed |
Notes: (1) This shifts da[i] --> da[i - 1] for all i > index. (2) It should not be used repeatedly on large arrays, because the function is O(n).
Definition at line 569 of file dnabasic.c.
References L_Dna::array, l_dnaGetCount(), and L_Dna::n.
l_ok l_dnaReplaceNumber | ( | L_DNA * | da, |
l_int32 | index, | ||
l_float64 | val | ||
) |
[in] | da | |
[in] | index | element to be replaced |
[in] | val | new value to replace old one |
Definition at line 600 of file dnabasic.c.
References L_Dna::array, and l_dnaGetCount().
l_ok l_dnaSetCount | ( | L_DNA * | da, |
l_int32 | newcount | ||
) |
[in] | da | |
[in] | newcount |
Notes: (1) If newcount <= da->nalloc, this resets da->n. Using newcount = 0 is equivalent to l_dnaEmpty(). (2) If newcount > da->nalloc, this causes a realloc to a size da->nalloc = newcount. (3) All the previously unused values in da are set to 0.0.
Definition at line 658 of file dnabasic.c.
References L_Dna::array, L_Dna::n, L_Dna::nalloc, and reallocNew().
l_ok l_dnaSetParameters | ( | L_DNA * | da, |
l_float64 | startx, | ||
l_float64 | delx | ||
) |
[in] | da | |
[in] | startx | x value corresponding to da[0] |
[in] | delx | difference in x values for the situation where the elements of da correspond to the evaluation of a function at equal intervals of size delx |
Definition at line 965 of file dnabasic.c.
References L_Dna::delx, and L_Dna::startx.
Referenced by l_dnaCopyParameters().
l_ok l_dnaSetValue | ( | L_DNA * | da, |
l_int32 | index, | ||
l_float64 | val | ||
) |
[in] | da | |
[in] | index | to element to be set |
[in] | val | to set element |
Definition at line 759 of file dnabasic.c.
References L_Dna::array, and L_Dna::n.
l_ok l_dnaShiftValue | ( | L_DNA * | da, |
l_int32 | index, | ||
l_float64 | diff | ||
) |
[in] | da | |
[in] | index | to element to change relative to the current value |
[in] | diff | increment if diff > 0 or decrement if diff < 0 |
Definition at line 784 of file dnabasic.c.
References L_Dna::array, and L_Dna::n.
l_ok l_dnaWrite | ( | const char * | filename, |
L_DNA * | da | ||
) |
[in] | filename | |
[in] | da |
Definition at line 1124 of file dnabasic.c.
References fopenWriteStream(), and l_dnaWriteStream().
l_ok l_dnaWriteMem | ( | l_uint8 ** | pdata, |
size_t * | psize, | ||
L_DNA * | da | ||
) |
[out] | pdata | data of serialized dna; ascii |
[out] | psize | size of returned data |
[in] | da |
Notes: (1) Serializes a dna in memory and puts the result in a buffer.
Definition at line 1231 of file dnabasic.c.
References fopenWriteWinTempfile(), l_binaryReadStream(), and l_dnaWriteStream().
l_ok l_dnaWriteStderr | ( | L_DNA * | da | ) |
l_dnaWriteStrderr()
[in] | da |
Definition at line 1191 of file dnabasic.c.
References L_Dna::array, DNA_VERSION_NUMBER, l_dnaGetCount(), l_dnaGetParameters(), and lept_stderr().
Referenced by l_dnaWriteStream(), and parseTrailerPdf().
l_ok l_dnaWriteStream | ( | FILE * | fp, |
L_DNA * | da | ||
) |
[in] | fp | file stream; use NULL to write to stderr |
[in] | da |
Definition at line 1155 of file dnabasic.c.
References L_Dna::array, DNA_VERSION_NUMBER, l_dnaGetCount(), l_dnaGetParameters(), and l_dnaWriteStderr().
Referenced by l_dnaaWriteStream(), l_dnaWrite(), and l_dnaWriteMem().
|
static |
n'importe quoi
Definition at line 164 of file dnabasic.c.