Automatic Differentiation
 
Loading...
Searching...
No Matches
diag_matrix.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_OPENCL_PRIM_DIAG_MATRIX_HPP
2#define STAN_MATH_OPENCL_PRIM_DIAG_MATRIX_HPP
3#ifdef STAN_OPENCL
8
9namespace stan {
10namespace math {
11
23template <typename T_x,
24 require_all_kernel_expressions_and_none_scalar_t<T_x>* = nullptr>
25inline auto diag_matrix(T_x&& x) { // NOLINT
26 return add_diag(constant(value_type_t<T_x>(0), x.size(), x.size()).eval(), x);
27}
28} // namespace math
29} // namespace stan
30
31#endif
32#endif
auto constant(const T a, int rows, int cols)
Matrix of repeated values in kernel generator expressions.
Definition constant.hpp:130
typename value_type< T >::type value_type_t
Helper function for accessing underlying type.
auto add_diag(T_m &&mat, T_a &&to_add)
Returns a Matrix with values added along the main diagonal.
Definition add_diag.hpp:27
auto diag_matrix(T_x &&x)
Return a square diagonal matrix with the specified vector of coefficients as the diagonal values.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...