Automatic Differentiation
 
Loading...
Searching...
No Matches
index.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_OPENCL_KERNEL_GENERATOR_INDEX_HPP
2#define STAN_MATH_OPENCL_KERNEL_GENERATOR_INDEX_HPP
3#ifdef STAN_OPENCL
4
6
7namespace stan {
8namespace math {
9
17class row_index : public operation_cl<row_index, int> {
18 public:
19 using Scalar = int;
21 using base::var_name_;
22 int rows_;
23 int cols_;
24
31 : rows_(rows), cols_(cols) {}
32
37 inline row_index deep_copy() const { return row_index(rows_, cols_); }
38
46 inline kernel_parts generate(const std::string& row_index_name,
47 const std::string& col_index_name,
48 const bool view_handled) const {
49 kernel_parts res{};
50 res.body = "int " + var_name_ + " = " + row_index_name + ";\n";
51 return res;
52 }
53
59 inline int rows() const { return rows_; }
60
66 inline int cols() const { return cols_; }
67
72 inline std::pair<int, int> extreme_diagonals() const {
73 return {std::numeric_limits<int>::min(), std::numeric_limits<int>::max()};
74 }
75};
76
80class col_index : public operation_cl<col_index, int> {
81 public:
82 using Scalar = int;
84 using base::var_name_;
85 int rows_;
86 int cols_;
87
94 : rows_(rows), cols_(cols) {}
95
100 inline col_index deep_copy() const { return col_index(rows_, cols_); }
101
109 inline kernel_parts generate(const std::string& row_index_name,
110 const std::string& col_index_name,
111 const bool view_handled) const {
112 kernel_parts res{};
113 res.body = "int " + var_name_ + " = " + col_index_name + ";\n";
114 return res;
115 }
116
122 inline int rows() const { return rows_; }
123
129 inline int cols() const { return cols_; }
130
135 inline std::pair<int, int> extreme_diagonals() const {
136 return {std::numeric_limits<int>::min(), std::numeric_limits<int>::max()};
137 }
138};
141} // namespace math
142} // namespace stan
143
144#endif
145#endif
kernel_parts generate(const std::string &row_index_name, const std::string &col_index_name, const bool view_handled) const
Generates kernel code for this expression.
Definition index.hpp:109
int cols() const
Number of columns of a matrix that would be the result of evaluating this expression.
Definition index.hpp:129
col_index(int rows=base::dynamic, int cols=base::dynamic)
Constructor for given number of rows and columns.
Definition index.hpp:93
std::pair< int, int > extreme_diagonals() const
Determine indices of extreme sub- and superdiagonals written.
Definition index.hpp:135
col_index deep_copy() const
Creates a deep copy of this expression.
Definition index.hpp:100
int rows() const
Number of rows of a matrix that would be the result of evaluating this expression.
Definition index.hpp:122
Represents operation that determines column index.
Definition index.hpp:80
Base for all kernel generator operations.
row_index deep_copy() const
Creates a deep copy of this expression.
Definition index.hpp:37
int rows() const
Number of rows of a matrix that would be the result of evaluating this expression.
Definition index.hpp:59
int cols() const
Number of columns of a matrix that would be the result of evaluating this expression.
Definition index.hpp:66
std::pair< int, int > extreme_diagonals() const
Determine indices of extreme sub- and superdiagonals written.
Definition index.hpp:72
kernel_parts generate(const std::string &row_index_name, const std::string &col_index_name, const bool view_handled) const
Generates kernel code for this expression.
Definition index.hpp:46
row_index(int rows=base::dynamic, int cols=base::dynamic)
Constructor for given number of rows and columns.
Definition index.hpp:30
Represents operation that determines row index.
Definition index.hpp:17
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
Definition fvar.hpp:9
Parts of an OpenCL kernel, generated by an expression.