27 template <
typename... T>
36 template <
typename T0>
47 template <
typename T0,
typename T1>
60 template <
typename T0,
typename T1,
typename T2>
75 template <
typename T0,
typename T1,
typename T2,
typename T3>
92 template <
typename T0,
typename T1,
typename T2,
typename T3,
typename T4>
93 struct tuple<T0, T1, T2, T3, T4> {
111 template <
typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5>
112 struct tuple<T0, T1, T2, T3, T4, T5> {
132 template <
typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6>
133 struct tuple<T0, T1, T2, T3, T4, T5, T6> {
155 template <
typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6,
typename T7>
156 struct tuple<T0, T1, T2, T3, T4, T5, T6, T7> {
171 template <
typename... T>
179 template <
typename... T>
182 return tuple<T...>{args...};
185 template <
class... Types>
189 template <
class... Types>
198 template <
int i,
typename... T>
201 static_assert(i <
sizeof...(T),
"");
202 if constexpr (i == 0) {
205 if constexpr (i == 1) {
208 if constexpr (i == 2) {
211 if constexpr (i == 3) {
214 if constexpr (i == 4) {
217 if constexpr (i == 5) {
220 if constexpr (i == 6) {
223 if constexpr (i == 7) {
233 template <
int i,
typename... T>
236 static_assert(i <
sizeof...(T),
"");
237 if constexpr (i == 0) {
240 if constexpr (i == 1) {
243 if constexpr (i == 2) {
246 if constexpr (i == 3) {
249 if constexpr (i == 4) {
252 if constexpr (i == 5) {
255 if constexpr (i == 6) {
258 if constexpr (i == 7) {
273 template <
int i,
typename... T>
276 static_assert(i <
sizeof...(T),
"");
277 if constexpr (i == 0) {
280 if constexpr (i == 1) {
283 if constexpr (i == 2) {
286 if constexpr (i == 3) {
289 if constexpr (i == 4) {
292 if constexpr (i == 5) {
295 if constexpr (i == 6) {
298 if constexpr (i == 7) {
313 template <
typename... S,
typename... T,
int... i>
315 std::integer_sequence<int, i...>)
317 return tuple{get<i>(x) + get<i>(y)...};
327 template <
typename... S,
typename... T>
330 static_assert(
sizeof...(S) ==
sizeof...(T));
331 return plus_helper(x, y, std::make_integer_sequence<
int,
static_cast<int>(
sizeof...(S))>());
342 template <
typename... T,
int... i>
344 std::integer_sequence<int, i...>)
346 ((get<i>(x) += get<i>(y)), ...);
355 template <
typename... T>
358 return plus_equals_helper(x, y, std::make_integer_sequence<
int,
static_cast<int>(
sizeof...(T))>());
369 template <
typename... T,
int... i>
371 std::integer_sequence<int, i...>)
373 ((get<i>(x) -= get<i>(y)), ...);
382 template <
typename... T>
385 return minus_equals_helper(x, y, std::make_integer_sequence<
int,
static_cast<int>(
sizeof...(T))>());
398 template <
typename... S,
typename... T,
int... i>
400 std::integer_sequence<int, i...>)
402 return tuple{get<i>(x) - get<i>(y)...};
412 template <
typename... S,
typename... T>
415 static_assert(
sizeof...(S) ==
sizeof...(T));
416 return minus_helper(x, y, std::make_integer_sequence<
int,
static_cast<int>(
sizeof...(S))>());
427 template <
typename... T,
int... i>
430 return tuple{-get<i>(x)...};
438 template <
typename... T>
441 return unary_minus_helper(x, std::make_integer_sequence<
int,
static_cast<int>(
sizeof...(T))>());
454 template <
typename... S,
typename... T,
int... i>
456 std::integer_sequence<int, i...>)
458 return tuple{get<i>(x) / get<i>(y)...};
468 template <
typename... S,
typename... T>
471 static_assert(
sizeof...(S) ==
sizeof...(T));
472 return div_helper(x, y, std::make_integer_sequence<
int,
static_cast<int>(
sizeof...(S))>());
484 template <
typename... T,
int... i>
487 return tuple{a / get<i>(x)...};
499 template <
typename... T,
int... i>
502 return tuple{get<i>(x) / a...};
511 template <
typename... T>
514 return div_helper(a, x, std::make_integer_sequence<
int,
static_cast<int>(
sizeof...(T))>());
523 template <
typename... T>
526 return div_helper(x, a, std::make_integer_sequence<
int,
static_cast<int>(
sizeof...(T))>());
539 template <
typename... S,
typename... T,
int... i>
541 std::integer_sequence<int, i...>)
543 return tuple{get<i>(x) * get<i>(y)...};
553 template <
typename... S,
typename... T>
556 static_assert(
sizeof...(S) ==
sizeof...(T));
557 return mult_helper(x, y, std::make_integer_sequence<
int,
static_cast<int>(
sizeof...(S))>());
569 template <
typename... T,
int... i>
572 return tuple{a * get<i>(x)...};
584 template <
typename... T,
int... i>
587 return tuple{get<i>(x) * a...};
596 template <
typename... T>
599 return mult_helper(a, x, std::make_integer_sequence<
int,
static_cast<int>(
sizeof...(T))>());
608 template <
typename... T>
611 return mult_helper(x, a, std::make_integer_sequence<
int,
static_cast<int>(
sizeof...(T))>());
621 template <
typename... T, std::size_t... i>
625 (..., (out << (i == 0 ?
"" :
", ") << serac::get<i>(A)));
636 template <
typename... T>
639 return print_helper(out, A, std::make_integer_sequence<
size_t,
sizeof...(T)>());
652 template <
typename lambda,
typename... T,
int... i>
655 return f(get<i>(args)...);
667 template <
typename lambda,
typename... T>
670 return apply_helper(f, std::move(args), std::make_integer_sequence<
int,
static_cast<int>(
sizeof...(T))>());
676 template <
typename lambda,
typename... T,
int... i>
679 return f(get<i>(args)...);
691 template <
typename lambda,
typename... T>
694 return apply_helper(f, std::move(args), std::make_integer_sequence<
int,
static_cast<int>(
sizeof...(T))>());
705 template <
size_t I,
class T>
710 template <
size_t I,
class Head,
class... Tail>
716 template <
class Head,
class... Tail>
724 template <
typename T>
729 template <
typename... T>
736 template <
typename T>
743 template <
typename... T>
750 #include "serac/numerics/functional/tuple_tensor_dual_functions.hpp"
This file contains the interface used for initializing/terminating any hardware accelerator-related f...
#define SERAC_HOST_DEVICE
Macro that evaluates to __host__ __device__ when compiling with nvcc and does nothing on a host compi...
Accelerator functionality.
SERAC_HOST_DEVICE auto apply(lambda f, tuple< T... > &args)
a way of passing an n-tuple to a function that expects n separate arguments
constexpr SERAC_HOST_DEVICE auto plus_helper(const tuple< S... > &x, const tuple< T... > &y, std::integer_sequence< int, i... >)
A helper function for the + operator of tuples.
constexpr SERAC_HOST_DEVICE auto operator*(const dual< gradient_type > &a, double b)
multiplication of a dual number and a non-dual number
Domain operator-(const Domain &a, const Domain &b)
create a new domain that is the set difference of a and b
constexpr T & get(variant< T0, T1 > &v)
Returns the variant member of specified type.
constexpr SERAC_HOST_DEVICE auto operator+(dual< gradient_type > a, double b)
addition of a dual number and a non-dual number
constexpr SERAC_HOST_DEVICE void plus_equals_helper(tuple< T... > &x, const tuple< T... > &y, std::integer_sequence< int, i... >)
A helper function for the += operator of tuples.
auto & print_helper(std::ostream &out, const serac::tuple< T... > &A, std::integer_sequence< size_t, i... >)
helper used to implement printing a tuple of values
constexpr SERAC_HOST_DEVICE auto & operator-=(dual< gradient_type > &a, const dual< gradient_type > &b)
compound assignment (-) for dual numbers
constexpr SERAC_HOST_DEVICE auto unary_minus_helper(const tuple< T... > &x, std::integer_sequence< int, i... >)
A helper function for the - operator of tuples.
SERAC_HOST_DEVICE tuple< T... > make_tuple(const T &... args)
helper function for combining a list of values into a tuple
constexpr SERAC_HOST_DEVICE void minus_equals_helper(tuple< T... > &x, const tuple< T... > &y, std::integer_sequence< int, i... >)
A helper function for the -= operator of tuples.
auto & operator<<(std::ostream &out, dual< T > A)
overload of operator<< for dual to work with std::cout and other std::ostreams
tuple(T...) -> tuple< T... >
Class template argument deduction rule for tuples.
constexpr SERAC_HOST_DEVICE auto type(const tuple< T... > &values)
a function intended to be used for extracting the ith type from a tuple.
SERAC_HOST_DEVICE auto apply_helper(lambda f, tuple< T... > &args, std::integer_sequence< int, i... >)
A helper to apply a lambda to a tuple.
constexpr SERAC_HOST_DEVICE auto & operator+=(dual< gradient_type > &a, const dual< gradient_type > &b)
compound assignment (+) for dual numbers
constexpr SERAC_HOST_DEVICE auto div_helper(const tuple< S... > &x, const tuple< T... > &y, std::integer_sequence< int, i... >)
A helper function for the / operator of tuples.
constexpr SERAC_HOST_DEVICE auto minus_helper(const tuple< S... > &x, const tuple< T... > &y, std::integer_sequence< int, i... >)
A helper function for the - operator of tuples.
constexpr SERAC_HOST_DEVICE auto mult_helper(const tuple< S... > &x, const tuple< T... > &y, std::integer_sequence< int, i... >)
A helper function for the * operator of tuples.
constexpr SERAC_HOST_DEVICE auto operator/(const dual< gradient_type > &a, double b)
division of a dual number by a non-dual number
Trait for checking if a type if a serac::tuple containing only serac::tuple.
Trait for checking if a type is a serac::tuple.
T2 v2
The third member of the tuple.
T4 v4
The fifth member of the tuple.
T7 v7
The eighth member of the tuple.
T0 v0
The first member of the tuple.
T1 v1
The second member of the tuple.
T3 v3
The fourth member of the tuple.
T5 v5
The sixth member of the tuple.
T6 v6
The seventh member of the tuple.
T0 v0
The first member of the tuple.
T1 v1
The second member of the tuple.
T5 v5
The sixth member of the tuple.
T4 v4
The fifth member of the tuple.
T2 v2
The third member of the tuple.
T6 v6
The seventh member of the tuple.
T3 v3
The fourth member of the tuple.
T1 v1
The second member of the tuple.
T4 v4
The fifth member of the tuple.
T0 v0
The first member of the tuple.
T2 v2
The third member of the tuple.
T3 v3
The fourth member of the tuple.
T5 v5
The sixth member of the tuple.
T2 v2
The third member of the tuple.
T4 v4
The fifth member of the tuple.
T1 v1
The second member of the tuple.
T3 v3
The fourth member of the tuple.
T0 v0
The first member of the tuple.
T3 v3
The fourth member of the tuple.
T2 v2
The third member of the tuple.
T0 v0
The first member of the tuple.
T1 v1
The second member of the tuple.
T2 v2
The third member of the tuple.
T1 v1
The second member of the tuple.
T0 v0
The first member of the tuple.
T1 v1
The second member of the tuple.
T0 v0
The first member of the tuple.
T0 v0
The first member of the tuple.
Head type
the type at the specified index
a struct used to determine the type at index I of a tuple
This is a class that mimics most of std::tuple's interface, except that it is usable in CUDA kernels ...