Skip to content

Commit 4d7b4a2

Browse files
authored
Merge pull request #2873 from andrjohns/cpp17-compat-backport
StanHeaders: C++17 Compatibility Backports
2 parents 0454b69 + a80d1e2 commit 4d7b4a2

File tree

75 files changed

+154
-147
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+154
-147
lines changed

stan/math/opencl/matrix_cl.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ class matrix_cl<T, require_arithmetic_t<T>> : public matrix_cl_base {
272272
matrix_cl(const int rows, const int cols,
273273
matrix_cl_view partial_view = matrix_cl_view::Entire)
274274
: rows_(rows), cols_(cols), view_(partial_view) {
275-
if (size() == 0) {
275+
if (this->size() == 0) {
276276
return;
277277
}
278278
cl::Context& ctx = opencl_context.context();
@@ -310,7 +310,7 @@ class matrix_cl<T, require_arithmetic_t<T>> : public matrix_cl_base {
310310
matrix_cl_view partial_view = matrix_cl_view::Entire)
311311
: rows_(A.rows()), cols_(A.cols()), view_(partial_view) {
312312
using Mat_type = std::decay_t<ref_type_for_opencl_t<Mat>>;
313-
if (size() == 0) {
313+
if (this->size() == 0) {
314314
return;
315315
}
316316
initialize_buffer_no_heap_if<
@@ -489,7 +489,7 @@ class matrix_cl<T, require_arithmetic_t<T>> : public matrix_cl_base {
489489
template <bool in_order = false>
490490
cl::Event initialize_buffer(const T* A) {
491491
cl::Event transfer_event;
492-
if (size() == 0) {
492+
if (this->size() == 0) {
493493
return transfer_event;
494494
}
495495
cl::Context& ctx = opencl_context.context();
@@ -509,7 +509,7 @@ class matrix_cl<T, require_arithmetic_t<T>> : public matrix_cl_base {
509509
template <bool in_order = false>
510510
cl::Event initialize_buffer(T* A) {
511511
cl::Event transfer_event;
512-
if (size() == 0) {
512+
if (this->size() == 0) {
513513
return transfer_event;
514514
}
515515
cl::Context& ctx = opencl_context.context();
@@ -548,7 +548,7 @@ class matrix_cl<T, require_arithmetic_t<T>> : public matrix_cl_base {
548548
*/
549549
template <bool No_heap, typename U, std::enable_if_t<No_heap>* = nullptr>
550550
void initialize_buffer_no_heap_if(U&& obj) {
551-
if (size() == 0) {
551+
if (this->size() == 0) {
552552
return;
553553
}
554554
initialize_buffer(obj.data());
@@ -558,7 +558,7 @@ class matrix_cl<T, require_arithmetic_t<T>> : public matrix_cl_base {
558558
template <bool No_heap, typename U, std::enable_if_t<!No_heap>* = nullptr>
559559
void initialize_buffer_no_heap_if(U&& obj) {
560560
using U_val = std::decay_t<ref_type_for_opencl_t<U>>;
561-
if (size() == 0) {
561+
if (this->size() == 0) {
562562
return;
563563
}
564564
auto* obj_heap = new U_val(std::move(obj));

stan/math/opencl/prim/bernoulli_logit_glm_lpmf.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@ return_type_t<T_x_cl, T_alpha_cl, T_beta_cl> bernoulli_logit_glm_lpmf(
6666
const size_t M = x.cols();
6767

6868
if (is_y_vector) {
69-
check_size_match(function, "Rows of ", "x", N, "rows of ", "y", size(y));
69+
check_size_match(function, "Rows of ", "x", N, "rows of ", "y", math::size(y));
7070
}
7171
check_size_match(function, "Columns of ", "x_cl", M, "size of ", "beta",
72-
size(beta));
72+
math::size(beta));
7373
if (is_alpha_vector) {
7474
check_size_match(function, "Rows of ", "x", N, "size of ", "alpha",
75-
size(alpha));
75+
math::size(alpha));
7676
}
7777

7878
if (N == 0) {

stan/math/opencl/prim/bernoulli_logit_lpmf.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ return_type_t<T_prob_cl> bernoulli_logit_lpmf(const T_n_cl& n,
3636

3737
check_consistent_sizes(function, "Random variable", n,
3838
"Probability parameter", theta);
39-
const size_t N = is_n_vector ? size(n) : size(theta);
39+
const size_t N = is_n_vector ? math::size(n) : math::size(theta);
4040
if (N == 0) {
4141
return 0.0;
4242
}

stan/math/opencl/prim/bernoulli_lpmf.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ return_type_t<T_prob_cl> bernoulli_lpmf(const T_n_cl& n,
3838

3939
check_consistent_sizes(function, "Random variable", n,
4040
"Probability parameter", theta);
41-
const size_t N = is_n_vector ? size(n) : size(theta);
41+
const size_t N = is_n_vector ? math::size(n) : math::size(theta);
4242
if (N == 0) {
4343
return 0.0;
4444
}

stan/math/opencl/prim/categorical_logit_glm_lpmf.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ return_type_t<T_x, T_alpha, T_beta> categorical_logit_glm_lpmf(
6060
static const char* function = "categorical_logit_glm_lpmf";
6161
if (is_y_vector) {
6262
check_size_match(function, "Rows of ", "x", N_instances, "size of ", "y",
63-
size(y));
63+
math::size(y));
6464
}
6565
check_size_match(function, "Columns of ", "beta", N_classes, "size of ",
66-
"alpha", size(alpha));
66+
"alpha", math::size(alpha));
6767
check_size_match(function, "Columns of ", "x", N_attributes, "Rows of",
6868
"beta", beta.rows());
6969

stan/math/opencl/prim/neg_binomial_2_log_glm_lpmf.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,17 @@ neg_binomial_2_log_glm_lpmf(const T_y_cl& y, const T_x_cl& x,
8282
const size_t M = x.cols();
8383

8484
if (is_y_vector) {
85-
check_size_match(function, "Rows of ", "x", N, "rows of ", "y", size(y));
85+
check_size_match(function, "Rows of ", "x", N, "rows of ", "y", math::size(y));
8686
}
8787
check_size_match(function, "Columns of ", "x", M, "size of ", "beta",
88-
size(beta));
88+
math::size(beta));
8989
if (is_phi_vector) {
9090
check_size_match(function, "Rows of ", "x", N, "size of ", "phi",
91-
size(phi));
91+
math::size(phi));
9292
}
9393
if (is_alpha_vector) {
9494
check_size_match(function, "Rows of ", "x", N, "size of ", "alpha",
95-
size(alpha));
95+
math::size(alpha));
9696
}
9797
if (N == 0) {
9898
return 0;

stan/math/opencl/prim/normal_id_glm_lpdf.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,17 @@ normal_id_glm_lpdf(const T_y_cl& y, const T_x_cl& x, const T_alpha_cl& alpha,
7474
const size_t M = x.cols();
7575

7676
if (is_y_vector) {
77-
check_size_match(function, "Rows of ", "x", N, "rows of ", "y", size(y));
77+
check_size_match(function, "Rows of ", "x", N, "rows of ", "y", math::size(y));
7878
}
7979
check_size_match(function, "Columns of ", "x_cl", M, "size of ", "beta",
80-
size(beta));
80+
math::size(beta));
8181
if (is_sigma_vector) {
8282
check_size_match(function, "Rows of ", "x", N, "size of ", "sigma",
83-
size(sigma));
83+
math::size(sigma));
8484
}
8585
if (is_alpha_vector) {
8686
check_size_match(function, "Rows of ", "x", N, "size of ", "alpha",
87-
size(alpha));
87+
math::size(alpha));
8888
}
8989
if (!include_summand<propto, T_y_cl, T_x_cl, T_alpha_cl, T_beta_cl,
9090
T_sigma_cl>::value) {

stan/math/opencl/prim/num_elements.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#ifdef STAN_OPENCL
44

55
#include <stan/math/prim/meta.hpp>
6+
#include <stan/math/opencl/prim/size.hpp>
67

78
namespace stan {
89
namespace math {
@@ -16,7 +17,7 @@ namespace math {
1617
template <typename T,
1718
require_nonscalar_prim_or_rev_kernel_expression_t<T>* = nullptr>
1819
size_t num_elements(const T& m) {
19-
return size(m);
20+
return math::size(m);
2021
}
2122

2223
} // namespace math

stan/math/opencl/prim/ordered_logistic_glm_lpmf.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,19 @@ return_type_t<T_x, T_beta, T_cuts> ordered_logistic_glm_lpmf(
6363

6464
const size_t N_instances = x.rows();
6565
const size_t N_attributes = x.cols();
66-
const size_t N_classes = size(cuts) + 1;
66+
const size_t N_classes = math::size(cuts) + 1;
6767

6868
if (is_y_vector) {
6969
check_size_match(function, "Rows of ", "x", N_instances, "rows of ", "y",
70-
size(y));
70+
math::size(y));
7171
}
7272
check_size_match(function, "Columns of ", "x", N_attributes, "Size of",
73-
"beta", size(beta));
73+
"beta", math::size(beta));
7474

7575
const auto& cuts_val = eval(value_of(cuts));
7676
if (N_classes >= 2) {
77-
auto cuts_head = block_zero_based(cuts_val, 0, 0, size(cuts) - 1, 1);
78-
auto cuts_tail = block_zero_based(cuts_val, 1, 0, size(cuts) - 1, 1);
77+
auto cuts_head = block_zero_based(cuts_val, 0, 0, math::size(cuts) - 1, 1);
78+
auto cuts_tail = block_zero_based(cuts_val, 1, 0, math::size(cuts) - 1, 1);
7979
check_cl(function, "Cuts", cuts_head, "ordered and finite")
8080
= cuts_head < cuts_tail && isfinite(cuts_head) && isfinite(cuts_tail);
8181
} else {

stan/math/opencl/prim/poisson_log_glm_lpmf.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@ return_type_t<T_x_cl, T_alpha_cl, T_beta_cl> poisson_log_glm_lpmf(
6666
const size_t M = x.cols();
6767

6868
if (is_y_vector) {
69-
check_size_match(function, "Rows of ", "x", N, "rows of ", "y", size(y));
69+
check_size_match(function, "Rows of ", "x", N, "rows of ", "y", math::size(y));
7070
}
7171
check_size_match(function, "Columns of ", "x_cl", M, "size of ", "beta",
72-
size(beta));
72+
math::size(beta));
7373
if (is_alpha_vector) {
7474
check_size_match(function, "Rows of ", "x", N, "size of ", "alpha",
75-
size(alpha));
75+
math::size(alpha));
7676
}
7777
if (N == 0) {
7878
return 0;

0 commit comments

Comments
 (0)