AXOM
Axom provides a robust, flexible software infrastructure for the development of multi-physics applications and computational tools.
axom::utilities::detail Namespace Reference

Classes

struct  Delimiter
 
struct  less_than
 Predicate that implements less than. More...
 
struct  greater_than
 Predicate that implements greater than. More...
 

Functions

template<typename T >
constexpr static AXOM_HOST_DEVICEstack_size (T N)
 Computes stack size for qsort. More...
 
template<typename T >
AXOM_HOST_DEVICE void ifswap (T &a, T &b)
 Swap 2 elements if b < a. param a The first value. param b The second value. More...
 
AXOM_HOST_DEVICE void internal_swap (axom::IndexType, axom::IndexType)
 This method is called when there are no more values to swap. More...
 
template<typename T , typename... Args>
AXOM_HOST_DEVICE void internal_swap (axom::IndexType idx1, axom::IndexType idx2, T values, Args... args)
 Swap one set of values, move to next ones. More...
 
template<typename T , typename Predicate , typename... Args>
AXOM_HOST_DEVICE void ifswap_multiple (Predicate &&predicate, axom::IndexType idx1, axom::IndexType idx2, T values, Args... args)
 
template<typename T , typename Predicate , typename... Args>
static AXOM_HOST_DEVICE axom::IndexType partitionMultiple (Predicate &&predicate, axom::IndexType low, axom::IndexType high, T values, Args... args)
 Create a partition for qsort. More...
 
template<typename T , typename Predicate , typename... Args>
static AXOM_HOST_DEVICE void qsortMultiple (Predicate &&predicate, axom::IndexType n, T values, Args... args)
 Sort the input array using qsort. More...
 
template<typename T , typename Predicate , typename... Args>
static AXOM_HOST_DEVICE void insertionSortMultiple (Predicate &&predicate, axom::IndexType n, T values, Args... args)
 Perform actual sort on multiple data arrays. More...
 
template<typename T , typename Predicate , typename... Args>
static AXOM_HOST_DEVICE void sort_multiple_internal (Predicate &&predicate, axom::IndexType n, T first, Delimiter, Args... args)
 Terminal case for argument reordering where we know all of the array arguments as well as the array length argument. More...
 
template<typename T , typename Predicate , typename... Args>
static AXOM_HOST_DEVICE void sort_multiple_internal (Predicate &&predicate, T first, Delimiter d, axom::IndexType n, Args... args)
 Shift args to end until the array length is at the desired position. More...
 
template<typename T , typename Predicate , typename S , typename... Args>
static AXOM_HOST_DEVICE void sort_multiple_internal (Predicate &&predicate, T first, Delimiter d, S second, Args... args)
 Shift args to end until the array length is at the desired position. More...
 

Function Documentation

◆ stack_size()

template<typename T >
constexpr static AXOM_HOST_DEVICE T axom::utilities::detail::stack_size ( N)
staticconstexpr

Computes stack size for qsort.

Parameters
NThe largest number of items to support.
Returns
A number of elements for an array-based stack.

◆ ifswap()

template<typename T >
AXOM_HOST_DEVICE void axom::utilities::detail::ifswap ( T &  a,
T &  b 
)
inline

Swap 2 elements if b < a. param a The first value. param b The second value.

◆ internal_swap() [1/2]

AXOM_HOST_DEVICE void axom::utilities::detail::internal_swap ( axom::IndexType  ,
axom::IndexType   
)
inline

This method is called when there are no more values to swap.

◆ internal_swap() [2/2]

template<typename T , typename... Args>
AXOM_HOST_DEVICE void axom::utilities::detail::internal_swap ( axom::IndexType  idx1,
axom::IndexType  idx2,
values,
Args...  args 
)
inline

Swap one set of values, move to next ones.

Parameters
idx1The first array index.
idx2The second array index.
valuesThe current array values being swapped.
argsA parameter pack of additional arrays that need to be swapped.

References internal_swap(), and axom::utilities::swap().

◆ ifswap_multiple()

template<typename T , typename Predicate , typename... Args>
AXOM_HOST_DEVICE void axom::utilities::detail::ifswap_multiple ( Predicate &&  predicate,
axom::IndexType  idx1,
axom::IndexType  idx2,
values,
Args...  args 
)
inline

References internal_swap().

◆ partitionMultiple()

template<typename T , typename Predicate , typename... Args>
static AXOM_HOST_DEVICE axom::IndexType axom::utilities::detail::partitionMultiple ( Predicate &&  predicate,
axom::IndexType  low,
axom::IndexType  high,
values,
Args...  args 
)
static

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 internal_swap().

◆ qsortMultiple()

template<typename T , typename Predicate , typename... Args>
static AXOM_HOST_DEVICE void axom::utilities::detail::qsortMultiple ( Predicate &&  predicate,
axom::IndexType  n,
values,
Args...  args 
)
static

Sort the input array using qsort.

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

References partitionMultiple(), and stack_size().

◆ insertionSortMultiple()

template<typename T , typename Predicate , typename... Args>
static AXOM_HOST_DEVICE void axom::utilities::detail::insertionSortMultiple ( Predicate &&  predicate,
axom::IndexType  n,
values,
Args...  args 
)
static

Perform actual sort on multiple data arrays.

Parameters
nThe length of the data arrays.
valuesThe array being sorted.
argsThe rest of the arrays to be sorted the same way.

References internal_swap().

◆ sort_multiple_internal() [1/3]

template<typename T , typename Predicate , typename... Args>
static AXOM_HOST_DEVICE void axom::utilities::detail::sort_multiple_internal ( Predicate &&  predicate,
axom::IndexType  n,
first,
Delimiter  ,
Args...  args 
)
inlinestatic

Terminal case for argument reordering where we know all of the array arguments as well as the array length argument.

Parameters
predicateThe predicate to use for comparing elements,
firstThe first data array used for sorting.
dDelimiter
nThe length of the arrays.
argsA parameter pack containing all other arrays to be sorted.

References insertionSortMultiple(), and qsortMultiple().

◆ sort_multiple_internal() [2/3]

template<typename T , typename Predicate , typename... Args>
static AXOM_HOST_DEVICE void axom::utilities::detail::sort_multiple_internal ( Predicate &&  predicate,
first,
Delimiter  d,
axom::IndexType  n,
Args...  args 
)
inlinestatic

Shift args to end until the array length is at the desired position.

References sort_multiple_internal().

◆ sort_multiple_internal() [3/3]

template<typename T , typename Predicate , typename S , typename... Args>
static AXOM_HOST_DEVICE void axom::utilities::detail::sort_multiple_internal ( Predicate &&  predicate,
first,
Delimiter  d,
second,
Args...  args 
)
inlinestatic

Shift args to end until the array length is at the desired position.

References sort_multiple_internal().