Automatic Differentiation
 
Loading...
Searching...
No Matches
divide_columns.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_OPENCL_PRIM_DIVIDE_COLUMNS_HPP
2#define STAN_MATH_OPENCL_PRIM_DIVIDE_COLUMNS_HPP
3#ifdef STAN_OPENCL
4
10#include <CL/opencl.hpp>
11
12namespace stan {
13namespace math {
14
29template <typename T1, typename T2, typename = require_all_arithmetic_t<T1, T2>>
30inline void divide_columns(matrix_cl<T1>& A, const matrix_cl<T2>& B) {
31 if (A.size() == 0 || B.size() == 0) {
32 return;
33 }
34 check_size_match("divide_columns", "A mod B", A.size() % B.size(), "B mod",
35 0);
36 check_vector("divide_columns", "B", B);
37 try {
38 opencl_kernels::divide_columns_vec(cl::NDRange(A.size()), A, B, B.size());
39 } catch (const cl::Error& e) {
40 check_opencl_error("divide_columns", e);
41 }
42}
43
55template <typename T1, typename T2, typename = require_all_arithmetic_t<T1, T2>>
56inline void divide_columns(matrix_cl<T1>& A, const T2& divisor) {
57 A = elt_divide(A, divisor);
58}
59
60} // namespace math
61} // namespace stan
62
63#endif
64#endif
Represents an arithmetic matrix on the OpenCL device.
Definition matrix_cl.hpp:47
void check_opencl_error(const char *function, const cl::Error &e)
Throws the domain error with specifying the OpenCL error that occurred.
elt_divide_< as_operation_cl_t< T_a >, as_operation_cl_t< T_b > > elt_divide(T_a &&a, T_b &&b)
const kernel_cl< out_buffer, in_buffer, int > divide_columns_vec("divide_columns_vec", {indexing_helpers, divide_columns_kernel_code})
See the docs for divide_columns_vec() .
void divide_columns(matrix_cl< T1 > &A, const matrix_cl< T2 > &B)
Divides each column of a matrix by a vector.
static constexpr double e()
Return the base of the natural logarithm.
Definition constants.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 ...