Teuchos - Trilinos Tools Package Version of the Day
Public Member Functions
Teuchos::MaxLoc< Ordinal, ScalarType, IndexType > Class Template Reference

Teuchos version of MPI_MAXLOC. More...

Inheritance diagram for Teuchos::MaxLoc< Ordinal, ScalarType, IndexType >:
Teuchos::ValueTypeReductionOp< Ordinal, std::pair< ScalarType, IndexType > > Teuchos::Describable Teuchos::LabeledObject

List of all members.

Public Member Functions

void reduce (const Ordinal count, const std::pair< ScalarType, IndexType > inBuffer[], std::pair< ScalarType, IndexType > inoutBuffer[]) const

Detailed Description

template<class Ordinal, class ScalarType, class IndexType>
class Teuchos::MaxLoc< Ordinal, ScalarType, IndexType >

Teuchos version of MPI_MAXLOC.

Mark Hoemmen
Template Parameters:
OrdinalThe template parameter of Comm.
PacketA type with value semantics; the type on which to reduce.

MPI_MAXLOC is a standard reduction operator provided by the MPI standard. According to the standard, MPI_MAXLOC combines the (value, index) pairs (u,i) and (v,j) into (w,j), where $w = max(u,v)$, and

\[ k = \begin{cases} i & \text{if $u > v$}, \\ \min(i,j) & \text{if $u = v$}, \\ j & \text{if $u < v$}. \\ \end{cases} \]

This class implements the MPI_MAXLOC reduction operator for the Teuchos communication wrappers.

What happens to NaN ("Not a Number")? A NaN is neither less than, greater than, or equal to any floating-point number or any NaN. We can alter the above definition slightly so that a MaxLoc reduction has a well-defined result in case the array contains a NaN:

\[ w = \begin{cases} u & \text{if $u > v$}, \\ v & \text{if $u < v$}. \\ u & \text{otherwise}. \\ \end{cases} \]


\[ k = \begin{cases} i & \text{if $u > v$}, \\ j & \text{if $u < v$}. \\ \min(i,j) & \text{otherwise}. \\ \end{cases} \]

Defining MaxLoc in this way ensures that for any array containing a NaN, the value (w) returned is the first NaN, and the index (k) returned is the index of the first NaN.

Definition at line 104 of file Teuchos_TimeMonitor.cpp.

Member Function Documentation

template<class Ordinal , class ScalarType , class IndexType >
void Teuchos::MaxLoc< Ordinal, ScalarType, IndexType >::reduce ( const Ordinal  count,
const std::pair< ScalarType, IndexType >  inBuffer[],
std::pair< ScalarType, IndexType >  inoutBuffer[] 
) const [virtual]

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines