Automatic Differentiation
 
Loading...
Searching...
No Matches
diag_post_multiply.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_OPENCL_PRIM_DIAG_POST_MULTIPLY_HPP
2#define STAN_MATH_OPENCL_PRIM_DIAG_POST_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_post_multiply(const T1& m1, const T2& m2) {
26 check_size_match("diag_post_multiply", "m1.cols()", m1.cols(), "m2.size()",
27 m2.size());
28 check_vector("diag_post_multiply", "m2", m2);
29 // we need to eval - the branches would otherwise return different types
30 if (m2.rows() == 1) {
31 return eval(elt_multiply(m1, colwise_broadcast(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 colwise_broadcast(T &&a)
Broadcast an expression in colwise dimmension.
auto diag_post_multiply(const T1 &m1, const T2 &m2)
Return the product of a matrix and the diagonal matrix formed from the vector or row_vector.
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 ...
Definition fvar.hpp:9