Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions stan/math/opencl/matrix_cl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ class matrix_cl<T, require_arithmetic_t<T>> : public matrix_cl_base {
matrix_cl(const int rows, const int cols,
matrix_cl_view partial_view = matrix_cl_view::Entire)
: rows_(rows), cols_(cols), view_(partial_view) {
if (size() == 0) {
if (this->size() == 0) {
return;
}
cl::Context& ctx = opencl_context.context();
Expand Down Expand Up @@ -310,7 +310,7 @@ class matrix_cl<T, require_arithmetic_t<T>> : public matrix_cl_base {
matrix_cl_view partial_view = matrix_cl_view::Entire)
: rows_(A.rows()), cols_(A.cols()), view_(partial_view) {
using Mat_type = std::decay_t<ref_type_for_opencl_t<Mat>>;
if (size() == 0) {
if (this->size() == 0) {
return;
}
initialize_buffer_no_heap_if<
Expand Down Expand Up @@ -489,7 +489,7 @@ class matrix_cl<T, require_arithmetic_t<T>> : public matrix_cl_base {
template <bool in_order = false>
cl::Event initialize_buffer(const T* A) {
cl::Event transfer_event;
if (size() == 0) {
if (this->size() == 0) {
return transfer_event;
}
cl::Context& ctx = opencl_context.context();
Expand All @@ -509,7 +509,7 @@ class matrix_cl<T, require_arithmetic_t<T>> : public matrix_cl_base {
template <bool in_order = false>
cl::Event initialize_buffer(T* A) {
cl::Event transfer_event;
if (size() == 0) {
if (this->size() == 0) {
return transfer_event;
}
cl::Context& ctx = opencl_context.context();
Expand Down Expand Up @@ -548,7 +548,7 @@ class matrix_cl<T, require_arithmetic_t<T>> : public matrix_cl_base {
*/
template <bool No_heap, typename U, std::enable_if_t<No_heap>* = nullptr>
void initialize_buffer_no_heap_if(U&& obj) {
if (size() == 0) {
if (this->size() == 0) {
return;
}
initialize_buffer(obj.data());
Expand All @@ -558,7 +558,7 @@ class matrix_cl<T, require_arithmetic_t<T>> : public matrix_cl_base {
template <bool No_heap, typename U, std::enable_if_t<!No_heap>* = nullptr>
void initialize_buffer_no_heap_if(U&& obj) {
using U_val = std::decay_t<ref_type_for_opencl_t<U>>;
if (size() == 0) {
if (this->size() == 0) {
return;
}
auto* obj_heap = new U_val(std::move(obj));
Expand Down
6 changes: 3 additions & 3 deletions stan/math/opencl/prim/bernoulli_logit_glm_lpmf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ return_type_t<T_x_cl, T_alpha_cl, T_beta_cl> bernoulli_logit_glm_lpmf(
const size_t M = x.cols();

if (is_y_vector) {
check_size_match(function, "Rows of ", "x", N, "rows of ", "y", size(y));
check_size_match(function, "Rows of ", "x", N, "rows of ", "y", math::size(y));
}
check_size_match(function, "Columns of ", "x_cl", M, "size of ", "beta",
size(beta));
math::size(beta));
if (is_alpha_vector) {
check_size_match(function, "Rows of ", "x", N, "size of ", "alpha",
size(alpha));
math::size(alpha));
}

if (N == 0) {
Expand Down
2 changes: 1 addition & 1 deletion stan/math/opencl/prim/bernoulli_logit_lpmf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ return_type_t<T_prob_cl> bernoulli_logit_lpmf(const T_n_cl& n,

check_consistent_sizes(function, "Random variable", n,
"Probability parameter", theta);
const size_t N = is_n_vector ? size(n) : size(theta);
const size_t N = is_n_vector ? math::size(n) : math::size(theta);
if (N == 0) {
return 0.0;
}
Expand Down
2 changes: 1 addition & 1 deletion stan/math/opencl/prim/bernoulli_lpmf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ return_type_t<T_prob_cl> bernoulli_lpmf(const T_n_cl& n,

check_consistent_sizes(function, "Random variable", n,
"Probability parameter", theta);
const size_t N = is_n_vector ? size(n) : size(theta);
const size_t N = is_n_vector ? math::size(n) : math::size(theta);
if (N == 0) {
return 0.0;
}
Expand Down
4 changes: 2 additions & 2 deletions stan/math/opencl/prim/categorical_logit_glm_lpmf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ return_type_t<T_x, T_alpha, T_beta> categorical_logit_glm_lpmf(
static const char* function = "categorical_logit_glm_lpmf";
if (is_y_vector) {
check_size_match(function, "Rows of ", "x", N_instances, "size of ", "y",
size(y));
math::size(y));
}
check_size_match(function, "Columns of ", "beta", N_classes, "size of ",
"alpha", size(alpha));
"alpha", math::size(alpha));
check_size_match(function, "Columns of ", "x", N_attributes, "Rows of",
"beta", beta.rows());

Expand Down
8 changes: 4 additions & 4 deletions stan/math/opencl/prim/neg_binomial_2_log_glm_lpmf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,17 @@ neg_binomial_2_log_glm_lpmf(const T_y_cl& y, const T_x_cl& x,
const size_t M = x.cols();

if (is_y_vector) {
check_size_match(function, "Rows of ", "x", N, "rows of ", "y", size(y));
check_size_match(function, "Rows of ", "x", N, "rows of ", "y", math::size(y));
}
check_size_match(function, "Columns of ", "x", M, "size of ", "beta",
size(beta));
math::size(beta));
if (is_phi_vector) {
check_size_match(function, "Rows of ", "x", N, "size of ", "phi",
size(phi));
math::size(phi));
}
if (is_alpha_vector) {
check_size_match(function, "Rows of ", "x", N, "size of ", "alpha",
size(alpha));
math::size(alpha));
}
if (N == 0) {
return 0;
Expand Down
8 changes: 4 additions & 4 deletions stan/math/opencl/prim/normal_id_glm_lpdf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,17 @@ normal_id_glm_lpdf(const T_y_cl& y, const T_x_cl& x, const T_alpha_cl& alpha,
const size_t M = x.cols();

if (is_y_vector) {
check_size_match(function, "Rows of ", "x", N, "rows of ", "y", size(y));
check_size_match(function, "Rows of ", "x", N, "rows of ", "y", math::size(y));
}
check_size_match(function, "Columns of ", "x_cl", M, "size of ", "beta",
size(beta));
math::size(beta));
if (is_sigma_vector) {
check_size_match(function, "Rows of ", "x", N, "size of ", "sigma",
size(sigma));
math::size(sigma));
}
if (is_alpha_vector) {
check_size_match(function, "Rows of ", "x", N, "size of ", "alpha",
size(alpha));
math::size(alpha));
}
if (!include_summand<propto, T_y_cl, T_x_cl, T_alpha_cl, T_beta_cl,
T_sigma_cl>::value) {
Expand Down
3 changes: 2 additions & 1 deletion stan/math/opencl/prim/num_elements.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#ifdef STAN_OPENCL

#include <stan/math/prim/meta.hpp>
#include <stan/math/opencl/prim/size.hpp>

namespace stan {
namespace math {
Expand All @@ -16,7 +17,7 @@ namespace math {
template <typename T,
require_nonscalar_prim_or_rev_kernel_expression_t<T>* = nullptr>
size_t num_elements(const T& m) {
return size(m);
return math::size(m);
}

} // namespace math
Expand Down
10 changes: 5 additions & 5 deletions stan/math/opencl/prim/ordered_logistic_glm_lpmf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,19 @@ return_type_t<T_x, T_beta, T_cuts> ordered_logistic_glm_lpmf(

const size_t N_instances = x.rows();
const size_t N_attributes = x.cols();
const size_t N_classes = size(cuts) + 1;
const size_t N_classes = math::size(cuts) + 1;

if (is_y_vector) {
check_size_match(function, "Rows of ", "x", N_instances, "rows of ", "y",
size(y));
math::size(y));
}
check_size_match(function, "Columns of ", "x", N_attributes, "Size of",
"beta", size(beta));
"beta", math::size(beta));

const auto& cuts_val = eval(value_of(cuts));
if (N_classes >= 2) {
auto cuts_head = block_zero_based(cuts_val, 0, 0, size(cuts) - 1, 1);
auto cuts_tail = block_zero_based(cuts_val, 1, 0, size(cuts) - 1, 1);
auto cuts_head = block_zero_based(cuts_val, 0, 0, math::size(cuts) - 1, 1);
auto cuts_tail = block_zero_based(cuts_val, 1, 0, math::size(cuts) - 1, 1);
check_cl(function, "Cuts", cuts_head, "ordered and finite")
= cuts_head < cuts_tail && isfinite(cuts_head) && isfinite(cuts_tail);
} else {
Expand Down
6 changes: 3 additions & 3 deletions stan/math/opencl/prim/poisson_log_glm_lpmf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ return_type_t<T_x_cl, T_alpha_cl, T_beta_cl> poisson_log_glm_lpmf(
const size_t M = x.cols();

if (is_y_vector) {
check_size_match(function, "Rows of ", "x", N, "rows of ", "y", size(y));
check_size_match(function, "Rows of ", "x", N, "rows of ", "y", math::size(y));
}
check_size_match(function, "Columns of ", "x_cl", M, "size of ", "beta",
size(beta));
math::size(beta));
if (is_alpha_vector) {
check_size_match(function, "Rows of ", "x", N, "size of ", "alpha",
size(alpha));
math::size(alpha));
}
if (N == 0) {
return 0;
Expand Down
2 changes: 1 addition & 1 deletion stan/math/opencl/prim/poisson_log_lpmf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ return_type_t<T_log_rate_cl> poisson_log_lpmf(const T_n_cl& n,

check_consistent_sizes(function, "Random variable", n, "Log rate parameter",
alpha);
const size_t N = is_n_vector ? size(n) : size(alpha);
const size_t N = is_n_vector ? math::size(n) : math::size(alpha);
if (N == 0) {
return 0.0;
}
Expand Down
2 changes: 1 addition & 1 deletion stan/math/opencl/prim/poisson_lpmf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ return_type_t<T_rate_cl> poisson_lpmf(const T_n_cl& n,

check_consistent_sizes(function, "Random variable", n, "Rate parameter",
lambda);
const size_t N = is_n_vector ? size(n) : size(lambda);
const size_t N = is_n_vector ? math::size(n) : math::size(lambda);
if (N == 0) {
return 0.0;
}
Expand Down
2 changes: 1 addition & 1 deletion stan/math/opencl/prim/std_normal_lpdf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ inline return_type_t<T_y_cl> std_normal_lpdf(const T_y_cl& y) {
using std::isfinite;
using std::isnan;

const size_t N = size(y);
const size_t N = math::size(y);
if (N == 0) {
return 0.0;
}
Expand Down
2 changes: 1 addition & 1 deletion stan/math/opencl/zeros_strict_tri.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ inline void matrix_cl<T, require_arithmetic_t<T>>::zeros_strict_tri() try {
"zeros_strict_tri", "matrix_view",
"matrix_cl_view::Diagonal is not a valid template parameter value", "");
}
if (size() == 0) {
if (this->size() == 0) {
return;
}
this->view_ = both(this->view_, invert(matrix_view));
Expand Down
2 changes: 1 addition & 1 deletion stan/math/prim/fun/offset_multiplier_constrain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ inline return_type_t<T, M, S> offset_multiplier_constrain(const T& x,
return mu + x;
}
check_positive_finite("offset_multiplier_constrain", "multiplier", sigma);
lp += multiply_log(size(x), sigma);
lp += multiply_log(math::size(x), sigma);
return fma(sigma, x, mu);
}

Expand Down
3 changes: 2 additions & 1 deletion stan/math/prim/fun/size_zero.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef STAN_MATH_PRIM_FUN_SIZE_ZERO_HPP
#define STAN_MATH_PRIM_FUN_SIZE_ZERO_HPP

#include <stan/math/prim/fun/size.hpp>
#include <stan/math/prim/meta.hpp>
#include <utility>

Expand All @@ -16,7 +17,7 @@ namespace math {
*/
template <typename T>
inline bool size_zero(const T& x) {
return !size(x);
return !math::size(x);
}

/**
Expand Down
10 changes: 5 additions & 5 deletions stan/math/prim/functor/coupled_ode_system.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ struct coupled_ode_system_impl<true, F, T_y0, Args...> {

dz_dt.resize(y.size());

Eigen::VectorXd f_y_t
= apply([&](const Args&... args) { return f_(t, y, msgs_, args...); },
args_tuple_);
Eigen::VectorXd f_y_t = math::apply(
[&](const Args&... args) { return f_(t, y, msgs_, args...); },
args_tuple_);

check_size_match("coupled_ode_system", "dy_dt", f_y_t.size(), "states",
y.size());
Expand Down Expand Up @@ -110,8 +110,8 @@ struct coupled_ode_system
const Eigen::Matrix<T_y0, Eigen::Dynamic, 1>& y0,
std::ostream* msgs, const Args&... args)
: coupled_ode_system_impl<
std::is_arithmetic<return_type_t<T_y0, Args...>>::value, F, T_y0,
Args...>(f, y0, msgs, args...) {}
std::is_arithmetic<return_type_t<T_y0, Args...>>::value, F, T_y0,
Args...>(f, y0, msgs, args...) {}
};

} // namespace math
Expand Down
6 changes: 3 additions & 3 deletions stan/math/prim/functor/ode_rk45.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ ode_rk45_tol_impl(const char* function_name, const F& f, const T_y0& y0_arg,

std::tuple<ref_type_t<Args>...> args_ref_tuple(args...);

apply(
math::apply(
[&](const auto&... args_ref) {
// Code from https://stackoverflow.com/a/17340003
std::vector<int> unused_temp{
Expand All @@ -102,7 +102,7 @@ ode_rk45_tol_impl(const char* function_name, const F& f, const T_y0& y0_arg,

using return_t = return_type_t<T_y0, T_t0, T_ts, Args...>;
// creates basic or coupled system by template specializations
auto&& coupled_system = apply(
auto&& coupled_system = math::apply(
[&](const auto&... args_ref) {
return coupled_ode_system<F, T_y0_t0, ref_type_t<Args>...>(f, y0, msgs,
args_ref...);
Expand All @@ -128,7 +128,7 @@ ode_rk45_tol_impl(const char* function_name, const F& f, const T_y0& y0_arg,
observer_initial_recorded = true;
return;
}
apply(
math::apply(
[&](const auto&... args_ref) {
y.emplace_back(ode_store_sensitivities(
f, coupled_state, y0, t0, ts[time_index], msgs, args_ref...));
Expand Down
3 changes: 2 additions & 1 deletion stan/math/prim/functor/reduce_sum.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <stan/math/prim/meta.hpp>
#include <stan/math/prim/err.hpp>
#include <stan/math/prim/functor/apply.hpp>

#include <tbb/task_arena.h>
#include <tbb/parallel_reduce.h>
Expand Down Expand Up @@ -80,7 +81,7 @@ struct reduce_sum_impl<ReduceFunction, require_arithmetic_t<ReturnType>,
sub_slice.emplace_back(vmapped_[i]);
}

sum_ += apply(
sum_ += math::apply(
[&](auto&&... args) {
return ReduceFunction()(sub_slice, r.begin(), r.end() - 1, &msgs_,
args...);
Expand Down
2 changes: 1 addition & 1 deletion stan/math/prim/mat/fun/LDLT_factor.hpp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#include "../prim/fun/LDLT_factor.hpp"
#include "../../fun/LDLT_factor.hpp"
2 changes: 1 addition & 1 deletion stan/math/prim/prob/bernoulli_lpmf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ return_type_t<T_prob> bernoulli_lpmf(const T_n& n, const T_prob& theta) {
scalar_seq_view<T_theta_ref> theta_vec(theta_ref);
size_t N = max_size(n, theta);

if (size(theta) == 1) {
if (math::size(theta) == 1) {
size_t sum = 0;
for (size_t n = 0; n < N; n++) {
sum += n_vec.val(n);
Expand Down
2 changes: 1 addition & 1 deletion stan/math/prim/prob/beta_proportion_lpdf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ return_type_t<T_y, T_loc, T_prec> beta_proportion_lpdf(const T_y& y,
size_t N = max_size(y, mu, kappa);
T_partials_return logp(0);
if (include_summand<propto, T_prec>::value) {
logp += sum(lgamma(kappa_val)) * N / size(kappa);
logp += sum(lgamma(kappa_val)) * N / math::size(kappa);
}
if (include_summand<propto, T_loc, T_prec>::value) {
logp -= sum(lgamma(mukappa) + lgamma(kappa_val - mukappa)) * N
Expand Down
4 changes: 2 additions & 2 deletions stan/math/prim/prob/binomial_logit_lpmf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ return_type_t<T_prob> binomial_logit_lpmf(const T_n& n, const T_N& N,
ops_partials.edge1_.partials_
= n_val * inv_logit_neg_alpha - (N_val - n_val) * inv_logit_alpha;
} else {
T_partials_return sum_n = sum(n_val) * maximum_size / size(n);
T_partials_return sum_n = sum(n_val) * maximum_size / math::size(n);
ops_partials.edge1_.partials_[0] = forward_as<T_partials_return>(
sum_n * inv_logit_neg_alpha
- (sum(N_val) * maximum_size / size(N) - sum_n) * inv_logit_alpha);
- (sum(N_val) * maximum_size / math::size(N) - sum_n) * inv_logit_alpha);
}
}

Expand Down
2 changes: 1 addition & 1 deletion stan/math/prim/prob/cauchy_lpdf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ return_type_t<T_y, T_loc, T_scale> cauchy_lpdf(const T_y& y, const T_loc& mu,
logp -= N * LOG_PI;
}
if (include_summand<propto, T_scale>::value) {
logp -= sum(log(sigma_val)) * N / size(sigma);
logp -= sum(log(sigma_val)) * N / math::size(sigma);
}

if (!is_constant_all<T_y, T_loc, T_scale>::value) {
Expand Down
4 changes: 2 additions & 2 deletions stan/math/prim/prob/chi_square_cdf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ return_type_t<T_y, T_dof> chi_square_cdf(const T_y& y, const T_dof& nu) {
}

VectorBuilder<!is_constant_all<T_dof>::value, T_partials_return, T_dof>
gamma_vec(size(nu));
gamma_vec(math::size(nu));
VectorBuilder<!is_constant_all<T_dof>::value, T_partials_return, T_dof>
digamma_vec(size(nu));
digamma_vec(math::size(nu));

if (!is_constant_all<T_dof>::value) {
for (size_t i = 0; i < stan::math::size(nu); i++) {
Expand Down
Loading