Teuchos - Trilinos Tools Package  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | List of all members
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

Public Member Functions

void reduce (const Ordinal count, const std::pair< ScalarType, IndexType > inBuffer[], std::pair< ScalarType, IndexType > inoutBuffer[]) const
 
- Public Member Functions inherited from Teuchos::Describable
virtual std::string description () const
 Return a simple one-line description of this object. More...
 
virtual void describe (FancyOStream &out, const EVerbosityLevel verbLevel=verbLevel_default) const
 Print the object with some verbosity level to a FancyOStream. More...
 
void describe (std::ostream &out, const EVerbosityLevel verbLevel=verbLevel_default) const
 Version of describe() that takes an std::ostream instead of a FancyOStream. More...
 
virtual ~Describable ()
 Destructor (marked virtual for memory safety of derived classes). More...
 
- Public Member Functions inherited from Teuchos::LabeledObject
 LabeledObject ()
 Construct with an empty label. More...
 
virtual ~LabeledObject ()
 
virtual void setObjectLabel (const std::string &objectLabel)
 Set the object label (see LabeledObject). More...
 
virtual std::string getObjectLabel () const
 Get the object label (see LabeledObject). More...
 

Additional Inherited Members

- Static Public Attributes inherited from Teuchos::Describable
static const EVerbosityLevel verbLevel_default = VERB_DEFAULT
 Default value for the verbLevel argument of describe(). More...
 

Detailed Description

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

Teuchos version of MPI_MAXLOC.

Author
Mark Hoemmen
Template Parameters
OrdinalThe template parameter of Comm.
ScalarTypeType for which to find the maximum.
IndexTypeType indicating the index of the maximum.

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. We need to define this separately from MPI for two reasons. First, the Teuchos comm wrappers do not currently expose taking an MPI_Op. Second, we need MaxLoc to be templated on the scalar and index types, in order to match Teuchos' MPI interface.

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} \]

and

\[ 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 79 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: