AXOM
Axom provides a robust, flexible software infrastructure for the development of multi-physics applications and computational tools.
axom::utilities Namespace Reference

Namespaces

 filesystem
 
 string
 

Classes

class  LexiComparator
 Compares std::vector< T > in lexicographic order. More...
 
class  Timer
 A simple Timer class to measure execution time. More...
 

Functions

void processAbort ()
 Gracefully aborts the application. More...
 
template<typename T >
AXOM_HOST_DEVICEabs (const T &x)
 Returns the absolute value of x. More...
 
template<typename T >
AXOM_HOST_DEVICE const T & max (const T &x, const T &y)
 Returns the max value of x and y. More...
 
template<typename T >
AXOM_HOST_DEVICE const T & min (const T &x, const T &y)
 Returns the min value of x and y. More...
 
template<typename T >
AXOM_HOST_DEVICE void swap (T &a, T &b)
 Swaps the values of a, b. More...
 
template<typename T >
log2 (T &val)
 Returns the base 2 logarithm of the input. More...
 
template<typename T >
AXOM_HOST_DEVICEclampVal (T val, T lower, T upper)
 Clamps an input value to a given range. More...
 
template<typename T >
AXOM_HOST_DEVICEclampUpper (T val, T upper)
 Clamps the upper range on an input value. More...
 
template<typename T >
AXOM_HOST_DEVICEclampLower (T val, T lower)
 Clamps the lower range on an input value. More...
 
template<typename T >
random_real (const T &a, const T &b)
 Returns a random real number within the specified interval. More...
 
template<typename T >
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 isLittleEndian ()
 Tests the endianness of the system. More...
 
template<typename T >
swapEndian (T val)
 Swaps the endianness of the input value. More...
 
template<typename RealType >
AXOM_HOST_DEVICE bool 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 isNearlyEqualRelative (RealType a, RealType b, RealType relThresh=1.0e-6, RealType absThresh=1.0e-8)
 Fuzzy comparison of two real valued quantities. More...
 

Function Documentation

◆ processAbort()

void axom::utilities::processAbort ( )

Gracefully aborts the application.

Referenced by axom::Array< double >::dynamicRealloc(), and axom::Array< double >::setCapacity().

◆ abs()

template<typename T >
AXOM_HOST_DEVICE T axom::utilities::abs ( const T &  x)
inline

Returns the absolute value of x.

Parameters
[in]xvalue whose absolute value is computed.
Returns
abs(x) the absolute value of x.

Referenced by axom::primal::abs(), isNearlyEqual(), isNearlyEqualRelative(), axom::numerics::jacobi_eigensolve(), axom::numerics::lu_decompose(), axom::primal::Triangle< T, NDIMS >::physToBarycentric(), and axom::primal::Tetrahedron< T, NDIMS >::volume().

◆ max()

◆ min()

◆ swap()

template<typename T >
AXOM_HOST_DEVICE void axom::utilities::swap ( T &  a,
T &  b 
)
inline

Swaps the values of a, b.

Parameters
[in,out]a1st object to swap.
[in,out]b2nd object to swap.

Referenced by axom::primal::clip(), axom::numerics::eigen_sort(), axom::numerics::lu_solve(), axom::primal::BoundingBox< double, DIM >::shift(), and axom::numerics::Matrix< T >::swapRows().

◆ log2()

template<typename T >
T axom::utilities::log2 ( T &  val)
inline

Returns the base 2 logarithm of the input.

Parameters
[in]valThe input value

◆ clampVal()

template<typename T >
AXOM_HOST_DEVICE T axom::utilities::clampVal ( val,
lower,
upper 
)
inline

Clamps an input value to a given range.

Parameters
[in]valThe value to clamp.
[in]lowerThe lower range.
[in]upperThe upper range.
Returns
The clamped value.
Precondition
lower <= upper
Postcondition
lower <= returned value <= upper.

Referenced by axom::primal::NumericArray< IndexType, NDIMS >::clamp(), axom::spin::UniformGrid< T, NDIMS >::insert(), and axom::primal::NumericArray< IndexType, NDIMS >::NumericArray().

◆ clampUpper()

template<typename T >
AXOM_HOST_DEVICE T axom::utilities::clampUpper ( val,
upper 
)
inline

Clamps the upper range on an input value.

Parameters
[in]valThe value to clamp
[in]upperThe upper range
Returns
upper if val > upper, else val
Postcondition
returned value is less than or equal to upper

Referenced by axom::spin::ImplicitGrid< NDIMS, TheIndexType >::contains(), axom::spin::ImplicitGrid< NDIMS, TheIndexType >::getCandidates(), axom::spin::ImplicitGrid< NDIMS, TheIndexType >::insert(), and axom::primal::NumericArray< IndexType, NDIMS >::size().

◆ clampLower()

template<typename T >
AXOM_HOST_DEVICE T axom::utilities::clampLower ( val,
lower 
)
inline

Clamps the lower range on an input value.

Parameters
[in]valThe value to clamp
[in]lowerThe lower range
Returns
lower if val < lower, else val
Postcondition
returned value is greater than or equal to lower

Referenced by axom::spin::ImplicitGrid< NDIMS, TheIndexType >::contains(), axom::spin::ImplicitGrid< NDIMS, TheIndexType >::insert(), and axom::primal::NumericArray< IndexType, NDIMS >::size().

◆ random_real() [1/2]

template<typename T >
T axom::utilities::random_real ( const T &  a,
const T &  b 
)
inline

Returns a random real number within the specified interval.

Parameters
[in]athe interval's lower bound
[in]bthe interval's upper bound
Returns
r the random real number within the specified interval.
Template Parameters
Ta built-in floating point type, e.g., double, float, long double.
Note
Consecutive calls to this method will generate a non-deterministic sequence of numbers.
Precondition
a < b
Postcondition
a <= r < b

References AXOM_STATIC_ASSERT.

◆ random_real() [2/2]

template<typename T >
T axom::utilities::random_real ( const T &  a,
const T &  b,
unsigned int  seed 
)
inline

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.

Parameters
[in]athe interval's lower bound
[in]bthe interval's upper bound
[in]seeduser-supplied seed for the random number generator
Returns
r the random real number within the specified interval.
Template Parameters
Ta built-in floating type, e.g., double, float, long double.
Note
Consecutive calls to this method will generate a deterministic sequence of numbers.
Precondition
a < b
Postcondition
a <= r < b

References AXOM_STATIC_ASSERT.

◆ isLittleEndian()

bool axom::utilities::isLittleEndian ( )
inline

Tests the endianness of the system.

Returns
True, if the system is little endian, false otherwise.

◆ swapEndian()

template<typename T >
T axom::utilities::swapEndian ( val)

Swaps the endianness of the input value.

Parameters
[in]valThe input value.
Returns
The value with endianness swapped.
Note
Assumes endianness is either little or big (not PDP).
Precondition
T is a native arithmetic type (i.e. integral or floating point).
sizeof(T) must be 2, 4, or 8 bytes.

References AXOM_STATIC_ASSERT_MSG.

◆ isNearlyEqual()

template<typename RealType >
AXOM_HOST_DEVICE bool axom::utilities::isNearlyEqual ( RealType  a,
RealType  b,
RealType  thresh = 1.0e-8 
)
inline

◆ isNearlyEqualRelative()

template<typename RealType >
AXOM_HOST_DEVICE bool axom::utilities::isNearlyEqualRelative ( RealType  a,
RealType  b,
RealType  relThresh = 1.0e-6,
RealType  absThresh = 1.0e-8 
)
inline

Fuzzy comparison of two real valued quantities.

Parameters
[in]aThe first real valued quantities we are comparing.
[in]bThe second real valued quantities we are comparing.
[in]relThreshThe relative threshold of the fuzzy comparison. Default is 1.0e-6.
[in]absThreshThe absolute threshold of the fuzzy comparison. Default is 1.0e-8.
Returns
True if the absolute value of the difference is less than the sum of absThresh and the relative difference (relThresh times the absolute max of a and b).

References abs(), and max().