10#ifndef TPETRA_DETAILS_SHORTSORT_HPP 
   11#define TPETRA_DETAILS_SHORTSORT_HPP 
   21#include "TpetraCore_config.h" 
   22#include "Kokkos_Macros.hpp" 
   29#ifdef TPETRA_DETAILS_SWAP_KEYSANDVALUES 
   30#error "The TPETRA_DETAILS_SWAP_KEYSANDVALUES macro is already defined." 
   53#define TPETRA_DETAILS_SWAP_KEYSANDVALUES(i, j) \ 
   54  if (keys[i] > keys[j]) {                      \ 
   55    const KeyType tmpKey(keys[i]);              \ 
   58    const ValueType tmpVal(values[i]);          \ 
   59    values[i] = values[j];                      \ 
 
   64#ifdef TPETRA_DETAILS_SWAP_KEYS 
   65#error "The TPETRA_DETAILS_SWAP_KEYS macro is already defined." 
   85#define TPETRA_DETAILS_SWAP_KEYS(i, j) \ 
   86  if (keys[i] > keys[j]) {             \ 
   87    const KeyType tmpKey(keys[i]);     \ 
 
  102template <
class KeyType, 
class ValueType>
 
  117template <
class KeyType>
 
  136template <
class KeyType, 
class ValueType>
 
  157template <
class KeyType>
 
  182template <
class KeyType, 
class ValueType>
 
  205template <
class KeyType>
 
  232template <
class KeyType, 
class ValueType>
 
  269template <
class KeyType>
 
  305template <
class KeyType, 
class ValueType, 
class IndexType>
 
  310  static_assert(std::is_integral<IndexType>::value,
 
  311                "IndexType must be a signed integer type.");
 
  312  static_assert(std::is_signed<IndexType>::value,
 
  313                "IndexType must be a signed integer type.  " 
  314                "This implementation does a count-down loop, " 
  315                "and may thus loop forever " 
  316                "if one attempts to use it with unsigned IndexType.");
 
 
  345template <
class KeyType, 
class IndexType>
 
  348  static_assert(std::is_integral<IndexType>::value,
 
  349                "IndexType must be a signed integer type.");
 
  350  static_assert(std::is_signed<IndexType>::value,
 
  351                "IndexType must be a signed integer type.  " 
  352                "This implementation does a count-down loop, " 
  353                "and may thus loop forever " 
  354                "if one attempts to use it with unsigned IndexType.");
 
 
  376template <
typename KeyType, 
typename ValueType, 
typename IndexType>
 
  381  IndexType gaps[] = {3548, 1577, 701, 301, 132, 57, 23, 10, 4, 1};
 
  382  for (IndexType gapIndex = 0; gapIndex < ngaps; gapIndex++) {
 
  383    auto gap = gaps[gapIndex];
 
  387    for (IndexType gapOffset = 0; gapOffset < gap; gapOffset++) {
 
  388      for (IndexType i = gap + gapOffset; i < n; i += gap) {
 
  390        if (keys[i - gap] > keys[i]) {
 
  391          IndexType finalPos = i - gap;
 
  392          while (finalPos - gap >= 0 && keys[finalPos - gap] > keys[i]) {
 
  396          auto tempKey = keys[i];
 
  397          auto tempVal = values[i];
 
  398          for (IndexType j = i - gap; j >= finalPos; j -= gap) {
 
  399            keys[j + gap]   = keys[j];
 
  400            values[j + gap] = values[j];
 
  402          keys[finalPos]   = tempKey;
 
  403          values[finalPos] = tempVal;
 
#define TPETRA_DETAILS_SWAP_KEYS(i, j)
Macro that swaps the i and j entries of keys, if keys[i] > keys[j] (i.e., if keys[i] and keys[j] are ...
 
#define TPETRA_DETAILS_SWAP_KEYSANDVALUES(i, j)
Macro that swaps the i and j entries of keys and values, if keys[i] > keys[j] (i.e....
 
Struct that holds views of the contents of a CrsMatrix.
 
Implementation details of Tpetra.
 
KOKKOS_FUNCTION void shellSortKeys(KeyType keys[], const IndexType n)
Shellsort (yes, it's one word) the input array keys.
 
KOKKOS_FUNCTION void shortSortKeysAndValues_3(KeyType keys[3], ValueType values[3])
Sort keys and values jointly, by keys, for arrays of length 3.
 
KOKKOS_FUNCTION void shortSortKeysAndValues_8(KeyType keys[8], ValueType values[8])
Sort keys and values jointly, by keys, for arrays of length 8.
 
KOKKOS_FUNCTION void 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...
 
KOKKOS_FUNCTION void shortSortKeys_3(KeyType keys[3])
Sort length-3 array of keys.
 
KOKKOS_FUNCTION void shortSortKeysAndValues_2(KeyType keys[2], ValueType values[2])
Sort keys and values jointly, by keys, for arrays of length 2.
 
KOKKOS_FUNCTION void shortSortKeys_2(KeyType keys[2])
Sort length-2 array of keys.
 
KOKKOS_FUNCTION void shortSortKeys_8(KeyType keys[8])
Sort length-8 array of keys.
 
KOKKOS_FUNCTION void shortSortKeysAndValues_4(KeyType keys[4], ValueType values[4])
Sort keys and values jointly, by keys, for arrays of length 4.
 
KOKKOS_FUNCTION void shortSortKeys_4(KeyType keys[4])
Sort length-4 array of keys.
 
Namespace Tpetra contains the class and methods constituting the Tpetra library.
 
@ ZERO
Replace old values with zero.