SpECTRE
v2024.12.16
|
Contains an assortment of constexpr functions. More...
Functions | |
template<typename List , Requires< not tt::is_a_v< tmpl::list, tmpl::front< List > > > = nullptr> | |
KOKKOS_FUNCTION constexpr auto | make_cpp20_array_from_list () -> cpp20::array< std::decay_t< decltype(tmpl::front< List >::value)>, tmpl::size< List >::value > |
Make an array from a typelist that holds std::integral_constant's all of which have the same value_type More... | |
template<typename T , Requires< tt::is_integer_v< T > and std::is_unsigned_v< T > > = nullptr> | |
constexpr T | two_to_the (T n) |
Compute 2 to the n for integral types. More... | |
constexpr size_t | get_nth_bit (const size_t i, const size_t N) |
Get the nth bit from the right, counting from zero. More... | |
template<typename T > | |
constexpr decltype(auto) | square (const T &x) |
Compute the square of x | |
template<typename T > | |
constexpr decltype(auto) | cube (const T &x) |
Compute the cube of x | |
KOKKOS_FUNCTION constexpr uint64_t | falling_factorial (const uint64_t x, const uint64_t n) |
Compute the falling factorial of | |
KOKKOS_FUNCTION constexpr uint64_t | factorial (const uint64_t n) |
Compute the factorial of | |
template<int N, typename T > | |
constexpr decltype(auto) | pow (const T &t) |
Compute t^N where N is an integer (positive or negative) More... | |
template<typename T , Requires< tt::is_integer_v< T > or std::is_floating_point_v< T > > = nullptr> | |
KOKKOS_FUNCTION constexpr T | ce_abs (const T &x) |
Compute the absolute value of of its argument. More... | |
KOKKOS_FUNCTION constexpr double | ce_fabs (const double x) |
Compute the absolute value of its argument. | |
template<size_t NumTerms, typename Function , Requires< NumTerms==1 > = nullptr> | |
constexpr decltype(auto) | constexpr_sum (Function &&f) |
Returns f(ic<0>{}) + f(ic<1>{}) + ... + f(ic<NumTerms-1>{}) where ic<N> stands for std::integral_constant<size_t, N> . This function allows the result types of each operation to be different, and so works efficiently with expression templates. More... | |
template<typename List , Requires< not tt::is_a_v< tmpl::list, tmpl::front< List > > > = nullptr> | |
constexpr auto | make_array_from_list () -> std::array< std::decay_t< decltype(tmpl::front< List >::value)>, tmpl::size< List >::value > |
Make an array from a typelist that holds std::integral_constant's all of which have the same value_type More... | |
constexpr size_t | cstring_length (const char *str) |
Compute the length of a const char* at compile time. | |
constexpr size_t | cstring_hash (const char *str) |
Compute a hash of a const char* at compile time. | |
template<size_t I, typename T , size_t Size> | |
constexpr std::array< std::decay_t< T >, Size > | replace_at (const std::array< T, Size > &arr, T value) |
Replace at compile time the I th entry in the array with value | |
template<typename T , typename S , size_t size> | |
constexpr bool | array_equal (const std::array< T, size > &lhs, const std::array< S, size > &rhs, const size_t i=0) |
Check at compile time if two std::array s are equal. | |
template<typename T > | |
constexpr const T & | max_by_magnitude (const T &a, const T &b) |
Return the argument with the largest magnitude. More... | |
template<typename T > | |
constexpr T | max_by_magnitude (std::initializer_list< T > ilist) |
Return the argument with the largest magnitude. More... | |
template<typename T > | |
constexpr const T & | min_by_magnitude (const T &a, const T &b) |
Return the argument with the smallest magnitude. More... | |
template<typename T > | |
constexpr T | min_by_magnitude (std::initializer_list< T > ilist) |
Return the argument with the smallest magnitude. More... | |
Contains an assortment of constexpr functions.
Contains an assortment of constexpr functions that are useful for metaprogramming, or efficient mathematical computations, such as exponentiating to an integer power, where the power is known at compile time.
Contains an assortment of constexpr functions that are useful for metaprogramming, or efficient mathematical computations, such as exponentiating to an integer power, where the power is known at compile time.
|
constexpr |
Compute the absolute value of of its argument.
The argument must be comparable to an int and must be negatable.
|
constexpr |
Returns f(ic<0>{}) + f(ic<1>{}) + ... + f(ic<NumTerms-1>{})
where ic<N>
stands for std::integral_constant<size_t, N>
. This function allows the result types of each operation to be different, and so works efficiently with expression templates.
f
.
|
constexpr |
Compute the falling factorial of
The falling factorial
|
constexpr |
Get the nth bit from the right, counting from zero.
i | the value to be acted on. |
N | which place to extract the bit |
Returns: the value of the bit at that place.
|
inlineconstexpr |
Make an array from a typelist that holds std::integral_constant's all of which have the same value_type
Make an array of arrays from a typelist that holds typelists of std::integral_constant's all of which have the same value_type
List | the typelist of std::integral_constant's |
Returns: array of integral values from the typelist
List | the typelist of typelists of std::integral_constant's |
Returns: array of arrays of integral values from the typelists
|
inlineconstexpr |
Make an array from a typelist that holds std::integral_constant's all of which have the same value_type
List | the typelist of std::integral_constant's |
Returns: array of integral values from the typelist
|
constexpr |
Return the argument with the largest magnitude.
Magnitude is determined by constexpr_abs. In case of a tie, returns the leftmost of the tied values.
|
constexpr |
Return the argument with the largest magnitude.
Magnitude is determined by constexpr_abs. In case of a tie, returns the leftmost of the tied values.
|
constexpr |
Return the argument with the smallest magnitude.
Magnitude is determined by constexpr_abs. In case of a tie, returns the leftmost of the tied values.
|
constexpr |
Return the argument with the smallest magnitude.
Magnitude is determined by constexpr_abs. In case of a tie, returns the leftmost of the tied values.
|
constexpr |
Compute t^N where N is an integer (positive or negative)
pow<-10>(2) == 0
evaluates to true
pow<0>
of a vector type (e.g. DataVector
) will not be used for initialization or directly indexed, so pow<0>
returns simply 1.0
. In the case of use for initialization, a constructor should be used instead, and in the case of a direct index, the expression may be simplifyable to avoid the use of pow<0>
altogether. If a more complete treatment of pow<0>
is required, further overloads may be added to the ConstantExpressions_detail
namespace.N | the integer power being raised to in |
t | the value being exponentiated |
Returns: value
|
constexpr |
Compute 2 to the n for integral types.
n | the power of two to compute. |
Returns: 2^n