SAF
Loading...
Searching...
No Matches
saf_utility_misc.c File Reference

A collection of miscellaneous functions. More...

#include "saf_utilities.h"
#include "saf_externals.h"

Go to the source code of this file.

Functions

static void combinationUtil (int *arr, int *data, int start, int end, int index, int r, int **comb, int *nComb)
 Helper function for findCombinations()
 
void convert_0_360To_m180_180 (float *dirs_deg, int nDirs)
 Wraps around any angles exeeding 180 degrees (e.g., 200-> -160)
 
int nextpow2 (int numsamp)
 A simple function which returns the next power of 2.
 
void lagrangeWeights (int N, float *x, int len_x, float *weights)
 Computes Lagrange interpolation weights of order 'N' for value 'x'.
 
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-Rectangular Bandwidth (ERB)].
 
void randperm (int len, int *randperm)
 Returns the indices required to randomly permute a vector of length 'len'.
 
long double factorial (int n)
 Factorial, accurate up to n<=25.
 
float matlab_fmodf (float x, float y)
 C fmodf function, except it behaves like 'mod' in Matlab (i.e.
 
void cxcorr (float *a, float *b, float *x_ab, size_t la, size_t lb)
 Calculates the cross correlation between two vectors.
 
void rand_m1_1 (float *vector, int length)
 Generates random numbers between -1 and 1 and stores them in the input vector.
 
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 imaginary parts.
 
void rand_0_1 (float *vector, int length)
 Generates random numbers between 0 and 1 and stores them in the input vector.
 
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)
 
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 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 polyd_m (double *X, double_complex *poly, int size_x)
 Convert roots of a matrix to polynomial (real double precision)
 
float sumf (float *values, int nValues)
 Returns the sum of all values.
 
int anyLessThanf (float *values, int nValues, float threshold)
 Returns 1, if any value in 'values' (nValues x 1) is less than 'threshold', otherwise, it returns 0.
 
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 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"; derived based on [1].
 
void gexpm (float *D, int sizeD, int m1, float *Y)
 Numerically solves first-order, linear, homogeneous differential equation systems, with non-constant coefficients, by generalization of the Pade- approximant method for exponential matrices.
 

Variables

static const long double factorials_21 [21]
 Precomputed factorials for up to !21 (i.e.
 

Detailed Description

A collection of miscellaneous functions.

Author
Leo McCormack
Date
29.01.2020
License
ISC

Definition in file saf_utility_misc.c.

Function Documentation

◆ combinationUtil()

static void combinationUtil ( int * arr,
int * data,
int start,
int end,
int index,
int r,
int ** comb,
int * nComb )
static

Helper function for findCombinations()

Definition at line 37 of file saf_utility_misc.c.

Variable Documentation

◆ factorials_21

const long double factorials_21[21]
static
Initial value:
=
{1.0, 1.0, 2.0, 6.0, 24.0, 120.0, 720.0, 5040.0, 40320.0, 362880.0, 3628800.0, 39916800.0, 479001600.0, 6.2270208e9, 8.71782891e10, 1.307674368000000e12, 2.092278988800000e13, 3.556874280960000e14, 6.402373705728000e15, 1.216451004088320e17, 2.432902008176640e18}

Precomputed factorials for up to !21 (i.e.

the "getSH" functions will employ these up to 10th order)

Definition at line 33 of file saf_utility_misc.c.