AXOM
Axom provides a robust, flexible software infrastructure for the development of multi-physics applications and computational tools.
Utilities.hpp File Reference

Header file containing utility functions. More...

#include "axom/config.hpp"
#include "axom/core/Types.hpp"
#include "axom/core/Macros.hpp"
#include <cassert>
#include <cmath>
#include <cstdint>
#include <random>
#include <type_traits>

Classes

class  axom::utilities::LexiComparator< T >
 Compares std::vector< T > in lexicographic order. More...
 

Namespaces

 axom
 
 axom::utilities
 

Functions

void axom::utilities::processAbort ()
 Gracefully aborts the application. More...
 
template<typename T >
AXOM_HOST_DEVICEaxom::utilities::abs (const T &x)
 Returns the absolute value of x. More...
 
template<typename T >
AXOM_HOST_DEVICEaxom::utilities::floor (const T &x)
 Returns the largest integer less than or equal to x. More...
 
template<typename T >
AXOM_HOST_DEVICEaxom::utilities::ceil (const T &x)
 Returns the smallest integer greater than or equal to x. More...
 
template<typename T >
AXOM_HOST_DEVICE const T & axom::utilities::max (const T &x, const T &y)
 Returns the max value of x and y. More...
 
template<typename T >
AXOM_HOST_DEVICE const T & axom::utilities::min (const T &x, const T &y)
 Returns the min value of x and y. More...
 
template<typename T >
AXOM_HOST_DEVICE void axom::utilities::swap (T &a, T &b)
 Swaps the values of a, b. More...
 
template<typename T >
AXOM_HOST_DEVICEaxom::utilities::fma (const T &a, const T &b, const T &c)
 Returns the fused-multiply-add of a, b, and c. More...
 
template<typename T >
axom::utilities::log2 (T val)
 Returns the base 2 logarithm of the input. More...
 
template<typename T >
AXOM_HOST_DEVICEaxom::utilities::lerp (T v0, T v1, T t)
 Linearly interpolates between two values. More...
 
template<typename T >
AXOM_HOST_DEVICEaxom::utilities::clampVal (T val, T lower, T upper)
 Clamps an input value to a given range. More...
 
template<typename T >
AXOM_HOST_DEVICEaxom::utilities::clampUpper (T val, T upper)
 Clamps the upper range on an input value. More...
 
template<typename T >
AXOM_HOST_DEVICEaxom::utilities::clampLower (T val, T lower)
 Clamps the lower range on an input value. More...
 
template<typename T >
constexpr AXOM_HOST_DEVICE bool axom::utilities::inBounds_0_N (T value, T upper)
 Determine whether a value is in [0,upper). More...
 
int axom::utilities::binomialCoefficient (int n, int k)
 Computes the binomial coefficient n choose k More...
 
template<typename T >
axom::utilities::random_real (const T &a, const T &b)
 Returns a random real number within the specified interval. More...
 
template<typename T >
axom::utilities::random_real (const T &a, const T &b, unsigned int seed)
 Returns a random real number within the specified interval given the bounds of the interval and a seed value for the underlying random number generator. More...
 
bool axom::utilities::isLittleEndian ()
 Tests the endianness of the system. More...
 
template<typename T >
constexpr T axom::utilities::byteswap (T val) noexcept
 Reverses the bytes of the input value. More...
 
template<typename RealType >
AXOM_HOST_DEVICE bool axom::utilities::isNearlyEqual (RealType a, RealType b, RealType thresh=1.0e-8)
 Fuzzy comparison of two real valued quantities. More...
 
template<typename RealType >
AXOM_HOST_DEVICE bool axom::utilities::isNearlyEqualRelative (RealType a, RealType b, RealType relThresh=1.0e-6, RealType absThresh=1.0e-8)
 Fuzzy comparison of two real valued quantities. More...
 
template<typename T >
int axom::utilities::sign_of (const T &v, const T &eps={0})
 Sign of a value of any type that supports comparison and negation operators. More...
 
template<typename DataType , typename Predicate = std::less<DataType>>
AXOM_SUPPRESS_HD_WARN AXOM_HOST_DEVICE void axom::utilities::insertionSort (DataType *array, IndexType n, Predicate cmp={})
 Insertion sort of an array. More...
 
template<typename ContainerT , typename T >
AXOM_HOST_DEVICE std::int32_t axom::utilities::binary_search (const ContainerT &cont, T value)
 Use binary search to find the index of the value in the supplied sorted container. More...
 
AXOM_HOST_DEVICE std::uint64_t axom::utilities::hash_bytes (const std::uint8_t *data, std::uint32_t length)
 Hash a stream of bytes into a uint64_t hash value. More...
 

Detailed Description

Header file containing utility functions.