FNFT
|
Files | |
file | fnft__misc.h |
Miscellaneous functions used in the FNFT library. | |
Functions | |
void | fnft__misc_print_buf (const FNFT_INT len, FNFT_COMPLEX const *const buf, char const *const varname) |
Helper function for debugging. Prints an array in MATLAB style. More... | |
FNFT_REAL | fnft__misc_rel_err (const FNFT_INT len, FNFT_COMPLEX const *const vec_numer, FNFT_COMPLEX const *const vec_exact) |
Relative l1 error between two vectors. More... | |
FNFT_REAL | fnft__misc_hausdorff_dist (const FNFT_UINT lenA, FNFT_COMPLEX const *const vecA, const FNFT_UINT lenB, FNFT_COMPLEX const *const vecB) |
Hausdorff distance between two vectors. More... | |
FNFT_COMPLEX | fnft__misc_sech (FNFT_COMPLEX Z) |
Hyperbolic secant. More... | |
FNFT_REAL | fnft__misc_l2norm2 (const FNFT_UINT N, FNFT_COMPLEX const *const Z, const FNFT_REAL a, const FNFT_REAL b) |
Squared l2 norm. More... | |
FNFT_INT | fnft__misc_filter (FNFT_UINT *const N, FNFT_COMPLEX *const vals, FNFT_COMPLEX *const rearrange_as_well, FNFT_REAL const *const bounding_box) |
Filters array by retaining elements inside a bounding box. More... | |
FNFT_INT | fnft__misc_filter_nonreal (FNFT_UINT *N_ptr, FNFT_COMPLEX *const vals, const FNFT_REAL tol_im) |
Filter array based on specified tolerance. More... | |
FNFT_INT | fnft__misc_filter_inv (FNFT_UINT *const N_ptr, FNFT_COMPLEX *const vals, FNFT_COMPLEX *const rearrange_as_well, FNFT_REAL const *const bounding_box) |
Filters array by retaining elements outside a bounding box. More... | |
FNFT_INT | fnft__misc_merge (FNFT_UINT *N_ptr, FNFT_COMPLEX *const vals, FNFT_REAL tol) |
Merges elements in an array with distance lower than tol. More... | |
FNFT_INT | fnft__misc_downsample (const FNFT_UINT D, FNFT_COMPLEX const *const q, FNFT_UINT *const Dsub_ptr, FNFT_COMPLEX **qsub_ptr, FNFT_UINT *const first_last_index) |
Downsamples an array. More... | |
FNFT_COMPLEX | fnft__misc_CSINC (FNFT_COMPLEX x) |
Sinc function for complex arguments. More... | |
FNFT_UINT | fnft__misc_nextpowerof2 (const FNFT_UINT number) |
Closest larger or equal number that is a power of two. More... | |
FNFT_COMPLEX fnft__misc_CSINC | ( | FNFT_COMPLEX | x | ) |
Sinc function for complex arguments.
Functions computes the Sinc function sin(x)/x for FNFT_COMPLEX argument.
[in] | x | FNFT_COMPLEX argument. |
FNFT_INT fnft__misc_downsample | ( | const FNFT_UINT | D, |
FNFT_COMPLEX const *const | q, | ||
FNFT_UINT *const | Dsub_ptr, | ||
FNFT_COMPLEX ** | qsub_ptr, | ||
FNFT_UINT *const | first_last_index | ||
) |
Downsamples an array.
Computes a subsampled version of q. The length of q is D>=2. The routine will allocate memory for the subsampled signal qsub and updates the pointer *qsub_ptr such that it points to the newly allocated qsub. The user is responsible to freeing the memory later.
[in] | D | Number of samples in array q. |
[in] | q | Complex valued array to be subsampled. |
[out] | qsub_ptr | Pointer to the starting location of subsampled signal. |
[out] | Dsub_ptr | Pointer to new number of samples. Upon entry, *Dsub_ptr should contain a desired number of samples. Upon exit, *Dsub_ptr has been overwritten with the actual number of samples that the routine has chosen. It is usually close to the desired one. |
[out] | first_last_index | Vector of length two. Upon exit, it contains the original index of the first and the last sample in qsub. That is, qsub[0]=q[first_last_index[0]] and qsub[Dsub-1]=q[first_last_index[1]]. |
FNFT_INT fnft__misc_filter | ( | FNFT_UINT *const | N, |
FNFT_COMPLEX *const | vals, | ||
FNFT_COMPLEX *const | rearrange_as_well, | ||
FNFT_REAL const *const | bounding_box | ||
) |
Filters array by retaining elements inside a bounding box.
This function filters the array vals. Only values that satisfy
bounding_box[0] <= real(val) <= bounding_box[1]
and
bounding_box[2] <= imag(val) <= bounding_box[3]
are kept.
[in,out] | N | It is the pointer to the number of values to be filtered. On exit *N is overwritten with the number of values that have survived fitering. Their values will be moved to the beginning of vals. |
[in,out] | vals | Complex valued array with elements to be filtered. |
[in] | rearrange_as_well | Complex valued array. If the array rearrange_as_well is not NULL, then the values in there are rearranged together with the values in vals. |
[in] | bounding_box | A real array of 4 elements. The elements determine the corners of the bounding box being used for filtering. |
FNFT_INT fnft__misc_filter_inv | ( | FNFT_UINT *const | N_ptr, |
FNFT_COMPLEX *const | vals, | ||
FNFT_COMPLEX *const | rearrange_as_well, | ||
FNFT_REAL const *const | bounding_box | ||
) |
Filters array by retaining elements outside a bounding box.
This function filters the array vals. Only values OUTSIDE the bounding box are kept.
[in,out] | N_ptr | It is the pointer to the number of values to be filtered. On exit *N_ptr is overwritten with the number of values that have survived fitering. Their values will be moved to the beginning of vals. |
[in,out] | vals | Complex valued array with elements to be filtered. |
[in] | rearrange_as_well | Complex valued array. If the array rearrange_as_well is not NULL, then the values in there are rearranged together with the values in vals. |
[in] | bounding_box | A real array of 4 elements. The elements determine the corners of the bounding box being used for filtering. |
FNFT_INT fnft__misc_filter_nonreal | ( | FNFT_UINT * | N_ptr, |
FNFT_COMPLEX *const | vals, | ||
const FNFT_REAL | tol_im | ||
) |
Filter array based on specified tolerance.
This function removes all entries from the array vals with |Im(val)|>tol_im.
[in,out] | N_ptr | Pointer to number of values to be filtered. On exit *N_ptr is overwritten with the number of values that have survived fitering. Their values will be moved to the beginning of vals. |
[in,out] | vals | Complex valued array with elements to be filtered. |
[in] | tol_im | Real valued tolerance. |
FNFT_REAL fnft__misc_hausdorff_dist | ( | const FNFT_UINT | lenA, |
FNFT_COMPLEX const *const | vecA, | ||
const FNFT_UINT | lenB, | ||
FNFT_COMPLEX const *const | vecB | ||
) |
Hausdorff distance between two vectors.
This function computes the Hausdorff distance between two vectors vecA and vecB.
[in] | lenA | Length of vector vecA. |
[in] | vecA | Complex vector of length lenA. |
[in] | lenB | length of vector vecB. |
[in] | vecB | Complex vector of length lenB. |
FNFT_REAL fnft__misc_l2norm2 | ( | const FNFT_UINT | N, |
FNFT_COMPLEX const *const | Z, | ||
const FNFT_REAL | a, | ||
const FNFT_REAL | b | ||
) |
Squared l2 norm.
This function computes the quantity
\( val = \frac{b-a}{2N}.(|Z[0]|^2+|Z[N-1]|^2)+\sum_{i=1}^{i=N-2}\frac{b-a}{N}.|Z[i]|^2\).
[in] | N | Number of elements in the array. |
[in] | Z | Complex valued array of length N. |
[in] | a | Real number corresponding to first element of Z. |
[in] | b | Real number corresponding to last element of Z. |
FNFT_INT fnft__misc_merge | ( | FNFT_UINT * | N_ptr, |
FNFT_COMPLEX *const | vals, | ||
FNFT_REAL | tol | ||
) |
Merges elements in an array with distance lower than tol.
This function filters an array by merging elements if distance between the elements is less than tol.
[in,out] | N_ptr | It is the pointer to the number of elements to be filtered. On exit *N_ptr is overwritten with the number of values that have survived fitering. Their values will be moved to the beginning of vals. |
[in,out] | vals | Complex valued array with elements to be filtered. |
[in] | tol | Real valued tolerance. |
Closest larger or equal number that is a power of two.
[in] | number |
void fnft__misc_print_buf | ( | const FNFT_INT | len, |
FNFT_COMPLEX const *const | buf, | ||
char const *const | varname | ||
) |
Helper function for debugging. Prints an array in MATLAB style.
This function prints an array in MATLAB style.
[in] | len | Length of the array to be printed. |
[in] | buf | Array to be printed. |
[in] | varname | Name of the array being printed. |
FNFT_REAL fnft__misc_rel_err | ( | const FNFT_INT | len, |
FNFT_COMPLEX const *const | vec_numer, | ||
FNFT_COMPLEX const *const | vec_exact | ||
) |
Relative l1 error between two vectors.
This function computes the relative l1 error between two vectors.
\(err = \frac{\sum_{i=0}^{i=len-1} |vec\_numer[i]-vec\_exact[i]|}{\sum_{i=0}^{i=len-1} |vec\_exact[i]|}\).
[in] | len | Length of the vectors |
[in] | vec_numer | Complex array of numerically computed result of length len. |
[in] | vec_exact | Complex array of exact result of length len. |
FNFT_COMPLEX fnft__misc_sech | ( | FNFT_COMPLEX | Z | ) |
Hyperbolic secant.
This function returns the hyperbolic secant of a FNFT_COMPLEX.
[in] | Z | FNFT_COMPLEX argument. |