Skip to content

Commit c0af98f

Browse files
committed
Review comments
1 parent 82ac58e commit c0af98f

3 files changed

Lines changed: 14 additions & 10 deletions

File tree

stan/math/opencl/rev/matrix_power.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,17 @@ inline var_value<matrix_cl<double>> matrix_power(const var_value<T>& M,
3434
if (M.size() == 0)
3535
return M;
3636

37+
size_t N = M.rows();
38+
3739
if (n == 0) {
38-
return diag_matrix(constant(1.0, M.rows(), 1));
40+
return diag_matrix(constant(1.0, N, 1));
3941
}
4042
if (n == 1) {
4143
return M;
4244
}
4345

4446
arena_t<std::vector<matrix_cl<double>>> arena_powers(n + 1);
45-
arena_powers[0] = diag_matrix(constant(1.0, M.rows(), 1));
47+
arena_powers[0] = diag_matrix(constant(1.0, N, 1));
4648
arena_powers[1] = M.val();
4749
for (size_t i = 2; i <= n; ++i) {
4850
arena_powers[i] = arena_powers[1] * arena_powers[i - 1];

stan/math/prim/fun/lb_free.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,10 @@ inline auto lb_free(T&& y, L&& lb) {
8282
*/
8383
template <typename T, typename L, require_not_std_vector_t<L>* = nullptr>
8484
inline auto lb_free(const std::vector<T> y, const L& lb) {
85-
std::vector<decltype(lb_free(y[0], lb))> ret(y.size());
85+
auto&& lb_ref = to_ref(lb);
86+
std::vector<decltype(lb_free(y[0], lb_ref))> ret(y.size());
8687
std::transform(y.begin(), y.end(), ret.begin(),
87-
[&lb](auto&& yy) { return lb_free(yy, lb); });
88+
[&lb_ref](auto&& yy) { return lb_free(yy, lb_ref); });
8889
return ret;
8990
}
9091

stan/math/prim/prob/gaussian_dlm_obs_rng.hpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,23 +95,24 @@ inline Eigen::MatrixXd gaussian_dlm_obs_rng(const Eigen::MatrixXd &F,
9595
static const char *function = "gaussian_dlm_obs_rng";
9696

9797
int r = F.cols(); // number of variables
98+
int n = G.rows(); // number of states
9899

99-
check_size_match(function, "rows of F", F.rows(), "rows of G", G.rows());
100+
check_size_match(function, "rows of F", F.rows(), "rows of G", n);
100101
check_finite(function, "F", F);
101102
check_square(function, "G", G);
102103
check_finite(function, "G", G);
103-
check_size_match(function, "rows of V", V.rows(), "cols of F", F.cols());
104+
check_size_match(function, "rows of V", V.rows(), "cols of F", r);
104105
check_finite(function, "V", V);
105106
check_positive(function, "V rows", V.rows());
106107
check_symmetric(function, "V", V);
107-
check_size_match(function, "rows of W", W.rows(), "rows of G", G.rows());
108+
check_size_match(function, "rows of W", W.rows(), "rows of G", n);
108109
check_finite(function, "W", W);
109110
check_positive(function, "W rows", W.rows());
110111
check_symmetric(function, "W", W);
111-
check_size_match(function, "rows of W", W.rows(), "rows of G", G.rows());
112-
check_size_match(function, "size of m0", m0.size(), "rows of G", G.rows());
112+
check_size_match(function, "rows of W", W.rows(), "rows of G", n);
113+
check_size_match(function, "size of m0", m0.size(), "rows of G", n);
113114
check_finite(function, "m0", m0);
114-
check_size_match(function, "rows of C0", C0.rows(), "rows of G", G.rows());
115+
check_size_match(function, "rows of C0", C0.rows(), "rows of G", n);
115116
check_finite(function, "C0", C0);
116117
check_positive(function, "C0 rows", C0.rows());
117118
check_symmetric(function, "C0", C0);

0 commit comments

Comments
 (0)