Kokkos Core Kernels Package  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Types | Static Public Member Functions | List of all members
Kokkos::Details::InnerProductSpaceTraits< T > Class Template Reference

Traits class for inner product space operations on type T. More...

#include <Kokkos_InnerProductSpaceTraits.hpp>

Public Types

typedef T val_type
 The type T itself. More...
 
typedef ArithTraits< T >::mag_type mag_type
 The type returned by norm(x) for a value x of type T. More...
 
typedef T dot_type
 The type returned by dot(x,y) for values x and y of type T. More...
 

Static Public Member Functions

static
KOKKOS_FORCEINLINE_FUNCTION
mag_type 
norm (const T &x)
 The "norm" (absolute value or magnitude) of a value x of type T. More...
 
static
KOKKOS_FORCEINLINE_FUNCTION
dot_type 
dot (const T &x, const T &y)
 The "dot product" of two values x and y of type T. More...
 

Detailed Description

template<class T>
class Kokkos::Details::InnerProductSpaceTraits< T >

Traits class for inner product space operations on type T.

Template Parameters
T"Scalar" type of interest
Warning
This interface is not ready for exposure to users yet. Users beware!
This class is an implementation detail of Kokkos and Tpetra. You only need to deal with this class if you are implementing a new Scalar type for Tpetra, or if you are using Kokkos to implement your own linear algebra library.

This class defines typedefs and functions necessary for implementing inner product space operations on finite-dimensional vector spaces over T. A <t>finite-dimensional vector space over T of dimension N is $T^N$, supplied with vector space operations. An example would be the space of length N vectors of double; a more interesting (and motivating) example would be the space of length N vectors of one of Sacado's automatic differentiation (AD) types.

Mathematical definition

An inner product space is a vector space that has an inner product. For example, we can define a "Euclidean" inner product on $T^N$ as follows: [ dot(x,y) := dot(x_k, y_k). ] If T is a real-valued type, then $dot(x_k, y_k)$ is just the ordinary product of real numbers $x_k * y_k$. However, we do not require this. For example, if T is one of Sacado's AD types, we may wish to define $dot(x_k, y_k)$ to return a single scalar value, rather than an AD value. This is one way to use vectors of AD values in a Krylov solver, for example. (This is also why we put "Euclidean" in quotes above.)

Inner product spaces have a norm induced by their inner product. For example, given the above inner product definition, we can define a "Euclidean" norm ("two-norm") on $T^N$ as follows: [ norm(x) := norm(dot(x_k, x_k)). ] The result has the type of the absolute value of the product of two T values. We can express this as InnerProductSpaceTraits<InnerProductSpaceTraits<T>::dot_type>::mag_type. For example, if InnerProductSpaceTraits<T>::dot_type is complex, then its mag_type is real. The "norm" of a single complex value here is just its absolute value (i.e., its magnitude).

One could also define other kinds of norms using this class. For example, a "one-norm" analogue would look like this: [ norm(x,1) := norm(x_k). ] Note the use of the "norm" of a single element of the vector, that is, a single value of type T. That could be a different function than the "norm" that takes dot_type, which the above example uses.

Use of class methods in device kernels

All class methods must be suitable for parallel kernels, if the type T itself is suitable for parallel kernels. In particular, specializations for types T that make sense to use on a CUDA device must mark all class methods as device (and host) functions, using the KOKKOS_FORCEINLINE_FUNCTION macro. All class methods must be callable both inside and outside a parallel kernel (for CUDA, this means they must be marked as both device and host functions).

Unsupported types on CUDA devices

CUDA does not support long double or std::complex<T> in device functions. This class does have specializations for these types, but the class methods therein are not marked as device functions.

Adding a specialization for a new type T

You must first add a specialization of ArithTraits<T>. Please note that if CUDA does not support using T in device functions, then you must not</t> mark norm() or dot() as device functions in your specialization. (Simply omit the KOKKOS_FORCEINLINE_FUNCTION macro.) If CUDA does support using T in device functions, you must mark norm() and dot() as device functions in order to use them in device functions.

Definition at line 145 of file Kokkos_InnerProductSpaceTraits.hpp.

Member Typedef Documentation

template<class T>
typedef T Kokkos::Details::InnerProductSpaceTraits< T >::val_type

The type T itself.

Definition at line 148 of file Kokkos_InnerProductSpaceTraits.hpp.

The type returned by norm(x) for a value x of type T.

Definition at line 151 of file Kokkos_InnerProductSpaceTraits.hpp.

template<class T>
typedef T Kokkos::Details::InnerProductSpaceTraits< T >::dot_type

The type returned by dot(x,y) for values x and y of type T.

Definition at line 154 of file Kokkos_InnerProductSpaceTraits.hpp.

Member Function Documentation

template<class T>
static KOKKOS_FORCEINLINE_FUNCTION mag_type Kokkos::Details::InnerProductSpaceTraits< T >::norm ( const T &  x)
inlinestatic

The "norm" (absolute value or magnitude) of a value x of type T.

Definition at line 157 of file Kokkos_InnerProductSpaceTraits.hpp.

template<class T>
static KOKKOS_FORCEINLINE_FUNCTION dot_type Kokkos::Details::InnerProductSpaceTraits< T >::dot ( const T &  x,
const T &  y 
)
inlinestatic

The "dot product" of two values x and y of type T.

Definition at line 161 of file Kokkos_InnerProductSpaceTraits.hpp.


The documentation for this class was generated from the following file: