Leptonica 1.54
|
Input: na2d row of 2d array col of 2d array val (float or int to be added; stored as a float) Return: 0 if OK, 1 on error
Input: nrows (of 2d array) ncols (of 2d array) initsize (initial size of each allocated numa) Return: numa2d, or null on error
Notes: (1) The numa2d holds a doubly-indexed array of numa. (2) The numa ptr array is initialized with all ptrs set to NULL. (3) The numas are created only when a number is to be stored at an index (i,j) for which a numa has not yet been made.
void numa2dDestroy | ( | NUMA2D ** | pna2d | ) |
Input: &numa2d (<to be="" nulled="" if="" it="" exists>="">) Return: void
Input: na2d row of 2d array col of 2d array Return: size of numa at [row][col], or 0 if the numa doesn't exist or on error
l_int32 numa2dGetFValue | ( | NUMA2D * | na2d, |
l_int32 | row, | ||
l_int32 | col, | ||
l_int32 | index, | ||
l_float32 * | pval | ||
) |
Input: na2d row of 2d array col of 2d array index (into numa) &val (<return> float value) Return: 0 if OK, 1 on error
Input: na2d row of 2d array col of 2d array index (into numa) &val (<return> integer value) Return: 0 if OK, 1 on error
Input: na2d row of 2d array col of 2d array Return: na (a clone of the numa if it exists) or null if it doesn't
Notes: (1) This does not give an error if the index is out of bounds.
Input: naa na (to be added) copyflag (L_INSERT, L_COPY, L_CLONE) Return: 0 if OK, 1 on error
Input: naa index (of numa within numaa) val (float or int to be added; stored as a float) Return: 0 if OK, 1 on error
Notes: (1) Adds to an existing numa only.
Input: size of numa ptr array to be alloc'd (0 for default) Return: naa, or null on error
Input: na val (float or int to be added; stored as a float) Return: 0 if OK, 1 on error
void numaaDestroy | ( | NUMAA ** | pnaa | ) |
Input: &numaa <to be="" nulled="" if="" it="" exists>=""> Return: void
Input: naa Return: 0 if OK, 1 on error
Input: naa Return: count (number of numa), or 0 if no numa or on error
Input: naa index (to the index-th numa) accessflag (L_COPY or L_CLONE) Return: numa, or null on error
Input: naa index (of numa in naa) Return: count of numbers in the referenced numa, or 0 on error.
Input: naa Return: count (total number of numbers in the numaa), or 0 if no numbers or on error
Input: naa Return: the internal array of ptrs to Numa, or null on error
Notes: (1) This function is convenient for doing direct manipulation on a fixed size array of Numas. To do this, it sets the count to the full size of the allocated array of Numa ptrs. The originating Numaa owns this array: DO NOT free it! (2) Intended usage: Numaa *naa = numaaCreate(n); Numa **array = numaaGetPtrArray(naa); ... [manipulate Numas directly on the array] numaaDestroy(&naa); (3) Cautions:
Input: naa i (index of numa within numaa) j (index into numa) val (<return> float value) Return: 0 if OK, 1 on error
NUMAA* numaaRead | ( | const char * | filename | ) |
Input: filename Return: naa, or null on error
NUMAA* numaaReadStream | ( | FILE * | fp | ) |
Input: stream Return: naa, or null on error
Input: naa index (to the index-th numa) numa (insert and replace any existing one) Return: 0 if OK, 1 on error
Notes: (1) Any existing numa is destroyed, and the input one is inserted in its place. (2) If the index is invalid, return 1 (error)
Input: filename, naa Return: 0 if OK, 1 on error
Input: stream, naa Return: 0 if OK, 1 on error
numaChangeRefCount()
Input: na delta (change to be applied) Return: 0 if OK, 1 on error
Input: na Return: ptr to same numa, or null on error
Input: na Return: copy of numa, or null on error
Input: size of number array to be alloc'd (0 for default) Return: na, or null on error
Input: farray (float) size (of the array) copyflag (L_INSERT or L_COPY) Return: na, or null on error
Notes: (1) With L_INSERT, ownership of the input array is transferred to the returned numa, and all elements are considered to be valid.
Input: iarray (integer) size (of the array) Return: na, or null on error
Notes: (1) We can't insert this int array into the numa, because a numa takes a float array. So this just copies the data from the input array into the numa. The input array continues to be owned by the caller.
void numaDestroy | ( | NUMA ** | pna | ) |
Input: &na (<to be="" nulled="" if="" it="" exists>="">) Return: void
Notes: (1) Decrements the ref count and, if 0, destroys the numa. (2) Always nulls the input ptr.
Input: na Return: 0 if OK; 1 on error
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.
Input: na Return: 0 if OK, 1 on error
Input: na Return: count, or 0 if no numbers or on error
Input: na copyflag (L_NOCOPY or L_COPY) Return: either the bare internal array or a copy of it, or null on error
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 numa. (2) Very important: for L_NOCOPY, any writes to the array will be in the numa. Do not write beyond the size of the count field, because it will not be accessable from the numa! If necessary, be sure to set the count field to a larger number (such as the alloc size) BEFORE calling this function. Creating with numaMakeConstant() is another way to insure full initialization.
Input: na index (into numa) &val (<return> float value; 0.0 on error) Return: 0 if OK; 1 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.
Input: na Return: a copy of the bare internal array, integerized by rounding, or null on error Notes: (1) A copy of the array is always made, because we need to generate an integer array from the bare float 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 Numa. (3) This function is provided to simplify calculations using the bare internal array, rather than continually calling accessors on the numa. It is typically used on an array of size 256.
Input: na index (into numa) &ival (<return> integer value; 0 on error) Return: 0 if OK; 1 on error
Notes: (1) Caller may need to check the function return value to decide if a 0 in the returned ival is valid.
numaGetRefCount()
Input: na Return: refcount, or UNDEF on error
Input: na &startx (<optional return>=""> startx) &delx (<optional return>=""> delx) Return: 0 if OK, 1 on error
Input: nahash key (key to be hashed into a bucket number) value (float value to be appended to the specific numa) Return: 0 if OK; 1 on error
Input: nbuckets (the number of buckets in the hash table, which should be prime.) initsize (initial size of each allocated numa; 0 for default) Return: ptr to new nahash, or null on error
Note: actual numa are created only as required by numaHashAdd()
void numaHashDestroy | ( | NUMAHASH ** | pnahash | ) |
Input: &nahash (<to be nulled, if it exists>) Return: void
Input: nahash key (key to be hashed into a bucket number) Return: ptr to numa
Input: na index (location in na to insert new value) val (float32 or integer to be added) Return: 0 if OK, 1 on error
Notes: (1) This shifts na[i] --> na[i + 1] for all i >= index, and then inserts val as na[index]. (2) It should not be used repeatedly on large arrays, because the function is O(n).
NUMA* numaRead | ( | const char * | filename | ) |
Input: filename Return: na, or null on error
NUMA* numaReadStream | ( | FILE * | fp | ) |
Input: stream Return: numa, or null on error
Input: na index (element to be removed) Return: 0 if OK, 1 on error
Notes: (1) This shifts na[i] --> na[i - 1] for all i > index. (2) It should not be used repeatedly on large arrays, because the function is O(n).
Input: na index (element to be replaced) val (new value to replace old one) Return: 0 if OK, 1 on error
Input: na newcount Return: 0 if OK, 1 on error
Notes: (1) If newcount <= na->nalloc, this resets na->n. Using newcount = 0 is equivalent to numaEmpty(). (2) If newcount > na->nalloc, this causes a realloc to a size na->nalloc = newcount. (3) All the previously unused values in na are set to 0.0.
Input: na index (to element to be set) val (to set element) Return: 0 if OK; 1 on error
Input: na startx (x value corresponding to na[0]) delx (difference in x values for the situation where the elements of na correspond to the evaulation of a function at equal intervals of size ) Return: 0 if OK, 1 on error
Input: na index (to element to change relative to the current value) diff (increment if diff > 0 or decrement if diff < 0) Return: 0 if OK; 1 on error
Input: filename, na Return: 0 if OK, 1 on error
Input: stream, na Return: 0 if OK, 1 on error
const l_int32 INITIAL_PTR_ARRAYSIZE = 50 [static] |