1#ifndef STAN_MATH_OPENCL_PRIM_DOUBLE_SKEW_DOUBLE_EXPONENTIAL_LCCDF_HPP 
    2#define STAN_MATH_OPENCL_PRIM_DOUBLE_SKEW_DOUBLE_EXPONENTIAL_LCCDF_HPP 
   30template <
typename T_y_cl, 
typename T_loc_cl, 
typename T_scale_cl,
 
   31          typename T_skewness_cl,
 
   33              T_y_cl, T_loc_cl, T_scale_cl, T_skewness_cl>* = 
nullptr,
 
   35                                        T_skewness_cl>* = 
nullptr>
 
   36inline return_type_t<T_y_cl, T_loc_cl, T_scale_cl, T_skewness_cl>
 
   38                              const T_scale_cl& sigma,
 
   39                              const T_skewness_cl& tau) {
 
   40  static constexpr const char* function
 
   41      = 
"skew_double_exponential_lccdf(OpenCL)";
 
   42  using T_partials_return
 
   48                         mu, 
"Shape parameter", sigma, 
"Skewness parameter",
 
   50  const size_t N = 
max_size(y, mu, sigma, tau);
 
   61  const auto& mu_val = 
value_of(mu_col);
 
   62  const auto& sigma_val = 
value_of(sigma_col);
 
   63  const auto& tau_val = 
value_of(tau_col);
 
   66      = 
check_cl(function, 
"Random variable", y_val, 
"not NaN");
 
   67  auto y_not_nan_expr = !isnan(y_val);
 
   69      = 
check_cl(function, 
"Location parameter", mu_val, 
"finite");
 
   70  auto mu_finite_expr = 
isfinite(mu_val);
 
   71  auto check_sigma_positive_finite
 
   72      = 
check_cl(function, 
"Scale parameter", sigma_val, 
"positive finite");
 
   73  auto sigma_positive_finite_expr = 0.0 < sigma_val && 
isfinite(sigma_val);
 
   74  auto check_tau_bounded = 
check_cl(function, 
"Skewness parameter", tau_val,
 
   75                                    "in the interval [0, 1]");
 
   76  auto tau_bounded_expr = 0.0 < tau_val && tau_val <= 1.0;
 
   79  auto y_m_mu = y_val - mu_val;
 
   80  auto diff_sign = 
sign(y_m_mu);
 
   81  auto diff_sign_smaller_0 = diff_sign < 0;
 
   82  auto abs_diff_y_mu = 
fabs(y_m_mu);
 
   83  auto abs_diff_y_mu_over_sigma = 
elt_multiply(abs_diff_y_mu, inv_sigma);
 
   86                     abs_diff_y_mu_over_sigma);
 
   87  auto tau_minus_1 = tau_val - 1.0;
 
   95             log1m(tau_val) - 2.0 * expo));
 
   97  auto cond = y_val < mu_val;
 
   98  auto y_deriv = 
select(cond,
 
  103  auto mu_deriv = -y_deriv;
 
  104  auto sigma_deriv = 
select(
 
  124  results(check_y_not_nan, check_mu_finite, check_sigma_positive_finite,
 
  125          check_tau_bounded, lccdf_cl, y_deriv_cl, mu_deriv_cl, sigma_deriv_cl,
 
  127      = 
expressions(y_not_nan_expr, mu_finite_expr, sigma_positive_finite_expr,
 
  128                    tau_bounded_expr, lccdf_expr,
 
  129                    calc_if<is_autodiff_v<T_y_cl>>(y_deriv),
 
  130                    calc_if<is_autodiff_v<T_loc_cl>>(mu_deriv),
 
  131                    calc_if<is_autodiff_v<T_scale_cl>>(sigma_deriv),
 
  132                    calc_if<is_autodiff_v<T_skewness_cl>>(tau_deriv));
 
  139  if constexpr (is_autodiff_v<T_y_cl>) {
 
  140    partials<0>(ops_partials) = std::move(y_deriv_cl);
 
  142  if constexpr (is_autodiff_v<T_loc_cl>) {
 
  143    partials<1>(ops_partials) = std::move(mu_deriv_cl);
 
  145  if constexpr (is_autodiff_v<T_scale_cl>) {
 
  146    partials<2>(ops_partials) = std::move(sigma_deriv_cl);
 
  148  if constexpr (is_autodiff_v<T_skewness_cl>) {
 
  149    partials<3>(ops_partials) = std::move(tau_deriv_cl);
 
  152  return ops_partials.build(lccdf);
 
Represents an arithmetic matrix on the OpenCL device.
 
elt_multiply_< as_operation_cl_t< T_a >, as_operation_cl_t< T_b > > elt_multiply(T_a &&a, T_b &&b)
 
isfinite_< as_operation_cl_t< T > > isfinite(T &&a)
 
select_< as_operation_cl_t< T_condition >, as_operation_cl_t< T_then >, as_operation_cl_t< T_else > > select(T_condition &&condition, T_then &&then, T_else &&els)
Selection operation on kernel generator expressions.
 
auto check_cl(const char *function, const char *var_name, T &&y, const char *must_be)
Constructs a check on opencl matrix or expression.
 
results_cl< T_results... > results(T_results &&... results)
Deduces types for constructing results_cl object.
 
auto as_column_vector_or_scalar(T &&a)
as_column_vector_or_scalar of a kernel generator expression.
 
elt_divide_< as_operation_cl_t< T_a >, as_operation_cl_t< T_b > > elt_divide(T_a &&a, T_b &&b)
 
calc_if_< true, as_operation_cl_t< T > > calc_if(T &&a)
 
auto colwise_sum(T &&a)
Column wise sum - reduction of a kernel generator expression.
 
expressions_cl< T_expressions... > expressions(T_expressions &&... expressions)
Deduces types for constructing expressions_cl object.
 
return_type_t< T_y_cl, T_loc_cl, T_scale_cl, T_skewness_cl > skew_double_exponential_lccdf(const T_y_cl &y, const T_loc_cl &mu, const T_scale_cl &sigma, const T_skewness_cl &tau)
Returns the skew double exponential cumulative density function.
 
auto from_matrix_cl(const T &src)
Copies the source matrix that is stored on the OpenCL device to the destination Eigen matrix.
 
require_all_t< is_prim_or_rev_kernel_expression< std::decay_t< Types > >... > require_all_prim_or_rev_kernel_expression_t
Require type satisfies is_prim_or_rev_kernel_expression.
 
require_any_not_t< is_stan_scalar< std::decay_t< Types > >... > require_any_not_stan_scalar_t
Require at least one of the types do not satisfy is_stan_scalar.
 
auto sign(const T &x)
Returns signs of the arguments.
 
T value_of(const fvar< T > &v)
Return the value of the specified variable.
 
void check_consistent_sizes(const char *)
Trivial no input case, this function is a no-op.
 
auto sum(const std::vector< T > &m)
Return the sum of the entries of the specified standard vector.
 
int64_t max_size(const T1 &x1, const Ts &... xs)
Calculate the size of the largest input.
 
fvar< T > log1m(const fvar< T > &x)
 
auto make_partials_propagator(Ops &&... ops)
Construct an partials_propagator.
 
fvar< T > fabs(const fvar< T > &x)
 
fvar< T > square(const fvar< T > &x)
 
fvar< T > exp(const fvar< T > &x)
 
typename partials_return_type< Args... >::type partials_return_t
 
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
 
bool isnan(const stan::math::var &a)
Checks if the given number is NaN.