All Classes Namespaces Files Functions Variables Typedefs Macros
clizFunctions.h File Reference
#include "clizThirdParty.h"
#include <malloc.h>
#include <boost\thread.hpp>
Include dependency graph for clizFunctions.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  MemPool
 
class  SizedMemPool
 
class  MemoryManager
 
class  MemoryManagerPart
 
class  GlobalMemoryManager
 

Macros

#define _INCLUDE_CLIZFUNCTIONS
 
#define CHKHEAP()   (check_heap(__FILE__, __LINE__))
 
#define FLOATIFPRECISION   0.000001f
 
#define BIGFLOATVALUE   4294967269.0f
 
#define BIGINTVALUE   4294967269
 
#define ELEM_SWAP(a, b)   { register float t=(a);(a)=(b);(b)=t; }
 
#define ELEM_SWAPUI(a, b)   { unsigned int t=(a);(a)=(b);(b)=t; }
 
#define SWAP(a, b)   temp=(a);(a)=(b);(b)=temp;
 
#define SWAPUI(a, b)   temp2=(a);(a)=(b);(b)=temp2;
 
#define SWAPFFT(a, b)   tempr = (a); (a) = (b); (b) = tempr
 
#define M   7
 
#define SQR(x)   ((x)*(x))
 

Typedefs

typedef boost::thread Thread
 
typedef boost::mutex Mutex
 
typedef boost::condition_variable ConVar
 
typedef boost::mutex::scoped_lock Lock
 
typedef boost::unique_lock
< boost::shared_mutex > 
Writelock
 
typedef boost::shared_lock
< boost::shared_mutex > 
Readlock
 
typedef boost::mutex::scoped_lock locktype
 
typedef boost::unique_lock
< boost::shared_mutex > 
writelocktype
 
typedef boost::shared_lock
< boost::shared_mutex > 
readlocktype
 
typedef int memInt
 
typedef unsigned int memUInt
 
typedef float memFloat
 
typedef double memDouble
 
typedef void memPtr
 
typedef bool memBool
 
typedef unsigned short memShort
 
typedef unsigned char memByte
 
typedef unsigned short memAdrType
 

Functions

void check_heap (char *file, int line)
 
int clBinomial (int n, int k)
 
float clSign (float x)
 
int clMax (int a, int b)
 
void clSort (float vec[], int n)
 
void clSort (unsigned int vec[], int n)
 
void clSortTwo (unsigned int vec[], unsigned int vec2[], int n)
 
void clSortTwo (float vec[], float vec2[], int n)
 
void clSortTwo (float vec[], unsigned int vec2[], int n)
 
float clMedian (float vec[], int n)
 
float clMedian (unsigned int vec[], int n)
 
float clMean (float arr[], uint32_t n)
 
double clMean (double arr[], uint32_t n)
 
float clStd (float arr[], uint32_t n)
 
float clStdWithMean (float arr[], uint32_t n, float mean)
 
float * clAbs (float arr[], uint32_t n)
 
uint32_t clMaxIndex (float arr[], uint32_t begin, uint32_t end)
 
uint32_t clMaxAbsIndex (float arr[], uint32_t begin, uint32_t end)
 
uint32_t clMinIndex (float arr[], uint32_t begin, uint32_t end)
 
float clErfc (float x)
 
float clKSTest (float arr[], uint32_t n, MemoryManager &memMan)
 
void clFindHighestIndices (float arr[], uint32_t n, uint32_t output[], uint32_t numindices, MemoryManager &memMan)
 
void clFindLowestIndices (float arr[], uint32_t n, uint32_t output[], uint32_t numindices, MemoryManager &memMan)
 
void clSplineGetY2 (float y[], int n, float y2[], MemoryManager &memMan)
 
float clSplineInterp (float y[], float y2[], float x)
 
void clHaarWaveDecWithOffset (float spikes[], unsigned int size, uint8_t scales, float output[], uint32_t offset, MemoryManager &memMan)
 
void clXCorr (float *X, float *Y, unsigned int n, int maxshift, float *&output, MemoryManager &memMan)
 
void clXCorr (double *X, double *Y, unsigned int n, int maxshift, double *&output, MemoryManager &memMan)
 

Variables

const memShort MAXPOOLS = 2048
 
const memShort NUMMEMMAN = 4
 
const memShort MEMSIZECOUNT = 19
 
const memUInt MEMSIZE [22] = { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152 }
 
const memUInt POOLCAPACITY [22] = { 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 128, 128, 64, 64, 32, 16, 8, 4, 2 }
 
const memShort METASIZE = sizeof(memAdrType)
 
GlobalMemoryManager gMemMan
 

Macro Definition Documentation

#define _INCLUDE_CLIZFUNCTIONS
#define BIGFLOATVALUE   4294967269.0f
#define BIGINTVALUE   4294967269
#define CHKHEAP ( )    (check_heap(__FILE__, __LINE__))
#define ELEM_SWAP (   a,
 
)    { register float t=(a);(a)=(b);(b)=t; }
#define ELEM_SWAPUI (   a,
 
)    { unsigned int t=(a);(a)=(b);(b)=t; }
#define FLOATIFPRECISION   0.000001f
#define M   7
#define SQR (   x)    ((x)*(x))
#define SWAP (   a,
 
)    temp=(a);(a)=(b);(b)=temp;
#define SWAPFFT (   a,
 
)    tempr = (a); (a) = (b); (b) = tempr
#define SWAPUI (   a,
 
)    temp2=(a);(a)=(b);(b)=temp2;

Typedef Documentation

typedef boost::condition_variable ConVar
typedef boost::mutex::scoped_lock Lock
typedef boost::mutex::scoped_lock locktype
typedef unsigned short memAdrType
typedef bool memBool
typedef unsigned char memByte
typedef double memDouble
typedef float memFloat
typedef int memInt
typedef void memPtr
typedef unsigned short memShort
typedef unsigned int memUInt
typedef boost::mutex Mutex
typedef boost::shared_lock< boost::shared_mutex > Readlock
typedef boost::shared_lock< boost::shared_mutex > readlocktype
typedef boost::thread Thread
typedef boost::unique_lock< boost::shared_mutex > Writelock
typedef boost::unique_lock< boost::shared_mutex > writelocktype

Function Documentation

void check_heap ( char *  file,
int  line 
)
float* clAbs ( float  arr[],
uint32_t  n 
)

Changes all values of an array to their absolute values

Parameters
[in,out]arrArray to be converted to abs(arr)
[in]nNumber of values to be converted

Here is the caller graph for this function:

int clBinomial ( int  n,
int  k 
)

Binomial coefficient Number of combinations when choosing k elements from an n elements pool

Parameters
[in]nNumber of elements in pool
[in]knumber of chosen elements
Returns
Number of combinations
float clErfc ( float  x)
inline

Approximation of error function by Abramowitz and Stegun

Parameters
[in]xInput
void clFindHighestIndices ( float  arr[],
uint32_t  n,
uint32_t  output[],
uint32_t  numindices,
MemoryManager memMan 
)

Writes the indices of the highest values in output (descending)

Parameters
[in]arrArray to be searched
[in]nUp to which index the array should be searched
[out]outputArray to hold the indices of the highest values
[in]numindicesHow many indices should be written to output

Here is the call graph for this function:

Here is the caller graph for this function:

void clFindLowestIndices ( float  arr[],
uint32_t  n,
uint32_t  output[],
uint32_t  numindices,
MemoryManager memMan 
)

Writes the indices of the lowest values in output

Parameters
[in]arrArray to be searched
[in]nUp to which index the array should be searched
[out]outputArray to hold the indices of the lowest values
[in]numindicesHow many indices should be written to output

Here is the call graph for this function:

void clHaarWaveDecWithOffset ( float  spikes[],
unsigned int  size,
uint8_t  scales,
float  output[],
uint32_t  offset,
MemoryManager memMan 
)

Haar wavelet decomposition

Parameters
[in]spikesArray of data points to be decomposed
[in]sizeNumber of data points
[in]scalesHow deep the decomposition goes before plugging
[out]outputStore for the wavelet coefficients
[in]offsetWhere in the output array to start storing the wavelet coefficients

Here is the call graph for this function:

Here is the caller graph for this function:

float clKSTest ( float  arr[],
uint32_t  n,
MemoryManager memMan 
)

Lilliefors modification of the Kolmogorov-Smirnov (KS) test for normality

Parameters
[in]arrInput array
[in]nUp to which index deviation from normality should be calculated.
Returns
Maximum deviation from normality

Here is the call graph for this function:

Here is the caller graph for this function:

int clMax ( int  a,
int  b 
)

Max Returns the bigger value

Parameters
[in]avalue
[in]bvalue

Here is the caller graph for this function:

uint32_t clMaxAbsIndex ( float  arr[],
uint32_t  begin,
uint32_t  end 
)

Returns the index of the absolute maximum value

Parameters
[in]arrArray to be searched
[in]beginWhere the search starts
[in]endWhere the search ends

Here is the caller graph for this function:

uint32_t clMaxIndex ( float  arr[],
uint32_t  begin,
uint32_t  end 
)

Returns the index of the maximum value

Parameters
[in]arrArray to be searched
[in]beginWhere the search starts
[in]endWhere the search ends

Here is the caller graph for this function:

float clMean ( float  arr[],
uint32_t  n 
)

Mean

Parameters
[in]arrArray from which the mean is calculated
[in]nNumber of values from which the mean is calculated

Here is the caller graph for this function:

double clMean ( double  arr[],
uint32_t  n 
)

Mean

Parameters
[in]arrArray from which the mean is calculated
[in]nNumber of values from which the mean is calculated
float clMedian ( float  vec[],
int  n 
)

Median based on Quicksort Only correct for odd numbers of n

Parameters
[in,out]vecArray to be sorted
[in]nNumber of values to be sorted

Here is the caller graph for this function:

float clMedian ( unsigned int  vec[],
int  n 
)

Median based on Quicksort Only correct for odd numbers of n

Parameters
[in,out]vecArray to be sorted
[in]nNumber of values to be sorted
uint32_t clMinIndex ( float  arr[],
uint32_t  begin,
uint32_t  end 
)

Returns the index of the minimum value

Parameters
[in]arrArray to be searched
[in]beginWhere the search starts
[in]endWhere the search ends

Here is the caller graph for this function:

float clSign ( float  x)

Signum Returns 1 if x >= 0 and -1 otherwise

Parameters
[in]xvalue
void clSort ( float  vec[],
int  n 
)
inline

Quicksort based on Sedgewick, R. (1978) "Implementing Quicksort Programs"

Parameters
[in,out]vecArray to be sorted
[in]nNumber of values to be sorted

Here is the caller graph for this function:

void clSort ( unsigned int  vec[],
int  n 
)

Quicksort based on Sedgewick, R. (1978) "Implementing Quicksort Programs"

Parameters
[in,out]vecArray to be sorted
[in]nNumber of values to be sorted
void clSortTwo ( unsigned int  vec[],
unsigned int  vec2[],
int  n 
)

Quicksort based on Sedgewick, R. (1978) "Implementing Quicksort Programs" To sort a second array the same way, the first is sorted.

Parameters
[in,out]vecArray to be sorted
[in,out]vec2Array to be sorted in the same was as vec
[in]nNumber of values to be sorted

Here is the caller graph for this function:

void clSortTwo ( float  vec[],
float  vec2[],
int  n 
)

Quicksort based on Sedgewick, R. (1978) "Implementing Quicksort Programs" To sort a second array the same way, the first is sorted.

Parameters
[in,out]vecArray to be sorted
[in,out]vec2Array to be sorted in the same was as vec
[in]nNumber of values to be sorted
void clSortTwo ( float  vec[],
unsigned int  vec2[],
int  n 
)

Quicksort based on Sedgewick, R. (1978) "Implementing Quicksort Programs" To sort a second array the same way, the first is sorted.

Parameters
[in,out]vecArray to be sorted
[in,out]vec2Array to be sorted in the same was as vec
[in]nNumber of values to be sorted
void clSplineGetY2 ( float  y[],
int  n,
float  y2[],
MemoryManager memMan 
)

Cubic spline interpolation. Calculates second derivatives for cubic spline interpolation Works under the following assumptions: length(y)=length(x)=n x[i]=x(i) for i=0:1:n-1 Therefore, no x vector is needed as input.

Parameters
[in]yy values of the data points
[in]nUp to which index y2 should be calculated
[out]y2Second derivatives of the interpolating function

Here is the call graph for this function:

Here is the caller graph for this function:

float clSplineInterp ( float  y[],
float  y2[],
float  x 
)

Cubic spline interpolation. Interpolates y value for x based on second derivatives. Works under the following assumptions: length(y)=length(x)=n x[i]=x(i) for i=0:1:n-1 Therefore, no x vector is needed as input.

Parameters
[in]yy values of the data points
[in]y2Second derivatives of the interpolating function
[in]xx value of the point to be interpolated

Here is the caller graph for this function:

float clStd ( float  arr[],
uint32_t  n 
)

Standard deviation

Parameters
[in]arrArray from which the std is calculated
[in]nNumber of values from which the std is calculated

Here is the call graph for this function:

float clStdWithMean ( float  arr[],
uint32_t  n,
float  mean 
)
inline

Standard deviation with mean as argument (reduced computation compared to clStd if the mean was already calculated)

Parameters
[in]arrArray from which the std is calculated
[in]nNumber of values from which the std is calculated
[in]meanMean to use to calculate the std

Here is the caller graph for this function:

void clXCorr ( float *  X,
float *  Y,
unsigned int  n,
int  maxshift,
float *&  output,
MemoryManager memMan 
)

Cross-correlation

Parameters
[in]XInput vector
[in]YInput vector
[in]nNumber of elements in input vectors
[out]maxshiftMaximum number of shifts
[in]outputcross-correlation of X and Y

Here is the call graph for this function:

Here is the caller graph for this function:

void clXCorr ( double *  X,
double *  Y,
unsigned int  n,
int  maxshift,
double *&  output,
MemoryManager memMan 
)

Cross-correlation

Parameters
[in]XInput vector
[in]YInput vector
[in]nNumber of elements in input vectors
[out]maxshiftMaximum number of shifts
[in]outputcross-correlation of X and Y

Here is the call graph for this function:

Variable Documentation

const memShort MAXPOOLS = 2048
const memUInt MEMSIZE[22] = { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152 }
const memShort MEMSIZECOUNT = 19
const memShort METASIZE = sizeof(memAdrType)
const memShort NUMMEMMAN = 4
const memUInt POOLCAPACITY[22] = { 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 128, 128, 64, 64, 32, 16, 8, 4, 2 }