BeBOP Optimized Sparse Kernel Interface Library  1.0.1h
Functions
stat.c File Reference

Implements some simple statistics gathering utilities. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <oski/common.h>
#include "abort_prog.h"
#include "testvec.h"
#include "stat.h"

Functions

static int VTMANGLE() compare (const void *a, const void *b)
 "C++ template-like" comparison function
void VTMANGLE() CalcBasicStats (const VALTYPE *x, size_t n, VALTYPE *p_min, VALTYPE *p_max, VALTYPE *p_mean, VALTYPE *p_median)
 Compute min, max, median, and mean of an array of data.
void VTMANGLE() CalcMinMaxMedian (const VALTYPE *x, size_t n, VALTYPE *p_min, VALTYPE *p_max, VALTYPE *p_median)
void VTMANGLE() CalcMinMaxMean (const VALTYPE *x, size_t n, VALTYPE *p_min, VALTYPE *p_max, VALTYPE *p_mean)
VALTYPE VTMANGLE() CalcMin (const VALTYPE *x, size_t n)
VALTYPE VTMANGLE() CalcMax (const VALTYPE *x, size_t n)
VALTYPE VTMANGLE() CalcMean (const VALTYPE *x, size_t n)

Detailed Description

Implements some simple statistics gathering utilities.


Function Documentation

void VTMANGLE() CalcBasicStats ( const VALTYPE *  x,
size_t  n,
VALTYPE *  p_min,
VALTYPE *  p_max,
VALTYPE *  p_mean,
VALTYPE *  p_median 
)

Compute min, max, median, and mean of an array of data.

References CalcMean(), and CalcMinMaxMedian().

VALTYPE VTMANGLE() CalcMax ( const VALTYPE *  x,
size_t  n 
)
Parameters:
[in]xArray over which to compute the statistics. Must not equal NULL if the length, 'n', is greater than 0.
[in]nLength of the array 'x'.

If x is NULL or n <= 0, then this routine generates an error and exits the application.

References ABORT, and ERR_BAD_ARG.

VALTYPE VTMANGLE() CalcMean ( const VALTYPE *  x,
size_t  n 
)
Parameters:
[in]xArray over which to compute the statistics. Must not equal NULL if the length, 'n', is greater than 0.
[in]nLength of the array 'x'.

If x is NULL or n <= 0, then this routine generates an error and exits the application.

References ABORT, and ERR_BAD_ARG.

Referenced by CalcBasicStats().

VALTYPE VTMANGLE() CalcMin ( const VALTYPE *  x,
size_t  n 
)
Parameters:
[in]xArray over which to compute the statistics. Must not equal NULL if the length, 'n', is greater than 0.
[in]nLength of the array 'x'.

If x is NULL or n <= 0, then this routine generates an error and exits the application.

References ABORT, and ERR_BAD_ARG.

void VTMANGLE() CalcMinMaxMean ( const VALTYPE *  x,
size_t  n,
VALTYPE *  p_min,
VALTYPE *  p_max,
VALTYPE *  p_mean 
)
Parameters:
[in]xArray over which to compute the statistics. Must not equal NULL if the length, 'n', is greater than 0.
[in]nLength of the array 'x'.
[in,out]p_minPointer to location in which to store the minimum value. If NULL, the minimum is not returned.
[in,out]p_maxPointer to location in which to store the maximum value. If NULL, the maximum is not returned.
[in,out]p_meanPointer to location in which to store the mean value. If NULL, the mean is not returned.

If n <= 0, this routine simple returns and leaves the variables *p_min, *p_max, *p_mean unchanged. Otherwise, if x is NULL, then this routine exits the application.

References ABORT, and ERR_BAD_ARG.

void VTMANGLE() CalcMinMaxMedian ( const VALTYPE *  x,
size_t  n,
VALTYPE *  p_min,
VALTYPE *  p_max,
VALTYPE *  p_median 
)
Parameters:
[in]xArray on which to compute statistics. Must not equal NULL if the length, 'n', is greater than 0.
[in]nLength of x.
[in,out]p_minPointer to location in which to store the minimum value of the array x. If NULL, then the minimum is not returned.
[in,out]p_maxPointer to location in which to store the maximum value of the array x. If NULL, then the maximum is not returned.
[in,out]p_medainPointer to location in which to store the median value of the array x. Must not equal NULL.

This routine takes no action of n <= 0. If n > 0 and x is not equal to NULL, then this routine aborts.

References ABORT, compare(), ERR_BAD_ARG, ERR_OUT_OF_MEMORY, oski_CopyMem, oski_Free, and oski_Malloc.

Referenced by CalcBasicStats().