Automatic Differentiation
 
Loading...
Searching...
No Matches
diag_pre_multiply.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_OPENCL_PRIM_DIAG_PRE_MULTIPLY_HPP
2#define STAN_MATH_OPENCL_PRIM_DIAG_PRE_MULTIPLY_HPP
3#ifdef STAN_OPENCL
7
8namespace stan {
9namespace math {
10
23template <typename T1, typename T2,
24 require_all_kernel_expressions_and_none_scalar_t<T1, T2>* = nullptr>
25inline auto diag_pre_multiply(const T1& m1, const T2& m2) {
26 check_size_match("diag_pre_multiply", "m1.size()", m1.size(), "m2.rows()",
27 m2.rows());
28 check_vector("diag_pre_multiply", "m1", m1);
29 // we need to eval - the branches would otherwise return different types
30 if (m1.cols() == 1) {
31 return eval(elt_multiply(rowwise_broadcast(m1), m2));
32 } else {
34 }
35}
36} // namespace math
37} // namespace stan
38
39#endif
40#endif
elt_multiply_< as_operation_cl_t< T_a >, as_operation_cl_t< T_b > > elt_multiply(T_a &&a, T_b &&b)
auto transpose(Arg &&a)
Transposes a kernel generator expression.
auto rowwise_broadcast(T &&a)
Broadcast an expression in rowwise dimmension.
auto diag_pre_multiply(const T1 &m1, const T2 &m2)
Return the product of the diagonal matrix formed from the vector or row_vector and a matrix.
T eval(T &&arg)
Inputs which have a plain_type equal to the own time are forwarded unmodified (for Eigen expressions ...
Definition eval.hpp:20
void check_vector(const char *function, const char *name, const Mat &x)
Check the input is either a row vector or column vector or a matrix with a single row or column.
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 ...