Skip to content

Commit f5d49a6

Browse files
committed
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
1 parent 0426e8a commit f5d49a6

2 files changed

Lines changed: 48 additions & 47 deletions

File tree

stan/math/rev/core/var.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,7 +1022,8 @@ class var_value<T, internal::require_matrix_var_value<T>> {
10221022
* @param other the value to assign
10231023
* @return this
10241024
*/
1025-
template <typename S, typename T_ = T, require_assignable_t<value_type, S>* = nullptr,
1025+
template <typename S, typename T_ = T,
1026+
require_assignable_t<value_type, S>* = nullptr,
10261027
require_all_plain_type_t<T_, S>* = nullptr,
10271028
require_not_same_t<plain_type_t<T_>, plain_type_t<S>>* = nullptr>
10281029
inline var_value<T>& operator=(const var_value<S>& other) {
@@ -1049,7 +1050,7 @@ class var_value<T, internal::require_matrix_var_value<T>> {
10491050
if (!(this->vi_)) {
10501051
*this = var_value<T>(other);
10511052
return *this;
1052-
}
1053+
}
10531054
arena_t<plain_type_t<T>> prev_val(vi_->val_.rows(), vi_->val_.cols());
10541055
prev_val.hard_copy(vi_->val_);
10551056
vi_->val_.hard_copy(other.val());
@@ -1086,11 +1087,11 @@ class var_value<T, internal::require_matrix_var_value<T>> {
10861087
if (!(this->vi_)) {
10871088
[]() STAN_COLD_PATH {
10881089
throw std::domain_error(
1089-
"var_value<matrix>::operator=(var_value<expression>):"
1090-
" Internal Bug! Please report this with an example"
1091-
" of your model to the Stan math github repository.");
1090+
"var_value<matrix>::operator=(var_value<expression>):"
1091+
" Internal Bug! Please report this with an example"
1092+
" of your model to the Stan math github repository.");
10921093
}();
1093-
}
1094+
}
10941095
arena_t<plain_type_t<T>> prev_val = vi_->val_;
10951096
vi_->val_ = other.val();
10961097
// no need to change any adjoints - these are just zeros before the reverse
@@ -1111,7 +1112,6 @@ class var_value<T, internal::require_matrix_var_value<T>> {
11111112
return *this;
11121113
}
11131114

1114-
11151115
/**
11161116
* No-op to match with Eigen methods which call eval
11171117
*/

test/unit/math/rev/core/var_test.cpp

Lines changed: 41 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -912,47 +912,48 @@ TEST_F(AgradRev, matrix_compile_time_conversions) {
912912
}
913913

914914
TEST_F(AgradRev, assign_nan) {
915-
using stan::math::var_value;
916-
using var_vector = var_value<Eigen::Matrix<double,-1,1>>;
917-
using stan::math::var;
918-
Eigen::VectorXd x_val(10);
919-
for (int i = 0; i < 10; ++i) {
920-
x_val(i) = i + 0.1;
921-
}
922-
var_vector x(x_val);
923-
var_vector y = var_vector(Eigen::Matrix<double,-1,1>::Constant(10, std::numeric_limits<double>::quiet_NaN()));
924-
y = stan::math::head(x, 10);
925-
var sigma = 1.0;
926-
var lp = stan::math::normal_lpdf<false>(y, 0, sigma);
927-
lp.grad();
928-
Eigen::VectorXd x_ans_adj(10);
929-
for (int i = 0; i < 10; ++i) {
930-
x_ans_adj(i) = -(i + 0.1);
931-
}
932-
EXPECT_MATRIX_EQ(x.adj(), x_ans_adj);
933-
Eigen::VectorXd y_ans_adj = Eigen::VectorXd::Zero(10);
934-
EXPECT_MATRIX_EQ(y_ans_adj, y.adj());
915+
using stan::math::var_value;
916+
using var_vector = var_value<Eigen::Matrix<double, -1, 1>>;
917+
using stan::math::var;
918+
Eigen::VectorXd x_val(10);
919+
for (int i = 0; i < 10; ++i) {
920+
x_val(i) = i + 0.1;
921+
}
922+
var_vector x(x_val);
923+
var_vector y = var_vector(Eigen::Matrix<double, -1, 1>::Constant(
924+
10, std::numeric_limits<double>::quiet_NaN()));
925+
y = stan::math::head(x, 10);
926+
var sigma = 1.0;
927+
var lp = stan::math::normal_lpdf<false>(y, 0, sigma);
928+
lp.grad();
929+
Eigen::VectorXd x_ans_adj(10);
930+
for (int i = 0; i < 10; ++i) {
931+
x_ans_adj(i) = -(i + 0.1);
932+
}
933+
EXPECT_MATRIX_EQ(x.adj(), x_ans_adj);
934+
Eigen::VectorXd y_ans_adj = Eigen::VectorXd::Zero(10);
935+
EXPECT_MATRIX_EQ(y_ans_adj, y.adj());
935936
}
936937

937938
TEST_F(AgradRev, assign_nullptr_vari) {
938-
using stan::math::var_value;
939-
using var_vector = var_value<Eigen::Matrix<double,-1,1>>;
940-
using stan::math::var;
941-
Eigen::VectorXd x_val(10);
942-
for (int i = 0; i < 10; ++i) {
943-
x_val(i) = i + 0.1;
944-
}
945-
var_vector x(x_val);
946-
var_vector y;
947-
y = stan::math::head(x, 10);
948-
var sigma = 1.0;
949-
var lp = stan::math::normal_lpdf<false>(y, 0, sigma);
950-
lp.grad();
951-
Eigen::VectorXd x_ans_adj(10);
952-
for (int i = 0; i < 10; ++i) {
953-
x_ans_adj(i) = -(i + 0.1);
954-
}
955-
EXPECT_MATRIX_EQ(x.adj(), x_ans_adj);
956-
Eigen::VectorXd y_ans_adj = Eigen::VectorXd::Zero(10);
957-
EXPECT_MATRIX_EQ(y_ans_adj, y.adj());
939+
using stan::math::var_value;
940+
using var_vector = var_value<Eigen::Matrix<double, -1, 1>>;
941+
using stan::math::var;
942+
Eigen::VectorXd x_val(10);
943+
for (int i = 0; i < 10; ++i) {
944+
x_val(i) = i + 0.1;
945+
}
946+
var_vector x(x_val);
947+
var_vector y;
948+
y = stan::math::head(x, 10);
949+
var sigma = 1.0;
950+
var lp = stan::math::normal_lpdf<false>(y, 0, sigma);
951+
lp.grad();
952+
Eigen::VectorXd x_ans_adj(10);
953+
for (int i = 0; i < 10; ++i) {
954+
x_ans_adj(i) = -(i + 0.1);
955+
}
956+
EXPECT_MATRIX_EQ(x.adj(), x_ans_adj);
957+
Eigen::VectorXd y_ans_adj = Eigen::VectorXd::Zero(10);
958+
EXPECT_MATRIX_EQ(y_ans_adj, y.adj());
958959
}

0 commit comments

Comments
 (0)