1#ifndef STAN_MATH_OPENCL_KERNEL_GENERATOR_BROADCAST_HPP
2#define STAN_MATH_OPENCL_KERNEL_GENERATOR_BROADCAST_HPP
30template <
typename T,
bool Colwise,
bool Rowwise>
33 typename std::remove_reference_t<T>::Scalar, T> {
35 using Scalar =
typename std::remove_reference_t<T>::Scalar;
44 const char* function =
"broadcast";
58 auto&& arg_copy = this->
template get_arg<0>().deep_copy();
59 return broadcast_<std::remove_reference_t<
decltype(arg_copy)>, Colwise,
60 Rowwise>{std::move(arg_copy)};
69 std::string& col_index_name)
const {
84 return Colwise ?
base::dynamic : this->
template get_arg<0>().rows();
93 return Rowwise ?
base::dynamic : this->
template get_arg<0>().cols();
101 std::pair<int, int> arg_diags
102 = this->
template get_arg<0>().extreme_diagonals();
103 return {Colwise ? std::numeric_limits<int>::min() : arg_diags.first,
104 Rowwise ? std::numeric_limits<int>::max() : arg_diags.second};
123template <
bool Colwise,
bool Rowwise,
typename T,
127 return broadcast_<std::remove_reference_t<
decltype(a_operation)>, Colwise,
128 Rowwise>(std::move(a_operation));
146 return broadcast<false, true>(std::forward<T>(a));
164 return broadcast<true, false>(std::forward<T>(a));
auto deep_copy() const
Creates a deep copy of this expression.
std::pair< int, int > extreme_diagonals() const
Determine indices of extreme sub- and superdiagonals written.
int cols() const
Number of columns of a matrix that would be the result of evaluating this expression.
broadcast_(T &&a)
Constructor.
int rows() const
Number of rows of a matrix that would be the result of evaluating this expression.
typename std::remove_reference_t< T >::Scalar Scalar
void modify_argument_indices(std::string &row_index_name, std::string &col_index_name) const
Sets index/indices along broadcasted dimmension(s) to 0.
Represents a broadcasting operation in kernel generator expressions.
static constexpr int dynamic
Base for all kernel generator operations.
auto rowwise_broadcast(T &&a)
Broadcast an expression in rowwise dimmension.
auto colwise_broadcast(T &&a)
Broadcast an expression in colwise dimmension.
auto broadcast(T &&a)
Broadcast an expression in specified dimension(s).
T_operation && as_operation_cl(T_operation &&a)
Converts any valid kernel generator expression into an operation.
require_all_t< is_kernel_expression_and_not_scalar< Types >... > require_all_kernel_expressions_and_none_scalar_t
Enables a template if all given types are non-scalar types that are a valid kernel generator expressi...
void check_size_match(const char *function, const char *name_i, T_size1 i, const char *name_j, T_size2 j)
Check if the provided sizes match.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...