Stan Math Library  2.20.0
reverse mode automatic differentiation
diagonal_multiply.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_OPENCL_DIAGONAL_MULTIPLY_HPP
2 #define STAN_MATH_OPENCL_DIAGONAL_MULTIPLY_HPP
3 #ifdef STAN_OPENCL
8 
9 namespace stan {
10 namespace math {
19 inline matrix_cl diagonal_multiply(const matrix_cl& A, const double scalar) {
20  matrix_cl B(A);
21  if (B.size() == 0)
22  return B;
23  // For rectangular matrices
24  int min_dim = B.rows();
25  if (B.cols() < min_dim)
26  min_dim = B.cols();
27  try {
28  opencl_kernels::scalar_mul_diagonal(cl::NDRange(min_dim), B, scalar,
29  B.rows(), min_dim);
30  } catch (const cl::Error& e) {
31  check_opencl_error("diagonal_multiply", e);
32  }
33  return B;
34 }
35 } // namespace math
36 } // namespace stan
37 
38 #endif
39 #endif
const kernel_cl< in_out_buffer, double, int, int > scalar_mul_diagonal("scalar_mul_diagonal", {indexing_helpers, scalar_mul_diagonal_kernel_code})
See the docs for add() .
The matrix_cl class - allocates memory space on the OpenCL device, functions for transfering matrices...
Represents a matrix on the OpenCL device.
Definition: matrix_cl.hpp:29
checking OpenCL error numbers
double e()
Return the base of the natural logarithm.
Definition: constants.hpp:87
void check_opencl_error(const char *function, const cl::Error &e)
Throws the domain error with specifying the OpenCL error that occured.
matrix_cl diagonal_multiply(const matrix_cl &A, const double scalar)
Multiplies the diagonal of a matrix on the OpenCL device with the specified scalar.

     [ Stan Home Page ] © 2011–2018, Stan Development Team.