Tpetra parallel linear algebra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Namespaces | Macros | Functions
Tpetra_Details_shortSort.hpp File Reference

Declaration and definition of functions for sorting "short" arrays of keys and corresponding values. More...

#include "TpetraCore_config.h"
#include "Kokkos_Macros.hpp"
#include <type_traits>

Go to the source code of this file.

Namespaces

 Tpetra
 Namespace Tpetra contains the class and methods constituting the Tpetra library.
 
 Tpetra::Details
 Namespace for Tpetra implementation details.
 

Macros

#define TPETRA_DETAILS_SWAP_KEYSANDVALUES(i, j)
 Macro that swaps the i and j entries of keys and values, if keys[i] > keysj. More...
 
#define TPETRA_DETAILS_SWAP_KEYS(i, j)
 Macro that swaps the i and j entries of keys, if keys[i] > keysj. More...
 

Functions

template<class KeyType , class ValueType >
KOKKOS_FUNCTION void Tpetra::Details::shortSortKeysAndValues_2 (KeyType keys[2], ValueType values[2])
 Sort keys and values jointly, by keys, for arrays of length 2. More...
 
template<class KeyType >
KOKKOS_FUNCTION void Tpetra::Details::shortSortKeys_2 (KeyType keys[2])
 Sort length-2 array of keys. More...
 
template<class KeyType , class ValueType >
KOKKOS_FUNCTION void Tpetra::Details::shortSortKeysAndValues_3 (KeyType keys[3], ValueType values[3])
 Sort keys and values jointly, by keys, for arrays of length 3. More...
 
template<class KeyType >
KOKKOS_FUNCTION void Tpetra::Details::shortSortKeys_3 (KeyType keys[3])
 Sort length-3 array of keys. More...
 
template<class KeyType , class ValueType >
KOKKOS_FUNCTION void Tpetra::Details::shortSortKeysAndValues_4 (KeyType keys[4], ValueType values[4])
 Sort keys and values jointly, by keys, for arrays of length 4. More...
 
template<class KeyType >
KOKKOS_FUNCTION void Tpetra::Details::shortSortKeys_4 (KeyType keys[4])
 Sort length-4 array of keys. More...
 
template<class KeyType , class ValueType >
KOKKOS_FUNCTION void Tpetra::Details::shortSortKeysAndValues_8 (KeyType keys[8], ValueType values[8])
 Sort keys and values jointly, by keys, for arrays of length 8. More...
 
template<class KeyType >
KOKKOS_FUNCTION void Tpetra::Details::shortSortKeys_8 (KeyType keys[8])
 Sort length-8 array of keys. More...
 
template<class KeyType , class ValueType , class IndexType >
KOKKOS_FUNCTION void Tpetra::Details::shellSortKeysAndValues (KeyType keys[], ValueType values[], const IndexType n)
 Shellsort (yes, it's one word) the input array keys, and apply the resulting permutation to the input array values. More...
 
template<class KeyType , class IndexType >
KOKKOS_FUNCTION void Tpetra::Details::shellSortKeys (KeyType keys[], const IndexType n)
 Shellsort (yes, it's one word) the input array keys. More...
 

Detailed Description

Declaration and definition of functions for sorting "short" arrays of keys and corresponding values.

"Short" means "having few entries." This matters because optimal (in terms of fewest comparisons) sorting algorithms are different for short arrays.

Definition in file Tpetra_Details_shortSort.hpp.

Macro Definition Documentation

#define TPETRA_DETAILS_SWAP_KEYSANDVALUES (   i,
 
)
Value:
if (keys[i] > keys[j]) { \
const KeyType tmpKey (keys[i]); \
keys[i] = keys[j]; \
keys[j] = tmpKey; \
const ValueType tmpVal (values[i]); \
values[i] = values[j]; \
values[j] = tmpVal; \
}

Macro that swaps the i and j entries of keys and values, if keys[i] > keysj.

Warning
This macro is an implementation detail of shortSortKeysAndValues_2, shortSortKeysAndValues_3, shortSortKeysAndValues_4, and shortSortKeysAndValues_8 (see below). Do not rely on this macro anywhere in your code. The macro must be called inside those functions, because it assumes that certain symbols exist (see list below).
Parameters
i[in] Integer index. i <= j.
j[in] Integer index. i <= j.

Captured symbols:

  • keys: Array of keys; each entry has type KeyType
  • values: Array of values; each entry has type ValueType
  • KeyType: Type of each entry of keys
  • ValueType: Type of each entry of values

Definition at line 87 of file Tpetra_Details_shortSort.hpp.

#define TPETRA_DETAILS_SWAP_KEYS (   i,
 
)
Value:
if (keys[i] > keys[j]) { \
const KeyType tmpKey (keys[i]); \
keys[i] = keys[j]; \
keys[j] = tmpKey; \
}

Macro that swaps the i and j entries of keys, if keys[i] > keysj.

Warning
This macro is an implementation detail of shortSortKeys_2, shortSortKeys_3, shortSortKeys_4, and shortSortKeys_8 (see below). Do not rely on this macro anywhere in your code. The macro must be called inside those functions, because it assumes that certain symbols exist (see list below).
Parameters
i[in] Integer index. i <= j.
j[in] Integer index. i <= j.

Captured symbols:

  • keys: Array of keys; each entry has type KeyType
  • KeyType: Type of each entry of keys

Definition at line 119 of file Tpetra_Details_shortSort.hpp.