Automatic Differentiation
 
Loading...
Searching...
No Matches
symmetrize_from_upper_tri.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_OPENCL_PRIM_SYMMETRIZE_FROM_UPPER_TRI_HPP
2#define STAN_MATH_OPENCL_PRIM_SYMMETRIZE_FROM_UPPER_TRI_HPP
3#ifdef STAN_OPENCL
4
7
8namespace stan {
9namespace math {
10
19template <typename T_x,
20 require_all_kernel_expressions_and_none_scalar_t<T_x>* = nullptr>
21inline auto symmetrize_from_upper_tri(T_x&& x) {
22 check_square("symmetrize_from_upper_tri", "x", x);
23 return make_holder_cl(
24 [](auto& arg) {
25 return select(col_index() < row_index(), transpose(arg), arg);
26 },
27 std::forward<T_x>(x));
28}
29} // namespace math
30} // namespace stan
31#endif
32#endif
Represents operation that determines column index.
Definition index.hpp:80
Represents operation that determines row index.
Definition index.hpp:17
auto make_holder_cl(const T &func, Args &&... args)
Constructs an expression from given arguments using given functor.
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.
Definition select.hpp:148
auto transpose(Arg &&a)
Transposes a kernel generator expression.
void check_square(const char *function, const char *name, const T_y &y)
Check if the specified matrix is square.
fvar< T > arg(const std::complex< fvar< T > > &z)
Return the phase angle of the complex argument.
Definition arg.hpp:19
auto symmetrize_from_upper_tri(T_x &&x)
Return a symmetric matrix using elements from the lower triangular part of the input matrix.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...