Skip to content

Commit

Permalink
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
Browse files Browse the repository at this point in the history
…4.1 (tags/RELEASE_600/final)
  • Loading branch information
stan-buildbot committed Dec 18, 2020
1 parent 0db6223 commit a7deb36
Show file tree
Hide file tree
Showing 16 changed files with 36 additions and 31 deletions.
3 changes: 2 additions & 1 deletion stan/math/rev/fun/atan.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ template <typename VarMat, require_var_matrix_t<VarMat>* = nullptr>
inline auto atan(const VarMat& x) {
return make_callback_var(
x.val().array().atan().matrix(), [x](const auto& vi) mutable {
x.adj().array() += vi.adj().array() / (1.0 + (x.val().array().square()));
x.adj().array()
+= vi.adj().array() / (1.0 + (x.val().array().square()));
});
}
/**
Expand Down
10 changes: 5 additions & 5 deletions stan/math/rev/fun/tan.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ inline var tan(const var& a) {
*/
template <typename VarMat, require_var_matrix_t<VarMat>* = nullptr>
inline auto tan(const VarMat& a) {
return make_callback_var(
a.val().array().tan().matrix(), [a](const auto& vi) mutable {
a.adj().noalias() += vi.adj().cwiseProduct(
(1.0 + vi.val().array().square()).matrix());
});
return make_callback_var(a.val().array().tan().matrix(),
[a](const auto& vi) mutable {
a.adj().noalias() += vi.adj().cwiseProduct(
(1.0 + vi.val().array().square()).matrix());
});
}

/**
Expand Down
7 changes: 4 additions & 3 deletions test/unit/math/mix/fun/acos_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,17 @@ TEST(mathMixMatFun, acos) {
}

TEST(mathMixMatFun, acos_varmat) {
using stan::math::vec_concat;
using stan::test::expect_ad_vector_matvar;
using stan::test::internal::common_nonzero_args;
using stan::math::vec_concat;
auto f = [](const auto& x1) {
using stan::math::acos;
return acos(x1);
};
std::vector<double> com_args = common_nonzero_args();
std::vector<double> args{-2.2, -0.8, 0.5, 1 + std::numeric_limits<double>::epsilon(), 1.5, 3, 3.4,
4};
std::vector<double> args{
-2.2, -0.8, 0.5, 1 + std::numeric_limits<double>::epsilon(),
1.5, 3, 3.4, 4};
auto all_args = vec_concat(com_args, args);
Eigen::VectorXd A(all_args.size());
for (int i = 0; i < all_args.size(); ++i) {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/math/mix/fun/acosh_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ TEST(mathMixMatFun, acosh) {
}

TEST(mathMixMatFun, acosh_varmat) {
using stan::math::vec_concat;
using stan::test::expect_ad_vector_matvar;
using stan::test::internal::common_args;
using stan::math::vec_concat;
auto f = [](const auto& x1) {
using stan::math::acosh;
return acosh(x1);
Expand Down
2 changes: 1 addition & 1 deletion test/unit/math/mix/fun/asin_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ TEST(mathMixMatFun, asin) {
}

TEST(mathMixMatFun, asin_varmat) {
using stan::math::vec_concat;
using stan::test::expect_ad_vector_matvar;
using stan::test::internal::common_nonzero_args;
using stan::math::vec_concat;
auto f = [](const auto& x1) {
using stan::math::asin;
return asin(x1);
Expand Down
2 changes: 1 addition & 1 deletion test/unit/math/mix/fun/asinh_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ TEST(mathMixFun, asinh) {
}

TEST(mathMixMatFun, asinh_varmat) {
using stan::math::vec_concat;
using stan::test::expect_ad_vector_matvar;
using stan::test::internal::common_args;
using stan::math::vec_concat;
auto f = [](const auto& x1) {
using stan::math::asinh;
return asinh(x1);
Expand Down
2 changes: 1 addition & 1 deletion test/unit/math/mix/fun/atan_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ TEST(mathMixMatFun, atan) {
}

TEST(mathMixMatFun, atan_varmat) {
using stan::math::vec_concat;
using stan::test::expect_ad_vector_matvar;
using stan::test::internal::common_nonzero_args;
using stan::math::vec_concat;
auto f = [](const auto& x1) {
using stan::math::atan;
return atan(x1);
Expand Down
2 changes: 1 addition & 1 deletion test/unit/math/mix/fun/atanh_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ TEST(mathMixMatFun, atanh) {
}

TEST(mathMixMatFun, atanh_varmat) {
using stan::math::vec_concat;
using stan::test::expect_ad_vector_matvar;
using stan::test::internal::common_args;
using stan::math::vec_concat;
auto f = [](const auto& x1) {
using stan::math::atanh;
return atanh(x1);
Expand Down
2 changes: 1 addition & 1 deletion test/unit/math/mix/fun/cbrt_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ TEST(mathMixMatFun, cbrt) {
}

TEST(mathMixMatFun, cbrt_varmat) {
using stan::math::vec_concat;
using stan::test::expect_ad_vector_matvar;
using stan::test::internal::common_nonzero_args;
using stan::math::vec_concat;
auto f = [](const auto& x1) {
using stan::math::cbrt;
return cbrt(x1);
Expand Down
2 changes: 1 addition & 1 deletion test/unit/math/mix/fun/cos_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ TEST(mathMixMatFun, cos) {
}

TEST(mathMixMatFun, cos_varmat) {
using stan::math::vec_concat;
using stan::test::expect_ad_vector_matvar;
using stan::test::internal::common_nonzero_args;
using stan::math::vec_concat;
auto f = [](const auto& x1) {
using stan::math::cos;
return cos(x1);
Expand Down
2 changes: 1 addition & 1 deletion test/unit/math/mix/fun/cosh_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ TEST(mathMixMatFun, cosh) {
}

TEST(mathMixMatFun, cosh_varmat) {
using stan::math::vec_concat;
using stan::test::expect_ad_vector_matvar;
using stan::test::internal::common_args;
using stan::math::vec_concat;
auto f = [](const auto& x1) {
using stan::math::cosh;
return cosh(x1);
Expand Down
2 changes: 1 addition & 1 deletion test/unit/math/mix/fun/sin_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ TEST(mathMixMatFun, sin) {
}

TEST(mathMixMatFun, sin_varmat) {
using stan::math::vec_concat;
using stan::test::expect_ad_vector_matvar;
using stan::test::internal::common_nonzero_args;
using stan::math::vec_concat;
auto f = [](const auto& x1) {
using stan::math::sin;
return sin(x1);
Expand Down
2 changes: 1 addition & 1 deletion test/unit/math/mix/fun/sinh_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ TEST(mathMixMatFun, sinh) {
}

TEST(mathMixMatFun, sinh_varmat) {
using stan::math::vec_concat;
using stan::test::expect_ad_vector_matvar;
using stan::test::internal::common_nonzero_args;
using stan::math::vec_concat;
auto f = [](const auto& x1) {
using stan::math::sinh;
return sinh(x1);
Expand Down
2 changes: 1 addition & 1 deletion test/unit/math/mix/fun/tan_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ TEST(mathMixMatFun, tan) {
}

TEST(mathMixMatFun, tan_varmat) {
using stan::math::vec_concat;
using stan::test::expect_ad_vector_matvar;
using stan::test::internal::common_nonzero_args;
using stan::math::vec_concat;
auto f = [](const auto& x1) {
using stan::math::tan;
return tan(x1);
Expand Down
2 changes: 1 addition & 1 deletion test/unit/math/mix/fun/tanh_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ TEST(mathMixMatFun, tanh) {
}

TEST(mathMixMatFun, tanh_varmat) {
using stan::math::vec_concat;
using stan::test::expect_ad_vector_matvar;
using stan::test::internal::common_nonzero_args;
using stan::math::vec_concat;
auto f = [](const auto& x1) {
using stan::math::tanh;
return tanh(x1);
Expand Down
23 changes: 13 additions & 10 deletions test/unit/math/test_ad.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2099,36 +2099,39 @@ void expect_ad_matvar(const ad_tolerances& tols, const F& f,
}

/**
* For an unary function check that an Eigen matrix, vector and row vector of vars
* and an `var_value` with inner eigen matrix, vector, and row vector type return the same values
* and adjoints.
* For an unary function check that an Eigen matrix, vector and row vector of
* vars and an `var_value` with inner eigen matrix, vector, and row vector type
* return the same values and adjoints.
*
* @tparam F A lambda or functor type that calls the unary function.
* @tparam EigVec An Eigen vector type
* @param f a lambda
* @param x An Eigen vector.
*/
template <typename F, typename EigVec, require_eigen_vector_t<EigVec>* = nullptr>
template <typename F, typename EigVec,
require_eigen_vector_t<EigVec>* = nullptr>
void expect_ad_vector_matvar(const F& f, EigVec& x) {
ad_tolerances tols;
expect_ad_vector_matvar(tols, f, x);
}

template <typename F, typename EigVec, require_eigen_vector_t<EigVec>* = nullptr>
void expect_ad_vector_matvar(const ad_tolerances& tols, const F& f, const EigVec& x) {
template <typename F, typename EigVec,
require_eigen_vector_t<EigVec>* = nullptr>
void expect_ad_vector_matvar(const ad_tolerances& tols, const F& f,
const EigVec& x) {
Eigen::VectorXd v = x;
Eigen::RowVectorXd r = x.transpose();
Eigen::MatrixXd m(x.size(), 2);
m.col(0) = x;
m.col(1) = x.reverse(); // reverse just to mix stuff up
m.col(1) = x.reverse(); // reverse just to mix stuff up

expect_ad_matvar(f, v);
expect_ad_matvar(f, r);
expect_ad_matvar(f, m);

std::vector<Eigen::VectorXd> vv = { v, v };
std::vector<Eigen::RowVectorXd> rv = { r, r };
std::vector<Eigen::MatrixXd> mv = { m, m };
std::vector<Eigen::VectorXd> vv = {v, v};
std::vector<Eigen::RowVectorXd> rv = {r, r};
std::vector<Eigen::MatrixXd> mv = {m, m};

expect_ad_matvar(f, vv);
expect_ad_matvar(f, rv);
Expand Down

0 comments on commit a7deb36

Please sign in to comment.