Automatic Differentiation
 
Loading...
Searching...
No Matches
zeros_strict_tri.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_OPENCL_ZEROS_HPP
2#define STAN_MATH_OPENCL_ZEROS_HPP
3#ifdef STAN_OPENCL
4
11
12#include <CL/opencl.hpp>
13
14namespace stan {
15namespace math {
16
30template <typename T>
31template <matrix_cl_view matrix_view>
33 if (matrix_view == matrix_cl_view::Entire) {
35 "zeros_strict_tri", "matrix_view",
36 "matrix_cl_view::Entire is not a valid template parameter value", "");
37 }
38 if (matrix_view == matrix_cl_view::Diagonal) {
40 "zeros_strict_tri", "matrix_view",
41 "matrix_cl_view::Diagonal is not a valid template parameter value", "");
42 }
43 if (this->size() == 0) {
44 return;
45 }
46 this->view_ = both(this->view_, invert(matrix_view));
47 cl::CommandQueue& cmdQueue = opencl_context.queue();
48 opencl_kernels::fill_strict_tri(cl::NDRange(this->rows(), this->cols()),
49 *this, 0.0, this->rows(), this->cols(),
50 matrix_view);
51} catch (const cl::Error& e) {
52 check_opencl_error("zeros_strict_tri", e);
53}
54
55} // namespace math
56} // namespace stan
57
58#endif
59#endif
The API to access the methods and values in opencl_context_base.
void check_opencl_error(const char *function, const cl::Error &e)
Throws the domain error with specifying the OpenCL error that occurred.
void zeros_strict_tri()
Stores zeros in the strict's triangular part (excluding the diagonal) of a matrix on the OpenCL devic...
cl::CommandQueue & queue() noexcept
Returns the reference to the active OpenCL command queue for the device.
const kernel_cl< out_buffer, double, int, int, matrix_cl_view > fill_strict_tri("fill_strict_tri", {indexing_helpers, view_kernel_helpers, fill_strict_tri_kernel_code})
See the docs for fill_strict_tri_kernel_code() .
const matrix_cl_view both(const matrix_cl_view left_view, const matrix_cl_view right_view)
Determines which parts are nonzero in both input views.
int rows(const T_x &x)
Returns the number of rows in the specified kernel generator expression.
Definition rows.hpp:21
const matrix_cl_view invert(const matrix_cl_view view)
Inverts a view.
int cols(const T_x &x)
Returns the number of columns in the specified kernel generator expression.
Definition cols.hpp:20
size_t size(const T &m)
Returns the size (number of the elements) of a matrix_cl or var_value<matrix_cl<T>>.
Definition size.hpp:18
static constexpr double e()
Return the base of the natural logarithm.
Definition constants.hpp:20
void invalid_argument(const char *function, const char *name, const T &y, const char *msg1, const char *msg2)
Throw an invalid_argument exception with a consistently formatted message.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
Definition fvar.hpp:9