Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into feature/issue-spee…
Browse files Browse the repository at this point in the history
…dup-rev
  • Loading branch information
wds15 committed Feb 10, 2020
2 parents d73745c + 42f7f43 commit f541961
Show file tree
Hide file tree
Showing 275 changed files with 1,543 additions and 776 deletions.
16 changes: 10 additions & 6 deletions stan/math/fwd/fun/multiply.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ template <typename T, int R1, int C1, int R2, int C2>
inline Eigen::Matrix<fvar<T>, R1, C2> multiply(
const Eigen::Matrix<fvar<T>, R1, C1>& m1,
const Eigen::Matrix<fvar<T>, R2, C2>& m2) {
check_multiplicable("multiply", "m1", m1, "m2", m2);
check_size_match("multiply", "Columns of m1", m1.cols(), "Rows of m2",
m2.rows());
Eigen::Matrix<fvar<T>, R1, C2> result(m1.rows(), m2.cols());
for (size_type i = 0; i < m1.rows(); i++) {
Eigen::Matrix<fvar<T>, 1, C1> crow = m1.row(i);
Expand All @@ -75,7 +76,8 @@ template <typename T, int R1, int C1, int R2, int C2>
inline Eigen::Matrix<fvar<T>, R1, C2> multiply(
const Eigen::Matrix<fvar<T>, R1, C1>& m1,
const Eigen::Matrix<double, R2, C2>& m2) {
check_multiplicable("multiply", "m1", m1, "m2", m2);
check_size_match("multiply", "Columns of m1", m1.cols(), "Rows of m2",
m2.rows());
Eigen::Matrix<fvar<T>, R1, C2> result(m1.rows(), m2.cols());
for (size_type i = 0; i < m1.rows(); i++) {
Eigen::Matrix<fvar<T>, 1, C1> crow = m1.row(i);
Expand All @@ -91,7 +93,8 @@ template <typename T, int R1, int C1, int R2, int C2>
inline Eigen::Matrix<fvar<T>, R1, C2> multiply(
const Eigen::Matrix<double, R1, C1>& m1,
const Eigen::Matrix<fvar<T>, R2, C2>& m2) {
check_multiplicable("multiply", "m1", m1, "m2", m2);
check_size_match("multiply", "Columns of m1", m1.cols(), "Rows of m2",
m2.rows());
Eigen::Matrix<fvar<T>, R1, C2> result(m1.rows(), m2.cols());
for (size_type i = 0; i < m1.rows(); i++) {
Eigen::Matrix<double, 1, C1> crow = m1.row(i);
Expand All @@ -106,21 +109,22 @@ inline Eigen::Matrix<fvar<T>, R1, C2> multiply(
template <typename T, int C1, int R2>
inline fvar<T> multiply(const Eigen::Matrix<fvar<T>, 1, C1>& rv,
const Eigen::Matrix<fvar<T>, R2, 1>& v) {
check_multiplicable("multiply", "rv", rv, "v", v);
check_matching_sizes("multiply", "rv", rv, "v", v);
return dot_product(rv, v);
}

template <typename T, int C1, int R2>
inline fvar<T> multiply(const Eigen::Matrix<fvar<T>, 1, C1>& rv,
const Eigen::Matrix<double, R2, 1>& v) {
check_multiplicable("multiply", "rv", rv, "v", v);
check_matching_sizes("multiply", "rv", rv, "v", v);
return dot_product(rv, v);
}

template <typename T, int C1, int R2>
inline fvar<T> multiply(const Eigen::Matrix<double, 1, C1>& rv,
const Eigen::Matrix<fvar<T>, R2, 1>& v) {
check_multiplicable("multiply", "rv", rv, "v", v);
check_matching_sizes("multiply", "rv", rv, "v", v);

return dot_product(rv, v);
}

Expand Down
2 changes: 1 addition & 1 deletion stan/math/fwd/meta/operands_and_partials.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define STAN_MATH_FWD_META_OPERANDS_AND_PARTIALS_HPP

#include <stan/math/prim/fun/Eigen.hpp>
#include <stan/math/prim/meta/size.hpp>
#include <stan/math/prim/fun/size.hpp>
#include <stan/math/prim/meta/broadcast_array.hpp>
#include <stan/math/prim/meta/operands_and_partials.hpp>
#include <stan/math/fwd/core/fvar.hpp>
Expand Down
1 change: 1 addition & 0 deletions stan/math/opencl/prim/bernoulli_logit_glm_lpmf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <stan/math/prim/err.hpp>
#include <stan/math/prim/fun/Eigen.hpp>
#include <stan/math/prim/fun/constants.hpp>
#include <stan/math/prim/fun/size.hpp>
#include <stan/math/prim/fun/size_zero.hpp>
#include <stan/math/prim/fun/sum.hpp>
#include <stan/math/prim/fun/value_of.hpp>
Expand Down
1 change: 1 addition & 0 deletions stan/math/opencl/prim/neg_binomial_2_log_glm_lpmf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <stan/math/prim/fun/digamma.hpp>
#include <stan/math/prim/fun/lgamma.hpp>
#include <stan/math/prim/fun/multiply_log.hpp>
#include <stan/math/prim/fun/size.hpp>
#include <stan/math/prim/fun/sum.hpp>
#include <stan/math/prim/fun/value_of_rec.hpp>
#include <stan/math/opencl/copy.hpp>
Expand Down
1 change: 1 addition & 0 deletions stan/math/opencl/prim/normal_id_glm_lpdf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <stan/math/prim/meta.hpp>
#include <stan/math/prim/err.hpp>
#include <stan/math/prim/fun/constants.hpp>
#include <stan/math/prim/fun/size.hpp>
#include <stan/math/prim/fun/size_zero.hpp>
#include <stan/math/prim/fun/sum.hpp>
#include <stan/math/prim/fun/value_of_rec.hpp>
Expand Down
1 change: 1 addition & 0 deletions stan/math/opencl/prim/ordered_logistic_glm_lpmf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <stan/math/prim/meta.hpp>
#include <stan/math/prim/err.hpp>
#include <stan/math/prim/fun/log1m_exp.hpp>
#include <stan/math/prim/fun/size.hpp>
#include <stan/math/prim/fun/size_zero.hpp>
#include <stan/math/prim/fun/sum.hpp>
#include <stan/math/prim/fun/value_of_rec.hpp>
Expand Down
1 change: 1 addition & 0 deletions stan/math/opencl/prim/poisson_log_glm_lpmf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <stan/math/prim/meta.hpp>
#include <stan/math/prim/err.hpp>
#include <stan/math/prim/fun/constants.hpp>
#include <stan/math/prim/fun/size.hpp>
#include <stan/math/prim/fun/size_zero.hpp>
#include <stan/math/prim/fun/sum.hpp>
#include <stan/math/prim/fun/value_of.hpp>
Expand Down
1 change: 1 addition & 0 deletions stan/math/opencl/rev/matrix_cl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include <stan/math/prim/err.hpp>
#include <stan/math/prim/fun/Eigen.hpp>
#include <stan/math/prim/fun/size.hpp>
#include <stan/math/prim/fun/typedefs.hpp>
#include <stan/math/prim/fun/vec_concat.hpp>
#include <stan/math/rev/core.hpp>
Expand Down
3 changes: 3 additions & 0 deletions stan/math/prim/err/check_bounded.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
#include <stan/math/prim/meta.hpp>
#include <stan/math/prim/err/throw_domain_error.hpp>
#include <stan/math/prim/err/throw_domain_error_vec.hpp>
#include <stan/math/prim/fun/get.hpp>
#include <stan/math/prim/fun/max_size.hpp>
#include <stan/math/prim/fun/size.hpp>
#include <string>

namespace stan {
Expand Down
5 changes: 3 additions & 2 deletions stan/math/prim/err/check_consistent_size.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/invalid_argument.hpp>
#include <stan/math/prim/fun/size.hpp>
#include <sstream>
#include <string>

Expand All @@ -23,7 +24,7 @@ template <typename T>
inline void check_consistent_size(const char* function, const char* name,
const T& x, size_t expected_size) {
if (!is_vector<T>::value
|| (is_vector<T>::value && expected_size == size(x))) {
|| (is_vector<T>::value && expected_size == stan::math::size(x))) {
return;
}

Expand All @@ -35,7 +36,7 @@ inline void check_consistent_size(const char* function, const char* name,
<< "multidimensional values of the same shape.";
std::string msg_str(msg.str());

invalid_argument(function, name, size(x),
invalid_argument(function, name, stan::math::size(x),
"has dimension = ", msg_str.c_str());
}

Expand Down
1 change: 1 addition & 0 deletions stan/math/prim/err/check_consistent_size_mvt.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/invalid_argument.hpp>
#include <stan/math/prim/fun/size_mvt.hpp>
#include <sstream>
#include <string>
#include <type_traits>
Expand Down
28 changes: 16 additions & 12 deletions stan/math/prim/err/check_consistent_sizes.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/check_consistent_size.hpp>
#include <stan/math/prim/fun/size.hpp>
#include <algorithm>

namespace stan {
Expand All @@ -25,8 +26,8 @@ template <typename T1, typename T2>
inline void check_consistent_sizes(const char* function, const char* name1,
const T1& x1, const char* name2,
const T2& x2) {
size_t max_size = std::max(is_vector<T1>::value * size(x1),
is_vector<T2>::value * size(x2));
size_t max_size = std::max(is_vector<T1>::value * stan::math::size(x1),
is_vector<T2>::value * stan::math::size(x2));
check_consistent_size(function, name1, x1, max_size);
check_consistent_size(function, name2, x2, max_size);
}
Expand All @@ -52,9 +53,10 @@ inline void check_consistent_sizes(const char* function, const char* name1,
const T1& x1, const char* name2,
const T2& x2, const char* name3,
const T3& x3) {
size_t max_size = std::max(is_vector<T1>::value * size(x1),
std::max(is_vector<T2>::value * size(x2),
is_vector<T3>::value * size(x3)));
size_t max_size
= std::max(is_vector<T1>::value * stan::math::size(x1),
std::max(is_vector<T2>::value * stan::math::size(x2),
is_vector<T3>::value * stan::math::size(x3)));
check_consistent_size(function, name1, x1, max_size);
check_consistent_size(function, name2, x2, max_size);
check_consistent_size(function, name3, x3, max_size);
Expand Down Expand Up @@ -85,11 +87,11 @@ inline void check_consistent_sizes(const char* function, const char* name1,
const T2& x2, const char* name3,
const T3& x3, const char* name4,
const T4& x4) {
size_t max_size
= std::max(is_vector<T1>::value * size(x1),
std::max(is_vector<T2>::value * size(x2),
std::max(is_vector<T3>::value * size(x3),
is_vector<T4>::value * size(x4))));
size_t max_size = std::max(
is_vector<T1>::value * stan::math::size(x1),
std::max(is_vector<T2>::value * stan::math::size(x2),
std::max(is_vector<T3>::value * stan::math::size(x3),
is_vector<T4>::value * stan::math::size(x4))));
check_consistent_size(function, name1, x1, max_size);
check_consistent_size(function, name2, x2, max_size);
check_consistent_size(function, name3, x3, max_size);
Expand All @@ -103,8 +105,10 @@ inline void check_consistent_sizes(const char* function, const char* name1,
const T4& x4, const char* name5,
const T5& x5) {
size_t max_size = std::max(
size(x1),
std::max(size(x2), std::max(size(x3), std::max(size(x4), size(x5)))));
stan::math::size(x1),
std::max(stan::math::size(x2),
std::max(stan::math::size(x3),
std::max(stan::math::size(x4), stan::math::size(x5)))));
check_consistent_size(function, name1, x1, max_size);
check_consistent_size(function, name2, x2, max_size);
check_consistent_size(function, name3, x3, max_size);
Expand Down
2 changes: 1 addition & 1 deletion stan/math/prim/err/check_consistent_sizes_mvt.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#ifndef STAN_MATH_PRIM_ERR_CHECK_CONSISTENT_SIZES_MVT_HPP
#define STAN_MATH_PRIM_ERR_CHECK_CONSISTENT_SIZES_MVT_HPP

#include <stan/math/prim/meta.hpp>
#include <stan/math/prim/err/check_consistent_size_mvt.hpp>
#include <stan/math/prim/fun/size_mvt.hpp>
#include <algorithm>

namespace stan {
Expand Down
4 changes: 3 additions & 1 deletion stan/math/prim/err/check_finite.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
#include <stan/math/prim/err/is_scal_finite.hpp>
#include <stan/math/prim/err/throw_domain_error.hpp>
#include <stan/math/prim/err/throw_domain_error_vec.hpp>
#include <stan/math/prim/fun/Eigen.hpp>
#include <stan/math/prim/fun/get.hpp>
#include <stan/math/prim/fun/size.hpp>
#include <stan/math/prim/fun/value_of.hpp>
#include <stan/math/prim/fun/value_of_rec.hpp>
#include <stan/math/prim/fun/Eigen.hpp>
#include <cmath>

namespace stan {
Expand Down
2 changes: 2 additions & 0 deletions stan/math/prim/err/check_greater.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <stan/math/prim/meta.hpp>
#include <stan/math/prim/err/throw_domain_error.hpp>
#include <stan/math/prim/err/throw_domain_error_vec.hpp>
#include <stan/math/prim/fun/get.hpp>
#include <stan/math/prim/fun/size.hpp>
#include <functional>
#include <string>

Expand Down
2 changes: 2 additions & 0 deletions stan/math/prim/err/check_greater_or_equal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <stan/math/prim/meta.hpp>
#include <stan/math/prim/err/throw_domain_error_vec.hpp>
#include <stan/math/prim/err/throw_domain_error.hpp>
#include <stan/math/prim/fun/get.hpp>
#include <stan/math/prim/fun/size.hpp>
#include <string>

namespace stan {
Expand Down
2 changes: 2 additions & 0 deletions stan/math/prim/err/check_less.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <stan/math/prim/meta.hpp>
#include <stan/math/prim/err/throw_domain_error.hpp>
#include <stan/math/prim/err/throw_domain_error_vec.hpp>
#include <stan/math/prim/fun/get.hpp>
#include <stan/math/prim/fun/size.hpp>
#include <functional>
#include <string>

Expand Down
2 changes: 2 additions & 0 deletions stan/math/prim/err/check_less_or_equal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <stan/math/prim/meta.hpp>
#include <stan/math/prim/err/throw_domain_error.hpp>
#include <stan/math/prim/err/throw_domain_error_vec.hpp>
#include <stan/math/prim/fun/get.hpp>
#include <stan/math/prim/fun/size.hpp>
#include <string>

namespace stan {
Expand Down
2 changes: 2 additions & 0 deletions stan/math/prim/err/check_nonnegative.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <stan/math/prim/meta.hpp>
#include <stan/math/prim/err/throw_domain_error.hpp>
#include <stan/math/prim/err/throw_domain_error_vec.hpp>
#include <stan/math/prim/fun/get.hpp>
#include <stan/math/prim/fun/size.hpp>
#include <type_traits>

namespace stan {
Expand Down
4 changes: 3 additions & 1 deletion stan/math/prim/err/check_not_nan.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
#include <stan/math/prim/meta.hpp>
#include <stan/math/prim/err/throw_domain_error.hpp>
#include <stan/math/prim/err/throw_domain_error_vec.hpp>
#include <stan/math/prim/fun/value_of_rec.hpp>
#include <stan/math/prim/fun/get.hpp>
#include <stan/math/prim/fun/is_nan.hpp>
#include <stan/math/prim/fun/size.hpp>
#include <stan/math/prim/fun/value_of_rec.hpp>

namespace stan {
namespace math {
Expand Down
2 changes: 2 additions & 0 deletions stan/math/prim/err/check_positive.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include <stan/math/prim/err/throw_domain_error.hpp>
#include <stan/math/prim/err/throw_domain_error_vec.hpp>
#include <stan/math/prim/err/invalid_argument.hpp>
#include <stan/math/prim/fun/get.hpp>
#include <stan/math/prim/fun/size.hpp>
#include <type_traits>
#include <string>

Expand Down
1 change: 1 addition & 0 deletions stan/math/prim/err/invalid_argument_vec.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/invalid_argument.hpp>
#include <stan/math/prim/fun/get.hpp>
#include <sstream>
#include <string>

Expand Down
2 changes: 2 additions & 0 deletions stan/math/prim/err/is_less_or_equal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#define STAN_MATH_PRIM_ERR_IS_LESS_OR_EQUAL_HPP

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

namespace stan {
namespace math {
Expand Down
4 changes: 3 additions & 1 deletion stan/math/prim/err/is_not_nan.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
#define STAN_MATH_PRIM_ERR_IS_NOT_NAN_HPP

#include <stan/math/prim/meta.hpp>
#include <stan/math/prim/fun/value_of_rec.hpp>
#include <stan/math/prim/fun/get.hpp>
#include <stan/math/prim/fun/is_nan.hpp>
#include <stan/math/prim/fun/size.hpp>
#include <stan/math/prim/fun/value_of_rec.hpp>

namespace stan {
namespace math {
Expand Down
2 changes: 2 additions & 0 deletions stan/math/prim/err/is_positive.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#define STAN_MATH_PRIM_ERR_IS_POSITIVE_HPP

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

namespace stan {
namespace math {
Expand Down
2 changes: 2 additions & 0 deletions stan/math/prim/err/is_scal_finite.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#define STAN_MATH_PRIM_ERR_IS_SCAL_FINITE_HPP

#include <stan/math/prim/meta.hpp>
#include <stan/math/prim/fun/get.hpp>
#include <stan/math/prim/fun/size.hpp>
#include <stan/math/prim/fun/value_of_rec.hpp>
#include <cmath>

Expand Down
1 change: 1 addition & 0 deletions stan/math/prim/err/throw_domain_error_vec.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/throw_domain_error.hpp>
#include <stan/math/prim/fun/get.hpp>
#include <sstream>
#include <string>

Expand Down
Loading

0 comments on commit f541961

Please sign in to comment.