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 Sep 14, 2021
1 parent b6536cc commit 1b909ee
Show file tree
Hide file tree
Showing 19 changed files with 94 additions and 76 deletions.
9 changes: 6 additions & 3 deletions stan/math/prim/fun/cholesky_corr_constrain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,19 @@ inline auto cholesky_corr_constrain(const T& y, int K, return_type_t<T>& lp) {
* Constraint Transforms.
* @tparam Jacobian if `true`, increment log density accumulator with log
* absolute Jacobian determinant of constraining transform
* @tparam T A standard vector with inner type inheriting from `Eigen::DenseBase` or a `var_value` with inner type inheriting from `Eigen::DenseBase` with compile time dynamic rows and 1 column
* @tparam T A standard vector with inner type inheriting from
* `Eigen::DenseBase` or a `var_value` with inner type inheriting from
* `Eigen::DenseBase` with compile time dynamic rows and 1 column
* @param y Linearly Serialized vector of size `(K * (K - 1))/2` holding the
* column major order elements of the lower triangurlar
* @param K The size of the matrix to return
* @param[in,out] lp log density accumulator
*/
template <bool Jacobian, typename T, require_std_vector_t<T>* = nullptr>
inline auto cholesky_corr_constrain(const T& y, int K, return_type_t<T>& lp) {
return apply_vector_unary<T>::apply(
y, [&lp, K](auto&& v) { return cholesky_corr_constrain<Jacobian>(v, K, lp); });
return apply_vector_unary<T>::apply(y, [&lp, K](auto&& v) {
return cholesky_corr_constrain<Jacobian>(v, K, lp);
});
}

} // namespace math
Expand Down
12 changes: 8 additions & 4 deletions stan/math/prim/fun/cholesky_factor_constrain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,21 @@ inline auto cholesky_factor_constrain(const T& x, int M, int N,
*
* @tparam Jacobian if `true`, increment log density accumulator with log
* absolute Jacobian determinant of constraining transform
* @tparam T A standard vector with inner type inheriting from `Eigen::DenseBase` or a `var_value` with inner type inheriting from `Eigen::DenseBase` with compile time dynamic rows and 1 column
* @tparam T A standard vector with inner type inheriting from
* `Eigen::DenseBase` or a `var_value` with inner type inheriting from
* `Eigen::DenseBase` with compile time dynamic rows and 1 column
* @param x Vector of unconstrained values
* @param M number of rows
* @param N number of columns
* @param[in,out] lp log density accumulator
* @return Cholesky factor
*/
template <bool Jacobian, typename T, require_std_vector_t<T>* = nullptr>
inline auto cholesky_factor_constrain(const T& x, int M, int N, return_type_t<T>& lp) {
return apply_vector_unary<T>::apply(
x, [&lp, M, N](auto&& v) { return cholesky_factor_constrain<Jacobian>(v, M, N, lp); });
inline auto cholesky_factor_constrain(const T& x, int M, int N,
return_type_t<T>& lp) {
return apply_vector_unary<T>::apply(x, [&lp, M, N](auto&& v) {
return cholesky_factor_constrain<Jacobian>(v, M, N, lp);
});
}

} // namespace math
Expand Down
11 changes: 6 additions & 5 deletions stan/math/prim/fun/corr_matrix_constrain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,18 @@ inline auto corr_matrix_constrain(const T& x, Eigen::Index k,
*
* @tparam Jacobian if `true`, increment log density accumulator with log
* absolute Jacobian determinant of constraining transform
* @tparam T A standard vector with inner type inheriting from `Eigen::DenseBase` or a `var_value` with
* inner type inheriting from `Eigen::DenseBase` with compile time dynamic rows
* and 1 column
* @tparam T A standard vector with inner type inheriting from
* `Eigen::DenseBase` or a `var_value` with inner type inheriting from
* `Eigen::DenseBase` with compile time dynamic rows and 1 column
* @param x Vector of unconstrained partial correlations
* @param k Dimensionality of returned correlation matrix
* @param[in,out] lp log density accumulator
*/
template <bool Jacobian, typename T, require_std_vector_t<T>* = nullptr>
inline auto corr_matrix_constrain(const T& y, int K, return_type_t<T>& lp) {
return apply_vector_unary<T>::apply(
y, [&lp, K](auto&& v) { return corr_matrix_constrain<Jacobian>(v, K, lp); });
return apply_vector_unary<T>::apply(y, [&lp, K](auto&& v) {
return corr_matrix_constrain<Jacobian>(v, K, lp);
});
}

} // namespace math
Expand Down
16 changes: 9 additions & 7 deletions stan/math/prim/fun/cov_matrix_constrain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ cov_matrix_constrain(const T& x, Eigen::Index K, return_type_t<T>& lp) {
* @throws std::domain_error if (x.size() != K + (K choose 2)).
*/
template <bool Jacobian, typename T, require_not_std_vector_t<T>* = nullptr>
inline auto cov_matrix_constrain(const T& x, Eigen::Index K, return_type_t<T>& lp) {
inline auto cov_matrix_constrain(const T& x, Eigen::Index K,
return_type_t<T>& lp) {
if (Jacobian) {
return cov_matrix_constrain(x, K, lp);
} else {
Expand All @@ -123,19 +124,20 @@ inline auto cov_matrix_constrain(const T& x, Eigen::Index K, return_type_t<T>& l
*
* @tparam Jacobian if `true`, increment log density accumulator with log
* absolute Jacobian determinant of constraining transform
* @tparam T A standard vector with inner type inheriting from `Eigen::DenseBase` or a `var_value` with
* inner type inheriting from `Eigen::DenseBase` with compile time dynamic rows
* and 1 column
* @tparam T A standard vector with inner type inheriting from
* `Eigen::DenseBase` or a `var_value` with inner type inheriting from
* `Eigen::DenseBase` with compile time dynamic rows and 1 column
* @param x The vector to convert to a covariance matrix
* @param K The dimensions of the resulting covariance matrix
* @param[in, out] lp log density accumulator
* @throws std::domain_error if (x.size() != K + (K choose 2)).
*/
template <bool Jacobian, typename T, require_std_vector_t<T>* = nullptr>
inline auto cov_matrix_constrain(const T& x, Eigen::Index K, return_type_t<T>& lp) {
inline auto cov_matrix_constrain(const T& x, Eigen::Index K,
return_type_t<T>& lp) {
return apply_vector_unary<T>::apply(x, [&lp, K](auto&& v) {
return cov_matrix_constrain<Jacobian>(v, K, lp);
});
return cov_matrix_constrain<Jacobian>(v, K, lp);
});
}

} // namespace math
Expand Down
16 changes: 9 additions & 7 deletions stan/math/prim/fun/cov_matrix_constrain_lkj.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ cov_matrix_constrain_lkj(const T& x, size_t k, return_type_t<T>& lp) {
* correlations and deviations.
*/
template <bool Jacobian, typename T, require_not_std_vector_t<T>* = nullptr>
inline auto cov_matrix_constrain_lkj(const T& x, size_t k, return_type_t<T>& lp) {
inline auto cov_matrix_constrain_lkj(const T& x, size_t k,
return_type_t<T>& lp) {
if (Jacobian) {
return cov_matrix_constrain_lkj(x, k, lp);
} else {
Expand All @@ -102,9 +103,9 @@ inline auto cov_matrix_constrain_lkj(const T& x, size_t k, return_type_t<T>& lp)
*
* @tparam Jacobian if `true`, increment log density accumulator with log
* absolute Jacobian determinant of constraining transform
* @tparam T A standard vector with inner type inheriting from `Eigen::DenseBase` or a `var_value` with
* inner type inheriting from `Eigen::DenseBase` with compile time rows or
* columns equal to 1
* @tparam T A standard vector with inner type inheriting from
* `Eigen::DenseBase` or a `var_value` with inner type inheriting from
* `Eigen::DenseBase` with compile time rows or columns equal to 1
* @param x Input vector of unconstrained partial correlations and
* standard deviations
* @param k Dimensionality of returned covariance matrix
Expand All @@ -113,10 +114,11 @@ inline auto cov_matrix_constrain_lkj(const T& x, size_t k, return_type_t<T>& lp)
* correlations and deviations.
*/
template <bool Jacobian, typename T, require_std_vector_t<T>* = nullptr>
inline auto cov_matrix_constrain_lkj(const T& x, size_t k, return_type_t<T>& lp) {
inline auto cov_matrix_constrain_lkj(const T& x, size_t k,
return_type_t<T>& lp) {
return apply_vector_unary<T>::apply(x, [&lp, k](auto&& v) {
return cov_matrix_constrain_lkj<Jacobian>(v, k, lp);
});
return cov_matrix_constrain_lkj<Jacobian>(v, k, lp);
});
}

} // namespace math
Expand Down
11 changes: 5 additions & 6 deletions stan/math/prim/fun/ordered_constrain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,17 @@ inline auto ordered_constrain(const T& x, return_type_t<T>& lp) {
*
* @tparam Jacobian if `true`, increment log density accumulator with log
* absolute Jacobian determinant of constraining transform
* @tparam T A standard vector with inner type inheriting from `Eigen::DenseBase` or a `var_value` with
* inner type inheriting from `Eigen::DenseBase` with compile time dynamic rows
* and 1 column
* @tparam T A standard vector with inner type inheriting from
* `Eigen::DenseBase` or a `var_value` with inner type inheriting from
* `Eigen::DenseBase` with compile time dynamic rows and 1 column
* @param x Free vector of scalars
* @param[in, out] lp log density accumulator
* @return Positive, increasing ordered vector.
*/
template <bool Jacobian, typename T, require_std_vector_t<T>* = nullptr>
inline auto ordered_constrain(const T& x, return_type_t<T>& lp) {
return apply_vector_unary<T>::apply(x, [&lp](auto&& v) {
return ordered_constrain<Jacobian>(v, lp);
});
return apply_vector_unary<T>::apply(
x, [&lp](auto&& v) { return ordered_constrain<Jacobian>(v, lp); });
}

} // namespace math
Expand Down
10 changes: 5 additions & 5 deletions stan/math/prim/fun/positive_constrain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,17 @@ inline auto positive_constrain(const T& x, return_type_t<T>& lp) {
*
* @tparam Jacobian if `true`, increment log density accumulator with log
* absolute Jacobian determinant of constraining transform
* @tparam T A standard vector with inner type inheriting from `Eigen::EigenBase`, a `var_value` with inner
* type inheriting from `Eigen::EigenBase`, a standard vector, or a scalar
* @tparam T A standard vector with inner type inheriting from
* `Eigen::EigenBase`, a `var_value` with inner type inheriting from
* `Eigen::EigenBase`, a standard vector, or a scalar
* @param x unconstrained value or container
* @param[in, out] lp log density accumulator
* @return positive constrained version of unconstrained value(s)
*/
template <bool Jacobian, typename T, require_std_vector_t<T>* = nullptr>
inline auto positive_constrain(const T& x, return_type_t<T>& lp) {
return apply_vector_unary<T>::apply(x, [&lp](auto&& v) {
return positive_constrain<Jacobian>(v, lp);
});
return apply_vector_unary<T>::apply(
x, [&lp](auto&& v) { return positive_constrain<Jacobian>(v, lp); });
}

} // namespace math
Expand Down
10 changes: 5 additions & 5 deletions stan/math/prim/fun/positive_ordered_constrain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,20 @@ inline auto positive_ordered_constrain(const Vec& x, return_type_t<Vec>& lp) {
*
* @tparam Jacobian if `true`, increment log density accumulator with log
* absolute Jacobian determinant of constraining transform
* @tparam Vec A standard vector with inner type inheriting from `Eigen::EigenBase`, a `var_value` with
* inner type inheriting from `Eigen::EigenBase`
* @tparam Vec A standard vector with inner type inheriting from
* `Eigen::EigenBase`, a `var_value` with inner type inheriting from
* `Eigen::EigenBase`
* @param x Free vector of scalars
* @param[in, out] lp log density accumulato
* @return Positive, increasing ordered vector
*/
template <bool Jacobian, typename T, require_std_vector_t<T>* = nullptr>
inline auto positive_ordered_constrain(const T& x, return_type_t<T>& lp) {
return apply_vector_unary<T>::apply(x, [&lp](auto&& v) {
return positive_ordered_constrain<Jacobian>(v, lp);
});
return positive_ordered_constrain<Jacobian>(v, lp);
});
}


} // namespace math
} // namespace stan

Expand Down
12 changes: 5 additions & 7 deletions stan/math/prim/fun/simplex_constrain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,21 +115,19 @@ auto simplex_constrain(const Vec& y, return_type_t<Vec>& lp) {
*
* @tparam Jacobian if `true`, increment log density accumulator with log
* absolute Jacobian determinant of constraining transform
* @tparam Vec A standard vector with inner type inheriting from `Eigen::DenseBase` or a `var_value` with
* inner type inheriting from `Eigen::DenseBase` with compile time dynamic rows
* and 1 column
* @tparam Vec A standard vector with inner type inheriting from
* `Eigen::DenseBase` or a `var_value` with inner type inheriting from
* `Eigen::DenseBase` with compile time dynamic rows and 1 column
* @param[in] y free vector
* @param[in, out] lp log density accumulator
* @return simplex of dimensionality one greater than `y`
*/
template <bool Jacobian, typename T, require_std_vector_t<T>* = nullptr>
inline auto simplex_constrain(const T& y, return_type_t<T>& lp) {
return apply_vector_unary<T>::apply(y, [&lp](auto&& v) {
return simplex_constrain<Jacobian>(v, lp);
});
return apply_vector_unary<T>::apply(
y, [&lp](auto&& v) { return simplex_constrain<Jacobian>(v, lp); });
}


} // namespace math
} // namespace stan

Expand Down
11 changes: 5 additions & 6 deletions stan/math/prim/fun/unit_vector_constrain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,17 @@ inline auto unit_vector_constrain(const T& y, return_type_t<T>& lp) {
*
* @tparam Jacobian if `true`, increment log density accumulator with log
* absolute Jacobian determinant of constraining transform
* @tparam T A standard vector with inner type inheriting from `Eigen::DenseBase` or a `var_value` with
* inner type inheriting from `Eigen::DenseBase` with compile time dynamic rows
* and 1 column
* @tparam T A standard vector with inner type inheriting from
* `Eigen::DenseBase` or a `var_value` with inner type inheriting from
* `Eigen::DenseBase` with compile time dynamic rows and 1 column
* @param y vector of K unrestricted variables
* @param[in, out] lp log density accumulator
* @return Unit length vector of dimension K
*/
template <bool Jacobian, typename T, require_std_vector_t<T>* = nullptr>
inline auto unit_vector_constrain(const T& y, return_type_t<T>& lp) {
return apply_vector_unary<T>::apply(y, [&lp](auto&& v) {
return unit_vector_constrain<Jacobian>(v, lp);
});
return apply_vector_unary<T>::apply(
y, [&lp](auto&& v) { return unit_vector_constrain<Jacobian>(v, lp); });
}

} // namespace math
Expand Down
6 changes: 4 additions & 2 deletions test/unit/math/prim/fun/cholesky_corr_transform_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ void test_cholesky_correlation_values(
std::vector<Matrix<double, Dynamic, Dynamic>> x_vec
= stan::math::cholesky_corr_constrain<false>(y_vec, K, lp);

std::vector<Matrix<double, Dynamic, 1>> yrt = stan::math::cholesky_corr_free(x_vec);
std::vector<Matrix<double, Dynamic, 1>> yrt
= stan::math::cholesky_corr_free(x_vec);

EXPECT_EQ(y.size(), yrt[0].size());
for (int i = 0; i < yrt.size(); ++i) {
Expand All @@ -71,7 +72,8 @@ void test_cholesky_correlation_values(
std::vector<Matrix<double, Dynamic, Dynamic>> x2_vec
= stan::math::cholesky_corr_constrain<true>(y_vec, K, lp);

std::vector<Matrix<double, Dynamic, 1>> yrt2 = stan::math::cholesky_corr_free(x2_vec);
std::vector<Matrix<double, Dynamic, 1>> yrt2
= stan::math::cholesky_corr_free(x2_vec);

for (auto&& yrt_i : yrt2) {
EXPECT_EQ(y.size(), yrt_i.size());
Expand Down
3 changes: 2 additions & 1 deletion test/unit/math/prim/fun/cholesky_factor_transform_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ TEST(ProbTransform, choleskyFactor) {
Matrix<double, Dynamic, 1> x(3);
x << 1, 2, 3;
std::vector<Matrix<double, Dynamic, 1>> x_vec = {x, x, x};
std::vector<Matrix<double, Dynamic, Dynamic>> y_vec = cholesky_factor_constrain<false>(x_vec, 2, 2, lp);
std::vector<Matrix<double, Dynamic, Dynamic>> y_vec
= cholesky_factor_constrain<false>(x_vec, 2, 2, lp);

std::vector<Matrix<double, Dynamic, 1>> x2_vec = cholesky_factor_free(y_vec);

Expand Down
6 changes: 3 additions & 3 deletions test/unit/math/prim/fun/corr_matrix_transform_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ TEST(prob_transform, stdvec_corr_matrix_j) {
x << -1.0, 2.0, 0.0, 1.0, 3.0, -1.5;
std::vector<Eigen::VectorXd> x_vec = {x, x, x};
double lp = -12.9;
std::vector<Eigen::MatrixXd> y_vec = stan::math::corr_matrix_constrain<true>(x_vec, K, lp);
std::vector<Eigen::VectorXd> xrt_vec
= stan::math::corr_matrix_free(y_vec);
std::vector<Eigen::MatrixXd> y_vec
= stan::math::corr_matrix_constrain<true>(x_vec, K, lp);
std::vector<Eigen::VectorXd> xrt_vec = stan::math::corr_matrix_free(y_vec);
for (auto&& x_i : xrt_vec) {
EXPECT_MATRIX_FLOAT_EQ(x, x_i);
}
Expand Down
3 changes: 2 additions & 1 deletion test/unit/math/prim/fun/cov_matrix_transform_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ TEST(prob_transform, cov_matrix_rt) {
Matrix<double, Dynamic, 1> x(K_choose_2 + K);
x << -1.0, 2.0, 0.0, 1.0, 3.0, -1.5, 1.0, 2.0, -1.5, 2.5;
std::vector<Matrix<double, Dynamic, 1>> x_vec = {x, x, x};
std::vector<Matrix<double, Dynamic, Dynamic>> y_vec = stan::math::cov_matrix_constrain<false>(x_vec, K, lp);
std::vector<Matrix<double, Dynamic, Dynamic>> y_vec
= stan::math::cov_matrix_constrain<false>(x_vec, K, lp);
std::vector<Eigen::VectorXd> xrt = stan::math::cov_matrix_free(y_vec);
for (auto&& x_i : xrt) {
EXPECT_EQ(x.size(), x_i.size());
Expand Down
5 changes: 3 additions & 2 deletions test/unit/math/prim/fun/ordered_transform_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ TEST(prob_transform, ordered_rt) {
TEST(prob_transform, ordered_vectorized) {
double lp = 0;
Eigen::VectorXd x = Eigen::VectorXd::Random(4);
std::vector<Eigen::VectorXd> x_vec ={x, x, x};
std::vector<Eigen::VectorXd> y_vec = stan::math::ordered_constrain<false>(x_vec, lp);
std::vector<Eigen::VectorXd> x_vec = {x, x, x};
std::vector<Eigen::VectorXd> y_vec
= stan::math::ordered_constrain<false>(x_vec, lp);
std::vector<Eigen::VectorXd> x_free_vec = stan::math::ordered_free(y_vec);
for (int i = 0; i < x_vec.size(); ++i) {
EXPECT_MATRIX_FLOAT_EQ(x_vec[i], x_free_vec[i]);
Expand Down
9 changes: 5 additions & 4 deletions test/unit/math/prim/fun/positive_ordered_transform_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,14 @@ TEST(prob_transform, positive_ordered_rt) {
}
}


TEST(prob_transform, positive_ordered_vectorized) {
double lp = 0;
Eigen::VectorXd x = Eigen::VectorXd::Random(4);
std::vector<Eigen::VectorXd> x_vec ={x, x, x};
std::vector<Eigen::VectorXd> y_vec = stan::math::positive_ordered_constrain<false>(x_vec, lp);
std::vector<Eigen::VectorXd> x_free_vec = stan::math::positive_ordered_free(y_vec);
std::vector<Eigen::VectorXd> x_vec = {x, x, x};
std::vector<Eigen::VectorXd> y_vec
= stan::math::positive_ordered_constrain<false>(x_vec, lp);
std::vector<Eigen::VectorXd> x_free_vec
= stan::math::positive_ordered_free(y_vec);
for (int i = 0; i < x_vec.size(); ++i) {
EXPECT_MATRIX_FLOAT_EQ(x_vec[i], x_free_vec[i]);
}
Expand Down
5 changes: 3 additions & 2 deletions test/unit/math/prim/fun/positive_transform_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ TEST(prob_transform, positive_rt) {
TEST(prob_transform, positive_vectorized) {
double lp = 0;
Eigen::VectorXd x = Eigen::VectorXd::Random(4);
std::vector<Eigen::VectorXd> x_vec ={x, x, x};
std::vector<Eigen::VectorXd> y_vec = stan::math::positive_constrain<false>(x_vec, lp);
std::vector<Eigen::VectorXd> x_vec = {x, x, x};
std::vector<Eigen::VectorXd> y_vec
= stan::math::positive_constrain<false>(x_vec, lp);
std::vector<Eigen::VectorXd> x_free_vec = stan::math::positive_free(y_vec);
for (int i = 0; i < x_vec.size(); ++i) {
EXPECT_MATRIX_FLOAT_EQ(x_vec[i], x_free_vec[i]);
Expand Down
5 changes: 3 additions & 2 deletions test/unit/math/prim/fun/simplex_transform_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ TEST(prob_transform, simplex_rt0) {
Matrix<double, Dynamic, 1> x(4);
x << 0.0, 0.0, 0.0, 0.0;
std::vector<Matrix<double, Dynamic, 1>> x_vec{x, x, x};
std::vector<Matrix<double, Dynamic, 1>> y_vec = stan::math::simplex_constrain<false>(x_vec, lp);
std::vector<Matrix<double, Dynamic, 1>> y_vec
= stan::math::simplex_constrain<false>(x_vec, lp);
for (auto&& y_i : y_vec) {
EXPECT_MATRIX_FLOAT_EQ(Eigen::VectorXd::Constant(5, 1.0/5.0), y_i);
EXPECT_MATRIX_FLOAT_EQ(Eigen::VectorXd::Constant(5, 1.0 / 5.0), y_i);
}
std::vector<Matrix<double, Dynamic, 1>> xrt = stan::math::simplex_free(y_vec);
EXPECT_EQ(x.size() + 1, y_vec[2].size());
Expand Down
Loading

0 comments on commit 1b909ee

Please sign in to comment.