28#ifndef SAF_MISC_H_INCLUDED
29#define SAF_MISC_H_INCLUDED
42# define SAF_SLEEP(msecs) Sleep(msecs)
43#elif defined(__unix) || defined(__APPLE__)
45# ifndef _POSIX_C_SOURCE
46# define _POSIX_C_SOURCE 199309L
49# define SAF_SLEEP(msecs) do { \
51 ts.tv_sec = msecs/1000; \
52 ts.tv_nsec = msecs%1000*1000; \
53 nanosleep(&ts, NULL); \
56# error "Unknown system"
84#define SAF_CASSERT(predicate, file) _impl_CASSERT_LINE(predicate,__LINE__,file)
86#define _impl_PASTE(a,b) a##b
88#define _impl_CASSERT_LINE(predicate, line, file) \
89 typedef char _impl_PASTE(assertion_failed_##file##_,line)[2*!!(predicate)-1];
235void convz(double_complex* x,
260 double_complex* poly,
271 double_complex* poly,
275float sumf(
float* values,
void findCombinations(int *arrValues, int nValues, int nElements, int **comb, int *nComb)
Given an array of values, find all the possible combinations (nCr) for subgroups of "nElements"; deri...
void findERBpartitions(float *centerFreq, int nBands, float maxFreqLim, int **erb_idx, float **erb_freqs, int *nERBBands)
This function takes a frequency vector and groups its frequencies into critical bands [Equivalent-Rec...
void convert_0_360To_m180_180(float *dirs_deg, int nDirs)
Wraps around any angles exeeding 180 degrees (e.g., 200-> -160)
float matlab_fmodf(float x, float y)
C fmodf function, except it behaves like 'mod' in Matlab (i.e.
void unique_i(int *input, int nInputs, int **uniqueVals, int **uniqueInds, int *nUnique)
Finds the unique values (and their indices) of the input vector.
void cxcorr(float *a, float *b, float *x_ab, size_t la, size_t lb)
Calculates the cross correlation between two vectors.
void rand_0_1(float *vector, int length)
Generates random numbers between 0 and 1 and stores them in the input vector.
void randperm(int len, int *randperm_inds)
Returns the indices required to randomly permute a vector of length 'len'.
void rand_cmplx_m1_1(float_complex *vector, int length)
Generates random numbers between -1 and 1 and stores them in the input vector for both the real and i...
void gexpm(float *D, int sizeD, int m1, float *Y)
Numerically solves first-order, linear, homogeneous differential equation systems,...
void polyd_m(double *X, double_complex *poly, int size_x)
Convert roots of a matrix to polynomial (real double precision)
long double factorial(int n)
Factorial, accurate up to n<=25.
float sumf(float *values, int nValues)
Returns the sum of all values.
void convd(double *x, double *h, int len_x, int len_h, double *y)
Basic 1-D direct convolution in the time-domain (real double precision)
int nextpow2(int numsamp)
A simple function which returns the next power of 2.
void polyd_v(double *x, double *poly, int len_x)
Convert roots of a vector to polynomial (real double precision)
void polyz_v(double_complex *x, double_complex *poly, int len_x)
Convert roots of a vector to polynomial (complex double precision)
void lagrangeWeights(int N, float *x, int len_x, float *weights)
Computes Lagrange interpolation weights of order 'N' for value 'x'.
int anyLessThanf(float *values, int nValues, float threshold)
Returns 1, if any value in 'values' (nValues x 1) is less than 'threshold', otherwise,...
void convz(double_complex *x, double_complex *h, int len_x, int len_h, double_complex *y)
Basic 1-D direct convolution in the time-domain (complex double precision)
void rand_m1_1(float *vector, int length)
Generates random numbers between -1 and 1 and stores them in the input vector.
Contains wrappers for handling complex numbers across both C99-compliant compilers and Microsoft Visu...