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

A collection of useful sorting functions. More...

#include "saf_utilities.h"

Go to the source code of this file.

Data Structures

struct  saf_sort_int
 Helper struct for sorting a vector of integers using 'qsort'. More...
 
struct  saf_sort_float
 Helper struct for sorting a vector of floats using 'qsort'. More...
 
struct  saf_sort_double
 Helper struct for sorting a vector of doubles using 'qsort'. More...
 

Functions

static int cmp_asc_int (const void *a, const void *b)
 Helper function for sorting a vector of integers using 'qsort' in ascending order.
 
static int cmp_desc_int (const void *a, const void *b)
 Helper function for a sorting vector of integers using 'qsort' in decending order.
 
static int cmp_asc_float (const void *a, const void *b)
 Helper function for a sorting vector of floats using 'qsort' in ascending order.
 
static int cmp_desc_float (const void *a, const void *b)
 Helper function for a sorting vector of floats using 'qsort' in decending order.
 
static int cmp_asc_double (const void *a, const void *b)
 Helper function for a sorting vector of doubles using 'qsort' in ascending order.
 
static int cmp_desc_double (const void *a, const void *b)
 Helper function for a sorting vector of doubles using 'qsort' in decending order.
 
void sorti (int *in_vec, int *out_vec, int *new_idices, int len, int descendFLAG)
 Sort a vector of integer values into ascending/decending order (optionally returning the new indices as well)
 
void sortf (float *in_vec, float *out_vec, int *new_idices, int len, int descendFLAG)
 Sort a vector of floating-point values into ascending/decending order (optionally returning the new indices as well)
 
void sortd (double *in_vec, double *out_vec, int *new_idices, int len, int descendFLAG)
 Sort a vector of double floating-point values into ascending/decending order (optionally returning the new indices as well)
 
void sortc (float_complex *in_vec, float_complex *out_vec, int len, int descendFLAG)
 Sort a vector of complex floating-point values into ascending/decending order.
 
void sortz (double_complex *in_vec, double_complex *out_vec, int len, int descendFLAG)
 Sort a vector of complex double floating-point values into ascending/ decending order.
 
void cmplxPairUp (double_complex *in_vec, double_complex *out_vec, int len)
 Pairs up complex numbers and sorts them in ascending order based on their real parts first, and then on their imaginary parts.
 
void findClosestGridPoints (float *grid_dirs, int nGrid, float *target_dirs, int nTarget, int degFLAG, int *idx_closest, float *dirs_closest, float *angle_diff)
 Finds indicies into "grid_dirs" that are the closest to "target dirs".
 
void findClosestGridPointsCartesian (float *grid_dirs_xyz, int nGrid, float *target_dirs_xyz, int nTarget, int *idx_closest, float *dirs_xyz_closest, float *angle_diff)
 Finds indicies into "grid_dirs_xyz" that are the closest to "target dirs_xyz".
 

Detailed Description

A collection of useful sorting functions.

Author
Leo McCormack
Date
30.07.2018
License
ISC

Definition in file saf_utility_sort.c.

Function Documentation

◆ cmp_asc_double()

static int cmp_asc_double ( const void * a,
const void * b )
static

Helper function for a sorting vector of doubles using 'qsort' in ascending order.

Definition at line 102 of file saf_utility_sort.c.

◆ cmp_asc_float()

static int cmp_asc_float ( const void * a,
const void * b )
static

Helper function for a sorting vector of floats using 'qsort' in ascending order.

Definition at line 78 of file saf_utility_sort.c.

◆ cmp_asc_int()

static int cmp_asc_int ( const void * a,
const void * b )
static

Helper function for sorting a vector of integers using 'qsort' in ascending order.

Definition at line 54 of file saf_utility_sort.c.

◆ cmp_desc_double()

static int cmp_desc_double ( const void * a,
const void * b )
static

Helper function for a sorting vector of doubles using 'qsort' in decending order.

Definition at line 114 of file saf_utility_sort.c.

◆ cmp_desc_float()

static int cmp_desc_float ( const void * a,
const void * b )
static

Helper function for a sorting vector of floats using 'qsort' in decending order.

Definition at line 90 of file saf_utility_sort.c.

◆ cmp_desc_int()

static int cmp_desc_int ( const void * a,
const void * b )
static

Helper function for a sorting vector of integers using 'qsort' in decending order.

Definition at line 66 of file saf_utility_sort.c.