Dendro  5.01
Dendro in Greek language means tree. The Dendro library is a large scale (262K cores on ORNL's Titan) distributed memory adaptive octree framework. The main goal of Dendro is to perform large scale multiphysics simulations efficeiently in mordern supercomputers. Dendro consists of efficient parallel data structures and algorithms to perform variational ( finite element) methods and finite difference mthods on 2:1 balanced arbitary adaptive octrees which enables the users to perform simulations raning from black holes (binary black hole mergers) to blood flow in human body, where applications ranging from relativity, astrophysics to biomedical engineering.
Functions
seq Namespace Reference

Collection of Generic Sequential Functions. More...

Functions

template<typename T >
void flashsort (T *a, int n, int m, int *ctr)
 Flash sort algo to sort an array in O(n). More...
 
template<typename T >
bool BinarySearch (const T *arr, unsigned int nelem, const T &key, unsigned int *idx)
 A binary search implementation. More...
 
template<typename T >
int UpperBound (unsigned int nelem, const T *arr, unsigned int startIdx, const T &key)
 Finds the index of the smallest upper bound of the search key in the array. More...
 
template<typename T >
bool maxLowerBound (const std::vector< T > &arr, const T &key, unsigned int &retIdx, unsigned int *leftIdx, unsigned int *rightIdx)
 Finds the index of the greatest lower bound of the search key in the array. The implementation uses a simple modification of the binary search algorithm. More...
 

Detailed Description

Collection of Generic Sequential Functions.

Author
Rahul Sampath
Milinda Fernando.

Function Documentation

◆ BinarySearch()

template<typename T >
bool seq::BinarySearch ( const T *  arr,
unsigned int  nelem,
const T &  key,
unsigned int *  idx 
)

A binary search implementation.

Author
Rahul Sampath
Parameters
arrA sorted array
nelemThe length of the array
keyThe search key
idx0-based index of the position of the key in the array
Returns
'true' if the key exists in the array and 'false' otherwise

◆ flashsort()

template<typename T >
void seq::flashsort ( T *  a,
int  n,
int  m,
int *  ctr 
)

Flash sort algo to sort an array in O(n).

Parameters
aThe array to be sorted
nThe number of elements in a
mSize of index vector. typically m = 0.1*n
ctrThe number of times flashsort was called.

Sorts array a with n elements by use of the index vector l of dimension m (with m about 0.1 n). The routine runs fastest with a uniform distribution of elements. The vector l is declare dynamically using the calloc function. The variable ctr counts the number of times that flashsort is called. THRESHOLD is a very important constant. It is the minimum number of elements required in a subclass before recursion is used.

Templated version of flashsort based on original C code by Karl-Dietrich Neubert.

◆ maxLowerBound()

template<typename T >
bool seq::maxLowerBound ( const std::vector< T > &  arr,
const T &  key,
unsigned int &  retIdx,
unsigned int *  leftIdx,
unsigned int *  rightIdx 
)

Finds the index of the greatest lower bound of the search key in the array. The implementation uses a simple modification of the binary search algorithm.

Author
Rahul Sampath
Parameters
arrA sorted array
keyThe search key
retIdxThe index of the position of the last element in the array <= key
leftIdxIf this is not NULL, then the search will be limited to elements at positions >= *leftIdx
rightIdxif this is not NULL, then the search will be limited to elements at positions <= *rightIdx
Returns
'true' if the search was successful

◆ UpperBound()

template<typename T >
int seq::UpperBound ( unsigned int  nelem,
const T *  arr,
unsigned int  startIdx,
const T &  key 
)

Finds the index of the smallest upper bound of the search key in the array.

Author
Santi Swaroop Adavani
Parameters
arrA sorted array
nelemThe length of the array
startIdxThe starting location to search from
keyThe search key
Returns
the index of the first element in the array >= key