AXOM
Axom provides a robust, flexible software infrastructure for the development of multi-physics applications and computational tools.
axom::utilities::Sorting< T, N > Struct Template Reference

This is a template suitable for sorting small arrays on device. More...

#include </home/docs/checkouts/readthedocs.org/user_builds/axom/checkouts/main/src/axom/core/utilities/Sorting.hpp>

Static Public Member Functions

static AXOM_HOST_DEVICE void sort (T *values, int n)
 Sort an array of values in place. More...
 
static AXOM_HOST_DEVICE void qsort (T *values, int n)
 Sort the input array using qsort. More...
 
static AXOM_HOST_DEVICE int partition (T *values, int low, int high)
 Create a partition for qsort. More...
 
static AXOM_HOST_DEVICE void insertionSort (T *values, int n)
 Sort the input array using insertion sort. More...
 

Static Public Attributes

static constexpr int MAX_SIZE = N
 
static constexpr int SORT_SIZE_CUTOFF = 11
 

Detailed Description

template<typename T, int N = axom::numeric_limits<int>::max()>
struct axom::utilities::Sorting< T, N >

This is a template suitable for sorting small arrays on device.

Template Parameters
TThe data type being sorted.
NThe biggest array size that will be used.
Note
For very short arrays, a simpler sort is faster. As the array size increases, the algorithm switches to qsort. Also, this is designed as a template class so it can be specialized.

Member Function Documentation

◆ sort()

template<typename T , int N = axom::numeric_limits<int>::max()>
static AXOM_HOST_DEVICE void axom::utilities::Sorting< T, N >::sort ( T *  values,
int  n 
)
inlinestatic

Sort an array of values in place.

Parameters
[in,out]valuesThe array of values to sort.
nThe number of values in the array.

References axom::utilities::insertionSort().

◆ qsort()

template<typename T , int N = axom::numeric_limits<int>::max()>
static AXOM_HOST_DEVICE void axom::utilities::Sorting< T, N >::qsort ( T *  values,
int  n 
)
inlinestatic

Sort the input array using qsort.

Parameters
[in,out]valuesThe array to be sorted.
nThe number of values in the array.

References axom::utilities::detail::stack_size().

◆ partition()

template<typename T , int N = axom::numeric_limits<int>::max()>
static AXOM_HOST_DEVICE int axom::utilities::Sorting< T, N >::partition ( T *  values,
int  low,
int  high 
)
inlinestatic

Create a partition for qsort.

Parameters
[in,out]valuesThe array to be sorted.
lowThe lower bound of the input partition.
highThe upper bound of the input partition.
Returns
A new pivot.

References axom::utilities::detail::ifswap(), and axom::utilities::swap().

◆ insertionSort()

template<typename T , int N = axom::numeric_limits<int>::max()>
static AXOM_HOST_DEVICE void axom::utilities::Sorting< T, N >::insertionSort ( T *  values,
int  n 
)
inlinestatic

Sort the input array using insertion sort.

Parameters
[in,out]valuesThe array to be sorted.
nThe number of values in the array.

References axom::utilities::swap().

Member Data Documentation

◆ MAX_SIZE

template<typename T , int N = axom::numeric_limits<int>::max()>
constexpr int axom::utilities::Sorting< T, N >::MAX_SIZE = N
staticconstexpr

◆ SORT_SIZE_CUTOFF

template<typename T , int N = axom::numeric_limits<int>::max()>
constexpr int axom::utilities::Sorting< T, N >::SORT_SIZE_CUTOFF = 11
staticconstexpr

The documentation for this struct was generated from the following file: