src/numafunc1.c
NUMA *
numaClipToInterval(NUMA    *nas,
                   l_int32  first,
                   l_int32  last)
{
l_int32    n, i, truelast;
l_float32  val;
NUMA      *nad;

    PROCNAME("numaClipToInterval");

    if (!nas)
        return (NUMA *)ERROR_PTR("nas not defined", procName, NULL);
    if (first > last)
        return (NUMA *)ERROR_PTR("range not valid", procName, NULL);

    n = numaGetCount(nas);
    if (first >= n)
        return (NUMA *)ERROR_PTR("no elements in range", procName, NULL);
    truelast = L_MIN(last, n - 1);
    if ((nad = numaCreate(truelast - first + 1)) == NULL)
        return (NUMA *)ERROR_PTR("nad not made", procName, NULL);
    for (i = first; i <= truelast; i++) {
        numaGetFValue(nas, i, &val);
        numaAddNumber(nad, val);
    }

    return nad;
}
/*!
 *  numaClipToInterval()
 *
 *      Input:  numa
 *              first, last (clipping interval)
 *      Return: numa with the same values as the input, but clipped
 *              to the specified interval
 *
 *  Note: If you want the indices of the array values to be unchanged,
 *        use first = 0.
 *  Usage: This is useful to clip a histogram that has a few nonzero
 *         values to its nonzero range.
 */
numaClipToInterval()
Input:  numa
first, last (clipping interval)
Return: numa with the same values as the input, but clipped
to the specified interval

If you want the indices of the array values to be unchanged,
use first = 0.
Usage: This is useful to clip a histogram that has a few nonzero
values to its nonzero range.
numaClipToInterval () Input : numa first last ( clipping interval ) Return : numa with the same values as the input but clipped to the specified interval If you want the indices of the array values to be unchanged use first = 0 . Usage : This is useful to clip a histogram that has a few nonzero values to its nonzero range .
NUMA *
numaClipToInterval(NUMA    *nas,
                   l_int32  first,
                   l_int32  last)
{
l_int32    n, i, truelast;
l_float32  val;
NUMA      *nad;
    PROCNAME("numaClipToInterval");
    if (!nas)
        return (NUMA *)ERROR_PTR("nas not defined", procName, NULL);
    if (first > last)
        return (NUMA *)ERROR_PTR("range not valid", procName, NULL);
    n = numaGetCount(nas);
    if (first >= n)
        return (NUMA *)ERROR_PTR("no elements in range", procName, NULL);
    truelast = L_MIN(last, n - 1);
    if ((nad = numaCreate(truelast - first + 1)) == NULL)
        return (NUMA *)ERROR_PTR("nad not made", procName, NULL);
    for (i = first; i <= truelast; i++) {
        numaGetFValue(nas, i, &val);
        numaAddNumber(nad, val);
    }
    return nad;
}
NUMA * numaClipToInterval ( NUMA * nas , l_int32 first , l_int32 last ) { l_int32 n , i , truelast ; l_float32 val ; NUMA * nad ; PROCNAME ( " " ) ; if ( ! nas ) return ( NUMA * ) ERROR_PTR ( " " , procName , NULL ) ; if ( first > last ) return ( NUMA * ) ERROR_PTR ( " " , procName , NULL ) ; n = numaGetCount ( nas ) ; if ( first >= n ) return ( NUMA * ) ERROR_PTR ( " " , procName , NULL ) ; truelast = L_MIN ( last , n - 1 ) ; if ( ( nad = numaCreate ( truelast - first + 1 ) ) == NULL ) return ( NUMA * ) ERROR_PTR ( " " , procName , NULL ) ; for ( i = first ; i <= truelast ; i ++ ) { numaGetFValue ( nas , i , & val ) ; numaAddNumber ( nad , val ) ; } return nad ; }
numaClipToInterval()
      Input:  numa
              first, last (clipping interval)
      Return: numa with the same values as the input, but clipped
              to the specified interval
numaClipToInterval () Input : numa first last ( clipping interval ) Return : numa with the same values as the input but clipped to the specified interval