Skip to content

Commit 4c18336

Browse files
committed
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
1 parent 15a9a72 commit 4c18336

3 files changed

Lines changed: 45 additions & 40 deletions

File tree

stan/math/prim/fun/value_of.hpp

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ namespace stan {
1212
namespace math {
1313

1414
/**
15-
* Return the value of the specified argument.
16-
* For types with a \ref base_type of double or int returns itself.
17-
* For types with a \ref base_type of \ref var or \ref fvar
15+
* Return the value of the specified argument.
16+
* For types with a \ref base_type of double or int returns itself.
17+
* For types with a \ref base_type of \ref var or \ref fvar
1818
* the `value` member of their class is returned.
19-
*
19+
*
2020
* So for `std::complex<fvar<var>>` this will return
2121
* a `std::complex<var>`. And for `std::vector<var>`
2222
* this will return a `std:vector<double>` whose
@@ -26,15 +26,16 @@ namespace math {
2626
* extract values without casting to <code>double</code>.
2727
* @tparam T A container or scalar type
2828
* @param x The object whose values will be extracted.
29-
* @return An object whose \ref scalar_type
29+
* @return An object whose \ref scalar_type
3030
*/
3131
template <typename T>
3232
inline constexpr decltype(auto) value_of(T&& x) {
3333
using val_t = std::decay_t<T>;
3434
// ints are cast to doubles, types with base double are passed along
3535
if constexpr (std::is_integral_v<val_t> || std::is_floating_point_v<val_t>) {
3636
return val_t{x};
37-
} else if constexpr (std::is_floating_point_v<base_type_t<val_t>> || std::is_integral_v<base_type_t<val_t>> ) {
37+
} else if constexpr (std::is_floating_point_v<base_type_t<
38+
val_t>> || std::is_integral_v<base_type_t<val_t>>) {
3839
if constexpr (std::is_rvalue_reference_v<T&&>) {
3940
return plain_type_t<T>(std::forward<T>(x));
4041
} else {
@@ -43,25 +44,27 @@ inline constexpr decltype(auto) value_of(T&& x) {
4344
} else if constexpr (is_complex<val_t>::value) {
4445
return std::complex<double>{value_of(x.real()), value_of(x.imag())};
4546
} else if constexpr (is_std_vector_v<val_t>) {
46-
std::vector<plain_type_t<decltype(value_of(std::declval<value_type_t<T>>()))>> ret;
47+
std::vector<
48+
plain_type_t<decltype(value_of(std::declval<value_type_t<T>>()))>>
49+
ret;
4750
ret.reserve(x.size());
4851
for (auto&& x_i : x) {
4952
ret.push_back(value_of(std::forward<decltype(x_i)>(x_i)));
5053
}
5154
return ret;
5255
} else if constexpr (is_eigen_v<val_t>) {
5356
return make_holder(
54-
[](auto& m) {
55-
return m.unaryExpr([](auto x_i) { return value_of(x_i); });
56-
},
57-
std::forward<T>(x));
57+
[](auto& m) {
58+
return m.unaryExpr([](auto x_i) { return value_of(x_i); });
59+
},
60+
std::forward<T>(x));
5861
} else if constexpr (is_tuple_v<val_t>) {
5962
return stan::math::apply(
60-
[](auto&&... args) {
61-
return partially_forward_as_tuple(
62-
value_of(std::forward<decltype(args)>(args))...);
63-
},
64-
std::forward<T>(x));
63+
[](auto&&... args) {
64+
return partially_forward_as_tuple(
65+
value_of(std::forward<decltype(args)>(args))...);
66+
},
67+
std::forward<T>(x));
6568
} else if constexpr (is_var_v<val_t>) {
6669
return x.vi_->val_;
6770
} else if constexpr (is_fvar<val_t>::value) {

stan/math/prim/fun/value_of_rec.hpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ namespace math {
1515
/**
1616
* Return the value of the specified scalar argument
1717
* converted to a double value. For types with a \ref base_type
18-
* of double this is itself. For types with a \ref base_type
19-
* of \ref var or \ref fvar this the `value_of_rec` of the
18+
* of double this is itself. For types with a \ref base_type
19+
* of \ref var or \ref fvar this the `value_of_rec` of the
2020
* value type until a double is found.
2121
*
2222
* <p>See the <code>primitive_value</code> function to
@@ -48,17 +48,17 @@ inline constexpr decltype(auto) value_of_rec(T&& x) {
4848
return ret;
4949
} else if constexpr (is_eigen_v<val_t>) {
5050
return make_holder(
51-
[](auto& m) {
52-
return m.unaryExpr([](auto x_i) { return value_of_rec(x_i); });
53-
},
54-
std::forward<T>(x));
51+
[](auto& m) {
52+
return m.unaryExpr([](auto x_i) { return value_of_rec(x_i); });
53+
},
54+
std::forward<T>(x));
5555
} else if constexpr (is_tuple_v<val_t>) {
5656
return stan::math::apply(
57-
[](auto&&... args) {
58-
return partially_forward_as_tuple(
59-
value_of_rec(std::forward<decltype(args)>(args))...);
60-
},
61-
std::forward<T>(x));
57+
[](auto&&... args) {
58+
return partially_forward_as_tuple(
59+
value_of_rec(std::forward<decltype(args)>(args))...);
60+
},
61+
std::forward<T>(x));
6262
} else if constexpr (is_var_v<val_t>) {
6363
return x.vi_->val_;
6464
} else if constexpr (is_fvar<val_t>::value) {

test/unit/math/prim/fun/value_of_rec_test.cpp

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -73,29 +73,31 @@ TEST(MathFunctions, value_of_rec_return_type_short_circuit_std_vector) {
7373
std::vector<double> a(5);
7474
const std::vector<double> b(5);
7575
EXPECT_TRUE((std::is_same<decltype(stan::math::value_of_rec(a)),
76-
std::vector<double>&>::value)) << "stan::math::value_of_rec(a)) = " <<
77-
stan::math::test::type_name<decltype(stan::math::value_of_rec(a))>() <<
78-
". But expected std::vector<double>&";
76+
std::vector<double>&>::value))
77+
<< "stan::math::value_of_rec(a)) = "
78+
<< stan::math::test::type_name<decltype(stan::math::value_of_rec(a))>()
79+
<< ". But expected std::vector<double>&";
7980
EXPECT_TRUE((std::is_same<decltype(stan::math::value_of_rec(b)),
80-
const std::vector<double>&>::value)) << "stan::math::value_of_rec(b)) = " <<
81-
stan::math::test::type_name<decltype(stan::math::value_of_rec(b))>() <<
82-
". But expected const std::vector<double>&";
81+
const std::vector<double>&>::value))
82+
<< "stan::math::value_of_rec(b)) = "
83+
<< stan::math::test::type_name<decltype(stan::math::value_of_rec(b))>()
84+
<< ". But expected const std::vector<double>&";
8385
}
8486

8587
TEST(MathFunctions, value_of_rec_return_type_short_circuit_vector_xd) {
8688
Eigen::Matrix<double, Eigen::Dynamic, 1> a(5);
8789
const Eigen::Matrix<double, Eigen::Dynamic, 1> b(5);
8890
EXPECT_TRUE((std::is_same<decltype(stan::math::value_of_rec(a)),
89-
Eigen::Matrix<double, Eigen::Dynamic, 1>&>::value))
90-
<< "stan::math::value_of_rec(a)) = " <<
91-
stan::math::test::type_name<decltype(stan::math::value_of_rec(a))>() <<
92-
". But expected Eigen::Matrix<double, Eigen::Dynamic, 1>&";
91+
Eigen::Matrix<double, Eigen::Dynamic, 1>&>::value))
92+
<< "stan::math::value_of_rec(a)) = "
93+
<< stan::math::test::type_name<decltype(stan::math::value_of_rec(a))>()
94+
<< ". But expected Eigen::Matrix<double, Eigen::Dynamic, 1>&";
9395
EXPECT_TRUE(
9496
(std::is_same<decltype(stan::math::value_of_rec(b)),
9597
const Eigen::Matrix<double, Eigen::Dynamic, 1>&>::value))
96-
<< "stan::math::value_of_rec(b)) = " <<
97-
stan::math::test::type_name<decltype(stan::math::value_of_rec(b))>() <<
98-
". But expected const Eigen::Matrix<double, Eigen::Dynamic, 1>&";
98+
<< "stan::math::value_of_rec(b)) = "
99+
<< stan::math::test::type_name<decltype(stan::math::value_of_rec(b))>()
100+
<< ". But expected const Eigen::Matrix<double, Eigen::Dynamic, 1>&";
99101
}
100102

101103
TEST(MathFunctions, value_of_rec_return_type_short_circuit_row_vector_xd) {

0 commit comments

Comments
 (0)