WarpX
Functions
utils::algorithms Namespace Reference

Functions

template<typename TV , typename TE , class = typename std::enable_if<std::is_convertible<TE,TV>::value>::type>
bool is_in (const std::vector< TV > &vect, const TE &elem)
 Returns true if an item of type TE is in a vector of TV objects (provided that TE can be converted into TV), false otherwise. More...
 
template<typename TV , typename TE , class = typename std::enable_if<std::is_convertible<TE,TV>::value>::type>
bool any_of_is_in (const std::vector< TV > &vect, const std::vector< TE > &elems)
 Returns true if any of the items of a vector<TE> is contained in another vector<TV> (provided that TE can be converted into TV) More...
 
template<typename T >
AMREX_GPU_DEVICE AMREX_FORCE_INLINElinear_interp (T x0, T x1, T f0, T f1, T x)
 Performs a linear interpolation. More...
 
template<typename T >
AMREX_GPU_DEVICE AMREX_FORCE_INLINEbilinear_interp (T x0, T x1, T y0, T y1, T f00, T f01, T f10, T f11, T x, T y)
 Performs a bilinear interpolation. More...
 
template<typename T >
AMREX_GPU_DEVICE AMREX_FORCE_INLINEtrilinear_interp (T x0, T x1, T y0, T y1, T z0, T z1, T f000, T f001, T f010, T f011, T f100, T f101, T f110, T f111, T x, T y, T z)
 Performs a trilinear interpolation. More...
 
template<typename T >
AMREX_GPU_DEVICE AMREX_FORCE_INLINE const T * upper_bound (const T *first, const T *last, const T &val)
 Returns a pointer to the first element in the range [first, last) that is greater than val. More...
 

Function Documentation

◆ any_of_is_in()

template<typename TV , typename TE , class = typename std::enable_if<std::is_convertible<TE,TV>::value>::type>
bool utils::algorithms::any_of_is_in ( const std::vector< TV > &  vect,
const std::vector< TE > &  elems 
)

Returns true if any of the items of a vector<TE> is contained in another vector<TV> (provided that TE can be converted into TV)

Template Parameters
TVthe typename of the first vector elements
TVthe typename of the second vector elements
Parameters
vecta vector of TV objects
elemsa vector of TE objects
Returns
true if any element of elems is in vect, false otherwise

◆ bilinear_interp()

template<typename T >
AMREX_GPU_DEVICE AMREX_FORCE_INLINE T utils::algorithms::bilinear_interp ( x0,
x1,
y0,
y1,
f00,
f01,
f10,
f11,
x,
y 
)

Performs a bilinear interpolation.

Performs a bilinear interpolation at (x,y) given the 4 points (x0, y0, f00), (x0, y1, f01), (x1, y0, f10), (x1, y1, f11).

◆ is_in()

template<typename TV , typename TE , class = typename std::enable_if<std::is_convertible<TE,TV>::value>::type>
bool utils::algorithms::is_in ( const std::vector< TV > &  vect,
const TE &  elem 
)

Returns true if an item of type TE is in a vector of TV objects (provided that TE can be converted into TV), false otherwise.

Template Parameters
TVthe typename of the vector elements
TEthe typename of the item
Parameters
vecta vector of TV objects
eleman object of type TE
Returns
true if elem is in vect, false otherwise

◆ linear_interp()

template<typename T >
AMREX_GPU_DEVICE AMREX_FORCE_INLINE T utils::algorithms::linear_interp ( x0,
x1,
f0,
f1,
x 
)

Performs a linear interpolation.

Performs a linear interpolation at x given the 2 points (x0, f0) and (x1, f1)

◆ trilinear_interp()

template<typename T >
AMREX_GPU_DEVICE AMREX_FORCE_INLINE T utils::algorithms::trilinear_interp ( x0,
x1,
y0,
y1,
z0,
z1,
f000,
f001,
f010,
f011,
f100,
f101,
f110,
f111,
x,
y,
z 
)

Performs a trilinear interpolation.

Performs a trilinear interpolation at (x,y,z) given the 8 points (x0, y0, z0, f000), (x0, y0, z1, f001), (x0, y1, z0, f010), (x0, y1, z1, f011), (x1, y0, z0, f100), (x1, y0, z1, f101), (x1, y1, z0, f110), (x1, y1, z1, f111)

◆ upper_bound()

template<typename T >
AMREX_GPU_DEVICE AMREX_FORCE_INLINE const T* utils::algorithms::upper_bound ( const T *  first,
const T *  last,
const T &  val 
)

Returns a pointer to the first element in the range [first, last) that is greater than val.

A re-implementation of the upper_bound algorithm suitable for GPU kernels.

Parameters
firstpointer to left limit of the range to consider
lastpointer to right limit of the range to consider
valvalue to compare the elements of [first, last) to