Stan Math Library  2.20.0
reverse mode automatic differentiation
subtract.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_OPENCL_SUBTRACT_HPP
2 #define STAN_MATH_OPENCL_SUBTRACT_HPP
3 #ifdef STAN_OPENCL
8 #include <CL/cl.hpp>
9 
10 namespace stan {
11 namespace math {
12 
28 inline auto subtract(const matrix_cl& A, const matrix_cl& B) {
29  check_matching_dims("subtract ((OpenCL))", "A", A, "B", B);
30  matrix_cl C(A.rows(), A.cols());
31  if (A.size() == 0) {
32  return C;
33  }
34  try {
35  opencl_kernels::subtract(cl::NDRange(A.rows(), A.cols()), C, A, B, A.rows(),
36  A.cols());
37  } catch (cl::Error& e) {
38  check_opencl_error("subtract", e);
39  }
40  return C;
41 }
42 
58 inline auto operator-(const matrix_cl& A, const matrix_cl& B) {
59  return subtract(A, B);
60 }
61 } // namespace math
62 } // namespace stan
63 
64 #endif
65 #endif
auto subtract(const matrix_cl &A, const matrix_cl &B)
Matrix subtraction on the OpenCL device Subtracts the second matrix from the first matrix and stores ...
Definition: subtract.hpp:28
fvar< T > operator-(const fvar< T > &x1, const fvar< T > &x2)
Return the difference of the specified arguments.
const kernel_cl< out_buffer, in_buffer, in_buffer, int, int > subtract("subtract", {indexing_helpers, subtract_kernel_code})
See the docs for subtract() .
The matrix_cl class - allocates memory space on the OpenCL device, functions for transfering matrices...
void check_matching_dims(const char *function, const char *name1, const matrix_cl &y1, const char *name2, const matrix_cl &y2)
Check if two matrix_cls have the same dimensions.
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.

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