Automatic Differentiation
 
Loading...
Searching...
No Matches
ref_type.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_OPENCL_REF_TYPE_HPP
2#define STAN_MATH_OPENCL_REF_TYPE_HPP
3#ifdef STAN_OPENCL
4
8#include <type_traits>
9
10namespace stan {
11
12namespace internal {
13
14template <typename T>
15struct is_trivial_kg_expression : public std::false_type {};
16
17template <>
18struct is_trivial_kg_expression<int> : public std::true_type {};
19template <>
20struct is_trivial_kg_expression<double> : public std::true_type {};
21template <typename T>
22struct is_trivial_kg_expression<math::matrix_cl<T>> : public std::true_type {};
23template <typename T>
24struct is_trivial_kg_expression<math::load_<T>> : public std::true_type {};
25template <typename T>
26struct is_trivial_kg_expression<math::scalar_<T>> : public std::true_type {};
27template <typename T>
28struct is_trivial_kg_expression<math::constant_<T>> : public std::true_type {};
29template <>
30struct is_trivial_kg_expression<math::row_index> : public std::true_type {};
31template <>
32struct is_trivial_kg_expression<math::col_index> : public std::true_type {};
33template <typename T>
34struct is_trivial_kg_expression<math::calc_if_<false, T>>
35 : public std::true_type {};
36
37template <typename T>
38struct is_trivial_kg_expression<math::as_column_vector_or_scalar_<T>>
39 : public is_trivial_kg_expression<std::decay_t<T>> {};
40template <typename T>
41struct is_trivial_kg_expression<math::block_<T>>
42 : public is_trivial_kg_expression<std::decay_t<T>> {};
43template <typename T, bool Colwise, bool Rowwise>
44struct is_trivial_kg_expression<math::broadcast_<T, Colwise, Rowwise>>
45 : public is_trivial_kg_expression<std::decay_t<T>> {};
46template <typename T>
47struct is_trivial_kg_expression<math::calc_if_<true, T>>
48 : public is_trivial_kg_expression<std::decay_t<T>> {};
49template <typename T>
50struct is_trivial_kg_expression<math::holder_cl_<T>>
51 : public is_trivial_kg_expression<std::decay_t<T>> {};
52template <typename T, bool Colwise, bool Rowwise>
53struct is_trivial_kg_expression<math::optional_broadcast_<T, Colwise, Rowwise>>
54 : public is_trivial_kg_expression<std::decay_t<T>> {};
55
56} // namespace internal
57
58template <bool Condition, typename T>
62 = std::conditional_t<std::is_rvalue_reference<T>::value,
63 std::remove_reference_t<T>, const T&>;
64 using type = std::conditional_t<
67};
68
69} // namespace stan
70#endif
71#endif
require_all_t< is_kernel_expression< Types >... > require_all_kernel_expressions_t
Enables a template if all given types are are a valid kernel generator expressions.
typename plain_type< T >::type plain_type_t
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
std::conditional_t< std::is_rvalue_reference< T >::value, std::remove_reference_t< T >, const T & > T_optionally_ref
Definition ref_type.hpp:63
std::conditional_t< internal::is_trivial_kg_expression< std::decay_t< T > >::value||!Condition, T_optionally_ref, T_plain > type
Definition ref_type.hpp:66
If the condition is true determines appropriate type for assigning expression of given type to,...
Definition ref_type.hpp:26