Main Page   Modules   Alphabetical List   Compound List   Compound Members  

Utility functions


Functions

double cpl_tools_kth_double (double *a, int n, int k)
 Get the kth smallest value in a double array. More...

float cpl_tools_kth_float (float *a, int n, int k)
 Get the kth smallest value in a float array. More...

int cpl_tools_kth_int (int *a, int n, int k)
 Get the kth smallest value in an integer array. More...

cpl_error_code cpl_tools_darray_sort (double *pix_arr, int n)
 Sort a double array. More...

cpl_error_code cpl_tools_iarray_sort (int *pix_arr, int n)
 Sort an integer array. More...

double cpl_tools_median_9double (double *p)
 Optimized median computation for 9 values arrays. More...

double cpl_tools_median_double (double *a, int n)
 Get the median value in a double array. More...

float cpl_tools_median_float (float *a, int n)
 Get the median value in a float array. More...

int cpl_tools_median_int (int *a, int n)
 Get the median value in an integer array. More...

double cpl_tools_cputime (int mode)
 Timer handling for benchmarking purposes. More...


Detailed Description

This module provides various functions to apply simple operations on data arrays (sorting, median computation) and a function to monitor the CPU time.
Synopsis:
   #include "cpl_tools.h"

Function Documentation

double cpl_tools_cputime int    mode
 

Timer handling for benchmarking purposes.

Parameters:
mode  is one of: CLOCK_START, CLOCK_STOP or CLOCK_TIME
Returns:
double indicating an elapsed time in seconds.
This routine is useful to benchmark the time spent in an image processing routine. It is used in three steps:

  • Start the timer by calling cpl_tools_cputime(CLOCK_START)
  • Stop the timer by calling cpl_tools_cputime(CLOCK_STOP)
  • Get the total time by calling cpl_tools_cputime(CLOCK_TIME)
It is possible to start/stop the clock several times in the same program. The last call should be done with CLOCK_TIME to get the total elapsed time.

The call with CLOCK_START returns the total elapsed time in seconds since the begining. The call with CLOCK_STOP returns the time elapsed since the last CLOCK_START call. The call with CLOCK_TIME return the total time elapsed between all previous CLOCK_START - CLOCK_STOP calls.

Possible _cpl_error_code_ set in this function:

  • CPL_ERROR_ILLEGAL_INPUT

cpl_error_code cpl_tools_darray_sort double *    pix_arr,
int    n
 

Sort a double array.

Parameters:
pix_arr  the array to sort
n  the array size
Returns:
the _cpl_error_code_ or CPL_ERROR_NONE
Possible _cpl_error_code_ set in this function:
  • CPL_ERROR_NULL_INPUT
  • CPL_ERROR_ILLEGAL_INPUT

cpl_error_code cpl_tools_iarray_sort int *    pix_arr,
int    n
 

Sort an integer array.

Parameters:
pix_arr  the array to sort
n  the array size
Returns:
the _cpl_error_code_ or CPL_ERROR_NONE
Possible _cpl_error_code_ set in this function:
  • CPL_ERROR_NULL_INPUT
  • CPL_ERROR_ILLEGAL_INPUT

double cpl_tools_kth_double double *    a,
int    n,
int    k
 

Get the kth smallest value in a double array.

Parameters:
a  the double array
n  the array size
k  the requested value position in the sorted array
Returns:
the kth smallest value in the sorted array.
The input array is modified. In case of error, the _cpl_error_code_ code is set, and the returned value is undefined.

Possible _cpl_error_code_ set in this function:

  • CPL_ERROR_NULL_INPUT

float cpl_tools_kth_float float *    a,
int    n,
int    k
 

Get the kth smallest value in a float array.

Parameters:
a  the float array
n  the array size
k  the requested value position in the sorted array
Returns:
the kth smallest value in the sorted array.
See also:
cpl_tools_kth_double()

int cpl_tools_kth_int int *    a,
int    n,
int    k
 

Get the kth smallest value in an integer array.

Parameters:
a  the integer array
n  the array size
k  the requested value position in the sorted array
Returns:
the kth smallest value in the sorted array.
See also:
cpl_tools_kth_double()

double cpl_tools_median_9double double *    p
 

Optimized median computation for 9 values arrays.

Parameters:
p  array to sort
Returns:
the requested median
See also:
cpl_tools_median_double()

double cpl_tools_median_double double *    a,
int    n
 

Get the median value in a double array.

Parameters:
a  the double array
n  the array size
Returns:
the requested median
See also:
cpl_tools_kth_double()
For a finite population or sample, the median is the middle value of an odd number of values (arranged in ascending order) or any value between the two middle values of an even number of values. The computed median should actually be a value of the input array, so, in case of an even number of values in the input array, the median would be the lowest of the two central values.

Example: the median of (1 2 3) is 2 and the median of (1 2 3 4) is 2.

float cpl_tools_median_float float *    a,
int    n
 

Get the median value in a float array.

Parameters:
a  the float array
n  the array size
Returns:
the requested median
See also:
cpl_tools_median_double()

int cpl_tools_median_int int *    a,
int    n
 

Get the median value in an integer array.

Parameters:
a  the integer array
n  the array size
Returns:
the requested median
See also:
cpl_tools_median_double()


Generated on Mon May 24 14:58:05 2004 for Common Pipeline Library Reference Manual by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002