Leptonica 1.68
C Image Processing Library

numabasic.c File Reference

Basic operations for float/int arrays (Numa, Numaa, Numa2d, NumaHash) More...

#include <string.h>
#include <math.h>
#include "allheaders.h"

Go to the source code of this file.

Functions

NUMAnumaCreate (l_int32 n)
NUMAnumaCreateFromIArray (l_int32 *iarray, l_int32 size)
NUMAnumaCreateFromFArray (l_float32 *farray, l_int32 size, l_int32 copyflag)
void numaDestroy (NUMA **pna)
NUMAnumaCopy (NUMA *na)
NUMAnumaClone (NUMA *na)
l_int32 numaEmpty (NUMA *na)
l_int32 numaAddNumber (NUMA *na, l_float32 val)
l_int32 numaExtendArray (NUMA *na)
l_int32 numaInsertNumber (NUMA *na, l_int32 index, l_float32 val)
l_int32 numaRemoveNumber (NUMA *na, l_int32 index)
l_int32 numaReplaceNumber (NUMA *na, l_int32 index, l_float32 val)
l_int32 numaGetCount (NUMA *na)
l_int32 numaSetCount (NUMA *na, l_int32 newcount)
l_int32 numaGetFValue (NUMA *na, l_int32 index, l_float32 *pval)
l_int32 numaGetIValue (NUMA *na, l_int32 index, l_int32 *pival)
l_int32 numaSetValue (NUMA *na, l_int32 index, l_float32 val)
l_int32 numaShiftValue (NUMA *na, l_int32 index, l_float32 diff)
l_int32numaGetIArray (NUMA *na)
l_float32numaGetFArray (NUMA *na, l_int32 copyflag)
l_int32 numaGetRefcount (NUMA *na)
l_int32 numaChangeRefcount (NUMA *na, l_int32 delta)
l_int32 numaGetXParameters (NUMA *na, l_float32 *pstartx, l_float32 *pdelx)
l_int32 numaSetXParameters (NUMA *na, l_float32 startx, l_float32 delx)
l_int32 numaCopyXParameters (NUMA *nad, NUMA *nas)
NUMAnumaRead (const char *filename)
NUMAnumaReadStream (FILE *fp)
l_int32 numaWrite (const char *filename, NUMA *na)
l_int32 numaWriteStream (FILE *fp, NUMA *na)
NUMAAnumaaCreate (l_int32 n)
void numaaDestroy (NUMAA **pnaa)
l_int32 numaaAddNuma (NUMAA *naa, NUMA *na, l_int32 copyflag)
l_int32 numaaExtendArray (NUMAA *naa)
l_int32 numaaGetCount (NUMAA *naa)
l_int32 numaaGetNumaCount (NUMAA *naa, l_int32 index)
l_int32 numaaGetNumberCount (NUMAA *naa)
NUMA ** numaaGetPtrArray (NUMAA *naa)
NUMAnumaaGetNuma (NUMAA *naa, l_int32 index, l_int32 accessflag)
l_int32 numaaReplaceNuma (NUMAA *naa, l_int32 index, NUMA *na)
l_int32 numaaGetValue (NUMAA *naa, l_int32 i, l_int32 j, l_float32 *pval)
l_int32 numaaAddNumber (NUMAA *naa, l_int32 index, l_float32 val)
NUMAAnumaaRead (const char *filename)
NUMAAnumaaReadStream (FILE *fp)
l_int32 numaaWrite (const char *filename, NUMAA *naa)
l_int32 numaaWriteStream (FILE *fp, NUMAA *naa)
NUMA2Dnuma2dCreate (l_int32 nrows, l_int32 ncols, l_int32 initsize)
void numa2dDestroy (NUMA2D **pna2d)
l_int32 numa2dAddNumber (NUMA2D *na2d, l_int32 row, l_int32 col, l_float32 val)
l_int32 numa2dGetCount (NUMA2D *na2d, l_int32 row, l_int32 col)
NUMAnuma2dGetNuma (NUMA2D *na2d, l_int32 row, l_int32 col)
l_int32 numa2dGetFValue (NUMA2D *na2d, l_int32 row, l_int32 col, l_int32 index, l_float32 *pval)
l_int32 numa2dGetIValue (NUMA2D *na2d, l_int32 row, l_int32 col, l_int32 index, l_int32 *pval)
NUMAHASHnumaHashCreate (l_int32 nbuckets, l_int32 initsize)
void numaHashDestroy (NUMAHASH **pnahash)
NUMAnumaHashGetNuma (NUMAHASH *nahash, l_uint32 key)
l_int32 numaHashAdd (NUMAHASH *nahash, l_uint32 key, l_float32 value)

Variables

static const l_int32 INITIAL_PTR_ARRAYSIZE = 50

Detailed Description

Basic operations for float/int arrays (Numa, Numaa, Numa2d, NumaHash)

    Numa creation, destruction, copy, clone, etc.
        NUMA        *numaCreate()
        NUMA        *numaCreateFromIArray()
        NUMA        *numaCreateFromFArray()
        void        *numaDestroy()
        NUMA        *numaCopy()
        NUMA        *numaClone()
        l_int32      numaEmpty()

    Add/remove number (float or integer)
        l_int32      numaAddNumber()
        l_int32      numaExtendArray()
        l_int32      numaInsertNumber()
        l_int32      numaRemoveNumber()
        l_int32      numaReplaceNumber()

    Numa accessors
        l_int32      numaGetCount()
        l_int32      numaSetCount()
        l_int32      numaGetIValue()
        l_int32      numaGetFValue()
        l_int32      numaSetValue()
        l_int32      numaShiftValue()
        l_int32     *numaGetIArray()
        l_float32   *numaGetFArray()
        l_int32      numaGetRefcount()
        l_int32      numaChangeRefcount()
        l_int32      numaGetXParameters()
        l_int32      numaSetXParameters()
        l_int32      numaCopyXParameters()

    Serialize numa for I/O
        l_int32      numaRead()
        l_int32      numaReadStream()
        l_int32      numaWrite()
        l_int32      numaWriteStream()

    Numaa creation, destruction
        NUMAA       *numaaCreate()
        void        *numaaDestroy()

    Add Numa to Numaa
        l_int32      numaaAddNuma()
        l_int32      numaaExtendArray()

    Numaa accessors
        l_int32      numaaGetCount()
        l_int32      numaaGetNumaCount()
        l_int32      numaaGetNumberCount()
        NUMA       **numaaGetPtrArray()
        NUMA        *numaaGetNuma()
        NUMA        *numaaReplaceNuma()
        l_int32      numaaGetValue()
        l_int32      numaaAddNumber()

    Serialize numaa for I/O
        l_int32      numaaRead()
        l_int32      numaaReadStream()
        l_int32      numaaWrite()
        l_int32      numaaWriteStream()

    Numa2d creation, destruction
        NUMA2D      *numa2dCreate()
        void        *numa2dDestroy()

    Numa2d Accessors
        l_int32      numa2dAddNumber()
        l_int32      numa2dGetCount()
        NUMA        *numa2dGetNuma()
        l_int32      numa2dGetFValue()
        l_int32      numa2dGetIValue()

    NumaHash creation, destruction
        NUMAHASH    *numaHashCreate()
        void        *numaHashDestroy()

    NumaHash Accessors
        NUMA        *numaHashGetNuma()
        void        *numaHashAdd()

  (1) The numa is a struct, not an array.  Always use the accessors
      in this file, never the fields directly.

  (2) The number array holds l_float32 values.  It can also
      be used to store l_int32 values.

  (3) Storing and retrieving numbers:

 to append a new number to the array, use numaAddNumber().  If
       the number is an int, it will will automatically be converted
       to l_float32 and stored.

 to reset a value stored in the array, use numaSetValue().

 to increment or decrement a value stored in the array,
       use numaShiftValue().

 to obtain a value from the array, use either numaGetIValue()
       or numaGetFValue(), depending on whether you are retrieving
       an integer or a float.  This avoids doing an explicit cast,
       such as
         (a) return a l_float32 and cast it to an l_int32
         (b) cast the return directly to (l_float32 *) to
             satisfy the function prototype, as in
               numaGetFValue(na, index, (l_float32 *)&ival);   [ugly!]

  (4) int <--> float conversions:

      Tradition dictates that type conversions go automatically from
      l_int32 --> l_float32, even though it is possible to lose
      precision for large integers, whereas you must cast (l_int32)
      to go from l_float32 --> l_int32 because you're truncating
      to the integer value.

  (5) As with other arrays in leptonica, the numa 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 numaSetCount().  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 numa 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 numa, and the two
      numas are typically denoted nay and nax.

  (7) The numa is also the basic struct used for histograms.  Every numa
      has startx and delx fields, initialized to 0.0 and 1.0, that can
      be used to represent the "x" value for the location of the
      first bin and the bin width, respectively.  Accessors are the
      numa*XParameters() functions.  All functions that make numa
      histograms must set these fields properly, and many functions
      that use numa histograms rely on the correctness of these values.

Definition in file numabasic.c.


Function Documentation

NUMA* numaCreate ( l_int32  n)

numaCreate()

Input: size of number array to be alloc'd (0 for default) Return: na, or null on error

Definition at line 177 of file numabasic.c.

References Numa::array, CALLOC, Numa::delx, ERROR_PTR, INITIAL_PTR_ARRAYSIZE, Numa::n, Numa::nalloc, NULL, PROCNAME, Numa::refcount, and Numa::startx.

Referenced by addColorizedGrayToCmap(), arrayFindEachSequence(), bmfGetWordWidths(), boxaaFlattenToBoxa(), boxaBinSort(), boxaExtractSortedPattern(), boxaGetRankSize(), boxaMakeSizeIndicator(), boxaSort(), boxaSort2d(), BoxaSortTest(), ccbaGenerateStepChains(), ccbaReadStream(), dewarpBuildModel(), fpixBuildHorizontalDisparity(), gplotCreate(), jbAccumulateComposites(), jbClasserCreate(), jbDataRead(), jbWordsInTextlines(), kernelCreateFromFile(), main(), mergeLookup(), numa2dAddNumber(), numaaCompareImagesByBoxes(), numaaFlattenToNuma(), numaClipToInterval(), numaContrastTRC(), numaConvertToInt(), numaCopy(), numaCreateFromFArray(), numaCreateFromIArray(), numaCrossingsByPeaks(), numaCrossingsByThreshold(), numaDifferentiateInterval(), numaDiscretizeRankAndIntensity(), numaEqualizeTRC(), numaEvalSyncError(), numaFindExtrema(), numaFindPeaks(), numaGammaTRC(), numaGetBinSortIndex(), numaGetCrossingDistances(), numaGetPartialSums(), numaGetPeakCentroids(), numaGetPeakWidthLUT(), numaGetSortIndex(), numaHashAdd(), numaInterpolateArbxInterval(), numaInterpolateEqxInterval(), numaLocatePeakRanges(), numaLowPassIntervals(), numaMakeDelta(), numaMakeHistogram(), numaMakeHistogramAuto(), numaMakeHistogramClipped(), numaMakeRankFromHistogram(), numaMakeSequence(), numaMakeThresholdIndicator(), numaNormalizeHistogram(), numaQuantizeCrossingsByWidth(), numaQuantizeCrossingsByWindow(), numaRandomPermutation(), numaReadStream(), numaRebinHistogram(), numaSelectCrossingThreshold(), numaSortByIndex(), numaSplitDistribution(), numaSubsample(), numaThresholdEdges(), numaTransform(), numaUniformSampling(), octreeGenerateAndPrune(), parseStringForNumbers(), parseTrailerPdf(), pdfdataCreate(), pixaaFlattenToPixa(), pixaBinSort(), pixaCountPixels(), pixaDisplayTiledInRows(), pixaFindAreaFraction(), pixaFindAreaPerimRatio(), pixaFindDimensions(), pixaFindPerimSizeRatio(), pixaFindWidthHeightProduct(), pixaFindWidthHeightRatio(), pixaSort(), pixAverageIntensityProfile(), pixAverageRasterScans(), pixcmapGetRankIntensity(), pixColorSegmentClean(), pixCompareRankDifference(), pixCountPixelsByColumn(), pixCountPixelsByRow(), pixExtractOnLine(), pixFillMapHoles(), pixFindBaselines(), pixFindHistoPeaksHSV(), pixFindSkewSweep(), pixFindSkewSweepAndSearchScorePivot(), pixGetBinnedColor(), pixGetCmapHistogram(), pixGetCmapHistogramMasked(), pixGetColorHistogram(), pixGetColorHistogramMasked(), pixGetDifferenceHistogram(), pixGetEdgeProfile(), pixGetGrayHistogram(), pixGetGrayHistogramMasked(), pixGetLocalSkewAngles(), pixGetRunCentersOnLine(), pixGetRunsOnLine(), pixMakeHistoHS(), pixMakeHistoHV(), pixMakeHistoSV(), pixOctcubeHistogram(), pixPlotAlongPta(), pixReversalProfile(), pixRunHistogramMorph(), pixSelectMinInConnComp(), pixSplitComponentIntoBoxa(), pixSumPixelsByColumn(), pixSumPixelsByRow(), pixWordMaskByDilation(), ptaaRemoveShortLines(), ptaGetArrays(), ptaGetCubicLSF(), ptaGetLinearLSF(), ptaGetQuadraticLSF(), ptaGetQuarticLSF(), ptaSort(), ptraConcatenatePdfToData(), selaCreateFromFile(), and wshedApply().

NUMA* numaCreateFromIArray ( l_int32 iarray,
l_int32  size 
)

numaCreateFromIArray()

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.

Definition at line 215 of file numabasic.c.

References ERROR_PTR, NULL, numaAddNumber(), numaCreate(), PROCNAME, and size.

Referenced by numaPseudorandomSequence().

NUMA* numaCreateFromFArray ( l_float32 farray,
l_int32  size,
l_int32  copyflag 
)

numaCreateFromFArray()

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.

Definition at line 250 of file numabasic.c.

References Numa::array, ERROR_PTR, FREE, L_COPY, L_INSERT, Numa::n, NULL, numaAddNumber(), numaCreate(), PROCNAME, and size.

Referenced by pixColumnStats(), and pixRowStats().

void numaDestroy ( NUMA **  pna)

numaDestroy()

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.

Definition at line 292 of file numabasic.c.

References Numa::array, FREE, L_WARNING, NULL, numaChangeRefcount(), numaGetRefcount(), and PROCNAME.

Referenced by addColorizedGrayToCmap(), arrayFindEachSequence(), bmfGetLineStrings(), boxaBinSort(), boxaEqual(), boxaGetRankSize(), boxaPermutePseudorandom(), boxaSelectBySize(), boxaSort(), boxaSort2d(), boxaSort2dByIndex(), BoxaSortTest(), ccbaStepChainsToPixCoords(), ccbaWriteStream(), dewarpBuildModel(), dewarpDestroy(), dewarpMinimize(), findSimilarSizedTemplatesDestroy(), findSimilarSizedTemplatesNext(), fpixBuildHorizontalDisparity(), GenerateSplitPlot(), gplotDestroy(), gplotRead(), gplotSimpleN(), jbClasserDestroy(), jbClassifyRankHaus(), jbDataDestroy(), jbWordsInTextlines(), kernelCreateFromFile(), kernelCreateFromString(), main(), mergeLookup(), numa2dDestroy(), numaaAddNumber(), numaaCompareImagesByBoxes(), numaaDestroy(), numaaGetNumberCount(), numaaReplaceNuma(), numaaWriteStream(), numaClose(), numaCountReversals(), numaCrossingsByPeaks(), numaDifferentiateInterval(), numaDiscretizeRankAndIntensity(), numaEqualizeTRC(), numaEvalSyncError(), numaFindPeaks(), numaGetBinSortIndex(), numaGetCrossingDistances(), numaGetMode(), numaGetRankBinValues(), numaGetRankValue(), numaGetStatsUsingHistogram(), numaHashDestroy(), numaIntegrateInterval(), numaInterpolateArbxInterval(), numaMakeHistogram(), numaMakeRankFromHistogram(), numaMakeThresholdIndicator(), numaOpen(), numaQuantizeCrossingsByWidth(), numaQuantizeCrossingsByWindow(), numaRandomPermutation(), numaSelectCrossingThreshold(), numaSortPair(), numaSplitDistribution(), numaWindowedMean(), numaWindowedMeanSquare(), numaWindowedStats(), octreeGenerateAndPrune(), parseTrailerPdf(), pdfdataDestroy(), pixaBinSort(), pixaDisplayTiledInRows(), pixaEqual(), pixaSelectByAreaFraction(), pixaSelectByAreaPerimRatio(), pixaSelectBySize(), pixaSelectByWidthHeightRatio(), pixaSort(), pixaSort2dByIndex(), PixaSortTest(), pixcmapContrastTRC(), pixcmapGammaTRC(), pixcmapGetRankIntensity(), pixColorContent(), pixColorGrayCmap(), pixColorMagnitude(), pixColorSegmentClean(), pixColorSegmentRemoveColors(), pixCompareGray(), pixCompareRankDifference(), pixCompareRGB(), pixContrastTRC(), pixContrastTRCMasked(), pixConvertGrayToColormap8(), pixConvertRGBToColormap(), pixDisplayPtaa(), pixEqualizeTRC(), pixExtractBarcodeCrossings(), pixExtractBarcodeWidths1(), pixExtractBarcodeWidths2(), pixFillMapHoles(), pixFindBaselines(), pixFindDifferentialSquareSum(), pixFindNormalizedSquareSum(), pixFindSkewSweep(), pixFindSkewSweepAndSearchScorePivot(), pixGammaTRC(), pixGammaTRCMasked(), pixGammaTRCWithAlpha(), pixGenerateSelWithRuns(), pixGetBinnedColor(), pixGetDifferenceStats(), pixGetGrayHistogram(), pixGetLocalSkewAngles(), pixGetLocalSkewTransform(), pixGetRankColorArray(), pixGetRankValueMasked(), pixGetRunCentersOnLine(), pixGetTextBaseline(), pixGlobalNormRGB(), pixGrayQuantFromHisto(), pixMeasureEdgeSmoothness(), pixNumSignificantGrayColors(), pixPlotAlongPta(), pixReadBarcodes(), pixReversalProfile(), pixRunHistogramMorph(), pixSelectMinInConnComp(), pixSplitComponentIntoBoxa(), pixSplitDistributionFgBg(), pixThresholdGrayArb(), pixUsesCmapColor(), pixWordMaskByDilation(), ptaaRemoveShortLines(), ptaRemoveDuplicates(), ptaSort(), ptraConcatenatePdfToData(), selaCreateFromFile(), substituteObjectNumbers(), TestProjection(), wshedApply(), wshedDestroy(), and wshedRenderFill().

NUMA* numaClone ( NUMA na)

numaClone()

Input: na Return: ptr to same numa, or null on error

Definition at line 355 of file numabasic.c.

References ERROR_PTR, NULL, numaChangeRefcount(), and PROCNAME.

Referenced by jbDataSave(), numa2dGetNuma(), numaaAddNuma(), numaaGetNuma(), numaHashGetNuma(), numaInterpolateArbxInterval(), and wshedBasins().

l_int32 numaEmpty ( NUMA na)

numaEmpty()

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.

Definition at line 379 of file numabasic.c.

References ERROR_INT, Numa::n, and PROCNAME.

Referenced by main(), parseTrailerPdf(), and pixFindSkewSweepAndSearchScorePivot().

l_int32 numaAddNumber ( NUMA na,
l_float32  val 
)

numaAddNumber()

Input: na val (float or int to be added; stored as a float) Return: 0 if OK, 1 on error

Definition at line 403 of file numabasic.c.

References Numa::array, ERROR_INT, Numa::n, Numa::nalloc, numaExtendArray(), numaGetCount(), and PROCNAME.

Referenced by addColorizedGrayToCmap(), arrayFindEachSequence(), bmfGetWordWidths(), boxaaFlattenToBoxa(), boxaBinSort(), boxaExtractSortedPattern(), boxaGetRankSize(), boxaMakeSizeIndicator(), boxaSort(), boxaSort2d(), BoxaSortTest(), ccbaGenerateStepChains(), ccbaReadStream(), dewarpBuildModel(), fpixBuildHorizontalDisparity(), generateColormapStringsPdf(), generateContentStringPdf(), generateFixedStringsPdf(), generatePageStringPdf(), generatePreXStringsPdf(), generateTrailerPdf(), gplotAddPlot(), jbAccumulateComposites(), jbAddPageComponents(), jbClassifyCorrelation(), jbClassifyRankHaus(), jbDataRead(), main(), mergeLookup(), numa2dAddNumber(), numaaAddNumber(), numaaCompareImagesByBoxes(), numaClipToInterval(), numaContrastTRC(), numaConvertToInt(), numaCopy(), numaCreateFromFArray(), numaCreateFromIArray(), numaCrossingsByPeaks(), numaCrossingsByThreshold(), numaDifferentiateInterval(), numaDiscretizeRankAndIntensity(), numaEqualizeTRC(), numaFindExtrema(), numaFindPeaks(), numaGammaTRC(), numaGetBinSortIndex(), numaGetCrossingDistances(), numaGetPartialSums(), numaGetPeakCentroids(), numaGetSortIndex(), numaHashAdd(), numaInterpolateArbxInterval(), numaInterpolateEqxInterval(), numaJoin(), numaLocatePeakRanges(), numaLowPassIntervals(), numaMakeDelta(), numaMakeHistogramAuto(), numaMakeRankFromHistogram(), numaMakeSequence(), numaMakeThresholdIndicator(), numaNormalizeHistogram(), numaQuantizeCrossingsByWidth(), numaQuantizeCrossingsByWindow(), numaRandomPermutation(), numaReadStream(), numaRebinHistogram(), numaSelectCrossingThreshold(), numaSortByIndex(), numaSplitDistribution(), numaSubsample(), numaThresholdEdges(), numaTransform(), numaUniformSampling(), octreeGenerateAndPrune(), parseStringForNumbers(), parseTrailerPdf(), pixaaFlattenToPixa(), pixaBinSort(), pixaCountPixels(), pixaDisplayTiledInRows(), pixaFindAreaFraction(), pixaFindAreaPerimRatio(), pixaFindDimensions(), pixaFindPerimSizeRatio(), pixaFindWidthHeightProduct(), pixaFindWidthHeightRatio(), pixaSort(), pixAverageIntensityProfile(), pixcmapGetRankIntensity(), pixColorSegmentClean(), pixCountPixelsByRow(), pixExtractOnLine(), pixFillMapHoles(), pixFindBaselines(), pixFindHistoPeaksHSV(), pixFindSkewSweep(), pixFindSkewSweepAndSearchScorePivot(), pixGetBinnedColor(), pixGetEdgeProfile(), pixGetLocalSkewAngles(), pixGetRunCentersOnLine(), pixGetRunsOnLine(), pixPlotAlongPta(), pixReversalProfile(), pixRunHistogramMorph(), pixSearchForRectangle(), pixSelectMinInConnComp(), pixSumPixelsByRow(), pixWordMaskByDilation(), ptaaRemoveShortLines(), ptaGetCubicLSF(), ptaGetLinearLSF(), ptaGetQuadraticLSF(), ptaGetQuarticLSF(), ptaSort(), ptraConcatenatePdfToData(), selaCreateFromFile(), and wshedSaveBasin().

l_int32 numaExtendArray ( NUMA na)

numaExtendArray()

Input: na Return: 0 if OK, 1 on error

Definition at line 429 of file numabasic.c.

References Numa::array, ERROR_INT, Numa::nalloc, NULL, PROCNAME, and reallocNew().

Referenced by numaAddNumber(), and numaInsertNumber().

l_int32 numaInsertNumber ( NUMA na,
l_int32  index,
l_float32  val 
)

numaInsertNumber()

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).

Definition at line 462 of file numabasic.c.

References Numa::array, ERROR_INT, Numa::n, Numa::nalloc, numaExtendArray(), numaGetCount(), and PROCNAME.

Referenced by main().

l_int32 numaRemoveNumber ( NUMA na,
l_int32  index 
)

numaRemoveNumber()

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).

Definition at line 499 of file numabasic.c.

References Numa::array, ERROR_INT, Numa::n, numaGetCount(), and PROCNAME.

Referenced by main().

l_int32 numaReplaceNumber ( NUMA na,
l_int32  index,
l_float32  val 
)

numaReplaceNumber()

Input: na index (element to be replaced) val (new value to replace old one) Return: 0 if OK, 1 on error

Definition at line 528 of file numabasic.c.

References Numa::array, ERROR_INT, numaGetCount(), and PROCNAME.

Referenced by boxaEqual(), GenerateSplitPlot(), main(), pixSplitDistributionFgBg(), and ptraConcatenatePdfToData().

l_int32 numaGetCount ( NUMA na)

numaGetCount()

Input: na Return: count, or 0 if no numbers or on error

Definition at line 557 of file numabasic.c.

References ERROR_INT, Numa::n, and PROCNAME.

Referenced by arrayFindEachSequence(), bmfGetLineStrings(), boxaSelectWithIndicator(), boxaSort2dByIndex(), ccbaStepChainsToPixCoords(), ccbaWriteStream(), count_ones(), countAlignedMatches(), findSimilarSizedTemplatesNext(), generatePagesObjStringPdf(), generateTrailerPdf(), gplotAddPlot(), jbDataRender(), kernelCreateFromFile(), kernelCreateFromString(), main(), makeGrayQuantTableArb(), makeTrailerStringPdf(), mergeLookup(), numaaCompareImagesByBoxes(), numaAddBorder(), numaAddNumber(), numaAddSpecifiedBorder(), numaaGetNumaCount(), numaaGetNumberCount(), numaArithOp(), numaClipToInterval(), numaConvertToInt(), numaCountReversals(), numaCrossingsByPeaks(), numaCrossingsByThreshold(), numaDifferentiateInterval(), numaDilate(), numaDiscretizeRankAndIntensity(), numaErode(), numaEvalHaarSum(), numaEvalSyncError(), numaFindExtrema(), numaFindPeaks(), numaFitMax(), numaGetBinSortIndex(), numaGetCountRelativeToZero(), numaGetCrossingDistances(), numaGetEdgeValues(), numaGetFArray(), numaGetHistogramStatsOnInterval(), numaGetIArray(), numaGetMax(), numaGetMin(), numaGetMode(), numaGetNonzeroRange(), numaGetPartialSums(), numaGetPeakCentroids(), numaGetPeakWidthLUT(), numaGetRankBinValues(), numaGetRankValue(), numaGetSortIndex(), numaGetSpanValues(), numaGetStatsUsingHistogram(), numaGetSum(), numaGetSumOnInterval(), numaHasOnlyIntegers(), numaHistogramGetRankFromVal(), numaHistogramGetValFromRank(), numaInsertNumber(), numaIntegrateInterval(), numaInterpolateArbxInterval(), numaInterpolateArbxVal(), numaInterpolateEqxInterval(), numaInterpolateEqxVal(), numaInvert(), numaIsSorted(), numaJoin(), numaLocatePeakRanges(), numaLogicalOp(), numaLowPassIntervals(), numaMakeDelta(), numaMakeHistogram(), numaMakeHistogramAuto(), numaMakeHistogramClipped(), numaMakeRankFromHistogram(), numaMakeThresholdIndicator(), numaNormalizeHistogram(), numaQuantizeCrossingsByWidth(), numaQuantizeCrossingsByWindow(), numaRandomPermutation(), numaRebinHistogram(), numaRemoveBorder(), numaRemoveNumber(), numaReplaceNumber(), numaSelectCrossingThreshold(), numaSort(), numaSortByIndex(), numaSplitDistribution(), numaSubsample(), numaThresholdEdges(), numaTransform(), numaUniformSampling(), numaWindowedMean(), numaWindowedMeanSquare(), numaWindowedStats(), numaWindowedVariance(), numaWriteStream(), octreeGenerateAndPrune(), parseTrailerPdf(), pixAddWithIndicator(), pixaDisplayTiledInRows(), pixaSelectWithIndicator(), pixaSort2dByIndex(), pixFewColorsOctcubeQuant2(), pixFindBaselines(), pixFindDifferentialSquareSum(), pixFindSkewSweepAndSearchScorePivot(), pixGenerateSelWithRuns(), pixGetEdgeProfile(), pixGetRunCentersOnLine(), pixGetTextBaseline(), pixMeasureEdgeSmoothness(), pixReadBarcodes(), pixRemoveWithIndicator(), pixThresholdGrayArb(), pixTRCMap(), pixWordMaskByDilation(), pmsCreate(), ptaaSortByIndex(), ptaCreateFromNuma(), ptaRemoveDuplicates(), ptraConcatenatePdfToData(), selaCreateFromFile(), substituteObjectNumbers(), and writeCustomTiffTags().

l_int32 numaSetCount ( NUMA na,
l_int32  newcount 
)

numaSetCount()

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.

Definition at line 582 of file numabasic.c.

References Numa::array, ERROR_INT, Numa::n, Numa::nalloc, NULL, PROCNAME, and reallocNew().

Referenced by main(), numaEvalSyncError(), numaGetPeakWidthLUT(), numaMakeHistogram(), numaMakeHistogramAuto(), numaMakeHistogramClipped(), pixAverageRasterScans(), pixCompareRankDifference(), pixCountPixelsByColumn(), pixGetCmapHistogram(), pixGetCmapHistogramMasked(), pixGetColorHistogram(), pixGetColorHistogramMasked(), pixGetDifferenceHistogram(), pixGetGrayHistogram(), pixGetGrayHistogramMasked(), pixMakeHistoHS(), pixMakeHistoHV(), pixMakeHistoSV(), pixOctcubeHistogram(), and pixSumPixelsByColumn().

l_int32 numaGetFValue ( NUMA na,
l_int32  index,
l_float32 pval 
)

numaGetFValue()

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.

Definition at line 614 of file numabasic.c.

References Numa::array, ERROR_INT, Numa::n, and PROCNAME.

Referenced by dewarpBuildModel(), gplotAddPlot(), jbTemplatesFromComposites(), kernelCreateFromFile(), kernelCreateFromString(), main(), numa2dGetFValue(), numaArithOp(), numaClipToInterval(), numaCrossingsByPeaks(), numaCrossingsByThreshold(), numaDiscretizeRankAndIntensity(), numaEqualizeTRC(), numaEvalHaarSum(), numaEvalSyncError(), numaFindExtrema(), numaFindPeaks(), numaFitMax(), numaGetCountRelativeToZero(), numaGetCrossingDistances(), numaGetHistogramStatsOnInterval(), numaGetMax(), numaGetMin(), numaGetNonzeroRange(), numaGetPartialSums(), numaGetPeakCentroids(), numaGetRankValue(), numaGetStatsUsingHistogram(), numaGetSum(), numaGetSumOnInterval(), numaHasOnlyIntegers(), numaHistogramGetRankFromVal(), numaHistogramGetValFromRank(), numaInterpolateArbxVal(), numaIsSorted(), numaJoin(), numaLocatePeakRanges(), numaLowPassIntervals(), numaMakeHistogramAuto(), numaMakeHistogramClipped(), numaMakeRankFromHistogram(), numaMakeThresholdIndicator(), numaNormalizeHistogram(), numaQuantizeCrossingsByWidth(), numaQuantizeCrossingsByWindow(), numaRandomPermutation(), numaSortByIndex(), numaSplitDistribution(), numaSubsample(), numaThresholdEdges(), numaTransform(), pixFindDifferentialSquareSum(), pixFindNormalizedSquareSum(), pixFindSkewSweepAndSearchScorePivot(), pixGetLocalSkewTransform(), and ptaCreateFromNuma().

l_int32 numaGetIValue ( NUMA na,
l_int32  index,
l_int32 pival 
)

numaGetIValue()

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.

Definition at line 647 of file numabasic.c.

References Numa::array, ERROR_INT, L_SIGN, Numa::n, and PROCNAME.

Referenced by bmfGetLineStrings(), boxaExtractSortedPattern(), boxaSelectWithIndicator(), boxaSort2d(), boxaSort2dByIndex(), boxaSortByIndex(), ccbaStepChainsToPixCoords(), ccbaWriteStream(), count_ones(), generatePagesObjStringPdf(), generateTrailerPdf(), gplotGenCommandFile(), jbClassifyCorrelation(), jbClassifyRankHaus(), jbDataRender(), jbDataWrite(), jbGetLLCorners(), jbGetULCorners(), main(), makeGrayQuantTableArb(), makeTrailerStringPdf(), mergeLookup(), numa2dGetIValue(), numaaCompareImagesByBoxes(), numaConvertToInt(), numaCrossingsByPeaks(), numaDiscretizeRankAndIntensity(), numaEvalSyncError(), numaGetBinSortIndex(), numaGetEdgeValues(), numaGetIArray(), numaGetPeakCentroids(), numaGetPeakWidthLUT(), numaGetSpanValues(), numaInvert(), numaLogicalOp(), numaMakeDelta(), numaMakeHistogram(), numaMakeHistogramAuto(), numaMakeHistogramClipped(), numaQuantizeCrossingsByWidth(), numaQuantizeCrossingsByWindow(), numaRandomPermutation(), numaRebinHistogram(), numaSelectCrossingThreshold(), numaSortByIndex(), octreeGenerateAndPrune(), parseTrailerPdf(), pixAddWithIndicator(), pixaDisplayTiledInRows(), pixaEqual(), pixaSelectWithIndicator(), pixaSort2dByIndex(), pixaSortByIndex(), pixcmapContrastTRC(), pixcmapGammaTRC(), pixcmapGetRankIntensity(), pixColorSegmentClean(), pixColorSegmentRemoveColors(), pixConvertGrayToColormap8(), pixDisplayPtaa(), pixFillMapHoles(), pixFindBaselines(), pixGenerateSelWithRuns(), pixGetBinnedColor(), pixGetEdgeProfile(), pixGetRunCentersOnLine(), pixGetTextBaseline(), pixMeasureEdgeSmoothness(), pixNumSignificantGrayColors(), pixOctcubeHistogram(), pixReadBarcodes(), pixRemoveWithIndicator(), pixSplitComponentIntoBoxa(), pixUsesCmapColor(), ptaaRemoveShortLines(), ptaaSortByIndex(), ptaRemoveDuplicates(), ptaSort(), selaCreateFromFile(), testLineAlignmentX(), writeCustomTiffTags(), wshedApply(), wshedGetHeight(), and wshedRenderFill().

l_int32 numaShiftValue ( NUMA na,
l_int32  index,
l_float32  diff 
)

numaShiftValue()

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

Definition at line 704 of file numabasic.c.

References Numa::array, ERROR_INT, Numa::n, and PROCNAME.

Referenced by pixMakeHistoHS(), pixMakeHistoHV(), and pixMakeHistoSV().

l_int32* numaGetIArray ( NUMA na)

numaGetIArray()

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.

Definition at line 738 of file numabasic.c.

References CALLOC, ERROR_PTR, NULL, numaGetCount(), numaGetIValue(), and PROCNAME.

Referenced by countAlignedMatches(), generateOutputDataPdf(), numaFillCmapFromHisto(), pixColorContent(), pixColorGrayCmap(), pixColorMagnitude(), pixFindBaselines(), pixGlobalNormRGB(), pixTRCMap(), pmsCreate(), ptraConcatenatePdfToData(), substituteObjectNumbers(), and wshedApply().

l_float32* numaGetFArray ( NUMA na,
l_int32  copyflag 
)

numaGetFArray()

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.

Definition at line 781 of file numabasic.c.

References Numa::array, CALLOC, ERROR_PTR, L_NOCOPY, NULL, numaGetCount(), and PROCNAME.

Referenced by dewarpBuildModel(), fpixBuildHorizontalDisparity(), numaAddBorder(), numaAddSpecifiedBorder(), numaDifferentiateInterval(), numaDilate(), numaErode(), numaGetMode(), numaGetPeakWidthLUT(), numaGetSortIndex(), numaIntegrateInterval(), numaInterpolateArbxInterval(), numaInterpolateArbxVal(), numaInterpolateEqxVal(), numaRemoveBorder(), numaUniformSampling(), numaWindowedMean(), numaWindowedMeanSquare(), numaWindowedVariance(), pixAverageRasterScans(), pixColumnStats(), pixCompareRankDifference(), pixCountPixelsByColumn(), pixGetCmapHistogram(), pixGetCmapHistogramMasked(), pixGetColorHistogram(), pixGetColorHistogramMasked(), pixGetDifferenceHistogram(), pixGetDifferenceStats(), pixGetGrayHistogram(), pixGetGrayHistogramMasked(), pixOctcubeHistogram(), pixRowStats(), and pixSumPixelsByColumn().

l_int32 numaGetRefcount ( NUMA na)

numaGetRefCount()

Input: na Return: refcount, or UNDEF on error

Definition at line 813 of file numabasic.c.

References ERROR_INT, PROCNAME, Numa::refcount, and UNDEF.

Referenced by numaDestroy().

l_int32 numaChangeRefcount ( NUMA na,
l_int32  delta 
)

numaChangeRefCount()

Input: na delta (change to be applied) Return: 0 if OK, 1 on error

Definition at line 831 of file numabasic.c.

References ERROR_INT, PROCNAME, and Numa::refcount.

Referenced by numaClone(), and numaDestroy().

l_int32 numaSetXParameters ( NUMA na,
l_float32  startx,
l_float32  delx 
)

numaSetXParameters()

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

Definition at line 878 of file numabasic.c.

References Numa::delx, ERROR_INT, PROCNAME, and Numa::startx.

Referenced by numaAddBorder(), numaCopyXParameters(), numaInterpolateEqxInterval(), numaMakeHistogram(), numaMakeHistogramAuto(), numaMakeHistogramClipped(), numaReadStream(), numaRebinHistogram(), numaRemoveBorder(), numaUniformSampling(), pixAverageIntensityProfile(), pixExtractOnLine(), and pixReversalProfile().

l_int32 numaCopyXParameters ( NUMA nad,
NUMA nas 
)

numaCopyXParameters()

Input: nad (destination Numa) nas (source Numa) Return: 0 if OK, 1 on error

Definition at line 901 of file numabasic.c.

References ERROR_INT, numaGetXParameters(), numaSetXParameters(), and PROCNAME.

Referenced by numaDilate(), numaErode(), and numaNormalizeHistogram().

NUMA* numaRead ( const char *  filename)

numaRead()

Input: filename Return: na, or null on error

Definition at line 927 of file numabasic.c.

References ERROR_PTR, fopenReadStream(), NULL, numaReadStream(), and PROCNAME.

Referenced by main().

NUMA* numaReadStream ( FILE *  fp)

numaReadStream()

Input: stream Return: numa, or null on error

Definition at line 957 of file numabasic.c.

References ERROR_PTR, NULL, NUMA_VERSION_NUMBER, numaAddNumber(), numaCreate(), numaSetXParameters(), PROCNAME, and version.

Referenced by gplotRead(), numaaReadStream(), and numaRead().

l_int32 numaWrite ( const char *  filename,
NUMA na 
)

numaWrite()

Input: filename, na Return: 0 if OK, 1 on error

Definition at line 1000 of file numabasic.c.

References ERROR_INT, fopenWriteStream(), NULL, numaWriteStream(), and PROCNAME.

Referenced by BoxaSortTest(), dewarpBuildModel(), main(), and PixaSortTest().

NUMAA* numaaCreate ( l_int32  n)

numaaCreate()

Input: size of numa ptr array to be alloc'd (0 for default) Return: naa, or null on error

Definition at line 1070 of file numabasic.c.

References CALLOC, ERROR_PTR, INITIAL_PTR_ARRAYSIZE, Numaa::n, Numaa::nalloc, NULL, Numaa::numa, and PROCNAME.

Referenced by boxaExtractSortedPattern(), boxaSort2d(), ccbaGenerateStepChains(), ccbaReadStream(), main(), numaaReadStream(), and ptraConcatenatePdfToData().

void numaaDestroy ( NUMAA **  pnaa)

numaaDestroy()

Input: &numaa <to be="" nulled="" if="" it="" exists>=""> Return: void

Definition at line 1098 of file numabasic.c.

References FREE, L_WARNING, Numaa::n, NULL, Numaa::numa, numaDestroy(), and PROCNAME.

Referenced by boxaSort2d(), ccbaGenerateStepChains(), ccbDestroy(), main(), pixGetWordsInTextlines(), and ptraConcatenatePdfToData().

l_int32 numaaAddNuma ( NUMAA naa,
NUMA na,
l_int32  copyflag 
)

numaaAddNuma()

Input: naa na (to be added) copyflag (L_INSERT, L_COPY, L_CLONE) Return: 0 if OK, 1 on error

Definition at line 1136 of file numabasic.c.

References ERROR_INT, L_CLONE, L_COPY, L_INSERT, Numaa::n, Numaa::nalloc, NULL, Numaa::numa, numaaExtendArray(), numaaGetCount(), numaClone(), numaCopy(), and PROCNAME.

Referenced by boxaExtractSortedPattern(), boxaSort2d(), ccbaGenerateStepChains(), ccbaReadStream(), main(), numaaReadStream(), and ptraConcatenatePdfToData().

l_int32 numaaExtendArray ( NUMAA naa)

numaaExtendArray()

Input: naa Return: 0 if OK, 1 on error

Definition at line 1177 of file numabasic.c.

References ERROR_INT, Numaa::nalloc, NULL, Numaa::numa, PROCNAME, and reallocNew().

Referenced by numaaAddNuma().

l_int32 numaaGetNumaCount ( NUMAA naa,
l_int32  index 
)

numaaGetNumaCount()

Input: naa index (of numa in naa) Return: count of numbers in the referenced numa, or 0 on error.

Definition at line 1222 of file numabasic.c.

References ERROR_INT, Numaa::n, Numaa::numa, numaGetCount(), and PROCNAME.

l_int32 numaaGetNumberCount ( NUMAA naa)

numaaGetNumberCount()

Input: naa Return: count (total number of numbers in the numaa), or 0 if no numbers or on error

Definition at line 1243 of file numabasic.c.

References ERROR_INT, L_CLONE, numaaGetCount(), numaaGetNuma(), numaDestroy(), numaGetCount(), and PROCNAME.

Referenced by boxaSort2dByIndex(), and pixaSort2dByIndex().

NUMA** numaaGetPtrArray ( NUMAA naa)

numaaGetPtrArray()

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:

  • Do not free this array; it is owned by tne Numaa.
  • Do not call any functions on the Numaa, other than numaaDestroy() when you're finished with the array. Adding a Numa will force a resize, destroying the ptr array.
  • Do not address the array outside its allocated size. With the bare array, there are no protections. If the allocated size is n, array[n] is an error.

Definition at line 1290 of file numabasic.c.

References ERROR_PTR, Numaa::n, Numaa::nalloc, NULL, Numaa::numa, and PROCNAME.

Referenced by numaaFlattenToNuma().

NUMA* numaaGetNuma ( NUMAA naa,
l_int32  index,
l_int32  accessflag 
)
l_int32 numaaReplaceNuma ( NUMAA naa,
l_int32  index,
NUMA na 
)

numaaReplaceNuma()

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)

Definition at line 1345 of file numabasic.c.

References ERROR_INT, Numaa::numa, numaaGetCount(), numaDestroy(), and PROCNAME.

Referenced by boxaSort2d().

l_int32 numaaGetValue ( NUMAA naa,
l_int32  i,
l_int32  j,
l_float32 pval 
)

numaaGetValue()

Input: naa i (index of numa within numaa) j (index into numa) val (<return> float value) Return: 0 if OK, 1 on error

Definition at line 1377 of file numabasic.c.

References Numa::array, ERROR_INT, Numa::n, Numaa::numa, numaaGetCount(), and PROCNAME.

l_int32 numaaAddNumber ( NUMAA naa,
l_int32  index,
l_float32  val 
)

numaaAddNumber()

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.

Definition at line 1415 of file numabasic.c.

References ERROR_INT, L_CLONE, numaAddNumber(), numaaGetCount(), numaaGetNuma(), numaDestroy(), and PROCNAME.

Referenced by boxaSort2d().

NUMAA* numaaRead ( const char *  filename)

numaaRead()

Input: filename Return: naa, or null on error

Definition at line 1447 of file numabasic.c.

References ERROR_PTR, fopenReadStream(), NULL, numaaReadStream(), and PROCNAME.

Referenced by main().

NUMAA* numaaReadStream ( FILE *  fp)

numaaReadStream()

Input: stream Return: naa, or null on error

Definition at line 1477 of file numabasic.c.

References ERROR_PTR, L_INSERT, NULL, NUMA_VERSION_NUMBER, numaaAddNuma(), numaaCreate(), numaReadStream(), PROCNAME, and version.

Referenced by numaaRead().

l_int32 numaaWrite ( const char *  filename,
NUMAA naa 
)

numaaWrite()

Input: filename, naa Return: 0 if OK, 1 on error

Definition at line 1517 of file numabasic.c.

References ERROR_INT, fopenWriteStream(), NULL, numaaWriteStream(), and PROCNAME.

Referenced by main().

l_int32 numaaWriteStream ( FILE *  fp,
NUMAA naa 
)

numaaWriteStream()

Input: stream, naa Return: 0 if OK, 1 on error

Definition at line 1546 of file numabasic.c.

References ERROR_INT, L_CLONE, NULL, NUMA_VERSION_NUMBER, numaaGetCount(), numaaGetNuma(), numaDestroy(), numaWriteStream(), and PROCNAME.

Referenced by numaaWrite(), and ptraConcatenatePdfToData().

NUMA2D* numa2dCreate ( l_int32  nrows,
l_int32  ncols,
l_int32  initsize 
)

numa2dCreate()

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.

Definition at line 1592 of file numabasic.c.

References CALLOC, ERROR_PTR, Numa2d::initsize, ncols, Numa2d::ncols, Numa2d::nrows, NULL, Numa2d::numa, and PROCNAME.

void numa2dDestroy ( NUMA2D **  pna2d)

numa2dDestroy()

Input: &numa2d (<to be="" nulled="" if="" it="" exists>="">) Return: void

Definition at line 1629 of file numabasic.c.

References FREE, L_WARNING, Numa2d::ncols, Numa2d::nrows, NULL, Numa2d::numa, numaDestroy(), and PROCNAME.

l_int32 numa2dAddNumber ( NUMA2D na2d,
l_int32  row,
l_int32  col,
l_float32  val 
)

numa2dAddNumber()

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

Definition at line 1671 of file numabasic.c.

References ERROR_INT, Numa2d::initsize, Numa2d::ncols, Numa2d::nrows, NULL, Numa2d::numa, numaAddNumber(), numaCreate(), and PROCNAME.

l_int32 numa2dGetCount ( NUMA2D na2d,
l_int32  row,
l_int32  col 
)

numa2dGetCount()

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

Definition at line 1706 of file numabasic.c.

References ERROR_INT, Numa::n, Numa2d::ncols, Numa2d::nrows, NULL, Numa2d::numa, and PROCNAME.

NUMA* numa2dGetNuma ( NUMA2D na2d,
l_int32  row,
l_int32  col 
)

numa2dGetNuma()

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.

Definition at line 1739 of file numabasic.c.

References ERROR_PTR, Numa2d::ncols, Numa2d::nrows, NULL, Numa2d::numa, numaClone(), and PROCNAME.

l_int32 numa2dGetFValue ( NUMA2D na2d,
l_int32  row,
l_int32  col,
l_int32  index,
l_float32 pval 
)

numa2dGetFValue()

Input: na2d row of 2d array col of 2d array index (into numa) &val (<return> float value) Return: 0 if OK, 1 on error

Definition at line 1768 of file numabasic.c.

References ERROR_INT, Numa2d::ncols, Numa2d::nrows, NULL, Numa2d::numa, numaGetFValue(), and PROCNAME.

l_int32 numa2dGetIValue ( NUMA2D na2d,
l_int32  row,
l_int32  col,
l_int32  index,
l_int32 pval 
)

numa2dGetIValue()

Input: na2d row of 2d array col of 2d array index (into numa) &val (<return> integer value) Return: 0 if OK, 1 on error

Definition at line 1806 of file numabasic.c.

References ERROR_INT, Numa2d::ncols, Numa2d::nrows, NULL, Numa2d::numa, numaGetIValue(), and PROCNAME.

NUMAHASH* numaHashCreate ( l_int32  nbuckets,
l_int32  initsize 
)

numaHashCreate()

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()

Definition at line 1847 of file numabasic.c.

References CALLOC, ERROR_PTR, FREE, NumaHash::initsize, NumaHash::nbuckets, NULL, NumaHash::numa, and PROCNAME.

Referenced by jbCorrelationInitInternal(), jbRankHausInit(), and ptaRemoveDuplicates().

void numaHashDestroy ( NUMAHASH **  pnahash)

numaHashDestroy()

Input: &nahash (<to be nulled, if it exists>) Return: void

Definition at line 1876 of file numabasic.c.

References FREE, L_WARNING, NumaHash::nbuckets, NULL, NumaHash::numa, numaDestroy(), and PROCNAME.

Referenced by jbClasserDestroy(), and ptaRemoveDuplicates().

NUMA* numaHashGetNuma ( NUMAHASH nahash,
l_uint32  key 
)

numaHashGetNuma()

Input: nahash key (key to be hashed into a bucket number) Return: ptr to numa

Definition at line 1910 of file numabasic.c.

References ERROR_PTR, NumaHash::nbuckets, NULL, NumaHash::numa, numaClone(), and PROCNAME.

Referenced by findSimilarSizedTemplatesNext(), and ptaRemoveDuplicates().

l_int32 numaHashAdd ( NUMAHASH nahash,
l_uint32  key,
l_float32  value 
)

numaHashAdd()

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

Definition at line 1937 of file numabasic.c.

References ERROR_INT, NumaHash::initsize, NumaHash::nbuckets, NULL, NumaHash::numa, numaAddNumber(), numaCreate(), and PROCNAME.

Referenced by jbClassifyCorrelation(), jbClassifyRankHaus(), and ptaRemoveDuplicates().


Variable Documentation

const l_int32 INITIAL_PTR_ARRAYSIZE = 50 [static]

Definition at line 164 of file numabasic.c.

Referenced by numaaCreate(), and numaCreate().

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines