From 00a9f4302e2f937718f7e2b4ca62299d3811ab87 Mon Sep 17 00:00:00 2001 From: Steve Bronder Date: Tue, 1 Aug 2023 18:11:04 -0400 Subject: [PATCH 01/52] Adds move semantics for arena matrix types --- stan/math/prim/prob/normal_lpdf.hpp | 6 +- stan/math/rev/core/arena_matrix.hpp | 47 +++++++++++++- stan/math/rev/core/chainable_object.hpp | 6 +- stan/math/rev/core/operator_addition.hpp | 34 +++++----- stan/math/rev/fun/multiply.hpp | 64 +++++++++---------- test/unit/math/rev/core/arena_matrix_test.cpp | 11 ++++ 6 files changed, 111 insertions(+), 57 deletions(-) diff --git a/stan/math/prim/prob/normal_lpdf.hpp b/stan/math/prim/prob/normal_lpdf.hpp index af473f88311..2375a5ec064 100644 --- a/stan/math/prim/prob/normal_lpdf.hpp +++ b/stan/math/prim/prob/normal_lpdf.hpp @@ -41,9 +41,9 @@ namespace math { template * = nullptr> -inline return_type_t normal_lpdf(const T_y& y, - const T_loc& mu, - const T_scale& sigma) { +inline return_type_t normal_lpdf(T_y&& y, + T_loc&& mu, + T_scale&& sigma) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_if_t::value, T_y>; using T_mu_ref = ref_type_if_t::value, T_loc>; diff --git a/stan/math/rev/core/arena_matrix.hpp b/stan/math/rev/core/arena_matrix.hpp index 3d3b095fc74..03e1268a096 100644 --- a/stan/math/rev/core/arena_matrix.hpp +++ b/stan/math/rev/core/arena_matrix.hpp @@ -4,7 +4,7 @@ #include #include #include - +#include namespace stan { namespace math { @@ -73,6 +73,51 @@ class arena_matrix : public Eigen::Map { *this = other; } + /** + * Constructs `arena_matrix` from an expression. + * @param other expression + */ + template * = nullptr, + require_not_arena_matrix_t* = nullptr> + arena_matrix(T&& other) // NOLINT + : Base::Map([](auto&& x) { + using base_map_t = + typename stan::math::arena_matrix::Base::Map; + using T_t = std::decay_t; + if (std::is_rvalue_reference::value && is_plain_type::value) { + // Note: plain_type_t here does nothing since T_t is plain type + auto other = make_chainable_ptr(plain_type_t(std::move(x))); + return base_map_t( + &(other->coeffRef(0)), + (RowsAtCompileTime == 1 && T_t::ColsAtCompileTime == 1) + || (ColsAtCompileTime == 1 + && T_t::RowsAtCompileTime == 1) + ? other->cols() + : other->rows(), + (RowsAtCompileTime == 1 && T_t::ColsAtCompileTime == 1) + || (ColsAtCompileTime == 1 + && T_t::RowsAtCompileTime == 1) + ? other->rows() + : other->cols()); + } else { + base_map_t map( + ChainableStack::instance_->memalloc_.alloc_array( + x.size()), + (RowsAtCompileTime == 1 && T_t::ColsAtCompileTime == 1) + || (ColsAtCompileTime == 1 + && T_t::RowsAtCompileTime == 1) + ? x.cols() + : x.rows(), + (RowsAtCompileTime == 1 && T_t::ColsAtCompileTime == 1) + || (ColsAtCompileTime == 1 + && T_t::RowsAtCompileTime == 1) + ? x.rows() + : x.cols()); + map = x; + return map; + } + }(std::forward(other))) {} + /** * Constructs `arena_matrix` from an expression. This makes an assumption that * any other `Eigen::Map` also contains memory allocated in the arena. diff --git a/stan/math/rev/core/chainable_object.hpp b/stan/math/rev/core/chainable_object.hpp index 0631d88354c..d4e22bb966d 100644 --- a/stan/math/rev/core/chainable_object.hpp +++ b/stan/math/rev/core/chainable_object.hpp @@ -1,11 +1,9 @@ #ifndef STAN_MATH_REV_CORE_CHAINABLE_OBJECT_HPP #define STAN_MATH_REV_CORE_CHAINABLE_OBJECT_HPP -#include -#include -#include #include -#include +#include +#include #include namespace stan { diff --git a/stan/math/rev/core/operator_addition.hpp b/stan/math/rev/core/operator_addition.hpp index 2ecf9204379..458fc3c5ce3 100644 --- a/stan/math/rev/core/operator_addition.hpp +++ b/stan/math/rev/core/operator_addition.hpp @@ -108,12 +108,12 @@ inline var operator+(Arith a, const var& b) { */ template * = nullptr> -inline auto add(const VarMat1& a, const VarMat2& b) { +inline auto add(VarMat1&& a, VarMat2&& b) { check_matching_dims("add", "a", a, "b", b); using op_ret_type = decltype(a.val() + b.val()); using ret_type = return_var_matrix_t; - arena_t arena_a(a); - arena_t arena_b(b); + arena_t arena_a(std::forward(a)); + arena_t arena_b(std::forward(b)); arena_t ret(arena_a.val() + arena_b.val()); reverse_pass_callback([ret, arena_a, arena_b]() mutable { for (Eigen::Index j = 0; j < ret.cols(); ++j) { @@ -124,7 +124,7 @@ inline auto add(const VarMat1& a, const VarMat2& b) { } } }); - return ret_type(ret); + return ret; } /** @@ -139,18 +139,18 @@ inline auto add(const VarMat1& a, const VarMat2& b) { template * = nullptr, require_rev_matrix_t* = nullptr> -inline auto add(const VarMat& a, const Arith& b) { +inline auto add(VarMat&& a, const Arith& b) { if (is_eigen::value) { check_matching_dims("add", "a", a, "b", b); } using op_ret_type = decltype((a.val().array() + as_array_or_scalar(b)).matrix()); using ret_type = return_var_matrix_t; - arena_t arena_a(a); + arena_t arena_a(std::forward(a)); arena_t ret(arena_a.val().array() + as_array_or_scalar(b)); reverse_pass_callback( [ret, arena_a]() mutable { arena_a.adj() += ret.adj_op(); }); - return ret_type(ret); + return ret; } /** @@ -165,8 +165,8 @@ inline auto add(const VarMat& a, const Arith& b) { template * = nullptr, require_rev_matrix_t* = nullptr> -inline auto add(const Arith& a, const VarMat& b) { - return add(b, a); +inline auto add(const Arith& a, VarMat&& b) { + return add(std::forward(b), a); } /** @@ -185,7 +185,7 @@ inline auto add(const Var& a, const EigMat& b) { using ret_type = return_var_matrix_t; arena_t ret(a.val() + b.array()); reverse_pass_callback([ret, a]() mutable { a.adj() += ret.adj().sum(); }); - return ret_type(ret); + return ret; } /** @@ -217,9 +217,9 @@ inline auto add(const EigMat& a, const Var& b) { template * = nullptr, require_rev_matrix_t* = nullptr> -inline auto add(const Var& a, const VarMat& b) { +inline auto add(const Var& a, VarMat&& b) { using ret_type = return_var_matrix_t; - arena_t arena_b(b); + arena_t arena_b(std::forward(b)); arena_t ret(a.val() + arena_b.val().array()); reverse_pass_callback([ret, a, arena_b]() mutable { for (Eigen::Index j = 0; j < ret.cols(); ++j) { @@ -230,7 +230,7 @@ inline auto add(const Var& a, const VarMat& b) { } } }); - return ret_type(ret); + return ret; } /** @@ -246,8 +246,8 @@ inline auto add(const Var& a, const VarMat& b) { template * = nullptr, require_rev_matrix_t* = nullptr> -inline auto add(const VarMat& a, const Var& b) { - return add(b, a); +inline auto add(VarMat&& a, const Var& b) { + return add(b, std::forward(a)); } template * = nullptr> -inline auto operator+(const VarMat1& a, const VarMat2& b) { - return add(a, b); +inline auto operator+(VarMat1&& a, VarMat2&& b) { + return add(std::forward(a), std::forward(b)); } } // namespace math diff --git a/stan/math/rev/fun/multiply.hpp b/stan/math/rev/fun/multiply.hpp index 6851952a721..a2c1348896a 100644 --- a/stan/math/rev/fun/multiply.hpp +++ b/stan/math/rev/fun/multiply.hpp @@ -26,11 +26,11 @@ namespace math { template * = nullptr, require_return_type_t* = nullptr, require_not_row_and_col_vector_t* = nullptr> -inline auto multiply(const T1& A, const T2& B) { +inline auto multiply(T1&& A, T2&& B) { check_multiplicable("multiply", "A", A, "B", B); if (!is_constant::value && !is_constant::value) { - arena_t> arena_A = A; - arena_t> arena_B = B; + arena_t> arena_A(std::forward(A)); + arena_t> arena_B(std::forward(B)); auto arena_A_val = to_arena(arena_A.val()); auto arena_B_val = to_arena(arena_B.val()); using return_t @@ -48,19 +48,19 @@ inline auto multiply(const T1& A, const T2& B) { arena_B.adj() += arena_A_val.transpose() * res_adj; } }); - return return_t(res); + return res; } else if (!is_constant::value) { arena_t> arena_A = value_of(A); - arena_t> arena_B = B; + arena_t> arena_B(std::forward(B)); using return_t = return_var_matrix_t; arena_t res = arena_A * arena_B.val_op(); reverse_pass_callback([arena_B, arena_A, res]() mutable { arena_B.adj() += arena_A.transpose() * res.adj_op(); }); - return return_t(res); + return res; } else { - arena_t> arena_A = A; + arena_t> arena_A(std::forward(A)); arena_t> arena_B = value_of(B); using return_t = return_var_matrix_t* = nullptr, require_matrix_t* = nullptr, require_return_type_t* = nullptr, require_not_row_and_col_vector_t* = nullptr> -inline auto multiply(const T1& A, const T2& B) { +inline auto multiply(const T1& a, T2&& B) { if (!is_constant::value && !is_constant::value) { - arena_t> arena_A = A; - arena_t> arena_B = B; + arena_t> arena_B(std::forward(B)); using return_t = return_var_matrix_t; - arena_t res = arena_A.val() * arena_B.val().array(); - reverse_pass_callback([arena_A, arena_B, res]() mutable { - const auto a_val = arena_A.val(); + var av = a; + auto a_val = value_of(av); + arena_t res = a_val * arena_B.val().array(); + reverse_pass_callback([av, a_val, arena_B, res]() mutable { for (Eigen::Index j = 0; j < res.cols(); ++j) { for (Eigen::Index i = 0; i < res.rows(); ++i) { const auto res_adj = res.adj().coeffRef(i, j); - arena_A.adj() += res_adj * arena_B.val().coeff(i, j); + av.adj() += res_adj * arena_B.val().coeff(i, j); arena_B.adj().coeffRef(i, j) += a_val * res_adj; } } }); - return return_t(res); + return res; } else if (!is_constant::value) { - arena_t> arena_A = value_of(A); - arena_t> arena_B = B; + double val_a = value_of(a); + arena_t> arena_B(std::forward(B)); using return_t = return_var_matrix_t; - arena_t res = arena_A * arena_B.val().array(); - reverse_pass_callback([arena_A, arena_B, res]() mutable { - arena_B.adj().array() += arena_A * res.adj().array(); + arena_t res = val_a * arena_B.val().array(); + reverse_pass_callback([val_a, arena_B, res]() mutable { + arena_B.adj().array() += val_a * res.adj().array(); }); - return return_t(res); + return res; } else { - arena_t> arena_A = A; + var av = a; arena_t> arena_B = value_of(B); using return_t = return_var_matrix_t; - arena_t res = arena_A.val() * arena_B.array(); - reverse_pass_callback([arena_A, arena_B, res]() mutable { - arena_A.adj() += (res.adj().array() * arena_B.array()).sum(); + arena_t res = av.val() * arena_B.array(); + reverse_pass_callback([av, arena_B, res]() mutable { + av.adj() += (res.adj().array() * arena_B.array()).sum(); }); - return return_t(res); + return res; } } @@ -192,8 +192,8 @@ template * = nullptr, require_not_complex_t>* = nullptr, require_not_complex_t>* = nullptr, require_not_row_and_col_vector_t* = nullptr> -inline auto multiply(const T1& A, const T2& B) { - return multiply(B, A); +inline auto multiply(T1&& A, T2&& B) { + return multiply(std::forward(B), std::forward(A)); } /** @@ -207,8 +207,8 @@ inline auto multiply(const T1& A, const T2& B) { * @param b The right hand side of the multiplication */ template * = nullptr> -inline auto operator*(const T1& a, const T2& b) { - return multiply(a, b); +inline auto operator*(T1&& a, T2&& b) { + return multiply(std::forward(a), std::forward(b)); } } // namespace math diff --git a/test/unit/math/rev/core/arena_matrix_test.cpp b/test/unit/math/rev/core/arena_matrix_test.cpp index 1bc59cac007..6ecdef0c665 100644 --- a/test/unit/math/rev/core/arena_matrix_test.cpp +++ b/test/unit/math/rev/core/arena_matrix_test.cpp @@ -20,6 +20,7 @@ TEST(AgradRevArenaMat, arena_matrix_matrix_test) { a = c; a2 = std::move(d); a3 = 2 * a; + b = d; b2 = std::move(c); e = e + a; @@ -104,3 +105,13 @@ TEST(AgradRevArenaMat, arena_matrix_transpose_test) { stan::math::recover_memory(); } + +TEST(AgradRevArenaMat, arena_matrix_move_test) { + using stan::math::arena_matrix; + Eigen::VectorXd c = Eigen::VectorXd::Random(3); + Eigen::VectorXd d = c; + arena_matrix a(std::move(c)); + EXPECT_MATRIX_EQ(a, d); + EXPECT_EQ(stan::math::ChainableStack::instance_->var_alloc_stack_.size(), 1); + stan::math::recover_memory(); +} \ No newline at end of file From 056e29753cdc341587d2ac23f2f9e8e458425de7 Mon Sep 17 00:00:00 2001 From: Steve Bronder Date: Wed, 2 Aug 2023 10:41:17 -0400 Subject: [PATCH 02/52] use forwarding in sum --- stan/math/rev/fun/sum.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stan/math/rev/fun/sum.hpp b/stan/math/rev/fun/sum.hpp index 832ce2c8719..9f4ba90ec5b 100644 --- a/stan/math/rev/fun/sum.hpp +++ b/stan/math/rev/fun/sum.hpp @@ -44,8 +44,8 @@ inline var sum(const std::vector& m) { * @return Sum of coefficients of matrix. */ template * = nullptr> -inline var sum(const T& x) { - arena_t x_arena = x; +inline var sum(T&& x) { + arena_t x_arena(std::forward(x)); return make_callback_var(sum(x_arena.val()), [x_arena](auto& vi) mutable { x_arena.adj().array() += vi.adj(); }); From 3a6c11eae5517c07697091a09013a09e5b5d1c99 Mon Sep 17 00:00:00 2001 From: Steve Bronder Date: Wed, 2 Aug 2023 15:45:14 -0400 Subject: [PATCH 03/52] add docs related to auto dangers with the math library --- .../contributor_help_pages/common_pitfalls.md | 16 ++++++++++++++++ stan/math/rev/core/arena_matrix.hpp | 7 +++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/doxygen/contributor_help_pages/common_pitfalls.md b/doxygen/contributor_help_pages/common_pitfalls.md index f3e8fb817ad..b126b6be1fc 100644 --- a/doxygen/contributor_help_pages/common_pitfalls.md +++ b/doxygen/contributor_help_pages/common_pitfalls.md @@ -190,6 +190,22 @@ The general rules to follow for passing values to a function are: 2. If you are writing a function for reverse mode, pass values by `const&` 3. In prim, if you are confident and working with larger types, use perfect forwarding to pass values that can be moved from. Otherwise simply pass values by `const&`. + +### Using auto is Dangerous With Eigen Matrix Functions in Reverse Mode + + +```c++ +Eigen::Matrix y; +Eigen::Matrix X; +// Bad!! Will change memory used by reverse pass callback within multiply! +auto mu = multiply(X, y); +mu(4) = 1.0; +// Good! Will not change memory used by reverse pass callback within multiply +auto mu_good = multiply(X, y); +mu_good(4) = 1.0; +``` + + ### Passing variables that need destructors called after the reverse pass (`make_chainable_ptr`) When possible, non-arena variables should be copied to the arena to be used in the reverse pass. diff --git a/stan/math/rev/core/arena_matrix.hpp b/stan/math/rev/core/arena_matrix.hpp index 03e1268a096..9a8761d536a 100644 --- a/stan/math/rev/core/arena_matrix.hpp +++ b/stan/math/rev/core/arena_matrix.hpp @@ -54,7 +54,7 @@ class arena_matrix : public Eigen::Map { size) {} /** - * Constructs `arena_matrix` from an expression. + * Constructs `arena_matrix` from an expression * @param other expression */ template * = nullptr> @@ -74,8 +74,11 @@ class arena_matrix : public Eigen::Map { } /** - * Constructs `arena_matrix` from an expression. + * Constructs `arena_matrix` from an expression, then send it to either the object stack or memory arena. + * @tparam T A type that inherits from Eigen::DenseBase that is not an `arena_matrix`. * @param other expression + * @note When T is both an rvalue and a plain type, the expression is moved to the object stack. However + * when T is an lvalue, or an rvalue that is not a plain type, the expression is copied to the memory arena. */ template * = nullptr, require_not_arena_matrix_t* = nullptr> From fa8a464ac47b5a44bf85b3ca9756b8921a3a8693 Mon Sep 17 00:00:00 2001 From: Steve Bronder Date: Wed, 2 Aug 2023 15:45:38 -0400 Subject: [PATCH 04/52] add docs related to auto dangers with the math library --- .../contributor_help_pages/common_pitfalls.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/doxygen/contributor_help_pages/common_pitfalls.md b/doxygen/contributor_help_pages/common_pitfalls.md index b126b6be1fc..9fecb241989 100644 --- a/doxygen/contributor_help_pages/common_pitfalls.md +++ b/doxygen/contributor_help_pages/common_pitfalls.md @@ -193,6 +193,9 @@ The general rules to follow for passing values to a function are: ### Using auto is Dangerous With Eigen Matrix Functions in Reverse Mode +Like in [Eigen](https://eigen.tuxfamily.org/dox/TopicPitfalls.html), the use of `auto` with the Stan math library should be used with care. Along with the cautions mentioned in the Eigen docs, there are also memory considerations when using reverse mode automatic differentiation. When returning from a function in the Stan math library with an Eigen matrix output with a scalar `var` type, the actual returned type will often be an `arena_matrix>`. The `arena_matrix` class is an Eigen matrix where the underlying array of memory is located in Stan's memory arena. The `arena_matrix` that is returned by Stan functions is normally the same one resting in the callback used to calculate gradients in the reverse pass. Directly changing the elements of this matrix would also change the memory the reverse pass callback sees which would result in incorrect calculations. + +The simple solution to this is that when you use a math library function that returns a matrix and then want to assign to any of the individual elements of the matrix, assign to an actual Eigen matrix type instead of using auto. In the below example, we see the first case which uses auto and will change the memory of the `arena_matrix` returned in the callback for multiply's reverse mode. Directly below it is the safe version, which just directly assigns to an Eigen matrix type and is safe to do element insertion into. ```c++ Eigen::Matrix y; @@ -201,10 +204,23 @@ Eigen::Matrix X; auto mu = multiply(X, y); mu(4) = 1.0; // Good! Will not change memory used by reverse pass callback within multiply -auto mu_good = multiply(X, y); +Eigen::Matrix mu_good = multiply(X, y); mu_good(4) = 1.0; ``` +The reason we do this is for cases where functions returns are passe to other functions. An `arena_matrix` will always make a shallow copy when being constructed from another `arena_matrix`, which let's the functions avoid unnecessary copies. + +```c++ +Eigen::Matrix y1; +Eigen::Matrix X1; +Eigen::Matrix y2; +Eigen::Matrix X2; +auto mu1 = multiply(X1, y1); +auto mu2 = multiply(X2, y2); +// Inputs not copied in this case! +auto z = add(mu1, mu2); +``` + ### Passing variables that need destructors called after the reverse pass (`make_chainable_ptr`) From 3f0788493b8ac26cfebdeb51be1af9cfd2f41f1b Mon Sep 17 00:00:00 2001 From: Stan Jenkins Date: Wed, 2 Aug 2023 15:50:50 -0400 Subject: [PATCH 05/52] [Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1 --- stan/math/prim/prob/normal_lpdf.hpp | 3 +-- stan/math/rev/core/arena_matrix.hpp | 17 +++++++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/stan/math/prim/prob/normal_lpdf.hpp b/stan/math/prim/prob/normal_lpdf.hpp index 2375a5ec064..45b39ffcc4a 100644 --- a/stan/math/prim/prob/normal_lpdf.hpp +++ b/stan/math/prim/prob/normal_lpdf.hpp @@ -41,8 +41,7 @@ namespace math { template * = nullptr> -inline return_type_t normal_lpdf(T_y&& y, - T_loc&& mu, +inline return_type_t normal_lpdf(T_y&& y, T_loc&& mu, T_scale&& sigma) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_if_t::value, T_y>; diff --git a/stan/math/rev/core/arena_matrix.hpp b/stan/math/rev/core/arena_matrix.hpp index 9a8761d536a..15131470a62 100644 --- a/stan/math/rev/core/arena_matrix.hpp +++ b/stan/math/rev/core/arena_matrix.hpp @@ -74,11 +74,14 @@ class arena_matrix : public Eigen::Map { } /** - * Constructs `arena_matrix` from an expression, then send it to either the object stack or memory arena. - * @tparam T A type that inherits from Eigen::DenseBase that is not an `arena_matrix`. + * Constructs `arena_matrix` from an expression, then send it to either the + * object stack or memory arena. + * @tparam T A type that inherits from Eigen::DenseBase that is not an + * `arena_matrix`. * @param other expression - * @note When T is both an rvalue and a plain type, the expression is moved to the object stack. However - * when T is an lvalue, or an rvalue that is not a plain type, the expression is copied to the memory arena. + * @note When T is both an rvalue and a plain type, the expression is moved to + * the object stack. However when T is an lvalue, or an rvalue that is not a + * plain type, the expression is copied to the memory arena. */ template * = nullptr, require_not_arena_matrix_t* = nullptr> @@ -87,9 +90,11 @@ class arena_matrix : public Eigen::Map { using base_map_t = typename stan::math::arena_matrix::Base::Map; using T_t = std::decay_t; - if (std::is_rvalue_reference::value && is_plain_type::value) { + if (std::is_rvalue_reference::value + && is_plain_type::value) { // Note: plain_type_t here does nothing since T_t is plain type - auto other = make_chainable_ptr(plain_type_t(std::move(x))); + auto other + = make_chainable_ptr(plain_type_t(std::move(x))); return base_map_t( &(other->coeffRef(0)), (RowsAtCompileTime == 1 && T_t::ColsAtCompileTime == 1) From e5e226b033027d2527d26ceb417df3696ce687c8 Mon Sep 17 00:00:00 2001 From: Steve Bronder Date: Wed, 2 Aug 2023 16:50:54 -0400 Subject: [PATCH 06/52] newline --- test/unit/math/rev/core/arena_matrix_test.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/unit/math/rev/core/arena_matrix_test.cpp b/test/unit/math/rev/core/arena_matrix_test.cpp index 6ecdef0c665..20d47c18938 100644 --- a/test/unit/math/rev/core/arena_matrix_test.cpp +++ b/test/unit/math/rev/core/arena_matrix_test.cpp @@ -114,4 +114,5 @@ TEST(AgradRevArenaMat, arena_matrix_move_test) { EXPECT_MATRIX_EQ(a, d); EXPECT_EQ(stan::math::ChainableStack::instance_->var_alloc_stack_.size(), 1); stan::math::recover_memory(); -} \ No newline at end of file +} + From 53dc3995122ccbaacebb173ef1b374928658491d Mon Sep 17 00:00:00 2001 From: Stan Jenkins Date: Wed, 2 Aug 2023 16:52:10 -0400 Subject: [PATCH 07/52] [Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1 --- test/unit/math/rev/core/arena_matrix_test.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/test/unit/math/rev/core/arena_matrix_test.cpp b/test/unit/math/rev/core/arena_matrix_test.cpp index 20d47c18938..9d955dd86fa 100644 --- a/test/unit/math/rev/core/arena_matrix_test.cpp +++ b/test/unit/math/rev/core/arena_matrix_test.cpp @@ -115,4 +115,3 @@ TEST(AgradRevArenaMat, arena_matrix_move_test) { EXPECT_EQ(stan::math::ChainableStack::instance_->var_alloc_stack_.size(), 1); stan::math::recover_memory(); } - From fcca84d7dbdc3482480244b7bf9120a8ede67078 Mon Sep 17 00:00:00 2001 From: Steve Bronder Date: Wed, 2 Aug 2023 18:10:51 -0400 Subject: [PATCH 08/52] fix constructor alias bug --- stan/math/prim/fun/hypergeometric_2F1.hpp | 1 + stan/math/rev/core/arena_matrix.hpp | 2 +- stan/math/rev/fun/hypergeometric_2F1.hpp | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/stan/math/prim/fun/hypergeometric_2F1.hpp b/stan/math/prim/fun/hypergeometric_2F1.hpp index d66f14f1ac8..be3891d1596 100644 --- a/stan/math/prim/fun/hypergeometric_2F1.hpp +++ b/stan/math/prim/fun/hypergeometric_2F1.hpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include diff --git a/stan/math/rev/core/arena_matrix.hpp b/stan/math/rev/core/arena_matrix.hpp index 15131470a62..989b37c0b50 100644 --- a/stan/math/rev/core/arena_matrix.hpp +++ b/stan/math/rev/core/arena_matrix.hpp @@ -88,7 +88,7 @@ class arena_matrix : public Eigen::Map { arena_matrix(T&& other) // NOLINT : Base::Map([](auto&& x) { using base_map_t = - typename stan::math::arena_matrix::Base::Map; + typename stan::math::arena_matrix::Base; using T_t = std::decay_t; if (std::is_rvalue_reference::value && is_plain_type::value) { diff --git a/stan/math/rev/fun/hypergeometric_2F1.hpp b/stan/math/rev/fun/hypergeometric_2F1.hpp index 3b57a66790d..43b83be3af1 100644 --- a/stan/math/rev/fun/hypergeometric_2F1.hpp +++ b/stan/math/rev/fun/hypergeometric_2F1.hpp @@ -6,6 +6,8 @@ #include #include + + namespace stan { namespace math { From 2f42a0acf53e1a397d28d25d54f1a97e80d0592c Mon Sep 17 00:00:00 2001 From: Stan Jenkins Date: Wed, 2 Aug 2023 18:12:09 -0400 Subject: [PATCH 09/52] [Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1 --- stan/math/rev/fun/hypergeometric_2F1.hpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/stan/math/rev/fun/hypergeometric_2F1.hpp b/stan/math/rev/fun/hypergeometric_2F1.hpp index 43b83be3af1..3b57a66790d 100644 --- a/stan/math/rev/fun/hypergeometric_2F1.hpp +++ b/stan/math/rev/fun/hypergeometric_2F1.hpp @@ -6,8 +6,6 @@ #include #include - - namespace stan { namespace math { From 418936769a6cde656ab904577b59173247008b3f Mon Sep 17 00:00:00 2001 From: Steve Bronder Date: Thu, 3 Aug 2023 10:56:02 -0400 Subject: [PATCH 10/52] fix normal_lpdf templates --- stan/math/prim/prob/normal_log.hpp | 16 ++++++++-------- stan/math/prim/prob/normal_lpdf.hpp | 6 +++--- test/unit/math/prim/prob/normal_log_test.cpp | 12 ++++++------ 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/stan/math/prim/prob/normal_log.hpp b/stan/math/prim/prob/normal_log.hpp index 962d6657f08..cc82e2f112f 100644 --- a/stan/math/prim/prob/normal_log.hpp +++ b/stan/math/prim/prob/normal_log.hpp @@ -29,20 +29,20 @@ namespace math { * @tparam T_loc Type of location parameter. */ template -inline return_type_t normal_log(const T_y& y, - const T_loc& mu, - const T_scale& sigma) { - return normal_lpdf(y, mu, sigma); +inline return_type_t normal_log(T_y&& y, + T_loc&& mu, + T_scale&& sigma) { + return normal_lpdf(y, mu, sigma); } /** \ingroup prob_dists * @deprecated use normal_lpdf */ template -inline return_type_t normal_log(const T_y& y, - const T_loc& mu, - const T_scale& sigma) { - return normal_lpdf(y, mu, sigma); +inline return_type_t normal_log(T_y&& y, + T_loc&& mu, + T_scale&& sigma) { + return normal_lpdf(y, mu, sigma); } } // namespace math diff --git a/stan/math/prim/prob/normal_lpdf.hpp b/stan/math/prim/prob/normal_lpdf.hpp index 45b39ffcc4a..5b26f260017 100644 --- a/stan/math/prim/prob/normal_lpdf.hpp +++ b/stan/math/prim/prob/normal_lpdf.hpp @@ -105,9 +105,9 @@ inline return_type_t normal_lpdf(T_y&& y, T_loc&& mu, } template -inline return_type_t normal_lpdf(const T_y& y, - const T_loc& mu, - const T_scale& sigma) { +inline return_type_t normal_lpdf(T_y&& y, + T_loc&& mu, + T_scale&& sigma) { return normal_lpdf(y, mu, sigma); } diff --git a/test/unit/math/prim/prob/normal_log_test.cpp b/test/unit/math/prim/prob/normal_log_test.cpp index fc4906fdc7b..75528558b69 100644 --- a/test/unit/math/prim/prob/normal_log_test.cpp +++ b/test/unit/math/prim/prob/normal_log_test.cpp @@ -13,12 +13,12 @@ TEST(ProbNormal, log_matches_lpdf) { EXPECT_FLOAT_EQ((stan::math::normal_lpdf(y, mu, sigma)), (stan::math::normal_log(y, mu, sigma))); EXPECT_FLOAT_EQ( - (stan::math::normal_lpdf(y, mu, sigma)), - (stan::math::normal_log(y, mu, sigma))); + (stan::math::normal_lpdf(y, mu, sigma)), + (stan::math::normal_log(y, mu, sigma))); EXPECT_FLOAT_EQ( - (stan::math::normal_lpdf(y, mu, sigma)), - (stan::math::normal_log(y, mu, sigma))); + (stan::math::normal_lpdf(y, mu, sigma)), + (stan::math::normal_log(y, mu, sigma))); EXPECT_FLOAT_EQ( - (stan::math::normal_lpdf(y, mu, sigma)), - (stan::math::normal_log(y, mu, sigma))); + (stan::math::normal_lpdf(y, mu, sigma)), + (stan::math::normal_log(y, mu, sigma))); } From 5b76fc884c8bd846acef4cb3a1edfa251d146b0e Mon Sep 17 00:00:00 2001 From: Stan Jenkins Date: Thu, 3 Aug 2023 10:57:12 -0400 Subject: [PATCH 11/52] [Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1 --- stan/math/prim/prob/normal_log.hpp | 6 ++---- stan/math/prim/prob/normal_lpdf.hpp | 3 +-- test/unit/math/prim/prob/normal_log_test.cpp | 15 ++++++--------- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/stan/math/prim/prob/normal_log.hpp b/stan/math/prim/prob/normal_log.hpp index cc82e2f112f..3d007dfea26 100644 --- a/stan/math/prim/prob/normal_log.hpp +++ b/stan/math/prim/prob/normal_log.hpp @@ -29,8 +29,7 @@ namespace math { * @tparam T_loc Type of location parameter. */ template -inline return_type_t normal_log(T_y&& y, - T_loc&& mu, +inline return_type_t normal_log(T_y&& y, T_loc&& mu, T_scale&& sigma) { return normal_lpdf(y, mu, sigma); } @@ -39,8 +38,7 @@ inline return_type_t normal_log(T_y&& y, * @deprecated use normal_lpdf */ template -inline return_type_t normal_log(T_y&& y, - T_loc&& mu, +inline return_type_t normal_log(T_y&& y, T_loc&& mu, T_scale&& sigma) { return normal_lpdf(y, mu, sigma); } diff --git a/stan/math/prim/prob/normal_lpdf.hpp b/stan/math/prim/prob/normal_lpdf.hpp index 5b26f260017..1921506c120 100644 --- a/stan/math/prim/prob/normal_lpdf.hpp +++ b/stan/math/prim/prob/normal_lpdf.hpp @@ -105,8 +105,7 @@ inline return_type_t normal_lpdf(T_y&& y, T_loc&& mu, } template -inline return_type_t normal_lpdf(T_y&& y, - T_loc&& mu, +inline return_type_t normal_lpdf(T_y&& y, T_loc&& mu, T_scale&& sigma) { return normal_lpdf(y, mu, sigma); } diff --git a/test/unit/math/prim/prob/normal_log_test.cpp b/test/unit/math/prim/prob/normal_log_test.cpp index 75528558b69..3e4c618dbdb 100644 --- a/test/unit/math/prim/prob/normal_log_test.cpp +++ b/test/unit/math/prim/prob/normal_log_test.cpp @@ -12,13 +12,10 @@ TEST(ProbNormal, log_matches_lpdf) { (stan::math::normal_log(y, mu, sigma))); EXPECT_FLOAT_EQ((stan::math::normal_lpdf(y, mu, sigma)), (stan::math::normal_log(y, mu, sigma))); - EXPECT_FLOAT_EQ( - (stan::math::normal_lpdf(y, mu, sigma)), - (stan::math::normal_log(y, mu, sigma))); - EXPECT_FLOAT_EQ( - (stan::math::normal_lpdf(y, mu, sigma)), - (stan::math::normal_log(y, mu, sigma))); - EXPECT_FLOAT_EQ( - (stan::math::normal_lpdf(y, mu, sigma)), - (stan::math::normal_log(y, mu, sigma))); + EXPECT_FLOAT_EQ((stan::math::normal_lpdf(y, mu, sigma)), + (stan::math::normal_log(y, mu, sigma))); + EXPECT_FLOAT_EQ((stan::math::normal_lpdf(y, mu, sigma)), + (stan::math::normal_log(y, mu, sigma))); + EXPECT_FLOAT_EQ((stan::math::normal_lpdf(y, mu, sigma)), + (stan::math::normal_log(y, mu, sigma))); } From 5fbaf55f1ce3d931f9e9a2938ba67ca85f8cd939 Mon Sep 17 00:00:00 2001 From: Steve Bronder Date: Fri, 4 Aug 2023 16:27:14 -0400 Subject: [PATCH 12/52] fix transpose issues with arena matrix --- stan/math/rev/core/arena_matrix.hpp | 54 ++++++++++++++-------------- stan/math/rev/fun/fill.hpp | 4 +-- test/unit/math/rev/core/var_test.cpp | 8 +---- test/unit/math/rev/fun/fill_test.cpp | 15 ++++---- test/unit/math/rev/util.hpp | 11 ++++++ 5 files changed, 49 insertions(+), 43 deletions(-) diff --git a/stan/math/rev/core/arena_matrix.hpp b/stan/math/rev/core/arena_matrix.hpp index 989b37c0b50..64467e19a35 100644 --- a/stan/math/rev/core/arena_matrix.hpp +++ b/stan/math/rev/core/arena_matrix.hpp @@ -95,18 +95,8 @@ class arena_matrix : public Eigen::Map { // Note: plain_type_t here does nothing since T_t is plain type auto other = make_chainable_ptr(plain_type_t(std::move(x))); - return base_map_t( - &(other->coeffRef(0)), - (RowsAtCompileTime == 1 && T_t::ColsAtCompileTime == 1) - || (ColsAtCompileTime == 1 - && T_t::RowsAtCompileTime == 1) - ? other->cols() - : other->rows(), - (RowsAtCompileTime == 1 && T_t::ColsAtCompileTime == 1) - || (ColsAtCompileTime == 1 - && T_t::RowsAtCompileTime == 1) - ? other->rows() - : other->cols()); + // other has it's rows and cols swapped already if it needed that + return base_map_t(&(other->coeffRef(0)), other->rows(), other->cols()); } else { base_map_t map( ChainableStack::instance_->memalloc_.alloc_array( @@ -163,23 +153,33 @@ class arena_matrix : public Eigen::Map { * @param a expression to evaluate into this * @return `*this` */ - template - arena_matrix& operator=(const T& a) { - // do we need to transpose? - if ((RowsAtCompileTime == 1 && T::ColsAtCompileTime == 1) - || (ColsAtCompileTime == 1 && T::RowsAtCompileTime == 1)) { - // placement new changes what data map points to - there is no allocation - new (this) Base( - ChainableStack::instance_->memalloc_.alloc_array(a.size()), - a.cols(), a.rows()); - + template * = nullptr> + arena_matrix& operator=(T&& a) { + using T_t = std::decay_t; + if (std::is_rvalue_reference::value + && is_plain_type::value) { + // Note: plain_type_t here does nothing since T_t is plain type + auto other + = make_chainable_ptr(plain_type_t(std::move(a))); + new (this) Base(&(other->coeffRef(0)), other->rows(), other->cols()); + return *this; } else { - new (this) Base( - ChainableStack::instance_->memalloc_.alloc_array(a.size()), - a.rows(), a.cols()); + // do we need to transpose? + if ((RowsAtCompileTime == 1 && T_t::ColsAtCompileTime == 1) + || (ColsAtCompileTime == 1 && T_t::RowsAtCompileTime == 1)) { + // placement new changes what data map points to - there is no allocation + new (this) Base( + ChainableStack::instance_->memalloc_.alloc_array(a.size()), + a.cols(), a.rows()); + + } else { + new (this) Base( + ChainableStack::instance_->memalloc_.alloc_array(a.size()), + a.rows(), a.cols()); + } + Base::operator=(a); + return *this; } - Base::operator=(a); - return *this; } }; diff --git a/stan/math/rev/fun/fill.hpp b/stan/math/rev/fun/fill.hpp index 2445c354537..703a2c657b6 100644 --- a/stan/math/rev/fun/fill.hpp +++ b/stan/math/rev/fun/fill.hpp @@ -23,7 +23,7 @@ namespace math { template * = nullptr, require_var_t* = nullptr> inline void fill(VarMat& x, const S& y) { - arena_t>> prev_vals = x.val().eval(); + arena_t>> prev_vals(x.val().eval()); x.vi_->val_.fill(y.val()); reverse_pass_callback([x, y, prev_vals]() mutable { x.vi_->val_ = prev_vals; @@ -46,7 +46,7 @@ inline void fill(VarMat& x, const S& y) { template * = nullptr, require_arithmetic_t* = nullptr> inline void fill(VarMat& x, const S& y) { - arena_t>> prev_vals = x.val().eval(); + arena_t>> prev_vals(x.val().eval()); x.vi_->val_.fill(y); reverse_pass_callback([x, prev_vals]() mutable { x.vi_->val_ = prev_vals; diff --git a/test/unit/math/rev/core/var_test.cpp b/test/unit/math/rev/core/var_test.cpp index be133e754c2..00a3d5954dd 100644 --- a/test/unit/math/rev/core/var_test.cpp +++ b/test/unit/math/rev/core/var_test.cpp @@ -2,19 +2,13 @@ #include #include #include +#include #include #include #include #include #include -struct AgradRev : public testing::Test { - void SetUp() { - // make sure memory's clean before starting each test - stan::math::recover_memory(); - } -}; - namespace stan { namespace test { template diff --git a/test/unit/math/rev/fun/fill_test.cpp b/test/unit/math/rev/fun/fill_test.cpp index 5a3fb8476b0..fa328aa0a68 100644 --- a/test/unit/math/rev/fun/fill_test.cpp +++ b/test/unit/math/rev/fun/fill_test.cpp @@ -1,9 +1,10 @@ #include -#include #include +#include +#include #include -TEST(AgradRevMatrix, fill) { +TEST_F(AgradRev, fill) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::fill; @@ -43,7 +44,7 @@ TEST(AgradRevMatrix, fill) { for (size_t j = 0; j < 2; ++j) EXPECT_FLOAT_EQ(54, d[i][j].val()); } -TEST(AgradRevMatrix, fillDouble) { +TEST_F(AgradRev, fillDouble) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::fill; @@ -53,13 +54,13 @@ TEST(AgradRevMatrix, fillDouble) { EXPECT_FLOAT_EQ(3.0, y[0]); } -TEST(AgradRevMatrix, fillVarMatDouble) { +TEST_F(AgradRev, fillVarMatDouble) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::fill; using stan::math::sum; using stan::math::var_value; - Matrix y_val(3); + Matrix y_val = Matrix::Constant(3, 2.0); var_value> y(y_val); fill(y, 3.0); EXPECT_EQ(3, y.size()); @@ -71,14 +72,14 @@ TEST(AgradRevMatrix, fillVarMatDouble) { } } -TEST(AgradRevMatrix, fillVarMatVar) { +TEST_F(AgradRev, fillVarMatVar) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::fill; using stan::math::sum; using stan::math::var; using stan::math::var_value; - Matrix y_val(3); + Matrix y_val = Matrix::Constant(3, 2.0); var_value> y(y_val); var z(3.0); fill(y, z); diff --git a/test/unit/math/rev/util.hpp b/test/unit/math/rev/util.hpp index 20b2934561e..3725aa1da0b 100644 --- a/test/unit/math/rev/util.hpp +++ b/test/unit/math/rev/util.hpp @@ -5,6 +5,17 @@ #include #include +struct AgradRev : public testing::Test { + void SetUp() { + // make sure memory's clean before starting each test + stan::math::recover_memory(); + } + void TearDown() { + // make sure memory's clean after each test + stan::math::recover_memory(); + } +}; + namespace stan { namespace math { namespace test { From 119099d091d8d463c0f2e2e54be848b3aa1498ec Mon Sep 17 00:00:00 2001 From: Stan Jenkins Date: Fri, 4 Aug 2023 16:28:44 -0400 Subject: [PATCH 13/52] [Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1 --- stan/math/rev/core/arena_matrix.hpp | 46 ++++++++++++++-------------- test/unit/math/rev/fun/fill_test.cpp | 6 ++-- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/stan/math/rev/core/arena_matrix.hpp b/stan/math/rev/core/arena_matrix.hpp index 64467e19a35..ed5ee3102ab 100644 --- a/stan/math/rev/core/arena_matrix.hpp +++ b/stan/math/rev/core/arena_matrix.hpp @@ -96,7 +96,8 @@ class arena_matrix : public Eigen::Map { auto other = make_chainable_ptr(plain_type_t(std::move(x))); // other has it's rows and cols swapped already if it needed that - return base_map_t(&(other->coeffRef(0)), other->rows(), other->cols()); + return base_map_t(&(other->coeffRef(0)), other->rows(), + other->cols()); } else { base_map_t map( ChainableStack::instance_->memalloc_.alloc_array( @@ -156,29 +157,28 @@ class arena_matrix : public Eigen::Map { template * = nullptr> arena_matrix& operator=(T&& a) { using T_t = std::decay_t; - if (std::is_rvalue_reference::value - && is_plain_type::value) { - // Note: plain_type_t here does nothing since T_t is plain type - auto other - = make_chainable_ptr(plain_type_t(std::move(a))); - new (this) Base(&(other->coeffRef(0)), other->rows(), other->cols()); - return *this; + if (std::is_rvalue_reference::value && is_plain_type::value) { + // Note: plain_type_t here does nothing since T_t is plain type + auto other = make_chainable_ptr(plain_type_t(std::move(a))); + new (this) Base(&(other->coeffRef(0)), other->rows(), other->cols()); + return *this; } else { - // do we need to transpose? - if ((RowsAtCompileTime == 1 && T_t::ColsAtCompileTime == 1) - || (ColsAtCompileTime == 1 && T_t::RowsAtCompileTime == 1)) { - // placement new changes what data map points to - there is no allocation - new (this) Base( - ChainableStack::instance_->memalloc_.alloc_array(a.size()), - a.cols(), a.rows()); - - } else { - new (this) Base( - ChainableStack::instance_->memalloc_.alloc_array(a.size()), - a.rows(), a.cols()); - } - Base::operator=(a); - return *this; + // do we need to transpose? + if ((RowsAtCompileTime == 1 && T_t::ColsAtCompileTime == 1) + || (ColsAtCompileTime == 1 && T_t::RowsAtCompileTime == 1)) { + // placement new changes what data map points to - there is no + // allocation + new (this) Base( + ChainableStack::instance_->memalloc_.alloc_array(a.size()), + a.cols(), a.rows()); + + } else { + new (this) Base( + ChainableStack::instance_->memalloc_.alloc_array(a.size()), + a.rows(), a.cols()); + } + Base::operator=(a); + return *this; } } }; diff --git a/test/unit/math/rev/fun/fill_test.cpp b/test/unit/math/rev/fun/fill_test.cpp index fa328aa0a68..7dae163c0f7 100644 --- a/test/unit/math/rev/fun/fill_test.cpp +++ b/test/unit/math/rev/fun/fill_test.cpp @@ -60,7 +60,8 @@ TEST_F(AgradRev, fillVarMatDouble) { using stan::math::fill; using stan::math::sum; using stan::math::var_value; - Matrix y_val = Matrix::Constant(3, 2.0); + Matrix y_val + = Matrix::Constant(3, 2.0); var_value> y(y_val); fill(y, 3.0); EXPECT_EQ(3, y.size()); @@ -79,7 +80,8 @@ TEST_F(AgradRev, fillVarMatVar) { using stan::math::sum; using stan::math::var; using stan::math::var_value; - Matrix y_val = Matrix::Constant(3, 2.0); + Matrix y_val + = Matrix::Constant(3, 2.0); var_value> y(y_val); var z(3.0); fill(y, z); From 90b23ab8aa1c42b3e4f93653c96b2f8ea598fcb2 Mon Sep 17 00:00:00 2001 From: stevebronder Date: Mon, 7 Aug 2023 14:29:40 -0400 Subject: [PATCH 14/52] cleanup after reduce_sum is called in tests --- lib/sundials_6.1.1/lib/stlTVNfQ | 0 lib/sundials_6.1.1/lib/stytHoFH | 0 .../mix/functor/reduce_sum_part1_test.cpp | 34 +++++++++---------- .../mix/functor/reduce_sum_part2_test.cpp | 13 +++---- .../mix/functor/reduce_sum_part3_test.cpp | 11 +++--- .../mix/functor/reduce_sum_part4_test.cpp | 11 +++--- 6 files changed, 36 insertions(+), 33 deletions(-) create mode 100644 lib/sundials_6.1.1/lib/stlTVNfQ create mode 100644 lib/sundials_6.1.1/lib/stytHoFH diff --git a/lib/sundials_6.1.1/lib/stlTVNfQ b/lib/sundials_6.1.1/lib/stlTVNfQ new file mode 100644 index 00000000000..e69de29bb2d diff --git a/lib/sundials_6.1.1/lib/stytHoFH b/lib/sundials_6.1.1/lib/stytHoFH new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/unit/math/mix/functor/reduce_sum_part1_test.cpp b/test/unit/math/mix/functor/reduce_sum_part1_test.cpp index abf7bc184f3..446aeaf7c33 100644 --- a/test/unit/math/mix/functor/reduce_sum_part1_test.cpp +++ b/test/unit/math/mix/functor/reduce_sum_part1_test.cpp @@ -1,14 +1,14 @@ #include #include #include - +#include #include #include // Reduce sum tests are broken up into four files to avoid windows compiler // error -TEST(MathMix_reduce_sum, grainsize_static) { +TEST_F(AgradRev, reduce_sum_grainsize_static) { using stan::math::test::get_new_msg; using stan::math::test::sum_lpdf; @@ -33,7 +33,7 @@ TEST(MathMix_reduce_sum, grainsize_static) { stan::test::expect_ad(f4, data); } -TEST(MathMix_reduce_sum, grainsize) { +TEST_F(AgradRev, reduce_sum_grainsize) { using stan::math::test::get_new_msg; using stan::math::test::sum_lpdf; auto f1 = [](auto&& data) { @@ -57,7 +57,7 @@ TEST(MathMix_reduce_sum, grainsize) { stan::test::expect_ad(f4, data); } -TEST(MathMix_reduce_sum, std_vector_zero_length) { +TEST_F(AgradRev, reduce_sum_std_vector_zero_length) { using stan::math::test::reduce_sum_static_sum_lpdf; using stan::math::test::reduce_sum_sum_lpdf; @@ -67,7 +67,7 @@ TEST(MathMix_reduce_sum, std_vector_zero_length) { stan::test::expect_ad(reduce_sum_sum_lpdf, data); } -TEST(MathMix_reduce_sum, std_vector_double_slice) { +TEST_F(AgradRev, reduce_sum_std_vector_double_slice) { using stan::math::test::reduce_sum_static_sum_lpdf; using stan::math::test::reduce_sum_sum_lpdf; @@ -77,7 +77,7 @@ TEST(MathMix_reduce_sum, std_vector_double_slice) { stan::test::expect_ad(reduce_sum_sum_lpdf, data); } -TEST(MathMix_reduce_sum, std_vector_std_vector_double_slice) { +TEST_F(AgradRev, reduce_sum_std_vector_std_vector_double_slice) { using stan::math::test::reduce_sum_static_sum_lpdf; using stan::math::test::reduce_sum_sum_lpdf; @@ -87,7 +87,7 @@ TEST(MathMix_reduce_sum, std_vector_std_vector_double_slice) { stan::test::expect_ad(reduce_sum_sum_lpdf, data); } -TEST(MathMix_reduce_sum, std_vector_eigen_vector_double_slice) { +TEST_F(AgradRev, reduce_sum_std_vector_eigen_vector_double_slice) { using stan::math::test::reduce_sum_static_sum_lpdf; using stan::math::test::reduce_sum_sum_lpdf; @@ -97,7 +97,7 @@ TEST(MathMix_reduce_sum, std_vector_eigen_vector_double_slice) { stan::test::expect_ad(reduce_sum_sum_lpdf, data); } -TEST(MathMix_reduce_sum, std_vector_eigen_row_vector_double_slice) { +TEST_F(AgradRev, reduce_sum_std_vector_eigen_row_vector_double_slice) { using stan::math::test::reduce_sum_static_sum_lpdf; using stan::math::test::reduce_sum_sum_lpdf; @@ -107,7 +107,7 @@ TEST(MathMix_reduce_sum, std_vector_eigen_row_vector_double_slice) { stan::test::expect_ad(reduce_sum_sum_lpdf, data); } -TEST(MathMix_reduce_sum, std_vector_eigen_matrix_double_slice) { +TEST_F(AgradRev, reduce_sum_std_vector_eigen_matrix_double_slice) { using stan::math::test::reduce_sum_static_sum_lpdf; using stan::math::test::reduce_sum_sum_lpdf; @@ -117,7 +117,7 @@ TEST(MathMix_reduce_sum, std_vector_eigen_matrix_double_slice) { stan::test::expect_ad(reduce_sum_sum_lpdf, data); } -TEST(MathMix_reduce_sum, std_vector_std_vector_std_vector_double_slice) { +TEST_F(AgradRev, reduce_sum_std_vector_std_vector_std_vector_double_slice) { using stan::math::test::reduce_sum_static_sum_lpdf; using stan::math::test::reduce_sum_sum_lpdf; @@ -128,7 +128,7 @@ TEST(MathMix_reduce_sum, std_vector_std_vector_std_vector_double_slice) { stan::test::expect_ad(reduce_sum_sum_lpdf, data); } -TEST(MathMix_reduce_sum, std_vector_std_vector_eigen_vector_double_slice) { +TEST_F(AgradRev, reduce_sum_std_vector_std_vector_eigen_vector_double_slice) { using stan::math::test::reduce_sum_static_sum_lpdf; using stan::math::test::reduce_sum_sum_lpdf; @@ -139,7 +139,7 @@ TEST(MathMix_reduce_sum, std_vector_std_vector_eigen_vector_double_slice) { stan::test::expect_ad(reduce_sum_sum_lpdf, data); } -TEST(MathMix_reduce_sum, std_vector_std_vector_eigen_row_vector_double_slice) { +TEST_F(AgradRev, reduce_sum_std_vector_std_vector_eigen_row_vector_double_slice) { using stan::math::test::reduce_sum_static_sum_lpdf; using stan::math::test::reduce_sum_sum_lpdf; @@ -150,7 +150,7 @@ TEST(MathMix_reduce_sum, std_vector_std_vector_eigen_row_vector_double_slice) { stan::test::expect_ad(reduce_sum_sum_lpdf, data); } -TEST(MathMix_reduce_sum, std_vector_std_vector_eigen_matrix_double_slice) { +TEST_F(AgradRev, reduce_sum_std_vector_std_vector_eigen_matrix_double_slice) { using stan::math::test::reduce_sum_static_sum_lpdf; using stan::math::test::reduce_sum_sum_lpdf; @@ -180,7 +180,7 @@ TEST(StanMath_reduce_sum_static, start_end_slice) { stan::test::expect_ad(start_end_static, data); } -TEST(MathMix_reduce_sum, int_arg) { +TEST_F(AgradRev, reduce_sum_int_arg) { using stan::math::test::reduce_sum_static_sum_lpdf; using stan::math::test::reduce_sum_sum_lpdf; std::vector data(2, 1.0); @@ -192,7 +192,7 @@ TEST(MathMix_reduce_sum, int_arg) { [&](auto&& data) { return reduce_sum_sum_lpdf(data, arg); }, data); } -TEST(MathMix_reduce_sum, std_vector_int_arg) { +TEST_F(AgradRev, reduce_sum_std_vector_int_arg) { using stan::math::test::reduce_sum_static_sum_lpdf; using stan::math::test::reduce_sum_sum_lpdf; std::vector data(2, 10.0); @@ -204,12 +204,12 @@ TEST(MathMix_reduce_sum, std_vector_int_arg) { [&](auto&& data) { return reduce_sum_sum_lpdf(data, arg); }, data); } -TEST(MathMix_reduce_sum, double_arg) { +TEST_F(AgradRev, reduce_sum_double_arg) { stan::math::test::expect_ad_reduce_sum_lpdf(std::vector(2, 10.0), 5.0); } -TEST(MathMix_reduce_sum, std_vector_double_arg) { +TEST_F(AgradRev, reduce_sum_std_vector_double_arg) { stan::math::test::expect_ad_reduce_sum_lpdf(std::vector(2, 10.0), std::vector(2, 10.0)); } diff --git a/test/unit/math/mix/functor/reduce_sum_part2_test.cpp b/test/unit/math/mix/functor/reduce_sum_part2_test.cpp index 524671b3223..16a9c7b4b2d 100644 --- a/test/unit/math/mix/functor/reduce_sum_part2_test.cpp +++ b/test/unit/math/mix/functor/reduce_sum_part2_test.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include @@ -8,41 +9,41 @@ // Reduce sum tests are broken up into four files to avoid windows compiler // error -TEST(MathMix_reduce_sum, eigen_vector_arg) { +TEST_F(AgradRev, reduce_sum_eigen_vector_arg) { std::vector data(2, 10.0); Eigen::VectorXd arg = Eigen::VectorXd::Ones(2); stan::math::test::expect_ad_reduce_sum_lpdf(data, arg); } -TEST(MathMix_reduce_sum, eigen_row_vector_arg) { +TEST_F(AgradRev, reduce_sum_eigen_row_vector_arg) { std::vector data(2, 10.0); Eigen::RowVectorXd arg = Eigen::RowVectorXd::Ones(2); stan::math::test::expect_ad_reduce_sum_lpdf(data, arg); } -TEST(MathMix_reduce_sum, eigen_matrix_arg) { +TEST_F(AgradRev, reduce_sum_eigen_matrix_arg) { std::vector data(2, 10.0); Eigen::MatrixXd arg = Eigen::MatrixXd::Ones(2, 2); stan::math::test::expect_ad_reduce_sum_lpdf(data, arg); } -TEST(MathMix_reduce_sum, std_vector_std_vector_double_arg) { +TEST_F(AgradRev, reduce_sum_std_vector_std_vector_double_arg) { std::vector data(2, 10.0); std::vector> arg(2, std::vector(2, 10.0)); stan::math::test::expect_ad_reduce_sum_lpdf(data, arg); } -TEST(MathMix_reduce_sum, std_vector_eigen_vector_arg) { +TEST_F(AgradRev, reduce_sum_std_vector_eigen_vector_arg) { std::vector data(2, 10.0); std::vector arg(2, Eigen::VectorXd::Ones(2)); stan::math::test::expect_ad_reduce_sum_lpdf(data, arg); } -TEST(MathMix_reduce_sum, std_vector_eigen_row_vector_arg) { +TEST_F(AgradRev, reduce_sum_std_vector_eigen_row_vector_arg) { std::vector data(2, 10.0); std::vector arg(2, Eigen::RowVectorXd::Ones(2)); diff --git a/test/unit/math/mix/functor/reduce_sum_part3_test.cpp b/test/unit/math/mix/functor/reduce_sum_part3_test.cpp index 52723cdeee3..1999ce0d871 100644 --- a/test/unit/math/mix/functor/reduce_sum_part3_test.cpp +++ b/test/unit/math/mix/functor/reduce_sum_part3_test.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include @@ -8,7 +9,7 @@ // Reduce sum tests are broken up into four files to avoid windows compiler // error -TEST(MathMix_reduce_sum, eigen_three_args1) { +TEST_F(AgradRev, reduce_sum_eigen_three_args1) { using stan::math::test::reduce_sum_int_sum_lpdf; using stan::math::test::reduce_sum_static_int_sum_lpdf; Eigen::VectorXd arg1 = Eigen::VectorXd::Ones(2); @@ -19,7 +20,7 @@ TEST(MathMix_reduce_sum, eigen_three_args1) { stan::test::expect_ad(reduce_sum_int_sum_lpdf, arg1, arg2, arg3); } -TEST(MathMix_reduce_sum, eigen_three_args2) { +TEST_F(AgradRev, reduce_sum_eigen_three_args2) { using stan::math::test::reduce_sum_int_sum_lpdf; using stan::math::test::reduce_sum_static_int_sum_lpdf; double arg1 = 1.0; @@ -30,7 +31,7 @@ TEST(MathMix_reduce_sum, eigen_three_args2) { stan::test::expect_ad(reduce_sum_int_sum_lpdf, arg1, arg2, arg3); } -TEST(MathMix_reduce_sum, eigen_three_args3) { +TEST_F(AgradRev, reduce_sum_eigen_three_args3) { using stan::math::test::reduce_sum_int_sum_lpdf; using stan::math::test::reduce_sum_static_int_sum_lpdf; double arg1 = 1.0; @@ -41,7 +42,7 @@ TEST(MathMix_reduce_sum, eigen_three_args3) { stan::test::expect_ad(reduce_sum_int_sum_lpdf, arg1, arg2, arg3); } -TEST(MathMix_reduce_sum, eigen_three_args_with_ints1) { +TEST_F(AgradRev, reduce_sum_eigen_three_args_with_ints1) { using stan::math::test::reduce_sum_int_sum_lpdf; using stan::math::test::reduce_sum_static_int_sum_lpdf; Eigen::VectorXd arg1 = Eigen::VectorXd::Ones(2); @@ -63,7 +64,7 @@ TEST(MathMix_reduce_sum, eigen_three_args_with_ints1) { arg1, arg2, arg3); } -TEST(MathMix_reduce_sum, eigen_three_args_with_ints2) { +TEST_F(AgradRev, reduce_sum_eigen_three_args_with_ints2) { using stan::math::test::reduce_sum_int_sum_lpdf; using stan::math::test::reduce_sum_static_int_sum_lpdf; double arg1 = 1.0; diff --git a/test/unit/math/mix/functor/reduce_sum_part4_test.cpp b/test/unit/math/mix/functor/reduce_sum_part4_test.cpp index e2cfead9893..95d7ccf2fa7 100644 --- a/test/unit/math/mix/functor/reduce_sum_part4_test.cpp +++ b/test/unit/math/mix/functor/reduce_sum_part4_test.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include @@ -8,7 +9,7 @@ // Reduce sum tests are broken up into four files to avoid windows compiler // error -TEST(MathMix_reduce_sum, eigen_three_args_with_ints3) { +TEST_F(AgradRev, reduce_sum_eigen_three_args_with_ints3) { using stan::math::test::reduce_sum_int_sum_lpdf; using stan::math::test::reduce_sum_static_int_sum_lpdf; double arg1 = 1.0; @@ -30,7 +31,7 @@ TEST(MathMix_reduce_sum, eigen_three_args_with_ints3) { arg1, arg2, arg3); } -TEST(MathMix_reduce_sum, eigen_three_args_with_doubles1) { +TEST_F(AgradRev, reduce_sum_eigen_three_args_with_doubles1) { using stan::math::test::reduce_sum_static_sum_lpdf; using stan::math::test::reduce_sum_sum_lpdf; Eigen::VectorXd arg1 = Eigen::VectorXd::Ones(2); @@ -53,7 +54,7 @@ TEST(MathMix_reduce_sum, eigen_three_args_with_doubles1) { arg1, arg2, arg3); } -TEST(MathMix_reduce_sum, eigen_three_args_with_doubles2) { +TEST_F(AgradRev, reduce_sum_eigen_three_args_with_doubles2) { using stan::math::test::reduce_sum_static_sum_lpdf; using stan::math::test::reduce_sum_sum_lpdf; double arg1 = 1.0; @@ -77,7 +78,7 @@ TEST(MathMix_reduce_sum, eigen_three_args_with_doubles2) { arg1, arg2, arg3); } -TEST(MathMix_reduce_sum, eigen_three_args_with_doubles3) { +TEST_F(AgradRev, reduce_sum_eigen_three_args_with_doubles3) { using stan::math::test::reduce_sum_static_sum_lpdf; using stan::math::test::reduce_sum_sum_lpdf; double arg1 = 1.0; @@ -102,7 +103,7 @@ TEST(MathMix_reduce_sum, eigen_three_args_with_doubles3) { } #ifdef STAN_THREADS -TEST(MathMix_reduce_sum, static_check) { +TEST_F(AgradRev, reduce_sum_static_check) { using stan::math::test::get_new_msg; using stan::math::test::static_check_lpdf; From 9ce5c50f95d47e5ae4711767f6c2765b5ee753d5 Mon Sep 17 00:00:00 2001 From: Stan Jenkins Date: Mon, 7 Aug 2023 14:30:48 -0400 Subject: [PATCH 15/52] [Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1 --- test/unit/math/mix/functor/reduce_sum_part1_test.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/unit/math/mix/functor/reduce_sum_part1_test.cpp b/test/unit/math/mix/functor/reduce_sum_part1_test.cpp index 446aeaf7c33..ad219f26182 100644 --- a/test/unit/math/mix/functor/reduce_sum_part1_test.cpp +++ b/test/unit/math/mix/functor/reduce_sum_part1_test.cpp @@ -139,7 +139,8 @@ TEST_F(AgradRev, reduce_sum_std_vector_std_vector_eigen_vector_double_slice) { stan::test::expect_ad(reduce_sum_sum_lpdf, data); } -TEST_F(AgradRev, reduce_sum_std_vector_std_vector_eigen_row_vector_double_slice) { +TEST_F(AgradRev, + reduce_sum_std_vector_std_vector_eigen_row_vector_double_slice) { using stan::math::test::reduce_sum_static_sum_lpdf; using stan::math::test::reduce_sum_sum_lpdf; From 1871c648e0e8864bca8dcf6b4f67d442013a3577 Mon Sep 17 00:00:00 2001 From: stevebronder Date: Mon, 7 Aug 2023 14:32:25 -0400 Subject: [PATCH 16/52] remove tmp sundials files --- lib/sundials_6.1.1/lib/stlTVNfQ | 0 lib/sundials_6.1.1/lib/stytHoFH | 0 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 lib/sundials_6.1.1/lib/stlTVNfQ delete mode 100644 lib/sundials_6.1.1/lib/stytHoFH diff --git a/lib/sundials_6.1.1/lib/stlTVNfQ b/lib/sundials_6.1.1/lib/stlTVNfQ deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/lib/sundials_6.1.1/lib/stytHoFH b/lib/sundials_6.1.1/lib/stytHoFH deleted file mode 100644 index e69de29bb2d..00000000000 From 0ec5253c679eb373e117659d5d696667c88cb7d0 Mon Sep 17 00:00:00 2001 From: Steve Bronder Date: Tue, 8 Aug 2023 10:39:50 -0400 Subject: [PATCH 17/52] use agradrev in mix/probs test --- .../math/mix/prob/bernoulli_logit_glm_lpmf_test.cpp | 2 +- .../mix/prob/categorical_logit_glm_lpmf_test.cpp | 2 +- test/unit/math/mix/prob/categorical_logit_test.cpp | 9 +++++---- test/unit/math/mix/prob/categorical_test.cpp | 9 +++++---- test/unit/math/mix/prob/dirichlet_test.cpp | 10 +++++----- test/unit/math/mix/prob/gamma_cdf_log_test.cpp | 2 +- test/unit/math/mix/prob/gaussian_dlm_obs_test.cpp | 9 +++++---- .../math/mix/prob/inv_wishart_cholesky_test.cpp | 6 +++--- test/unit/math/mix/prob/inv_wishart_test.cpp | 6 +++--- test/unit/math/mix/prob/lkj_corr_test.cpp | 13 +++++++------ test/unit/math/mix/prob/matrix_normal_prec_test.cpp | 6 +++--- test/unit/math/mix/prob/multi_gp_cholesky_test.cpp | 5 +++-- test/unit/math/mix/prob/multi_gp_test.cpp | 6 +++--- .../math/mix/prob/multi_normal_cholesky_test.cpp | 6 +++--- test/unit/math/mix/prob/multi_normal_prec_test.cpp | 6 +++--- test/unit/math/mix/prob/multi_normal_test.cpp | 6 +++--- test/unit/math/mix/prob/multi_student_t_test.cpp | 6 +++--- test/unit/math/mix/prob/multinomial_logit_test.cpp | 2 +- test/unit/math/mix/prob/multinomial_test.cpp | 5 +++-- .../mix/prob/neg_binomial_2_log_glm_lpmf_test.cpp | 2 +- test/unit/math/mix/prob/neg_binomial_2_log_test.cpp | 2 +- test/unit/math/mix/prob/neg_binomial_test.cpp | 2 +- test/unit/math/mix/prob/normal_ccdf_log_test.cpp | 2 +- test/unit/math/mix/prob/normal_cdf_log_test.cpp | 2 +- test/unit/math/mix/prob/normal_cdf_test.cpp | 2 +- test/unit/math/mix/prob/normal_id_glm_lpdf_test.cpp | 2 +- test/unit/math/mix/prob/normal_test.cpp | 2 +- .../mix/prob/ordered_logistic_glm_lpmf_test.cpp | 2 +- test/unit/math/mix/prob/ordered_logistic_test.cpp | 13 +++++++------ .../math/mix/prob/poisson_log_glm_lpmf_test.cpp | 2 +- .../unit/math/mix/prob/std_normal_ccdf_log_test.cpp | 2 +- test/unit/math/mix/prob/std_normal_cdf_log_test.cpp | 2 +- test/unit/math/mix/prob/std_normal_cdf_test.cpp | 2 +- test/unit/math/mix/prob/std_normal_log_qf_test.cpp | 8 ++++---- test/unit/math/mix/prob/std_normal_test.cpp | 2 +- test/unit/math/mix/prob/von_mises_cdf_test.cpp | 2 +- test/unit/math/mix/prob/von_mises_test.cpp | 11 ++++++----- test/unit/math/mix/prob/wishart_cholesky_test.cpp | 6 +++--- test/unit/math/mix/prob/wishart_test.cpp | 6 +++--- test/unit/math/test_ad.hpp | 3 ++- 40 files changed, 101 insertions(+), 92 deletions(-) diff --git a/test/unit/math/mix/prob/bernoulli_logit_glm_lpmf_test.cpp b/test/unit/math/mix/prob/bernoulli_logit_glm_lpmf_test.cpp index 430ff1a4769..fd29b24989e 100644 --- a/test/unit/math/mix/prob/bernoulli_logit_glm_lpmf_test.cpp +++ b/test/unit/math/mix/prob/bernoulli_logit_glm_lpmf_test.cpp @@ -1,7 +1,7 @@ #include #include -TEST(mathMixScalFun, bernoulli_logit_glm_lpmf) { +TEST_F(AgradRev, mathMixScalFun_bernoulli_logit_glm_lpmf) { auto f = [](const auto y) { return [=](const auto& x, const auto& alpha, const auto& beta) { return stan::math::bernoulli_logit_glm_lpmf(y, x, alpha, beta); diff --git a/test/unit/math/mix/prob/categorical_logit_glm_lpmf_test.cpp b/test/unit/math/mix/prob/categorical_logit_glm_lpmf_test.cpp index 084a92fc166..68de98a2cd8 100644 --- a/test/unit/math/mix/prob/categorical_logit_glm_lpmf_test.cpp +++ b/test/unit/math/mix/prob/categorical_logit_glm_lpmf_test.cpp @@ -1,7 +1,7 @@ #include #include -TEST(mathMixScalFun, categorical_logit_glm_lpmf) { +TEST_F(AgradRev, mathMixScalFun_categorical_logit_glm_lpmf) { auto f = [](const auto y) { return [=](const auto& x, const auto& alpha, const auto& beta) { return stan::math::categorical_logit_glm_lpmf(y, x, alpha, beta); diff --git a/test/unit/math/mix/prob/categorical_logit_test.cpp b/test/unit/math/mix/prob/categorical_logit_test.cpp index 8c1d1d7c10d..7ef56a77e43 100644 --- a/test/unit/math/mix/prob/categorical_logit_test.cpp +++ b/test/unit/math/mix/prob/categorical_logit_test.cpp @@ -1,9 +1,10 @@ #include +#include #include #include #include -TEST(ProbDistributionsCategoricalLogit, fvar_var) { +TEST_F(AgradRev, ProbDistributionsCategoricalLogit_fvar_var) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::fvar; @@ -28,7 +29,7 @@ TEST(ProbDistributionsCategoricalLogit, fvar_var) { stan::math::categorical_logit_log(3, theta).d_.val()); } -TEST(ProbDistributionsCategoricalLogit, fvar_var_vectorized) { +TEST_F(AgradRev, ProbDistributionsCategoricalLogit_fvar_var_vectorized) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::fvar; @@ -57,7 +58,7 @@ TEST(ProbDistributionsCategoricalLogit, fvar_var_vectorized) { stan::math::categorical_logit_log(ms, theta).d_.val()); } -TEST(ProbDistributionsCategoricalLogit, fvar_fvar_var) { +TEST_F(AgradRev, ProbDistributionsCategoricalLogit_fvar_fvar_var) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::fvar; @@ -82,7 +83,7 @@ TEST(ProbDistributionsCategoricalLogit, fvar_fvar_var) { stan::math::categorical_logit_log(3, theta).d_.val_.val()); } -TEST(ProbDistributionsCategoricalLogit, fvar_fvar_var_vectorized) { +TEST_F(AgradRev, ProbDistributionsCategoricalLogit_fvar_fvar_var_vectorized) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::fvar; diff --git a/test/unit/math/mix/prob/categorical_test.cpp b/test/unit/math/mix/prob/categorical_test.cpp index 01d24102956..07677308496 100644 --- a/test/unit/math/mix/prob/categorical_test.cpp +++ b/test/unit/math/mix/prob/categorical_test.cpp @@ -1,10 +1,11 @@ #include +#include #include #include #include #include -TEST(ProbDistributionsCategorical, fvar_var) { +TEST_F(AgradRev, ProbDistributionsCategorical_fvar_var) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::fvar; @@ -24,7 +25,7 @@ TEST(ProbDistributionsCategorical, fvar_var) { EXPECT_FLOAT_EQ(1.0 / 0.5, stan::math::categorical_log(2, theta).d_.val()); EXPECT_FLOAT_EQ(1.0 / 0.2, stan::math::categorical_log(3, theta).d_.val()); } -TEST(ProbDistributionsCategorical, fvar_var_vector) { +TEST_F(AgradRev, ProbDistributionsCategorical_fvar_var_vector) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::fvar; @@ -45,7 +46,7 @@ TEST(ProbDistributionsCategorical, fvar_var_vector) { stan::math::categorical_log(xs, theta).d_.val()); } -TEST(ProbDistributionsCategorical, fvar_fvar_var) { +TEST_F(AgradRev, ProbDistributionsCategorical_fvar_fvar_var) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::fvar; @@ -68,7 +69,7 @@ TEST(ProbDistributionsCategorical, fvar_fvar_var) { EXPECT_FLOAT_EQ(1.0 / 0.2, stan::math::categorical_log(3, theta).d_.val_.val()); } -TEST(ProbDistributionsCategorical, fvar_fvar_var_vector) { +TEST_F(AgradRev, ProbDistributionsCategorical_fvar_fvar_var_vector) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::fvar; diff --git a/test/unit/math/mix/prob/dirichlet_test.cpp b/test/unit/math/mix/prob/dirichlet_test.cpp index 8c014167bf3..badcf4c2019 100644 --- a/test/unit/math/mix/prob/dirichlet_test.cpp +++ b/test/unit/math/mix/prob/dirichlet_test.cpp @@ -16,7 +16,7 @@ T vectorize_softmax(const T& y) { } } // namespace dirichlet_test -TEST(ProbDistributions, dirichlet) { +TEST_F(AgradRev, ProbDistributions_dirichlet) { auto f = [](const auto& y, const auto& alpha) { auto y_simplex = dirichlet_test::vectorize_softmax(y); auto lp = stan::math::dirichlet_lpdf(y_simplex, alpha); @@ -36,7 +36,7 @@ TEST(ProbDistributions, dirichlet) { stan::test::expect_ad(f, vs, vs); } -TEST(ProbDistributions, fvar_var) { +TEST_F(AgradRev, ProbDistributions_fvar_var) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::fvar; @@ -70,7 +70,7 @@ TEST(ProbDistributions, fvar_var) { stan::math::dirichlet_log(theta2, alpha2).d_.val()); } -TEST(ProbDistributions, fvar_varVectorized) { +TEST_F(AgradRev, ProbDistributions_fvar_varVectorized) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::dirichlet_log; @@ -126,7 +126,7 @@ TEST(ProbDistributions, fvar_varVectorized) { EXPECT_FLOAT_EQ(result.d().val().sum(), out.d_.val()); } -TEST(ProbDistributions, fvar_fvar_var) { +TEST_F(AgradRev, ProbDistributions_fvar_fvar_var) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::fvar; @@ -161,7 +161,7 @@ TEST(ProbDistributions, fvar_fvar_var) { stan::math::dirichlet_log(theta2, alpha2).d_.val_.val()); } -TEST(ProbDistributions, fvar_fvar_varVectorized) { +TEST_F(AgradRev, ProbDistributions_fvar_fvar_varVectorized) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::dirichlet_log; diff --git a/test/unit/math/mix/prob/gamma_cdf_log_test.cpp b/test/unit/math/mix/prob/gamma_cdf_log_test.cpp index b2b60663610..185bc13c450 100644 --- a/test/unit/math/mix/prob/gamma_cdf_log_test.cpp +++ b/test/unit/math/mix/prob/gamma_cdf_log_test.cpp @@ -1,7 +1,7 @@ #include #include -TEST(mathMixScalFun, gamma_lcdf) { +TEST_F(AgradRev, mathMixScalFun_gamma_lcdf) { auto f = [](const auto& y, const auto& alpha, const auto& beta) { return stan::math::gamma_lcdf(y, alpha, beta); }; diff --git a/test/unit/math/mix/prob/gaussian_dlm_obs_test.cpp b/test/unit/math/mix/prob/gaussian_dlm_obs_test.cpp index 5c9c0370709..186ddcd15dd 100644 --- a/test/unit/math/mix/prob/gaussian_dlm_obs_test.cpp +++ b/test/unit/math/mix/prob/gaussian_dlm_obs_test.cpp @@ -1,7 +1,8 @@ #include +#include #include -TEST(ProbDistributionsGaussianDLM, LoglikeUU_fvar_var) { +TEST_F(AgradRev, ProbDistributionsGaussianDLM_LoglikeUU_fvar_var) { using Eigen::Dynamic; using Eigen::Matrix; using Eigen::MatrixXd; @@ -34,7 +35,7 @@ TEST(ProbDistributionsGaussianDLM, LoglikeUU_fvar_var) { EXPECT_FLOAT_EQ(-3.8427677, lp_ref.d_.val()); } -TEST(ProbDistributionsGaussianDLM, LoglikeMM_fvar_var) { +TEST_F(AgradRev, ProbDistributionsGaussianDLM_LoglikeMM_fvar_var) { using Eigen::Dynamic; using Eigen::Matrix; using Eigen::MatrixXd; @@ -87,7 +88,7 @@ TEST(ProbDistributionsGaussianDLM, LoglikeMM_fvar_var) { EXPECT_NEAR(18.89044287309947, lp_ref.d_.val(), 1e-4); } -TEST(ProbDistributionsGaussianDLM, LoglikeUU_fvar_fvar_var) { +TEST_F(AgradRev, ProbDistributionsGaussianDLM_LoglikeUU_fvar_fvar_var) { using Eigen::Dynamic; using Eigen::Matrix; using Eigen::MatrixXd; @@ -125,7 +126,7 @@ TEST(ProbDistributionsGaussianDLM, LoglikeUU_fvar_fvar_var) { EXPECT_FLOAT_EQ(-3.8427677, lp_ref.d_.val_.val()); } -TEST(ProbDistributionsGaussianDLM, LoglikeMM_fvar_fvar_var) { +TEST_F(AgradRev, ProbDistributionsGaussianDLM_LoglikeMM_fvar_fvar_var) { using Eigen::Dynamic; using Eigen::Matrix; using Eigen::MatrixXd; diff --git a/test/unit/math/mix/prob/inv_wishart_cholesky_test.cpp b/test/unit/math/mix/prob/inv_wishart_cholesky_test.cpp index 9976e80239c..04556b5efaa 100644 --- a/test/unit/math/mix/prob/inv_wishart_cholesky_test.cpp +++ b/test/unit/math/mix/prob/inv_wishart_cholesky_test.cpp @@ -1,6 +1,6 @@ #include -TEST(ProbDistributionsInvWishartCholesky, matvar) { +TEST_F(AgradRev, ProbDistributionsInvWishartCholesky_matvar) { auto f = [](const auto& L_Y, const auto& dof, const auto& L_S) { return stan::math::inv_wishart_cholesky_lpdf(L_Y, dof, L_S); }; @@ -34,7 +34,7 @@ TEST(ProbDistributionsInvWishartCholesky, matvar) { stan::test::expect_ad_matvar(f, L_Y11, dof, L_S00); } -TEST(ProbDistributionsInvWishartCholesky, fvar_var) { +TEST_F(AgradRev, ProbDistributionsInvWishartCholesky_fvar_var) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::fvar; @@ -69,7 +69,7 @@ TEST(ProbDistributionsInvWishartCholesky, fvar_var) { stan::math::recover_memory(); } -TEST(ProbDistributionsInvWishartCholesky, fvar_fvar_var) { +TEST_F(AgradRev, ProbDistributionsInvWishartCholesky_fvar_fvar_var) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::fvar; diff --git a/test/unit/math/mix/prob/inv_wishart_test.cpp b/test/unit/math/mix/prob/inv_wishart_test.cpp index d4da0b7babc..60155381d58 100644 --- a/test/unit/math/mix/prob/inv_wishart_test.cpp +++ b/test/unit/math/mix/prob/inv_wishart_test.cpp @@ -1,6 +1,6 @@ #include -TEST(ProbDistributionsInvWishart, matvar) { +TEST_F(AgradRev, ProbDistributionsInvWishart_matvar) { auto f = [](const auto& y, const auto& dof, const auto& sigma) { auto y_sym = stan::math::multiply(0.5, y + y.transpose()); auto sigma_sym = stan::math::multiply(0.5, sigma + sigma.transpose()); @@ -34,7 +34,7 @@ TEST(ProbDistributionsInvWishart, matvar) { stan::test::expect_ad_matvar(f, y11, dof, Sigma00); } -TEST(ProbDistributionsInvWishart, fvar_var) { +TEST_F(AgradRev, ProbDistributionsInvWishart_fvar_var) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::fvar; @@ -66,7 +66,7 @@ TEST(ProbDistributionsInvWishart, fvar_var) { stan::math::recover_memory(); } -TEST(ProbDistributionsInvWishart, fvar_fvar_var) { +TEST_F(AgradRev, ProbDistributionsInvWishart_fvar_fvar_var) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::fvar; diff --git a/test/unit/math/mix/prob/lkj_corr_test.cpp b/test/unit/math/mix/prob/lkj_corr_test.cpp index 64c65d419ea..aa023d4f4ad 100644 --- a/test/unit/math/mix/prob/lkj_corr_test.cpp +++ b/test/unit/math/mix/prob/lkj_corr_test.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -6,7 +7,7 @@ #include #include -TEST(ProbDistributionsLkjCorr, fvar_var) { +TEST_F(AgradRev, ProbDistributionsLkjCorr_fvar_var) { using stan::math::fvar; using stan::math::var; boost::random::mt19937 rng; @@ -28,7 +29,7 @@ TEST(ProbDistributionsLkjCorr, fvar_var) { EXPECT_FLOAT_EQ(f.d_.val(), stan::math::lkj_corr_log(Sigma, eta).d_.val()); } -TEST(ProbDistributionsLkjCorrCholesky, fvar_var) { +TEST_F(AgradRev, ProbDistributionsLkjCorrCholesky_fvar_var) { using stan::math::fvar; using stan::math::var; boost::random::mt19937 rng; @@ -51,7 +52,7 @@ TEST(ProbDistributionsLkjCorrCholesky, fvar_var) { EXPECT_FLOAT_EQ(3, stan::math::lkj_corr_cholesky_log(Sigma, eta).d_.val()); } -TEST(ProbDistributionsLkjCorr, fvar_fvar_var) { +TEST_F(AgradRev, ProbDistributionsLkjCorr_fvar_fvar_var) { using stan::math::fvar; using stan::math::var; boost::random::mt19937 rng; @@ -75,7 +76,7 @@ TEST(ProbDistributionsLkjCorr, fvar_fvar_var) { stan::math::lkj_corr_log(Sigma, eta).d_.val_.val()); } -TEST(ProbDistributionsLkjCorrCholesky, fvar_fvar_var) { +TEST_F(AgradRev, ProbDistributionsLkjCorrCholesky_fvar_fvar_var) { using stan::math::fvar; using stan::math::var; boost::random::mt19937 rng; @@ -101,7 +102,7 @@ TEST(ProbDistributionsLkjCorrCholesky, fvar_fvar_var) { stan::math::lkj_corr_cholesky_log(Sigma, eta).d_.val_.val()); } -TEST(ProbDistributionsLkjCorrCholesky, hessian) { +TEST_F(AgradRev, ProbDistributionsLkjCorrCholesky_hessian) { int dim_mat = 3; Eigen::Matrix x1(dim_mat); Eigen::Matrix x2(1); @@ -162,7 +163,7 @@ TEST(ProbDistributionsLkjCorrCholesky, hessian) { EXPECT_FLOAT_EQ(fx_hess_1, fx_hess_ad_1); } -TEST(ProbDistributionsLkjCorrCholesky, grad_hessian) { +TEST_F(AgradRev, ProbDistributionsLkjCorrCholesky_grad_hessian) { int dim_mat = 3; Eigen::Matrix x1(dim_mat); Eigen::Matrix x2(1); diff --git a/test/unit/math/mix/prob/matrix_normal_prec_test.cpp b/test/unit/math/mix/prob/matrix_normal_prec_test.cpp index ea9fd3c2a7f..500e840570a 100644 --- a/test/unit/math/mix/prob/matrix_normal_prec_test.cpp +++ b/test/unit/math/mix/prob/matrix_normal_prec_test.cpp @@ -1,6 +1,6 @@ #include -TEST(ProbDistributionsMatrixNormal, matvar) { +TEST_F(AgradRev, ProbDistributionsMatrixNormal_matvar) { auto f = [](const auto& y, const auto& mu, const auto& sigma, const auto& D) { auto sigma_sym = stan::math::multiply(0.5, sigma + sigma.transpose()); auto D_sym = stan::math::multiply(0.5, D + D.transpose()); @@ -64,7 +64,7 @@ TEST(ProbDistributionsMatrixNormal, matvar) { stan::test::expect_ad_matvar(f, y1, mu1, Sigma00, D11); } -TEST(ProbDistributionsMatrixNormal, fvar_var) { +TEST_F(AgradRev, ProbDistributionsMatrixNormal_fvar_var) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::fvar; @@ -102,7 +102,7 @@ TEST(ProbDistributionsMatrixNormal, fvar_var) { stan::math::recover_memory(); } -TEST(ProbDistributionsMatrixNormal, fvar_fvar_var) { +TEST_F(AgradRev, ProbDistributionsMatrixNormal_fvar_fvar_var) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::fvar; diff --git a/test/unit/math/mix/prob/multi_gp_cholesky_test.cpp b/test/unit/math/mix/prob/multi_gp_cholesky_test.cpp index 30433c822e2..c4c65272ce3 100644 --- a/test/unit/math/mix/prob/multi_gp_cholesky_test.cpp +++ b/test/unit/math/mix/prob/multi_gp_cholesky_test.cpp @@ -1,7 +1,8 @@ #include +#include #include -TEST(ProbDistributionsMultiGPCholesky, fvar_var) { +TEST_F(AgradRev, ProbDistributionsMultiGPCholesky_fvar_var) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::fvar; @@ -48,7 +49,7 @@ TEST(ProbDistributionsMultiGPCholesky, fvar_var) { stan::math::recover_memory(); } -TEST(ProbDistributionsMultiGPCholesky, fvar_fvar_var) { +TEST_F(AgradRev, ProbDistributionsMultiGPCholesky_fvar_fvar_var) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::fvar; diff --git a/test/unit/math/mix/prob/multi_gp_test.cpp b/test/unit/math/mix/prob/multi_gp_test.cpp index ca0e6ed699b..95edddcf0f2 100644 --- a/test/unit/math/mix/prob/multi_gp_test.cpp +++ b/test/unit/math/mix/prob/multi_gp_test.cpp @@ -2,7 +2,7 @@ #include #include -TEST(ProbDistributionsMultiGP, matvar) { +TEST_F(AgradRev, ProbDistributionsMultiGP_matvar) { auto f = [](const auto& y, const auto& sigma, const auto& w) { auto sigma_sym = stan::math::multiply(0.5, sigma + sigma.transpose()); return stan::math::multi_gp_lpdf(y, sigma_sym, w); @@ -46,7 +46,7 @@ TEST(ProbDistributionsMultiGP, matvar) { stan::test::expect_ad(f, y22, Sigma00, w0); } -TEST(ProbDistributionsMultiGP, fvar_var) { +TEST_F(AgradRev, ProbDistributionsMultiGP_fvar_var) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::fvar; @@ -90,7 +90,7 @@ TEST(ProbDistributionsMultiGP, fvar_var) { stan::math::recover_memory(); } -TEST(ProbDistributionsMultiGP, fvar_fvar_var) { +TEST_F(AgradRev, ProbDistributionsMultiGP_fvar_fvar_var) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::fvar; diff --git a/test/unit/math/mix/prob/multi_normal_cholesky_test.cpp b/test/unit/math/mix/prob/multi_normal_cholesky_test.cpp index f1a637d6adf..c27483121b3 100644 --- a/test/unit/math/mix/prob/multi_normal_cholesky_test.cpp +++ b/test/unit/math/mix/prob/multi_normal_cholesky_test.cpp @@ -1,6 +1,6 @@ #include -TEST(ProbDistributionsMultiNormalCholesky, matvar) { +TEST_F(AgradRev, ProbDistributionsMultiNormalCholesky_matvar) { auto f = [](const auto& y, const auto& mu, const auto& sigma) { auto sigma_sym = stan::math::multiply(0.5, sigma + sigma.transpose()); auto L = stan::math::cholesky_decompose(sigma_sym); @@ -45,7 +45,7 @@ TEST(ProbDistributionsMultiNormalCholesky, matvar) { stan::test::expect_ad_matvar(f, y1, mu1, Sigma00); } -TEST(ProbDistributionsMultiNormalCholesky, fvar_var) { +TEST_F(AgradRev, ProbDistributionsMultiNormalCholesky_fvar_var) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::fvar; @@ -73,7 +73,7 @@ TEST(ProbDistributionsMultiNormalCholesky, fvar_var) { stan::math::multi_normal_cholesky_log(y, mu, L).d_.val()); } -TEST(ProbDistributionsMultiNormalCholesky, fvar_fvar_var) { +TEST_F(AgradRev, ProbDistributionsMultiNormalCholesky_fvar_fvar_var) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::fvar; diff --git a/test/unit/math/mix/prob/multi_normal_prec_test.cpp b/test/unit/math/mix/prob/multi_normal_prec_test.cpp index abd3a819f69..65434d9a68d 100644 --- a/test/unit/math/mix/prob/multi_normal_prec_test.cpp +++ b/test/unit/math/mix/prob/multi_normal_prec_test.cpp @@ -1,6 +1,6 @@ #include -TEST(ProbDistributionsMultiNormalPrec, matvar) { +TEST_F(AgradRev, ProbDistributionsMultiNormalPrec_matvar) { auto f = [](const auto& y, const auto& mu, const auto& sigma) { auto inv_sigma_sym = stan::math::multiply(0.5, sigma + sigma.transpose()); return stan::math::multi_normal_prec_lpdf(y, mu, inv_sigma_sym); @@ -37,7 +37,7 @@ TEST(ProbDistributionsMultiNormalPrec, matvar) { stan::test::expect_ad_matvar(f, y1, mu1, InvSigma00); } -TEST(ProbDistributionsMultiNormalPrec, fvar_var) { +TEST_F(AgradRev, ProbDistributionsMultiNormalPrec_fvar_var) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::fvar; @@ -67,7 +67,7 @@ TEST(ProbDistributionsMultiNormalPrec, fvar_var) { stan::math::recover_memory(); } -TEST(ProbDistributionsMultiNormalPrec, fvar_fvar_var) { +TEST_F(AgradRev, ProbDistributionsMultiNormalPrec_fvar_fvar_var) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::fvar; diff --git a/test/unit/math/mix/prob/multi_normal_test.cpp b/test/unit/math/mix/prob/multi_normal_test.cpp index bb1fc347d70..1b64f6063e7 100644 --- a/test/unit/math/mix/prob/multi_normal_test.cpp +++ b/test/unit/math/mix/prob/multi_normal_test.cpp @@ -1,6 +1,6 @@ #include -TEST(ProbDistributionsMultiNormal, matvar) { +TEST_F(AgradRev, ProbDistributionsMultiNormal_matvar) { auto f = [](const auto& y, const auto& mu, const auto& sigma) { auto sigma_sym = stan::math::multiply(0.5, sigma + sigma.transpose()); return stan::math::multi_normal_lpdf(y, mu, sigma_sym); @@ -47,7 +47,7 @@ TEST(ProbDistributionsMultiNormal, matvar) { stan::test::expect_ad_matvar(f, y1, mu1, Sigma00); } -TEST(ProbDistributionsMultiNormal, fvar_var) { +TEST_F(AgradRev, ProbDistributionsMultiNormal_fvar_var) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::fvar; @@ -74,7 +74,7 @@ TEST(ProbDistributionsMultiNormal, fvar_var) { stan::math::recover_memory(); } -TEST(ProbDistributionsMultiNormal, fvar_fvar_var) { +TEST_F(AgradRev, ProbDistributionsMultiNormal_fvar_fvar_var) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::fvar; diff --git a/test/unit/math/mix/prob/multi_student_t_test.cpp b/test/unit/math/mix/prob/multi_student_t_test.cpp index 232493f554b..e2f778e0b17 100644 --- a/test/unit/math/mix/prob/multi_student_t_test.cpp +++ b/test/unit/math/mix/prob/multi_student_t_test.cpp @@ -1,6 +1,6 @@ #include -TEST(ProbDistributionsMultiStudentT, matvar) { +TEST_F(AgradRev, ProbDistributionsMultiStudentT_matvar) { auto f = [](const auto& y, const auto& nu, const auto& mu, const auto& sigma) { auto sigma_sym = stan::math::multiply(0.5, sigma + sigma.transpose()); @@ -58,7 +58,7 @@ TEST(ProbDistributionsMultiStudentT, matvar) { stan::test::expect_ad_matvar(f, y1, nu, mu1, Sigma00); } -TEST(ProbDistributionsMultiStudentT, fvar_var) { +TEST_F(AgradRev, ProbDistributionsMultiStudentT_fvar_var) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::fvar; @@ -87,7 +87,7 @@ TEST(ProbDistributionsMultiStudentT, fvar_var) { stan::math::recover_memory(); } -TEST(ProbDistributionsMultiStudentT, fvar_fvar_var) { +TEST_F(AgradRev, ProbDistributionsMultiStudentT_fvar_fvar_var) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::fvar; diff --git a/test/unit/math/mix/prob/multinomial_logit_test.cpp b/test/unit/math/mix/prob/multinomial_logit_test.cpp index de8a3e1296c..1c6e54767f4 100644 --- a/test/unit/math/mix/prob/multinomial_logit_test.cpp +++ b/test/unit/math/mix/prob/multinomial_logit_test.cpp @@ -1,6 +1,6 @@ #include -TEST(mathMixScalFun, multinomialLogit) { +TEST_F(AgradRev, mathMixScalFun_multinomialLogit) { std::vector ns{0, 1, 2, 3}; Eigen::VectorXd beta(4); beta << 0.1, 0.1, 0.5, 0.3; diff --git a/test/unit/math/mix/prob/multinomial_test.cpp b/test/unit/math/mix/prob/multinomial_test.cpp index 9289d5d26f6..9cb81c0f6f2 100644 --- a/test/unit/math/mix/prob/multinomial_test.cpp +++ b/test/unit/math/mix/prob/multinomial_test.cpp @@ -1,10 +1,11 @@ #include +#include #include #include #include #include -TEST(ProbDistributionsMultinomial, fvar_var) { +TEST_F(AgradRev, ProbDistributionsMultinomial_fvar_var) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::fvar; @@ -22,7 +23,7 @@ TEST(ProbDistributionsMultinomial, fvar_var) { EXPECT_FLOAT_EQ(17.666666, stan::math::multinomial_log(ns, theta).d_.val()); } -TEST(ProbDistributionsMultinomial, fvar_fvar_var) { +TEST_F(AgradRev, ProbDistributionsMultinomial_fvar_fvar_var) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::fvar; diff --git a/test/unit/math/mix/prob/neg_binomial_2_log_glm_lpmf_test.cpp b/test/unit/math/mix/prob/neg_binomial_2_log_glm_lpmf_test.cpp index 92d8e42754f..5934aaf04b2 100644 --- a/test/unit/math/mix/prob/neg_binomial_2_log_glm_lpmf_test.cpp +++ b/test/unit/math/mix/prob/neg_binomial_2_log_glm_lpmf_test.cpp @@ -1,7 +1,7 @@ #include #include -TEST(mathMixScalFun, neg_binomial_2_log_glm_lpmf) { +TEST_F(AgradRev, mathMixScalFun_neg_binomial_2_log_glm_lpmf) { auto f = [](const auto y, const auto& x) { return [=](const auto& alpha, const auto& beta, const auto& phi) { return stan::math::neg_binomial_2_log_glm_lpmf(y, x, alpha, beta, phi); diff --git a/test/unit/math/mix/prob/neg_binomial_2_log_test.cpp b/test/unit/math/mix/prob/neg_binomial_2_log_test.cpp index a04071c0ccb..2ef7f77b49d 100644 --- a/test/unit/math/mix/prob/neg_binomial_2_log_test.cpp +++ b/test/unit/math/mix/prob/neg_binomial_2_log_test.cpp @@ -3,7 +3,7 @@ #include #include -TEST(mathMixScalFun, neg_binomial_2_log_lpmf_derivatives) { +TEST_F(AgradRev, mathMixScalFun_neg_binomial_2_log_lpmf_derivatives) { auto f1 = [](const auto& eta, const auto& phi) { return stan::math::neg_binomial_2_log_lpmf(0, eta, phi); }; diff --git a/test/unit/math/mix/prob/neg_binomial_test.cpp b/test/unit/math/mix/prob/neg_binomial_test.cpp index a17998ded93..7d69ade8b1c 100644 --- a/test/unit/math/mix/prob/neg_binomial_test.cpp +++ b/test/unit/math/mix/prob/neg_binomial_test.cpp @@ -3,7 +3,7 @@ #include #include -TEST(mathMixScalFun, neg_binomial_lpmf_derivatives) { +TEST_F(AgradRev, mathMixScalFun_neg_binomial_lpmf_derivatives) { auto f = [](const int y) { return [=](const auto& alpha, const auto& beta) { return stan::math::neg_binomial_lpmf(y, alpha, beta); diff --git a/test/unit/math/mix/prob/normal_ccdf_log_test.cpp b/test/unit/math/mix/prob/normal_ccdf_log_test.cpp index 7c0cfc41b0b..e573e7da289 100644 --- a/test/unit/math/mix/prob/normal_ccdf_log_test.cpp +++ b/test/unit/math/mix/prob/normal_ccdf_log_test.cpp @@ -1,7 +1,7 @@ #include #include -TEST(mathMixScalFun, normal_lccdf) { +TEST_F(AgradRev, mathMixScalFun_normal_lccdf) { auto f = [](const double mu, const double sigma) { return [=](const auto& y) { return stan::math::normal_lccdf(y, mu, sigma); }; diff --git a/test/unit/math/mix/prob/normal_cdf_log_test.cpp b/test/unit/math/mix/prob/normal_cdf_log_test.cpp index 38560deda7b..7a737c87c77 100644 --- a/test/unit/math/mix/prob/normal_cdf_log_test.cpp +++ b/test/unit/math/mix/prob/normal_cdf_log_test.cpp @@ -1,7 +1,7 @@ #include #include -TEST(mathMixScalFun, normal_lcdf) { +TEST_F(AgradRev, mathMixScalFun_normal_lcdf) { auto f = [](const double mu, const double sigma) { return [=](const auto& y) { return stan::math::normal_lcdf(y, mu, sigma); }; }; diff --git a/test/unit/math/mix/prob/normal_cdf_test.cpp b/test/unit/math/mix/prob/normal_cdf_test.cpp index 80e85c3ac4f..a73594c447f 100644 --- a/test/unit/math/mix/prob/normal_cdf_test.cpp +++ b/test/unit/math/mix/prob/normal_cdf_test.cpp @@ -1,7 +1,7 @@ #include #include -TEST(mathMixScalFun, normal_cdf) { +TEST_F(AgradRev, mathMixScalFun_normal_cdf) { auto f = [](const double mu, const double sigma) { return [=](const auto& y) { return stan::math::normal_cdf(y, mu, sigma); }; }; diff --git a/test/unit/math/mix/prob/normal_id_glm_lpdf_test.cpp b/test/unit/math/mix/prob/normal_id_glm_lpdf_test.cpp index 3af9083a628..f38537c3c08 100644 --- a/test/unit/math/mix/prob/normal_id_glm_lpdf_test.cpp +++ b/test/unit/math/mix/prob/normal_id_glm_lpdf_test.cpp @@ -1,7 +1,7 @@ #include #include -TEST(mathMixScalFun, normal_id_glm_lpdf) { +TEST_F(AgradRev, mathMixScalFun_normal_id_glm_lpdf) { auto f = [](const auto& y, const auto& x) { return [=](const auto& alpha, const auto& beta, const auto& sigma) { return stan::math::normal_id_glm_lpdf(y, x, alpha, beta, sigma); diff --git a/test/unit/math/mix/prob/normal_test.cpp b/test/unit/math/mix/prob/normal_test.cpp index 81136b202d2..029c9ada73d 100644 --- a/test/unit/math/mix/prob/normal_test.cpp +++ b/test/unit/math/mix/prob/normal_test.cpp @@ -1,7 +1,7 @@ #include #include -TEST(mathMixScalFun, normal_lpdf) { +TEST_F(AgradRev, mathMixScalFun_normal_lpdf) { auto f = [](const double mu, const double sigma) { return [=](const auto& y) { return stan::math::normal_lpdf(y, mu, sigma); }; }; diff --git a/test/unit/math/mix/prob/ordered_logistic_glm_lpmf_test.cpp b/test/unit/math/mix/prob/ordered_logistic_glm_lpmf_test.cpp index db0a34f9d92..b4791cdbed5 100644 --- a/test/unit/math/mix/prob/ordered_logistic_glm_lpmf_test.cpp +++ b/test/unit/math/mix/prob/ordered_logistic_glm_lpmf_test.cpp @@ -1,7 +1,7 @@ #include #include -TEST(mathMixScalFun, ordered_logistic_glm_lpmf) { +TEST_F(AgradRev, mathMixScalFun_ordered_logistic_glm_lpmf) { auto f = [](const auto y) { return [=](const auto& x, const auto& beta, const auto& cutpoints) { return stan::math::ordered_logistic_glm_lpmf(y, x, beta, cutpoints); diff --git a/test/unit/math/mix/prob/ordered_logistic_test.cpp b/test/unit/math/mix/prob/ordered_logistic_test.cpp index 8270e873c80..c749d754223 100644 --- a/test/unit/math/mix/prob/ordered_logistic_test.cpp +++ b/test/unit/math/mix/prob/ordered_logistic_test.cpp @@ -1,9 +1,10 @@ #include +#include #include #include #include -TEST(ProbDistributionsOrdLog, fv_fv) { +TEST_F(AgradRev, ProbDistributionsOrdLog_fv_fv) { using stan::math::fvar; using stan::math::ordered_logistic_lpmf; using stan::math::var; @@ -54,7 +55,7 @@ TEST(ProbDistributionsOrdLog, fv_fv) { EXPECT_FLOAT_EQ(c_ffv[2].d_.val_.adj(), 0.0); } -TEST(ProbDistributionsOrdLog, fv_d) { +TEST_F(AgradRev, ProbDistributionsOrdLog_fv_d) { using stan::math::fvar; using stan::math::ordered_logistic_lpmf; using stan::math::var; @@ -122,7 +123,7 @@ TEST(ProbDistributionsOrdLog, fv_d) { EXPECT_FLOAT_EQ(c_ffv[2].d_.val_.adj(), 0.0); } -TEST(ProbDistributionsOrdLog, fv_fv_vec) { +TEST_F(AgradRev, ProbDistributionsOrdLog_fv_fv_vec) { using stan::math::fvar; using stan::math::ordered_logistic_lpmf; using stan::math::var; @@ -187,7 +188,7 @@ TEST(ProbDistributionsOrdLog, fv_fv_vec) { EXPECT_FLOAT_EQ(c_ffv[2].d_.val_.adj(), 0.557132795804491); } -TEST(ProbDistributionsOrdLog, fv_d_vec) { +TEST_F(AgradRev, ProbDistributionsOrdLog_fv_d_vec) { using stan::math::fvar; using stan::math::ordered_logistic_lpmf; using stan::math::var; @@ -270,7 +271,7 @@ TEST(ProbDistributionsOrdLog, fv_d_vec) { EXPECT_FLOAT_EQ(c_ffv[2].d_.val_.adj(), 1.20737912023631); } -TEST(ProbDistributionsOrdLog, fv_fv_stvec) { +TEST_F(AgradRev, ProbDistributionsOrdLog_fv_fv_stvec) { using stan::math::fvar; using stan::math::ordered_logistic_lpmf; using stan::math::var; @@ -398,7 +399,7 @@ TEST(ProbDistributionsOrdLog, fv_fv_stvec) { EXPECT_FLOAT_EQ(std_c_ffv[3][2].d_.val_.adj(), -0.497500020833125); } -TEST(ProbDistributionsOrdLog, fv_d_stvec) { +TEST_F(AgradRev, ProbDistributionsOrdLog_fv_d_stvec) { using stan::math::fvar; using stan::math::ordered_logistic_lpmf; using stan::math::var; diff --git a/test/unit/math/mix/prob/poisson_log_glm_lpmf_test.cpp b/test/unit/math/mix/prob/poisson_log_glm_lpmf_test.cpp index 081b5816344..87292183450 100644 --- a/test/unit/math/mix/prob/poisson_log_glm_lpmf_test.cpp +++ b/test/unit/math/mix/prob/poisson_log_glm_lpmf_test.cpp @@ -1,7 +1,7 @@ #include #include -TEST(mathMixScalFun, poisson_log_glm_lpmf) { +TEST_F(AgradRev, mathMixScalFun_poisson_log_glm_lpmf) { auto f = [](const auto y) { return [=](const auto& x, const auto& alpha, const auto& beta) { return stan::math::poisson_log_glm_lpmf(y, x, alpha, beta); diff --git a/test/unit/math/mix/prob/std_normal_ccdf_log_test.cpp b/test/unit/math/mix/prob/std_normal_ccdf_log_test.cpp index 7aed750e4c2..3c2b01d395a 100644 --- a/test/unit/math/mix/prob/std_normal_ccdf_log_test.cpp +++ b/test/unit/math/mix/prob/std_normal_ccdf_log_test.cpp @@ -1,7 +1,7 @@ #include #include -TEST(mathMixScalFun, std_normal_lccdf) { +TEST_F(AgradRev, mathMixScalFun_std_normal_lccdf) { auto f = [](const auto& y) { return stan::math::std_normal_lccdf(y); }; stan::test::expect_ad(f, -50.0); diff --git a/test/unit/math/mix/prob/std_normal_cdf_log_test.cpp b/test/unit/math/mix/prob/std_normal_cdf_log_test.cpp index 3bc6ee837f6..7f566f3452f 100644 --- a/test/unit/math/mix/prob/std_normal_cdf_log_test.cpp +++ b/test/unit/math/mix/prob/std_normal_cdf_log_test.cpp @@ -1,7 +1,7 @@ #include #include -TEST(mathMixScalFun, std_normal_lcdf) { +TEST_F(AgradRev, mathMixScalFun_std_normal_lcdf) { auto f = [](const auto& y) { return stan::math::std_normal_lcdf(y); }; stan::test::expect_ad(f, -50.0); diff --git a/test/unit/math/mix/prob/std_normal_cdf_test.cpp b/test/unit/math/mix/prob/std_normal_cdf_test.cpp index 008203b6b7d..f19e47d5d81 100644 --- a/test/unit/math/mix/prob/std_normal_cdf_test.cpp +++ b/test/unit/math/mix/prob/std_normal_cdf_test.cpp @@ -1,7 +1,7 @@ #include #include -TEST(mathMixScalFun, std_normal_cdf) { +TEST_F(AgradRev, mathMixScalFun_std_normal_cdf) { auto f = [](const auto& y) { return stan::math::std_normal_cdf(y); }; stan::test::expect_ad(f, -50.0); diff --git a/test/unit/math/mix/prob/std_normal_log_qf_test.cpp b/test/unit/math/mix/prob/std_normal_log_qf_test.cpp index d71498a2a4e..1ae44dd9c27 100644 --- a/test/unit/math/mix/prob/std_normal_log_qf_test.cpp +++ b/test/unit/math/mix/prob/std_normal_log_qf_test.cpp @@ -4,7 +4,7 @@ #include #include -TEST(mathMixLogFun, stdNormalLogQf) { +TEST_F(AgradRev, mathMixLogFun_stdNormalLogQf) { auto f = [](const auto& x1) { return stan::math::std_normal_log_qf(x1); }; stan::test::expect_ad(f, -100.25); stan::test::expect_unary_vectorized( @@ -14,7 +14,7 @@ TEST(mathMixLogFun, stdNormalLogQf) { stan::test::expect_unary_vectorized(f, log(0.02425), log(0.97575)); } -TEST(mathMixScalLogFun, stdNormalLogQfInt) { +TEST_F(AgradRev, mathMixScalLogFun_stdNormalLogQfInt) { auto f = [](const auto& x1) { return stan::math::std_normal_log_qf(x1); }; int y = 1; stan::test::expect_ad(f, y); @@ -22,7 +22,7 @@ TEST(mathMixScalLogFun, stdNormalLogQfInt) { stan::test::expect_ad(f, y); } -TEST(mathMixZeroLogFun, stdNormalLogQfZero) { +TEST_F(AgradRev, mathMixZeroLogFun_stdNormalLogQfZero) { auto f = [](const auto& x1) { return stan::math::std_normal_log_qf(x1); }; int y_int = 0; stan::test::expect_ad(f, y_int); @@ -31,7 +31,7 @@ TEST(mathMixZeroLogFun, stdNormalLogQfZero) { stan::test::expect_ad(f, y); } -TEST(mathMixMatFunLog, stdNormalLogQfVarmat) { +TEST_F(AgradRev, mathMixMatFunLog_stdNormalLogQfVarmat) { using stan::math::vec_concat; using stan::test::expect_ad_vector_matvar; using stan::test::internal::common_args; diff --git a/test/unit/math/mix/prob/std_normal_test.cpp b/test/unit/math/mix/prob/std_normal_test.cpp index 5638d9d7481..22a3483409a 100644 --- a/test/unit/math/mix/prob/std_normal_test.cpp +++ b/test/unit/math/mix/prob/std_normal_test.cpp @@ -1,7 +1,7 @@ #include #include -TEST(mathMixScalFun, std_normal) { +TEST_F(AgradRev, mathMixScalFun_std_normal) { auto f = [](const auto& y) { return stan::math::std_normal_lpdf(y); }; stan::test::expect_ad(f, -0.3); diff --git a/test/unit/math/mix/prob/von_mises_cdf_test.cpp b/test/unit/math/mix/prob/von_mises_cdf_test.cpp index 3443bbfc202..2f5630e3341 100644 --- a/test/unit/math/mix/prob/von_mises_cdf_test.cpp +++ b/test/unit/math/mix/prob/von_mises_cdf_test.cpp @@ -1,7 +1,7 @@ #include #include -TEST(mathMixScalFun, von_mises_cdf) { +TEST_F(AgradRev, mathMixScalFun_von_mises_cdf) { auto f = [](const auto& x, const auto& mu, const auto& k) { return stan::math::von_mises_cdf(x, mu, k); }; diff --git a/test/unit/math/mix/prob/von_mises_test.cpp b/test/unit/math/mix/prob/von_mises_test.cpp index eed79db687f..86997839a1a 100644 --- a/test/unit/math/mix/prob/von_mises_test.cpp +++ b/test/unit/math/mix/prob/von_mises_test.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -22,7 +23,7 @@ std::vector test_von_mises_lpdf(double y, double mu, double kappa) { return grad; } -TEST(ProbAgradDistributionsVonMises, derivatives) { +TEST_F(AgradRev, ProbAgradDistributionsVonMises_derivatives) { using stan::math::fvar; using stan::math::von_mises_lpdf; @@ -39,7 +40,7 @@ TEST(ProbAgradDistributionsVonMises, derivatives) { EXPECT_NO_THROW(von_mises_lpdf(0, 1, kappa2)); } -TEST(ProbAgradDistributionsVonMises, FvarVar_1stDeriv) { +TEST_F(AgradRev, ProbAgradDistributionsVonMises_FvarVar_1stDeriv) { using stan::math::fvar; using stan::math::var; using stan::math::von_mises_lpdf; @@ -56,7 +57,7 @@ TEST(ProbAgradDistributionsVonMises, FvarVar_1stDeriv) { EXPECT_FLOAT_EQ(0, g[0]); } -TEST(ProbAgradDistributionsVonMises, FvarVar_2ndDeriv1) { +TEST_F(AgradRev, ProbAgradDistributionsVonMises_FvarVar_2ndDeriv1) { using stan::math::fvar; using stan::math::var; using stan::math::von_mises_lpdf; @@ -72,7 +73,7 @@ TEST(ProbAgradDistributionsVonMises, FvarVar_2ndDeriv1) { EXPECT_FLOAT_EQ(0, g[0]); } -TEST(ProbAgradDistributionsVonMises, FvarVar_2ndDeriv2) { +TEST_F(AgradRev, ProbAgradDistributionsVonMises_FvarVar_2ndDeriv2) { using stan::math::fvar; using stan::math::var; using stan::math::von_mises_lpdf; @@ -91,7 +92,7 @@ TEST(ProbAgradDistributionsVonMises, FvarVar_2ndDeriv2) { // This test once failed sanitizer checks -- nothing explicitly tested in the // code itself -TEST(ProbAgradDistributionsVonMises, sanitizer_error_fixed) { +TEST_F(AgradRev, ProbAgradDistributionsVonMises_sanitizer_error_fixed) { using stan::math::var; double y = boost::math::constants::third_pi(); double mu = boost::math::constants::sixth_pi(); diff --git a/test/unit/math/mix/prob/wishart_cholesky_test.cpp b/test/unit/math/mix/prob/wishart_cholesky_test.cpp index d6a4ebf19db..fc47988d445 100644 --- a/test/unit/math/mix/prob/wishart_cholesky_test.cpp +++ b/test/unit/math/mix/prob/wishart_cholesky_test.cpp @@ -1,6 +1,6 @@ #include -TEST(ProbDistributionsWishartCholesky, matvar) { +TEST_F(AgradRev, ProbDistributionsWishartCholesky_matvar) { auto f = [](const auto& L_Y, const auto& dof, const auto& L_S) { return stan::math::wishart_cholesky_lpdf(L_Y, dof, L_S); }; @@ -34,7 +34,7 @@ TEST(ProbDistributionsWishartCholesky, matvar) { stan::test::expect_ad_matvar(f, L_Y11, dof, L_S00); } -TEST(ProbDistributionsWishartCholesky, fvar_var) { +TEST_F(AgradRev, ProbDistributionsWishartCholesky_fvar_var) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::fvar; @@ -67,7 +67,7 @@ TEST(ProbDistributionsWishartCholesky, fvar_var) { stan::math::recover_memory(); } -TEST(ProbDistributionsWishartCholesky, fvar_fvar_var) { +TEST_F(AgradRev, ProbDistributionsWishartCholesky_fvar_fvar_var) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::fvar; diff --git a/test/unit/math/mix/prob/wishart_test.cpp b/test/unit/math/mix/prob/wishart_test.cpp index e100e55e0e1..735fe12aaf5 100644 --- a/test/unit/math/mix/prob/wishart_test.cpp +++ b/test/unit/math/mix/prob/wishart_test.cpp @@ -1,6 +1,6 @@ #include -TEST(ProbDistributionsWishart, matvar) { +TEST_F(AgradRev, ProbDistributionsWishart_matvar) { auto f = [](const auto& y, const auto& dof, const auto& sigma) { auto y_sym = stan::math::multiply(0.5, y + y.transpose()); auto sigma_sym = stan::math::multiply(0.5, sigma + sigma.transpose()); @@ -34,7 +34,7 @@ TEST(ProbDistributionsWishart, matvar) { stan::test::expect_ad_matvar(f, y11, dof, Sigma00); } -TEST(ProbDistributionsWishart, fvar_var) { +TEST_F(AgradRev, ProbDistributionsWishart_fvar_var) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::fvar; @@ -61,7 +61,7 @@ TEST(ProbDistributionsWishart, fvar_var) { stan::math::recover_memory(); } -TEST(ProbDistributionsWishart, fvar_fvar_var) { +TEST_F(AgradRev, ProbDistributionsWishart_fvar_fvar_var) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::fvar; diff --git a/test/unit/math/test_ad.hpp b/test/unit/math/test_ad.hpp index 6144336ad84..678b16b0482 100644 --- a/test/unit/math/test_ad.hpp +++ b/test/unit/math/test_ad.hpp @@ -9,12 +9,13 @@ #include #include #include +#include #include #include #include #include #include - +#include using d_t = double; using v_t = stan::math::var; using fd_t = stan::math::fvar; From d6b892d12fc01baf66f613e1c8cb3a5791447c2c Mon Sep 17 00:00:00 2001 From: Steve Bronder Date: Thu, 17 Aug 2023 12:13:57 -0400 Subject: [PATCH 18/52] use forwarding in normal_lpdf functions --- stan/math/prim/prob/normal_log.hpp | 4 ++-- stan/math/prim/prob/normal_lpdf.hpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/stan/math/prim/prob/normal_log.hpp b/stan/math/prim/prob/normal_log.hpp index 3d007dfea26..3ed8561e185 100644 --- a/stan/math/prim/prob/normal_log.hpp +++ b/stan/math/prim/prob/normal_log.hpp @@ -31,7 +31,7 @@ namespace math { template inline return_type_t normal_log(T_y&& y, T_loc&& mu, T_scale&& sigma) { - return normal_lpdf(y, mu, sigma); + return normal_lpdf(std::forward(y), std::forward(mu), std::forwrad(sigma)); } /** \ingroup prob_dists @@ -40,7 +40,7 @@ inline return_type_t normal_log(T_y&& y, T_loc&& mu, template inline return_type_t normal_log(T_y&& y, T_loc&& mu, T_scale&& sigma) { - return normal_lpdf(y, mu, sigma); + return normal_lpdf(std::forward(y), std::forward(mu), std::forwrad(sigma)); } } // namespace math diff --git a/stan/math/prim/prob/normal_lpdf.hpp b/stan/math/prim/prob/normal_lpdf.hpp index 1921506c120..f272f707116 100644 --- a/stan/math/prim/prob/normal_lpdf.hpp +++ b/stan/math/prim/prob/normal_lpdf.hpp @@ -107,7 +107,7 @@ inline return_type_t normal_lpdf(T_y&& y, T_loc&& mu, template inline return_type_t normal_lpdf(T_y&& y, T_loc&& mu, T_scale&& sigma) { - return normal_lpdf(y, mu, sigma); + return normal_lpdf(std::forward(y), std::forward(mu), std::forwrad(sigma)); } } // namespace math From a85e786cda9c70b583b95fc91731393f4bfed61b Mon Sep 17 00:00:00 2001 From: Stan Jenkins Date: Thu, 17 Aug 2023 12:15:01 -0400 Subject: [PATCH 19/52] [Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1 --- stan/math/prim/prob/normal_log.hpp | 6 ++++-- stan/math/prim/prob/normal_lpdf.hpp | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/stan/math/prim/prob/normal_log.hpp b/stan/math/prim/prob/normal_log.hpp index 3ed8561e185..feedd5f1288 100644 --- a/stan/math/prim/prob/normal_log.hpp +++ b/stan/math/prim/prob/normal_log.hpp @@ -31,7 +31,8 @@ namespace math { template inline return_type_t normal_log(T_y&& y, T_loc&& mu, T_scale&& sigma) { - return normal_lpdf(std::forward(y), std::forward(mu), std::forwrad(sigma)); + return normal_lpdf(std::forward(y), std::forward(mu), + std::forwrad(sigma)); } /** \ingroup prob_dists @@ -40,7 +41,8 @@ inline return_type_t normal_log(T_y&& y, T_loc&& mu, template inline return_type_t normal_log(T_y&& y, T_loc&& mu, T_scale&& sigma) { - return normal_lpdf(std::forward(y), std::forward(mu), std::forwrad(sigma)); + return normal_lpdf(std::forward(y), std::forward(mu), + std::forwrad(sigma)); } } // namespace math diff --git a/stan/math/prim/prob/normal_lpdf.hpp b/stan/math/prim/prob/normal_lpdf.hpp index f272f707116..9c5f99c0b67 100644 --- a/stan/math/prim/prob/normal_lpdf.hpp +++ b/stan/math/prim/prob/normal_lpdf.hpp @@ -107,7 +107,8 @@ inline return_type_t normal_lpdf(T_y&& y, T_loc&& mu, template inline return_type_t normal_lpdf(T_y&& y, T_loc&& mu, T_scale&& sigma) { - return normal_lpdf(std::forward(y), std::forward(mu), std::forwrad(sigma)); + return normal_lpdf(std::forward(y), std::forward(mu), + std::forwrad(sigma)); } } // namespace math From 1b0504acf4ac0781027b52a84198d5e262388fc7 Mon Sep 17 00:00:00 2001 From: Steve Bronder Date: Thu, 17 Aug 2023 12:23:28 -0400 Subject: [PATCH 20/52] fix typo --- stan/math/prim/prob/normal_log.hpp | 4 ++-- stan/math/prim/prob/normal_lpdf.hpp | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/stan/math/prim/prob/normal_log.hpp b/stan/math/prim/prob/normal_log.hpp index feedd5f1288..1b47d93b1fe 100644 --- a/stan/math/prim/prob/normal_log.hpp +++ b/stan/math/prim/prob/normal_log.hpp @@ -32,7 +32,7 @@ template inline return_type_t normal_log(T_y&& y, T_loc&& mu, T_scale&& sigma) { return normal_lpdf(std::forward(y), std::forward(mu), - std::forwrad(sigma)); + std::forward(sigma)); } /** \ingroup prob_dists @@ -42,7 +42,7 @@ template inline return_type_t normal_log(T_y&& y, T_loc&& mu, T_scale&& sigma) { return normal_lpdf(std::forward(y), std::forward(mu), - std::forwrad(sigma)); + std::forward(sigma)); } } // namespace math diff --git a/stan/math/prim/prob/normal_lpdf.hpp b/stan/math/prim/prob/normal_lpdf.hpp index 9c5f99c0b67..b78458db7ba 100644 --- a/stan/math/prim/prob/normal_lpdf.hpp +++ b/stan/math/prim/prob/normal_lpdf.hpp @@ -50,9 +50,9 @@ inline return_type_t normal_lpdf(T_y&& y, T_loc&& mu, static const char* function = "normal_lpdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Scale parameter", sigma); - T_y_ref y_ref = y; - T_mu_ref mu_ref = mu; - T_sigma_ref sigma_ref = sigma; + T_y_ref y_ref = std::forward(y); + T_mu_ref mu_ref = std::forward(mu); + T_sigma_ref sigma_ref = std::forward(sigma); decltype(auto) y_val = to_ref(as_value_column_array_or_scalar(y_ref)); decltype(auto) mu_val = to_ref(as_value_column_array_or_scalar(mu_ref)); @@ -62,7 +62,7 @@ inline return_type_t normal_lpdf(T_y&& y, T_loc&& mu, check_finite(function, "Location parameter", mu_val); check_positive(function, "Scale parameter", sigma_val); - if (size_zero(y, mu, sigma)) { + if (size_zero(y_ref, mu_ref, sigma_ref)) { return 0.0; } if (!include_summand::value) { @@ -77,7 +77,7 @@ inline return_type_t normal_lpdf(T_y&& y, T_loc&& mu, const auto& y_scaled_sq = to_ref_if::value>(y_scaled * y_scaled); - size_t N = max_size(y, mu, sigma); + size_t N = max_size(y_ref, mu_ref, sigma_ref); T_partials_return logp = -0.5 * sum(y_scaled_sq); if (include_summand::value) { logp += NEG_LOG_SQRT_TWO_PI * N; @@ -108,7 +108,7 @@ template inline return_type_t normal_lpdf(T_y&& y, T_loc&& mu, T_scale&& sigma) { return normal_lpdf(std::forward(y), std::forward(mu), - std::forwrad(sigma)); + std::forward(sigma)); } } // namespace math From 0d34e03ad7ff1f8af08e6e35dd248fc77eb0d28e Mon Sep 17 00:00:00 2001 From: Steve Bronder Date: Wed, 3 Jan 2024 16:17:13 -0500 Subject: [PATCH 21/52] update docs --- doxygen/contributor_help_pages/common_pitfalls.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/doxygen/contributor_help_pages/common_pitfalls.md b/doxygen/contributor_help_pages/common_pitfalls.md index 9fecb241989..fd01bf9e42e 100644 --- a/doxygen/contributor_help_pages/common_pitfalls.md +++ b/doxygen/contributor_help_pages/common_pitfalls.md @@ -190,10 +190,9 @@ The general rules to follow for passing values to a function are: 2. If you are writing a function for reverse mode, pass values by `const&` 3. In prim, if you are confident and working with larger types, use perfect forwarding to pass values that can be moved from. Otherwise simply pass values by `const&`. - ### Using auto is Dangerous With Eigen Matrix Functions in Reverse Mode -Like in [Eigen](https://eigen.tuxfamily.org/dox/TopicPitfalls.html), the use of `auto` with the Stan math library should be used with care. Along with the cautions mentioned in the Eigen docs, there are also memory considerations when using reverse mode automatic differentiation. When returning from a function in the Stan math library with an Eigen matrix output with a scalar `var` type, the actual returned type will often be an `arena_matrix>`. The `arena_matrix` class is an Eigen matrix where the underlying array of memory is located in Stan's memory arena. The `arena_matrix` that is returned by Stan functions is normally the same one resting in the callback used to calculate gradients in the reverse pass. Directly changing the elements of this matrix would also change the memory the reverse pass callback sees which would result in incorrect calculations. +The use of auto with the Stan Math library should be used with care, like in [Eigen](https://eigen.tuxfamily.org/dox/TopicPitfalls.html). Along with the cautions mentioned in the Eigen docs, there are also memory considerations when using reverse mode automatic differentiation. When returning from a function in the Stan math library with an Eigen matrix output with a scalar `var` type, the actual returned type will often be an `arena_matrix>`. The `arena_matrix` class is an Eigen matrix where the underlying array of memory is located in Stan's memory arena. The `arena_matrix` that is returned by Stan functions is normally the same one resting in the callback used to calculate gradients in the reverse pass. Directly changing the elements of this matrix would also change the memory the reverse pass callback sees which would result in incorrect calculations. The simple solution to this is that when you use a math library function that returns a matrix and then want to assign to any of the individual elements of the matrix, assign to an actual Eigen matrix type instead of using auto. In the below example, we see the first case which uses auto and will change the memory of the `arena_matrix` returned in the callback for multiply's reverse mode. Directly below it is the safe version, which just directly assigns to an Eigen matrix type and is safe to do element insertion into. From 0b49a282b71b14fa24af29cc7d60a300bea30a8b Mon Sep 17 00:00:00 2001 From: Daniel Lee Date: Wed, 3 Jan 2024 00:41:31 -0500 Subject: [PATCH 22/52] removing deprecated _log() probability functions --- stan/math/prim/prob/bernoulli_log.hpp | 28 --------- .../prim/prob/bernoulli_logit_glm_log.hpp | 31 ---------- stan/math/prim/prob/bernoulli_logit_log.hpp | 29 --------- stan/math/prim/prob/beta_binomial_log.hpp | 34 ----------- stan/math/prim/prob/beta_log.hpp | 31 ---------- stan/math/prim/prob/beta_proportion_log.hpp | 31 ---------- stan/math/prim/prob/binomial_log.hpp | 30 --------- stan/math/prim/prob/binomial_logit_log.hpp | 30 --------- stan/math/prim/prob/categorical_log.hpp | 32 ---------- stan/math/prim/prob/categorical_logit_log.hpp | 32 ---------- stan/math/prim/prob/cauchy_log.hpp | 47 -------------- stan/math/prim/prob/chi_square_log.hpp | 46 -------------- stan/math/prim/prob/dirichlet_log.hpp | 47 -------------- stan/math/prim/prob/dirichlet_lpmf.hpp | 27 -------- stan/math/prim/prob/discrete_range_log.hpp | 29 --------- .../math/prim/prob/double_exponential_log.hpp | 30 --------- stan/math/prim/prob/exp_mod_normal_log.hpp | 35 ----------- stan/math/prim/prob/exponential_log.hpp | 30 --------- stan/math/prim/prob/frechet_log.hpp | 32 ---------- stan/math/prim/prob/gamma_log.hpp | 53 ---------------- stan/math/prim/prob/gaussian_dlm_obs_log.hpp | 34 ----------- stan/math/prim/prob/gumbel_log.hpp | 31 ---------- stan/math/prim/prob/hypergeometric_log.hpp | 30 --------- stan/math/prim/prob/inv_chi_square_log.hpp | 48 --------------- stan/math/prim/prob/inv_gamma_log.hpp | 47 -------------- stan/math/prim/prob/inv_wishart_log.hpp | 50 --------------- stan/math/prim/prob/lkj_corr_cholesky_log.hpp | 31 ---------- stan/math/prim/prob/lkj_corr_log.hpp | 30 --------- stan/math/prim/prob/lkj_cov_log.hpp | 32 ---------- stan/math/prim/prob/logistic_log.hpp | 31 ---------- stan/math/prim/prob/loglogistic_log.hpp | 33 ---------- stan/math/prim/prob/lognormal_log.hpp | 31 ---------- .../math/prim/prob/matrix_normal_prec_log.hpp | 52 ---------------- stan/math/prim/prob/multi_gp_cholesky_log.hpp | 52 ---------------- stan/math/prim/prob/multi_gp_log.hpp | 51 ---------------- .../prim/prob/multi_normal_cholesky_log.hpp | 46 -------------- stan/math/prim/prob/multi_normal_log.hpp | 31 ---------- stan/math/prim/prob/multi_normal_prec_log.hpp | 31 ---------- stan/math/prim/prob/multi_student_t_log.hpp | 37 ----------- stan/math/prim/prob/multinomial_log.hpp | 32 ---------- stan/math/prim/prob/multinomial_logit_log.hpp | 33 ---------- stan/math/prim/prob/neg_binomial_2_log.hpp | 30 --------- .../prim/prob/neg_binomial_2_log_glm_log.hpp | 34 ----------- .../math/prim/prob/neg_binomial_2_log_log.hpp | 31 ---------- stan/math/prim/prob/neg_binomial_log.hpp | 31 ---------- stan/math/prim/prob/normal_id_glm_log.hpp | 34 ----------- stan/math/prim/prob/normal_log.hpp | 50 --------------- stan/math/prim/prob/normal_sufficient_log.hpp | 36 ----------- stan/math/prim/prob/ordered_logistic_log.hpp | 58 ------------------ stan/math/prim/prob/ordered_probit_log.hpp | 59 ------------------ stan/math/prim/prob/pareto_log.hpp | 32 ---------- stan/math/prim/prob/pareto_type_2_log.hpp | 34 ----------- stan/math/prim/prob/poisson_binomial_log.hpp | 30 --------- stan/math/prim/prob/poisson_log.hpp | 28 --------- stan/math/prim/prob/poisson_log_glm_log.hpp | 33 ---------- stan/math/prim/prob/poisson_log_log.hpp | 30 --------- stan/math/prim/prob/rayleigh_log.hpp | 29 --------- .../prim/prob/scaled_inv_chi_square_log.hpp | 51 ---------------- .../prim/prob/skew_double_exponential_log.hpp | 35 ----------- stan/math/prim/prob/skew_normal_log.hpp | 32 ---------- stan/math/prim/prob/std_normal_log.hpp | 39 ------------ stan/math/prim/prob/student_t_log.hpp | 60 ------------------ stan/math/prim/prob/uniform_log.hpp | 52 ---------------- stan/math/prim/prob/von_mises_log.hpp | 31 ---------- stan/math/prim/prob/weibull_log.hpp | 32 ---------- stan/math/prim/prob/wiener_log.hpp | 53 ---------------- stan/math/prim/prob/wishart_log.hpp | 61 ------------------- 67 files changed, 2502 deletions(-) delete mode 100644 stan/math/prim/prob/bernoulli_log.hpp delete mode 100644 stan/math/prim/prob/bernoulli_logit_glm_log.hpp delete mode 100644 stan/math/prim/prob/bernoulli_logit_log.hpp delete mode 100644 stan/math/prim/prob/beta_binomial_log.hpp delete mode 100644 stan/math/prim/prob/beta_log.hpp delete mode 100644 stan/math/prim/prob/beta_proportion_log.hpp delete mode 100644 stan/math/prim/prob/binomial_log.hpp delete mode 100644 stan/math/prim/prob/binomial_logit_log.hpp delete mode 100644 stan/math/prim/prob/categorical_log.hpp delete mode 100644 stan/math/prim/prob/categorical_logit_log.hpp delete mode 100644 stan/math/prim/prob/cauchy_log.hpp delete mode 100644 stan/math/prim/prob/chi_square_log.hpp delete mode 100644 stan/math/prim/prob/dirichlet_log.hpp delete mode 100644 stan/math/prim/prob/dirichlet_lpmf.hpp delete mode 100644 stan/math/prim/prob/discrete_range_log.hpp delete mode 100644 stan/math/prim/prob/double_exponential_log.hpp delete mode 100644 stan/math/prim/prob/exp_mod_normal_log.hpp delete mode 100644 stan/math/prim/prob/exponential_log.hpp delete mode 100644 stan/math/prim/prob/frechet_log.hpp delete mode 100644 stan/math/prim/prob/gamma_log.hpp delete mode 100644 stan/math/prim/prob/gaussian_dlm_obs_log.hpp delete mode 100644 stan/math/prim/prob/gumbel_log.hpp delete mode 100644 stan/math/prim/prob/hypergeometric_log.hpp delete mode 100644 stan/math/prim/prob/inv_chi_square_log.hpp delete mode 100644 stan/math/prim/prob/inv_gamma_log.hpp delete mode 100644 stan/math/prim/prob/inv_wishart_log.hpp delete mode 100644 stan/math/prim/prob/lkj_corr_cholesky_log.hpp delete mode 100644 stan/math/prim/prob/lkj_corr_log.hpp delete mode 100644 stan/math/prim/prob/lkj_cov_log.hpp delete mode 100644 stan/math/prim/prob/logistic_log.hpp delete mode 100644 stan/math/prim/prob/loglogistic_log.hpp delete mode 100644 stan/math/prim/prob/lognormal_log.hpp delete mode 100644 stan/math/prim/prob/matrix_normal_prec_log.hpp delete mode 100644 stan/math/prim/prob/multi_gp_cholesky_log.hpp delete mode 100644 stan/math/prim/prob/multi_gp_log.hpp delete mode 100644 stan/math/prim/prob/multi_normal_cholesky_log.hpp delete mode 100644 stan/math/prim/prob/multi_normal_log.hpp delete mode 100644 stan/math/prim/prob/multi_normal_prec_log.hpp delete mode 100644 stan/math/prim/prob/multi_student_t_log.hpp delete mode 100644 stan/math/prim/prob/multinomial_log.hpp delete mode 100644 stan/math/prim/prob/multinomial_logit_log.hpp delete mode 100644 stan/math/prim/prob/neg_binomial_2_log.hpp delete mode 100644 stan/math/prim/prob/neg_binomial_2_log_glm_log.hpp delete mode 100644 stan/math/prim/prob/neg_binomial_2_log_log.hpp delete mode 100644 stan/math/prim/prob/neg_binomial_log.hpp delete mode 100644 stan/math/prim/prob/normal_id_glm_log.hpp delete mode 100644 stan/math/prim/prob/normal_log.hpp delete mode 100644 stan/math/prim/prob/normal_sufficient_log.hpp delete mode 100644 stan/math/prim/prob/ordered_logistic_log.hpp delete mode 100644 stan/math/prim/prob/ordered_probit_log.hpp delete mode 100644 stan/math/prim/prob/pareto_log.hpp delete mode 100644 stan/math/prim/prob/pareto_type_2_log.hpp delete mode 100644 stan/math/prim/prob/poisson_binomial_log.hpp delete mode 100644 stan/math/prim/prob/poisson_log.hpp delete mode 100644 stan/math/prim/prob/poisson_log_glm_log.hpp delete mode 100644 stan/math/prim/prob/poisson_log_log.hpp delete mode 100644 stan/math/prim/prob/rayleigh_log.hpp delete mode 100644 stan/math/prim/prob/scaled_inv_chi_square_log.hpp delete mode 100644 stan/math/prim/prob/skew_double_exponential_log.hpp delete mode 100644 stan/math/prim/prob/skew_normal_log.hpp delete mode 100644 stan/math/prim/prob/std_normal_log.hpp delete mode 100644 stan/math/prim/prob/student_t_log.hpp delete mode 100644 stan/math/prim/prob/uniform_log.hpp delete mode 100644 stan/math/prim/prob/von_mises_log.hpp delete mode 100644 stan/math/prim/prob/weibull_log.hpp delete mode 100644 stan/math/prim/prob/wiener_log.hpp delete mode 100644 stan/math/prim/prob/wishart_log.hpp diff --git a/stan/math/prim/prob/bernoulli_log.hpp b/stan/math/prim/prob/bernoulli_log.hpp deleted file mode 100644 index dc4b05257e8..00000000000 --- a/stan/math/prim/prob/bernoulli_log.hpp +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_BERNOULLI_LOG_HPP -#define STAN_MATH_PRIM_PROB_BERNOULLI_LOG_HPP - -#include -#include - -namespace stan { -namespace math { - -/** \ingroup prob_dists - * @deprecated use bernoulli_lpmf - */ -template -return_type_t bernoulli_log(const T_n& n, const T_prob& theta) { - return bernoulli_lpmf(n, theta); -} - -/** \ingroup prob_dists - * @deprecated use bernoulli_lpmf - */ -template -inline return_type_t bernoulli_log(const T_y& n, const T_prob& theta) { - return bernoulli_lpmf(n, theta); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/bernoulli_logit_glm_log.hpp b/stan/math/prim/prob/bernoulli_logit_glm_log.hpp deleted file mode 100644 index a4103784ced..00000000000 --- a/stan/math/prim/prob/bernoulli_logit_glm_log.hpp +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_BERNOULLI_LOGIT_GLM_LOG_HPP -#define STAN_MATH_PRIM_PROB_BERNOULLI_LOGIT_GLM_LOG_HPP - -#include -#include - -namespace stan { -namespace math { - -/** \ingroup multivar_dists - * @deprecated use bernoulli_logit_glm_lpmf - */ -template -return_type_t bernoulli_logit_glm_log( - const T_y &y, const T_x &x, const T_alpha &alpha, const T_beta &beta) { - return bernoulli_logit_glm_lpmf( - y, x, alpha, beta); -} - -/** \ingroup multivar_dists - * @deprecated use bernoulli_logit_glm_lpmf - */ -template -inline return_type_t bernoulli_logit_glm_log( - const T_y &y, const T_x &x, const T_alpha &alpha, const T_beta &beta) { - return bernoulli_logit_glm_lpmf(y, x, alpha, beta); -} -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/bernoulli_logit_log.hpp b/stan/math/prim/prob/bernoulli_logit_log.hpp deleted file mode 100644 index d42f123732a..00000000000 --- a/stan/math/prim/prob/bernoulli_logit_log.hpp +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_BERNOULLI_LOGIT_LOG_HPP -#define STAN_MATH_PRIM_PROB_BERNOULLI_LOGIT_LOG_HPP - -#include -#include - -namespace stan { -namespace math { - -/** \ingroup prob_dists - * @deprecated use bernoulli_logit_lpmf - */ -template -return_type_t bernoulli_logit_log(const T_n& n, const T_prob& theta) { - return bernoulli_logit_lpmf(n, theta); -} - -/** \ingroup prob_dists - * @deprecated use bernoulli_logit_lpmf - */ -template -inline return_type_t bernoulli_logit_log(const T_n& n, - const T_prob& theta) { - return bernoulli_logit_lpmf(n, theta); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/beta_binomial_log.hpp b/stan/math/prim/prob/beta_binomial_log.hpp deleted file mode 100644 index dc8fb90c495..00000000000 --- a/stan/math/prim/prob/beta_binomial_log.hpp +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_BETA_BINOMIAL_LOG_HPP -#define STAN_MATH_PRIM_PROB_BETA_BINOMIAL_LOG_HPP - -#include -#include - -namespace stan { -namespace math { - -/** \ingroup prob_dists - * @deprecated use beta_binomial_lpmf - */ -template -return_type_t beta_binomial_log(const T_n& n, const T_N& N, - const T_size1& alpha, - const T_size2& beta) { - return beta_binomial_lpmf(n, N, alpha, - beta); -} - -/** \ingroup prob_dists - * @deprecated use beta_binomial_lpmf - */ -template -return_type_t beta_binomial_log(const T_n& n, const T_N& N, - const T_size1& alpha, - const T_size2& beta) { - return beta_binomial_lpmf(n, N, alpha, beta); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/beta_log.hpp b/stan/math/prim/prob/beta_log.hpp deleted file mode 100644 index 4e67084051b..00000000000 --- a/stan/math/prim/prob/beta_log.hpp +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_BETA_LOG_HPP -#define STAN_MATH_PRIM_PROB_BETA_LOG_HPP - -#include -#include - -namespace stan { -namespace math { - -/** \ingroup prob_dists - * @deprecated use beta_lpdf - */ -template -return_type_t beta_log( - const T_y& y, const T_scale_succ& alpha, const T_scale_fail& beta) { - return beta_lpdf(y, alpha, beta); -} - -/** \ingroup prob_dists - * @deprecated use beta_lpdf - */ -template -inline return_type_t beta_log( - const T_y& y, const T_scale_succ& alpha, const T_scale_fail& beta) { - return beta_lpdf(y, alpha, beta); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/beta_proportion_log.hpp b/stan/math/prim/prob/beta_proportion_log.hpp deleted file mode 100644 index 06ff7a7a4af..00000000000 --- a/stan/math/prim/prob/beta_proportion_log.hpp +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_BETA_PROPORTION_LOG_HPP -#define STAN_MATH_PRIM_PROB_BETA_PROPORTION_LOG_HPP - -#include -#include - -namespace stan { -namespace math { - -/** \ingroup prob_dists - * @deprecated use beta_proportion_lpdf - */ -template -return_type_t beta_proportion_log(const T_y& y, - const T_loc& mu, - const T_prec& kappa) { - return beta_proportion_lpdf(y, mu, kappa); -} - -/** \ingroup prob_dists - * @deprecated use beta_proportion_lpdf - */ -template -inline return_type_t beta_proportion_log( - const T_y& y, const T_loc& mu, const T_prec& kappa) { - return beta_proportion_lpdf(y, mu, kappa); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/binomial_log.hpp b/stan/math/prim/prob/binomial_log.hpp deleted file mode 100644 index 55157c0d3f5..00000000000 --- a/stan/math/prim/prob/binomial_log.hpp +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_BINOMIAL_LOG_HPP -#define STAN_MATH_PRIM_PROB_BINOMIAL_LOG_HPP - -#include -#include - -namespace stan { -namespace math { - -/** \ingroup prob_dists - * @deprecated use binomial_lpmf - */ -template -return_type_t binomial_log(const T_n& n, const T_N& N, - const T_prob& theta) { - return binomial_lpmf(n, N, theta); -} - -/** \ingroup prob_dists - * @deprecated use binomial_lpmf - */ -template -inline return_type_t binomial_log(const T_n& n, const T_N& N, - const T_prob& theta) { - return binomial_lpmf(n, N, theta); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/binomial_logit_log.hpp b/stan/math/prim/prob/binomial_logit_log.hpp deleted file mode 100644 index e3b4e6be181..00000000000 --- a/stan/math/prim/prob/binomial_logit_log.hpp +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_BINOMIAL_LOGIT_LOG_HPP -#define STAN_MATH_PRIM_PROB_BINOMIAL_LOGIT_LOG_HPP - -#include -#include - -namespace stan { -namespace math { - -/** \ingroup prob_dists - * @deprecated use binomial_logit_lpmf - */ -template -return_type_t binomial_logit_log(const T_n& n, const T_N& N, - const T_prob& alpha) { - return binomial_logit_lpmf(n, N, alpha); -} - -/** \ingroup prob_dists - * @deprecated use binomial_logit_lpmf - */ -template -inline return_type_t binomial_logit_log(const T_n& n, const T_N& N, - const T_prob& alpha) { - return binomial_logit_lpmf(n, N, alpha); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/categorical_log.hpp b/stan/math/prim/prob/categorical_log.hpp deleted file mode 100644 index 1b8e4c2317f..00000000000 --- a/stan/math/prim/prob/categorical_log.hpp +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_CATEGORICAL_LOG_HPP -#define STAN_MATH_PRIM_PROB_CATEGORICAL_LOG_HPP - -#include -#include -#include -#include - -namespace stan { -namespace math { - -/** \ingroup multivar_dists - * @deprecated use categorical_lpmf - */ -template -inline return_type_t categorical_log(const T_n& ns, - const T_prob& theta) { - return categorical_lpmf(ns, theta); -} - -/** \ingroup multivar_dists - * @deprecated use categorical_lpmf - */ -template -inline return_type_t categorical_log(const T_n& ns, - const T_prob& theta) { - return categorical_lpmf(ns, theta); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/categorical_logit_log.hpp b/stan/math/prim/prob/categorical_logit_log.hpp deleted file mode 100644 index 953cd1e43f0..00000000000 --- a/stan/math/prim/prob/categorical_logit_log.hpp +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_CATEGORICAL_LOGIT_LOG_HPP -#define STAN_MATH_PRIM_PROB_CATEGORICAL_LOGIT_LOG_HPP - -#include -#include -#include -#include - -namespace stan { -namespace math { - -/** \ingroup multivar_dists - * @deprecated use categorical_logit_lpmf - */ -template -inline return_type_t categorical_logit_log(const T_n& ns, - const T_prob& beta) { - return categorical_logit_lpmf(ns, beta); -} - -/** \ingroup multivar_dists - * @deprecated use categorical_logit_lpmf - */ -template -inline return_type_t categorical_logit_log(const T_n& ns, - const T_prob& beta) { - return categorical_logit_lpmf(ns, beta); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/cauchy_log.hpp b/stan/math/prim/prob/cauchy_log.hpp deleted file mode 100644 index 966a178c9ea..00000000000 --- a/stan/math/prim/prob/cauchy_log.hpp +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_CAUCHY_LOG_HPP -#define STAN_MATH_PRIM_PROB_CAUCHY_LOG_HPP - -#include -#include - -namespace stan { -namespace math { - -/** \ingroup prob_dists - * The log of the Cauchy density for the specified scalar(s) given - * the specified location parameter(s) and scale parameter(s). y, - * mu, or sigma can each either be scalar a vector. Any vector - * inputs must be the same length. - * - *

The result log probability is defined to be the sum of - * the log probabilities for each observation/mu/sigma triple. - * - * @deprecated use cauchy_lpdf - * - * @param y (Sequence of) scalar(s). - * @param mu (Sequence of) location(s). - * @param sigma (Sequence of) scale(s). - * @return The log of the product of densities. - * @tparam T_scale Type of scale. - * @tparam T_y Type of scalar outcome. - * @tparam T_loc Type of location. - */ -template -return_type_t cauchy_log(const T_y& y, const T_loc& mu, - const T_scale& sigma) { - return cauchy_lpdf(y, mu, sigma); -} - -/** \ingroup prob_dists - * @deprecated use cauchy_lpdf - */ -template -inline return_type_t cauchy_log(const T_y& y, - const T_loc& mu, - const T_scale& sigma) { - return cauchy_lpdf(y, mu, sigma); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/chi_square_log.hpp b/stan/math/prim/prob/chi_square_log.hpp deleted file mode 100644 index 71dd2bc8af0..00000000000 --- a/stan/math/prim/prob/chi_square_log.hpp +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_CHI_SQUARE_LOG_HPP -#define STAN_MATH_PRIM_PROB_CHI_SQUARE_LOG_HPP - -#include -#include - -namespace stan { -namespace math { - -/** \ingroup prob_dists - * The log of a chi-squared density for y with the specified - * degrees of freedom parameter. - * The degrees of freedom parameter must be greater than 0. - * y must be greater than or equal to 0. - * - \f{eqnarray*}{ - y &\sim& \chi^2_\nu \\ - \log (p (y \, |\, \nu)) &=& \log \left( \frac{2^{-\nu / 2}}{\Gamma (\nu / 2)} - y^{\nu / 2 - 1} \exp^{- y / 2} \right) \\ - &=& - \frac{\nu}{2} \log(2) - \log (\Gamma (\nu / 2)) + (\frac{\nu}{2} - 1) - \log(y) - \frac{y}{2} \\ & & \mathrm{ where } \; y \ge 0 \f} - * - * @deprecated use chi_square_lpdf - * @param y A scalar variable. - * @param nu Degrees of freedom. - * @throw std::domain_error if nu is not greater than or equal to 0 - * @throw std::domain_error if y is not greater than or equal to 0. - * @tparam T_y Type of scalar. - * @tparam T_dof Type of degrees of freedom. - */ -template -return_type_t chi_square_log(const T_y& y, const T_dof& nu) { - return chi_square_lpdf(y, nu); -} - -/** \ingroup prob_dists - * @deprecated use chi_square_lpdf - */ -template -inline return_type_t chi_square_log(const T_y& y, const T_dof& nu) { - return chi_square_lpdf(y, nu); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/dirichlet_log.hpp b/stan/math/prim/prob/dirichlet_log.hpp deleted file mode 100644 index 30413cdda80..00000000000 --- a/stan/math/prim/prob/dirichlet_log.hpp +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_DIRICHLET_LOG_HPP -#define STAN_MATH_PRIM_PROB_DIRICHLET_LOG_HPP - -#include -#include -#include - -namespace stan { -namespace math { - -/** \ingroup multivar_dists - * The log of the Dirichlet density for the given theta and - * a vector of prior sample sizes, alpha. - * Each element of alpha must be greater than 0. - * Each element of theta must be greater than or 0. - * Theta sums to 1. - * - * @deprecated use dirichlet_lpdf - * - * @param theta A scalar vector. - * @param alpha Prior sample sizes. - * @return The log of the Dirichlet density. - * @throw std::domain_error if any element of alpha is less than - * or equal to 0. - * @throw std::domain_error if any element of theta is less than 0. - * @throw std::domain_error if the sum of theta is not 1. - * @tparam T_prob Type of scalar. - * @tparam T_prior_size Type of prior sample sizes. - */ -template -return_type_t dirichlet_log(const T_prob& theta, - const T_prior_size& alpha) { - return dirichlet_lpdf(theta, alpha); -} - -/** \ingroup multivar_dists - * @deprecated use dirichlet_lpdf - */ -template -return_type_t dirichlet_log(const T_prob& theta, - const T_prior_size& alpha) { - return dirichlet_lpdf(theta, alpha); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/dirichlet_lpmf.hpp b/stan/math/prim/prob/dirichlet_lpmf.hpp deleted file mode 100644 index fd3b66a976c..00000000000 --- a/stan/math/prim/prob/dirichlet_lpmf.hpp +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_DIRICHLET_LPMF_HPP -#define STAN_MATH_PRIM_PROB_DIRICHLET_LPMF_HPP - -#include -#include - -namespace stan { -namespace math { - -/** \ingroup multivar_dists - * @deprecated use dirichlet_lpdf - */ -template -return_type_t dirichlet_lpmf(const T_prob& theta, - const T_prior_size& alpha) { - return dirichlet_lpdf(theta, alpha); -} - -template -return_type_t dirichlet_lpmf(const T_prob& theta, - const T_prior_size& alpha) { - return dirichlet_lpdf(theta, alpha); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/discrete_range_log.hpp b/stan/math/prim/prob/discrete_range_log.hpp deleted file mode 100644 index bee68587ae1..00000000000 --- a/stan/math/prim/prob/discrete_range_log.hpp +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_DISCRETE_RANGE_LOG_HPP -#define STAN_MATH_PRIM_PROB_DISCRETE_RANGE_LOG_HPP - -#include - -namespace stan { -namespace math { - -/** \ingroup prob_dists - * @deprecated use discrete_range_lpmf - */ -template -double discrete_range_log(const T_y& y, const T_lower& lower, - const T_upper& upper) { - return discrete_range_lpmf(y, lower, upper); -} - -/** \ingroup prob_dists - * @deprecated use discrete_range_lpmf - */ -template -inline double discrete_range_log(const T_y& y, const T_lower& lower, - const T_upper& upper) { - return discrete_range_lpmf(y, lower, upper); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/double_exponential_log.hpp b/stan/math/prim/prob/double_exponential_log.hpp deleted file mode 100644 index 731e67bd743..00000000000 --- a/stan/math/prim/prob/double_exponential_log.hpp +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_DOUBLE_EXPONENTIAL_LOG_HPP -#define STAN_MATH_PRIM_PROB_DOUBLE_EXPONENTIAL_LOG_HPP - -#include -#include - -namespace stan { -namespace math { - -/** \ingroup prob_dists - * @deprecated use double_exponential_lpdf - */ -template -return_type_t double_exponential_log( - const T_y& y, const T_loc& mu, const T_scale& sigma) { - return double_exponential_lpdf(y, mu, sigma); -} - -/** \ingroup prob_dists - * @deprecated use double_exponential_lpdf - */ -template -return_type_t double_exponential_log( - const T_y& y, const T_loc& mu, const T_scale& sigma) { - return double_exponential_lpdf(y, mu, sigma); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/exp_mod_normal_log.hpp b/stan/math/prim/prob/exp_mod_normal_log.hpp deleted file mode 100644 index 6146883ffda..00000000000 --- a/stan/math/prim/prob/exp_mod_normal_log.hpp +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_EXP_MOD_NORMAL_LOG_HPP -#define STAN_MATH_PRIM_PROB_EXP_MOD_NORMAL_LOG_HPP - -#include -#include - -namespace stan { -namespace math { - -/** \ingroup prob_dists - * @deprecated use exp_mod_normal_lpdf - */ -template -return_type_t exp_mod_normal_log( - const T_y& y, const T_loc& mu, const T_scale& sigma, - const T_inv_scale& lambda) { - return exp_mod_normal_lpdf( - y, mu, sigma, lambda); -} - -/** \ingroup prob_dists - * @deprecated use exp_mod_normal_lpdf - */ -template -inline return_type_t exp_mod_normal_log( - const T_y& y, const T_loc& mu, const T_scale& sigma, - const T_inv_scale& lambda) { - return exp_mod_normal_lpdf(y, mu, sigma, - lambda); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/exponential_log.hpp b/stan/math/prim/prob/exponential_log.hpp deleted file mode 100644 index 9373e3527ed..00000000000 --- a/stan/math/prim/prob/exponential_log.hpp +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_EXPONENTIAL_LOG_HPP -#define STAN_MATH_PRIM_PROB_EXPONENTIAL_LOG_HPP - -#include -#include - -namespace stan { -namespace math { - -/** \ingroup prob_dists - * @deprecated use exponential_lpdf - */ -template -return_type_t exponential_log(const T_y& y, - const T_inv_scale& beta) { - return exponential_lpdf(y, beta); -} - -/** \ingroup prob_dists - * @deprecated use exponential_lpdf - */ -template -inline return_type_t exponential_log( - const T_y& y, const T_inv_scale& beta) { - return exponential_lpdf(y, beta); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/frechet_log.hpp b/stan/math/prim/prob/frechet_log.hpp deleted file mode 100644 index 6c914e7bb6b..00000000000 --- a/stan/math/prim/prob/frechet_log.hpp +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_FRECHET_LOG_HPP -#define STAN_MATH_PRIM_PROB_FRECHET_LOG_HPP - -#include -#include - -namespace stan { -namespace math { - -/** \ingroup prob_dists - * @deprecated use frechet_lpdf - */ -template -return_type_t frechet_log(const T_y& y, - const T_shape& alpha, - const T_scale& sigma) { - return frechet_lpdf(y, alpha, sigma); -} - -/** \ingroup prob_dists - * @deprecated use frechet_lpdf - */ -template -inline return_type_t frechet_log(const T_y& y, - const T_shape& alpha, - const T_scale& sigma) { - return frechet_lpdf(y, alpha, sigma); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/gamma_log.hpp b/stan/math/prim/prob/gamma_log.hpp deleted file mode 100644 index bb7091b39ac..00000000000 --- a/stan/math/prim/prob/gamma_log.hpp +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_GAMMA_LOG_HPP -#define STAN_MATH_PRIM_PROB_GAMMA_LOG_HPP - -#include -#include - -namespace stan { -namespace math { - -/** \ingroup prob_dists - * The log of a gamma density for y with the specified - * shape and inverse scale parameters. - * Shape and inverse scale parameters must be greater than 0. - * y must be greater than or equal to 0. - * - \f{eqnarray*}{ - y &\sim& \mbox{\sf{Gamma}}(\alpha, \beta) \\ - \log (p (y \, |\, \alpha, \beta) ) &=& \log \left( - \frac{\beta^\alpha}{\Gamma(\alpha)} y^{\alpha - 1} \exp^{- \beta y} \right) \\ - &=& \alpha \log(\beta) - \log(\Gamma(\alpha)) + (\alpha - 1) \log(y) - \beta - y\\ & & \mathrm{where} \; y > 0 \f} - * - * @deprecated use gamma_lpdf - * - * @param y A scalar variable. - * @param alpha Shape parameter. - * @param beta Inverse scale parameter. - * @throw std::domain_error if alpha is not greater than 0. - * @throw std::domain_error if beta is not greater than 0. - * @throw std::domain_error if y is not greater than or equal to 0. - * @tparam T_y Type of scalar. - * @tparam T_shape Type of shape. - * @tparam T_inv_scale Type of inverse scale. - */ -template -return_type_t gamma_log(const T_y& y, - const T_shape& alpha, - const T_inv_scale& beta) { - return gamma_lpdf(y, alpha, beta); -} - -/** \ingroup prob_dists - * @deprecated use gamma_lpdf - */ -template -inline return_type_t gamma_log( - const T_y& y, const T_shape& alpha, const T_inv_scale& beta) { - return gamma_lpdf(y, alpha, beta); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/gaussian_dlm_obs_log.hpp b/stan/math/prim/prob/gaussian_dlm_obs_log.hpp deleted file mode 100644 index 3cda104319f..00000000000 --- a/stan/math/prim/prob/gaussian_dlm_obs_log.hpp +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_GAUSSIAN_DLM_OBS_LOG_HPP -#define STAN_MATH_PRIM_PROB_GAUSSIAN_DLM_OBS_LOG_HPP - -#include -#include -#include - -namespace stan { -namespace math { -/** \ingroup multivar_dists - * @deprecated use gaussian_dlm_obs_lpdf - */ -template -inline return_type_t gaussian_dlm_obs_log( - const T_y& y, const T_F& F, const T_G& G, const T_V& V, const T_W& W, - const T_m0& m0, const T_C0& C0) { - return gaussian_dlm_obs_lpdf(y, F, G, V, W, m0, C0); -} - -/** \ingroup multivar_dists - * @deprecated use gaussian_dlm_obs_lpdf - */ -template -inline return_type_t gaussian_dlm_obs_log( - const T_y& y, const T_F& F, const T_G& G, const T_V& V, const T_W& W, - const T_m0& m0, const T_C0& C0) { - return gaussian_dlm_obs_lpdf<>(y, F, G, V, W, m0, C0); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/gumbel_log.hpp b/stan/math/prim/prob/gumbel_log.hpp deleted file mode 100644 index 007f1c16b77..00000000000 --- a/stan/math/prim/prob/gumbel_log.hpp +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_GUMBEL_LOG_HPP -#define STAN_MATH_PRIM_PROB_GUMBEL_LOG_HPP - -#include -#include - -namespace stan { -namespace math { - -/** \ingroup prob_dists - * @deprecated use gumbel_lpdf - */ -template -return_type_t gumbel_log(const T_y& y, const T_loc& mu, - const T_scale& beta) { - return gumbel_lpdf(y, mu, beta); -} - -/** \ingroup prob_dists - * @deprecated use gumbel_lpdf - */ -template -inline return_type_t gumbel_log(const T_y& y, - const T_loc& mu, - const T_scale& beta) { - return gumbel_lpdf(y, mu, beta); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/hypergeometric_log.hpp b/stan/math/prim/prob/hypergeometric_log.hpp deleted file mode 100644 index eadf1a08e22..00000000000 --- a/stan/math/prim/prob/hypergeometric_log.hpp +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_HYPERGEOMETRIC_LOG_HPP -#define STAN_MATH_PRIM_PROB_HYPERGEOMETRIC_LOG_HPP - -#include -#include - -namespace stan { -namespace math { - -/** \ingroup prob_dists - * @deprecated use hypergeometric_lpmf - */ -template -double hypergeometric_log(const T_n& n, const T_N& N, const T_a& a, - const T_b& b) { - return hypergeometric_lpmf(n, N, a, b); -} - -/** \ingroup prob_dists - * @deprecated use hypergeometric_lpmf - */ -template -inline double hypergeometric_log(const T_n& n, const T_N& N, const T_a& a, - const T_b& b) { - return hypergeometric_lpmf(n, N, a, b); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/inv_chi_square_log.hpp b/stan/math/prim/prob/inv_chi_square_log.hpp deleted file mode 100644 index fe903688e1d..00000000000 --- a/stan/math/prim/prob/inv_chi_square_log.hpp +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_INV_CHI_SQUARE_LOG_HPP -#define STAN_MATH_PRIM_PROB_INV_CHI_SQUARE_LOG_HPP - -#include -#include - -namespace stan { -namespace math { - -/** \ingroup prob_dists - * The log of an inverse chi-squared density for y with the specified - * degrees of freedom parameter. - * The degrees of freedom parameter must be greater than 0. - * y must be greater than 0. - * - \f{eqnarray*}{ - y &\sim& \mbox{\sf{Inv-}}\chi^2_\nu \\ - \log (p (y \, |\, \nu)) &=& \log \left( \frac{2^{-\nu / 2}}{\Gamma (\nu / 2)} - y^{- (\nu / 2 + 1)} \exp^{-1 / (2y)} \right) \\ - &=& - \frac{\nu}{2} \log(2) - \log (\Gamma (\nu / 2)) - (\frac{\nu}{2} + 1) - \log(y) - \frac{1}{2y} \\ & & \mathrm{ where } \; y > 0 \f} - * - * @deprecated use inv_chi_square_lpdf - * - * @param y A scalar variable. - * @param nu Degrees of freedom. - * @throw std::domain_error if nu is not greater than or equal to 0 - * @throw std::domain_error if y is not greater than or equal to 0. - * @tparam T_y Type of scalar. - * @tparam T_dof Type of degrees of freedom. - */ -template -return_type_t inv_chi_square_log(const T_y& y, const T_dof& nu) { - return inv_chi_square_lpdf(y, nu); -} - -/** \ingroup prob_dists - * @deprecated use inv_chi_square_lpdf - */ -template -inline return_type_t inv_chi_square_log(const T_y& y, - const T_dof& nu) { - return inv_chi_square_lpdf(y, nu); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/inv_gamma_log.hpp b/stan/math/prim/prob/inv_gamma_log.hpp deleted file mode 100644 index 59199837a2e..00000000000 --- a/stan/math/prim/prob/inv_gamma_log.hpp +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_INV_GAMMA_LOG_HPP -#define STAN_MATH_PRIM_PROB_INV_GAMMA_LOG_HPP - -#include -#include - -namespace stan { -namespace math { - -/** \ingroup prob_dists - * The log of an inverse gamma density for y with the specified - * shape and scale parameters. - * Shape and scale parameters must be greater than 0. - * y must be greater than 0. - * - * @deprecated use inv_gamma_lpdf - * - * @param y A scalar variable. - * @param alpha Shape parameter. - * @param beta Scale parameter. - * @throw std::domain_error if alpha is not greater than 0. - * @throw std::domain_error if beta is not greater than 0. - * @throw std::domain_error if y is not greater than 0. - * @tparam T_y Type of scalar. - * @tparam T_shape Type of shape. - * @tparam T_scale Type of scale. - */ -template -return_type_t inv_gamma_log(const T_y& y, - const T_shape& alpha, - const T_scale& beta) { - return inv_gamma_lpdf(y, alpha, beta); -} - -/** \ingroup prob_dists - * @deprecated use inv_gamma_lpdf - */ -template -inline return_type_t inv_gamma_log(const T_y& y, - const T_shape& alpha, - const T_scale& beta) { - return inv_gamma_lpdf(y, alpha, beta); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/inv_wishart_log.hpp b/stan/math/prim/prob/inv_wishart_log.hpp deleted file mode 100644 index d790ae9c832..00000000000 --- a/stan/math/prim/prob/inv_wishart_log.hpp +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_INV_WISHART_LOG_HPP -#define STAN_MATH_PRIM_PROB_INV_WISHART_LOG_HPP - -#include -#include -#include - -namespace stan { -namespace math { - -/** \ingroup multivar_dists - * The log of the Inverse-Wishart density for the given W, degrees - * of freedom, and scale matrix. - * - * The scale matrix, S, must be k x k, symmetric, and semi-positive - * definite. - * - * @deprecated use inverse_wishart_lpdf - * - * @param W A scalar matrix - * @param nu Degrees of freedom - * @param S The scale matrix - * @return The log of the Inverse-Wishart density at W given nu and S. - * @throw std::domain_error if nu is not greater than k-1 - * @throw std::domain_error if S is not square, not symmetric, or not - * semi-positive definite. - * @tparam T_y Type of scalar. - * @tparam T_dof Type of degrees of freedom. - * @tparam T_scale Type of scale. - */ -template -return_type_t inv_wishart_log(const T_y& W, - const T_dof& nu, - const T_scale& S) { - return inv_wishart_lpdf(W, nu, S); -} - -/** \ingroup multivar_dists - * @deprecated use inverse_wishart_lpdf - */ -template -inline return_type_t inv_wishart_log(const T_y& W, - const T_dof& nu, - const T_scale& S) { - return inv_wishart_lpdf<>(W, nu, S); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/lkj_corr_cholesky_log.hpp b/stan/math/prim/prob/lkj_corr_cholesky_log.hpp deleted file mode 100644 index 0f2b0797006..00000000000 --- a/stan/math/prim/prob/lkj_corr_cholesky_log.hpp +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_LKJ_CORR_CHOLESKY_LOG_HPP -#define STAN_MATH_PRIM_PROB_LKJ_CORR_CHOLESKY_LOG_HPP - -#include -#include -#include - -namespace stan { -namespace math { - -/** \ingroup multivar_dists - * @deprecated use lkj_corr_cholesky_lpdf - */ -template -return_type_t lkj_corr_cholesky_log(const T_covar& L, - const T_shape& eta) { - return lkj_corr_cholesky_lpdf(L, eta); -} - -/** \ingroup multivar_dists - * @deprecated use lkj_corr_cholesky_lpdf - */ -template -inline return_type_t lkj_corr_cholesky_log( - const T_covar& L, const T_shape& eta) { - return lkj_corr_cholesky_lpdf<>(L, eta); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/lkj_corr_log.hpp b/stan/math/prim/prob/lkj_corr_log.hpp deleted file mode 100644 index 3906dc04b4c..00000000000 --- a/stan/math/prim/prob/lkj_corr_log.hpp +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_LKJ_CORR_LOG_HPP -#define STAN_MATH_PRIM_PROB_LKJ_CORR_LOG_HPP - -#include -#include -#include - -namespace stan { -namespace math { - -/** \ingroup multivar_dists - * @deprecated use lkj_corr_lpdf - */ -template -return_type_t lkj_corr_log(const T_y& y, const T_shape& eta) { - return lkj_corr_lpdf(y, eta); -} - -/** \ingroup multivar_dists - * @deprecated use lkj_corr_lpdf - */ -template -inline return_type_t lkj_corr_log(const T_y& y, - const T_shape& eta) { - return lkj_corr_lpdf<>(y, eta); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/lkj_cov_log.hpp b/stan/math/prim/prob/lkj_cov_log.hpp deleted file mode 100644 index 1544f1605b0..00000000000 --- a/stan/math/prim/prob/lkj_cov_log.hpp +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_LKJ_COV_LOG_HPP -#define STAN_MATH_PRIM_PROB_LKJ_COV_LOG_HPP - -#include -#include -#include - -namespace stan { -namespace math { - -/** \ingroup multivar_dists - * @deprecated use lkj_cov_lpdf - */ -template -inline return_type_t lkj_cov_log( - const T_y& y, const T_loc& mu, const T_scale& sigma, const T_shape& eta) { - return lkj_cov_lpdf(y, mu, sigma, eta); -} - -/** \ingroup multivar_dists - * @deprecated use lkj_cov_lpdf - */ -template -inline return_type_t lkj_cov_log( - const T_y& y, const T_loc& mu, const T_scale& sigma, const T_shape& eta) { - return lkj_cov_lpdf<>(y, mu, sigma, eta); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/logistic_log.hpp b/stan/math/prim/prob/logistic_log.hpp deleted file mode 100644 index ba29c409143..00000000000 --- a/stan/math/prim/prob/logistic_log.hpp +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_LOGISTIC_LOG_HPP -#define STAN_MATH_PRIM_PROB_LOGISTIC_LOG_HPP - -#include -#include - -namespace stan { -namespace math { - -/** \ingroup prob_dists - * @deprecated use logistic_lpdf - */ -template -return_type_t logistic_log(const T_y& y, const T_loc& mu, - const T_scale& sigma) { - return logistic_lpdf(y, mu, sigma); -} - -/** \ingroup prob_dists - * @deprecated use logistic_lpdf - */ -template -inline return_type_t logistic_log(const T_y& y, - const T_loc& mu, - const T_scale& sigma) { - return logistic_lpdf(y, mu, sigma); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/loglogistic_log.hpp b/stan/math/prim/prob/loglogistic_log.hpp deleted file mode 100644 index ec52a27702e..00000000000 --- a/stan/math/prim/prob/loglogistic_log.hpp +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_LOGLOGISTIC_LOG_HPP -#define STAN_MATH_PRIM_PROB_LOGLOGISTIC_LOG_HPP - -#include -#include - -namespace stan { -namespace math { - -/** \ingroup prob_dists - * @deprecated use loglogistic_lpdf - */ -template * = nullptr> -return_type_t loglogistic_log(const T_y& y, - const T_scale& alpha, - const T_shape& beta) { - return loglogistic_lpdf(y, alpha, beta); -} - -/** \ingroup prob_dists - * @deprecated use loglogistic_lpdf - */ -template -inline return_type_t loglogistic_log( - const T_y& y, const T_scale& alpha, const T_shape& beta) { - return loglogistic_lpdf(y, alpha, beta); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/lognormal_log.hpp b/stan/math/prim/prob/lognormal_log.hpp deleted file mode 100644 index 0dfed3c5add..00000000000 --- a/stan/math/prim/prob/lognormal_log.hpp +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_LOGNORMAL_LOG_HPP -#define STAN_MATH_PRIM_PROB_LOGNORMAL_LOG_HPP - -#include -#include - -namespace stan { -namespace math { - -/** \ingroup prob_dists - * @deprecated use lognormal_lpdf - */ -template -return_type_t lognormal_log(const T_y& y, const T_loc& mu, - const T_scale& sigma) { - return lognormal_lpdf(y, mu, sigma); -} - -/** \ingroup prob_dists - * @deprecated use lognormal_lpdf - */ -template -inline return_type_t lognormal_log(const T_y& y, - const T_loc& mu, - const T_scale& sigma) { - return lognormal_lpdf(y, mu, sigma); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/matrix_normal_prec_log.hpp b/stan/math/prim/prob/matrix_normal_prec_log.hpp deleted file mode 100644 index bd971db136d..00000000000 --- a/stan/math/prim/prob/matrix_normal_prec_log.hpp +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_MATRIX_NORMAL_PREC_LOG_HPP -#define STAN_MATH_PRIM_PROB_MATRIX_NORMAL_PREC_LOG_HPP - -#include -#include -#include - -namespace stan { -namespace math { -/** \ingroup multivar_dists - * The log of the matrix normal density for the given y, mu, Sigma and D - * where Sigma and D are given as precision matrices, not covariance - * matrices. - * - * @deprecated use matrix_normal_prec_lpdf - * - * @param y An mxn matrix. - * @param Mu The mean matrix. - * @param Sigma The mxm inverse covariance matrix (i.e., the precision - * matrix) of the rows of y. - * @param D The nxn inverse covariance matrix (i.e., the precision - * matrix) of the columns of y. - * @return The log of the matrix normal density. - * @throw std::domain_error if Sigma or D are not square, not symmetric, - * or not semi-positive definite. - * @tparam T_y Type of scalar. - * @tparam T_Mu Type of location. - * @tparam T_Sigma Type of Sigma. - * @tparam T_D Type of D. - */ -template * = nullptr> -return_type_t matrix_normal_prec_log( - const T_y& y, const T_Mu& Mu, const T_Sigma& Sigma, const T_D& D) { - return matrix_normal_prec_lpdf(y, Mu, Sigma, - D); -} - -/** \ingroup multivar_dists - * @deprecated use matrix_normal_prec_lpdf - */ -template * = nullptr> -return_type_t matrix_normal_prec_log( - const T_y& y, const T_Mu& Mu, const T_Sigma& Sigma, const T_D& D) { - return matrix_normal_prec_lpdf(y, Mu, Sigma, D); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/multi_gp_cholesky_log.hpp b/stan/math/prim/prob/multi_gp_cholesky_log.hpp deleted file mode 100644 index a8a283ffc70..00000000000 --- a/stan/math/prim/prob/multi_gp_cholesky_log.hpp +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_MULTI_GP_CHOLESKY_LOG_HPP -#define STAN_MATH_PRIM_PROB_MULTI_GP_CHOLESKY_LOG_HPP - -#include -#include -#include - -namespace stan { -namespace math { -/** \ingroup multivar_dists - * The log of a multivariate Gaussian Process for the given y, w, and - * a Cholesky factor L of the kernel matrix Sigma. - * Sigma = LL', a square, semi-positive definite matrix. - * y is a dxN matrix, where each column is a different observation and each - * row is a different output dimension. The Gaussian Process is assumed to - * have a scaled kernel matrix with a different scale for each output dimension. - * This distribution is equivalent to: - * for (i in 1:d) row(y, i) ~ multi_normal(0, (1/w[i])*LL'). - * - * @deprecated use multi_gp_cholesky_lpdf - * - * @param y A dxN matrix - * @param L The Cholesky decomposition of a kernel matrix - * @param w A d-dimensional vector of positive inverse scale parameters for each - * output. - * @return The log of the multivariate GP density. - * @throw std::domain_error if Sigma is not square, not symmetric, - * or not semi-positive definite. - * @tparam T_y Type of scalar. - * @tparam T_covar Type of kernel. - * @tparam T_w Type of weight. - */ -template -return_type_t multi_gp_cholesky_log(const T_y& y, - const T_covar& L, - const T_w& w) { - return multi_gp_cholesky_lpdf(y, L, w); -} - -/** \ingroup multivar_dists - * @deprecated use multi_gp_cholesky_lpdf - */ -template -inline return_type_t multi_gp_cholesky_log(const T_y& y, - const T_covar& L, - const T_w& w) { - return multi_gp_cholesky_lpdf<>(y, L, w); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/multi_gp_log.hpp b/stan/math/prim/prob/multi_gp_log.hpp deleted file mode 100644 index 511b75b1dd0..00000000000 --- a/stan/math/prim/prob/multi_gp_log.hpp +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_MULTI_GP_LOG_HPP -#define STAN_MATH_PRIM_PROB_MULTI_GP_LOG_HPP - -#include -#include -#include - -namespace stan { -namespace math { - -/** \ingroup multivar_dists - * The log of a multivariate Gaussian Process for the given y, Sigma, and - * w. y is a dxN matrix, where each column is a different observation and each - * row is a different output dimension. The Gaussian Process is assumed to - * have a scaled kernel matrix with a different scale for each output dimension. - * This distribution is equivalent to: - * for (i in 1:d) row(y, i) ~ multi_normal(0, (1/w[i])*Sigma). - * - * @deprecated use multi_gp_lpdf - * - * @param y A dxN matrix - * @param Sigma The NxN kernel matrix - * @param w A d-dimensional vector of positive inverse scale parameters for each - * output. - * @return The log of the multivariate GP density. - * @throw std::domain_error if Sigma is not square, not symmetric, - * or not semi-positive definite. - * @tparam T_y Type of scalar. - * @tparam T_covar Type of kernel. - * @tparam T_w Type of weight. - */ -template -return_type_t multi_gp_log(const T_y& y, - const T_covar& Sigma, - const T_w& w) { - return multi_gp_lpdf(y, Sigma, w); -} - -/** \ingroup multivar_dists - * @deprecated use multi_gp_lpdf - */ -template -inline return_type_t multi_gp_log(const T_y& y, - const T_covar& Sigma, - const T_w& w) { - return multi_gp_lpdf<>(y, Sigma, w); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/multi_normal_cholesky_log.hpp b/stan/math/prim/prob/multi_normal_cholesky_log.hpp deleted file mode 100644 index 7dd31f117cf..00000000000 --- a/stan/math/prim/prob/multi_normal_cholesky_log.hpp +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_MULTI_NORMAL_CHOLESKY_LOG_HPP -#define STAN_MATH_PRIM_PROB_MULTI_NORMAL_CHOLESKY_LOG_HPP - -#include -#include -#include - -namespace stan { -namespace math { -/** \ingroup multivar_dists - * The log of the multivariate normal density for the given y, mu, and - * a Cholesky factor L of the variance matrix. - * Sigma = LL', a square, semi-positive definite matrix. - * - * @deprecated use multi_normal_cholesky_lpdf - * - * @param y A scalar vector - * @param mu The mean vector of the multivariate normal distribution. - * @param L The Cholesky decomposition of a variance matrix - * of the multivariate normal distribution - * @return The log of the multivariate normal density. - * @throw std::domain_error if LL' is not square, not symmetric, - * or not semi-positive definite. - * @tparam T_y Type of scalar. - * @tparam T_loc Type of location. - * @tparam T_covar Type of scale. - */ -template -return_type_t multi_normal_cholesky_log(const T_y& y, - const T_loc& mu, - const T_covar& L) { - return multi_normal_cholesky_lpdf(y, mu, L); -} - -/** \ingroup multivar_dists - * @deprecated use multi_normal_cholesky_lpdf - */ -template -inline return_type_t multi_normal_cholesky_log( - const T_y& y, const T_loc& mu, const T_covar& L) { - return multi_normal_cholesky_lpdf(y, mu, L); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/multi_normal_log.hpp b/stan/math/prim/prob/multi_normal_log.hpp deleted file mode 100644 index c53676beea3..00000000000 --- a/stan/math/prim/prob/multi_normal_log.hpp +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_MULTI_NORMAL_LOG_HPP -#define STAN_MATH_PRIM_PROB_MULTI_NORMAL_LOG_HPP - -#include -#include - -namespace stan { -namespace math { - -/** \ingroup multivar_dists - * @deprecated use matrix_normal_lpdf - */ -template -return_type_t multi_normal_log(const T_y& y, - const T_loc& mu, - const T_covar& Sigma) { - return multi_normal_lpdf(y, mu, Sigma); -} - -/** \ingroup multivar_dists - * @deprecated use matrix_normal_lpdf - */ -template -inline return_type_t multi_normal_log( - const T_y& y, const T_loc& mu, const T_covar& Sigma) { - return multi_normal_lpdf(y, mu, Sigma); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/multi_normal_prec_log.hpp b/stan/math/prim/prob/multi_normal_prec_log.hpp deleted file mode 100644 index 05076694c2e..00000000000 --- a/stan/math/prim/prob/multi_normal_prec_log.hpp +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_MULTI_NORMAL_PREC_LOG_HPP -#define STAN_MATH_PRIM_PROB_MULTI_NORMAL_PREC_LOG_HPP - -#include -#include - -namespace stan { -namespace math { - -/** \ingroup multivar_dists - * @deprecated use multi_normal_prec_lpdf - */ -template -return_type_t multi_normal_prec_log(const T_y& y, - const T_loc& mu, - const T_covar& Sigma) { - return multi_normal_prec_lpdf(y, mu, Sigma); -} - -/** \ingroup multivar_dists - * @deprecated use multi_normal_prec_lpdf - */ -template -inline return_type_t multi_normal_prec_log( - const T_y& y, const T_loc& mu, const T_covar& Sigma) { - return multi_normal_prec_lpdf(y, mu, Sigma); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/multi_student_t_log.hpp b/stan/math/prim/prob/multi_student_t_log.hpp deleted file mode 100644 index a3b3a0b46cb..00000000000 --- a/stan/math/prim/prob/multi_student_t_log.hpp +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_MULTI_STUDENT_T_LOG_HPP -#define STAN_MATH_PRIM_PROB_MULTI_STUDENT_T_LOG_HPP - -#include -#include - -namespace stan { -namespace math { - -/** \ingroup multivar_dists - * Return the log of the multivariate Student t distribution - * at the specified arguments. - * - * @deprecated use multi_student_t_lpdf - * - * @tparam propto Carry out calculations up to a proportion - */ -template -return_type_t multi_student_t_log( - const T_y& y, const T_dof& nu, const T_loc& mu, const T_scale& Sigma) { - return multi_student_t_lpdf(y, nu, mu, - Sigma); -} - -/** \ingroup multivar_dists - * @deprecated use multi_student_t_lpdf - */ -template -inline return_type_t multi_student_t_log( - const T_y& y, const T_dof& nu, const T_loc& mu, const T_scale& Sigma) { - return multi_student_t_lpdf(y, nu, mu, Sigma); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/multinomial_log.hpp b/stan/math/prim/prob/multinomial_log.hpp deleted file mode 100644 index 1a5c18c60f1..00000000000 --- a/stan/math/prim/prob/multinomial_log.hpp +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_MULTINOMIAL_LOG_HPP -#define STAN_MATH_PRIM_PROB_MULTINOMIAL_LOG_HPP - -#include -#include -#include -#include - -namespace stan { -namespace math { - -/** \ingroup multivar_dists - * @deprecated use multinomial_lpmf - */ -template -return_type_t multinomial_log(const std::vector& ns, - const T_prob& theta) { - return multinomial_lpmf(ns, theta); -} - -/** \ingroup multivar_dists - * @deprecated use multinomial_lpmf - */ -template -return_type_t multinomial_log(const std::vector& ns, - const T_prob& theta) { - return multinomial_lpmf(ns, theta); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/multinomial_logit_log.hpp b/stan/math/prim/prob/multinomial_logit_log.hpp deleted file mode 100644 index f721f0909a9..00000000000 --- a/stan/math/prim/prob/multinomial_logit_log.hpp +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_MULTINOMIAL_LOGIT_LOG_HPP -#define STAN_MATH_PRIM_PROB_MULTINOMIAL_LOGIT_LOG_HPP - -#include -#include -#include -#include - -namespace stan { -namespace math { - -/** \ingroup multivar_dists - * @deprecated use multinomial_logit_lpmf - */ -template * = nullptr> -return_type_t multinomial_logit_log(const std::vector& ns, - const T_beta& beta) { - return multinomial_logit_lpmf(ns, beta); -} - -/** \ingroup multivar_dists - * @deprecated use multinomial_logit_lpmf - */ -template * = nullptr> -return_type_t multinomial_logit_log(const std::vector& ns, - const T_beta& beta) { - return multinomial_logit_lpmf(ns, beta); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/neg_binomial_2_log.hpp b/stan/math/prim/prob/neg_binomial_2_log.hpp deleted file mode 100644 index 816eb97a6c9..00000000000 --- a/stan/math/prim/prob/neg_binomial_2_log.hpp +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_NEG_BINOMIAL_2_LOG_HPP -#define STAN_MATH_PRIM_PROB_NEG_BINOMIAL_2_LOG_HPP - -#include -#include - -namespace stan { -namespace math { - -/** \ingroup prob_dists - * @deprecated use neg_binomial_2_lpmf - */ -template -return_type_t neg_binomial_2_log( - const T_n& n, const T_location& mu, const T_precision& phi) { - return neg_binomial_2_lpmf(n, mu, phi); -} - -/** \ingroup prob_dists - * @deprecated use neg_binomial_2_lpmf - */ -template -inline return_type_t neg_binomial_2_log( - const T_n& n, const T_location& mu, const T_precision& phi) { - return neg_binomial_2_lpmf(n, mu, phi); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/neg_binomial_2_log_glm_log.hpp b/stan/math/prim/prob/neg_binomial_2_log_glm_log.hpp deleted file mode 100644 index 81fc4fccdab..00000000000 --- a/stan/math/prim/prob/neg_binomial_2_log_glm_log.hpp +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_NEG_BINOMIAL_2_LOG_GLM_LOG_HPP -#define STAN_MATH_PRIM_PROB_NEG_BINOMIAL_2_LOG_GLM_LOG_HPP - -#include -#include - -namespace stan { -namespace math { - -/** \ingroup multivar_dists - * @deprecated use neg_binomial_2_log_glm_lpmf - */ -template -return_type_t neg_binomial_2_log_glm_log( - const T_y &y, const T_x &x, const T_alpha &alpha, const T_beta &beta, - const T_precision &phi) { - return neg_binomial_2_log_glm_lpmf(y, x, alpha, beta, phi); -} - -/** \ingroup multivar_dists - * @deprecated use poisson_logit_glm_lpmf - */ -template -inline return_type_t -neg_binomial_2_log_glm_log(const T_y &y, const T_x &x, const T_alpha &alpha, - const T_beta &beta, const T_precision &phi) { - return neg_binomial_2_log_glm_lpmf(y, x, alpha, beta, phi); -} -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/neg_binomial_2_log_log.hpp b/stan/math/prim/prob/neg_binomial_2_log_log.hpp deleted file mode 100644 index 6903eccfa30..00000000000 --- a/stan/math/prim/prob/neg_binomial_2_log_log.hpp +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_NEG_BINOMIAL_2_LOG_LOG_HPP -#define STAN_MATH_PRIM_PROB_NEG_BINOMIAL_2_LOG_LOG_HPP - -#include -#include - -namespace stan { -namespace math { - -/** \ingroup prob_dists - * @deprecated use neg_binomial_2_log_lpmf - */ -template -return_type_t neg_binomial_2_log_log( - const T_n& n, const T_log_location& eta, const T_precision& phi) { - return neg_binomial_2_log_lpmf( - n, eta, phi); -} - -/** \ingroup prob_dists - * @deprecated use neg_binomial_2_log_lpmf - */ -template -inline return_type_t neg_binomial_2_log_log( - const T_n& n, const T_log_location& eta, const T_precision& phi) { - return neg_binomial_2_log_lpmf(n, eta, phi); -} -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/neg_binomial_log.hpp b/stan/math/prim/prob/neg_binomial_log.hpp deleted file mode 100644 index 5997cbca1b9..00000000000 --- a/stan/math/prim/prob/neg_binomial_log.hpp +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_NEG_BINOMIAL_LOG_HPP -#define STAN_MATH_PRIM_PROB_NEG_BINOMIAL_LOG_HPP - -#include -#include - -namespace stan { -namespace math { - -/** \ingroup prob_dists - * @deprecated use neg_binomial_lpmf - */ -template -return_type_t neg_binomial_log(const T_n& n, - const T_shape& alpha, - const T_inv_scale& beta) { - return neg_binomial_lpmf(n, alpha, beta); -} - -/** \ingroup prob_dists - * @deprecated use neg_binomial_lpmf - */ -template -inline return_type_t neg_binomial_log( - const T_n& n, const T_shape& alpha, const T_inv_scale& beta) { - return neg_binomial_lpmf(n, alpha, beta); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/normal_id_glm_log.hpp b/stan/math/prim/prob/normal_id_glm_log.hpp deleted file mode 100644 index 65cf1c30f6a..00000000000 --- a/stan/math/prim/prob/normal_id_glm_log.hpp +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_NORMAL_ID_GLM_LOG_HPP -#define STAN_MATH_PRIM_PROB_NORMAL_ID_GLM_LOG_HPP - -#include -#include - -namespace stan { -namespace math { - -/** \ingroup multivar_dists - * @deprecated use normal_id_glm_lpdf - */ -template -return_type_t normal_id_glm_log( - const T_y &y, const T_x &x, const T_alpha &alpha, const T_beta &beta, - const T_scale &sigma) { - return normal_id_glm_lpdf( - y, x, alpha, beta, sigma); -} - -/** \ingroup multivar_dists - * @deprecated use normal_id_glm_lpdf - */ -template -inline return_type_t normal_id_glm_log( - const T_y &y, const T_x &x, const T_alpha &alpha, const T_beta &beta, - const T_scale &sigma) { - return normal_id_glm_lpdf(y, x, alpha, beta, sigma); -} -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/normal_log.hpp b/stan/math/prim/prob/normal_log.hpp deleted file mode 100644 index 962d6657f08..00000000000 --- a/stan/math/prim/prob/normal_log.hpp +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_NORMAL_LOG_HPP -#define STAN_MATH_PRIM_PROB_NORMAL_LOG_HPP - -#include -#include - -namespace stan { -namespace math { - -/** \ingroup prob_dists - * The log of the normal density for the specified scalar(s) given - * the specified mean(s) and deviation(s). y, mu, or sigma can - * each be either a scalar or a vector. Any vector inputs - * must be the same length. - * - *

The result log probability is defined to be the sum of the - * log probabilities for each observation/mean/deviation triple. - * - * @deprecated use normal_lpdf - * - * @param y (Sequence of) scalar(s). - * @param mu (Sequence of) location parameter(s) - * for the normal distribution. - * @param sigma (Sequence of) scale parameters for the normal - * distribution. - * @return The log of the product of the densities. - * @throw std::domain_error if the scale is not positive. - * @tparam T_y Underlying type of scalar in sequence. - * @tparam T_loc Type of location parameter. - */ -template -inline return_type_t normal_log(const T_y& y, - const T_loc& mu, - const T_scale& sigma) { - return normal_lpdf(y, mu, sigma); -} - -/** \ingroup prob_dists - * @deprecated use normal_lpdf - */ -template -inline return_type_t normal_log(const T_y& y, - const T_loc& mu, - const T_scale& sigma) { - return normal_lpdf(y, mu, sigma); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/normal_sufficient_log.hpp b/stan/math/prim/prob/normal_sufficient_log.hpp deleted file mode 100644 index c6ddf70ae6b..00000000000 --- a/stan/math/prim/prob/normal_sufficient_log.hpp +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_NORMAL_SUFFICIENT_LOG_HPP -#define STAN_MATH_PRIM_PROB_NORMAL_SUFFICIENT_LOG_HPP - -#include -#include - -namespace stan { -namespace math { - -/** \ingroup prob_dists - * @deprecated use normal_lpdf - */ -template -inline return_type_t normal_sufficient_log( - const T_y& y_bar, const T_s& s_squared, const T_n& n_obs, const T_loc& mu, - const T_scale& sigma) { - return normal_sufficient_lpdf( - y_bar, s_squared, n_obs, mu, sigma); -} - -/** \ingroup prob_dists - * @deprecated use normal_lpdf - */ -template -inline return_type_t normal_sufficient_log( - const T_y& y_bar, const T_s& s_squared, const T_n& n_obs, const T_loc& mu, - const T_scale& sigma) { - return normal_sufficient_lpdf( - y_bar, s_squared, n_obs, mu, sigma); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/ordered_logistic_log.hpp b/stan/math/prim/prob/ordered_logistic_log.hpp deleted file mode 100644 index f6ca4ce4589..00000000000 --- a/stan/math/prim/prob/ordered_logistic_log.hpp +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_ORDERED_LOGISTIC_LOG_HPP -#define STAN_MATH_PRIM_PROB_ORDERED_LOGISTIC_LOG_HPP - -#include -#include - -namespace stan { -namespace math { - -/** \ingroup multivar_dists - * Returns the (natural) log probability of the integer/s - * given the vector of continuous location/s and - * specified cutpoints in an ordered logistic model. - * - *

Typically the continuous location - * will be the dot product of a vector of regression coefficients - * and a vector of predictors for the outcome. - * - * @tparam propto True if calculating up to a proportion. - * @tparam T_y y variable type (int or array of integers). - * @tparam T_loc Location type (double or vector). - * @tparam T_cut Cut-point type (vector or array of vectors). - * @param y Integers - * @param lambda Continuous location variables. - * @param c Positive increasing cutpoints. - * @return Log probability of outcome given location and - * cutpoints. - * @throw std::domain_error If the outcome is not between 1 and - * the number of cutpoints plus 2; if the cutpoint vector is - * empty; if the cutpoint vector contains a non-positive, - * non-finite value; or if the cutpoint vector is not sorted in - * ascending order. - * @throw std::invalid_argument If array y and vector lambda - * are different lengths. - * @throw std::invalid_argument if array y and array of vectors - * c are different lengths. - * - * @deprecated use ordered_logistic_lpmf - */ -template -return_type_t ordered_logistic_log(const T_y& y, - const T_loc& lambda, - const T_cut& c) { - return ordered_logistic_lpmf(y, lambda, c); -} - -/** \ingroup multivar_dists - * @deprecated use ordered_logistic_lpmf - */ -template -return_type_t ordered_logistic_log(const T_y& y, - const T_loc& lambda, - const T_cut& c) { - return ordered_logistic_lpmf(y, lambda, c); -} -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/ordered_probit_log.hpp b/stan/math/prim/prob/ordered_probit_log.hpp deleted file mode 100644 index ef1c47e7a0a..00000000000 --- a/stan/math/prim/prob/ordered_probit_log.hpp +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_ORDERED_PROBIT_LOG_HPP -#define STAN_MATH_PRIM_PROB_ORDERED_PROBIT_LOG_HPP - -#include -#include - -namespace stan { -namespace math { - -/** \ingroup multivar_dists - * Returns the (natural) log probability of the integer/s - * given the vector of continuous location/s and - * specified cutpoints in an ordered probit model. - * - *

Typically the continuous location - * will be the dot product of a vector of regression coefficients - * and a vector of predictors for the outcome. - * - * @tparam propto True if calculating up to a proportion. - * @tparam T_y y variable type (int or array of integers). - * @tparam T_loc Location type (double or vector). - * @tparam T_cut Cut-point type (vector or array of vectors). - * @param y Integers - * @param lambda Continuous location variables. - * @param c Positive increasing cutpoints. - * @return Log probability of outcome given location and - * cutpoints. - * @throw std::domain_error If the outcome is not between 1 and - * the number of cutpoints plus 2; if the cutpoint vector is - * empty; if the cutpoint vector contains a non-positive, - * non-finite value; or if the cutpoint vector is not sorted in - * ascending order. - * @throw std::invalid_argument If array y and vector lambda - * are different lengths. - * @throw std::invalid_argument if array y and array of vectors - * c are different lengths. - * - * @deprecated use ordered_probit_lpmf - */ -template -return_type_t ordered_probit_log(const T_y& y, - const T_loc& lambda, - const T_cut& c) { - return ordered_probit_lpmf(y, lambda, c); -} - -/** \ingroup multivar_dists - * @deprecated use ordered_probit_lpmf - */ -template -return_type_t ordered_probit_log(const T_y& y, - const T_loc& lambda, - const T_cut& c) { - return ordered_probit_lpmf(y, lambda, c); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/pareto_log.hpp b/stan/math/prim/prob/pareto_log.hpp deleted file mode 100644 index 22f6a4b4df3..00000000000 --- a/stan/math/prim/prob/pareto_log.hpp +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_PARETO_LOG_HPP -#define STAN_MATH_PRIM_PROB_PARETO_LOG_HPP - -#include -#include - -namespace stan { -namespace math { - -/** \ingroup prob_dists - * @deprecated use pareto_lpdf - */ -template -return_type_t pareto_log(const T_y& y, - const T_scale& y_min, - const T_shape& alpha) { - return pareto_lpdf(y, y_min, alpha); -} - -/** \ingroup prob_dists - * @deprecated use pareto_lpdf - */ -template -inline return_type_t pareto_log(const T_y& y, - const T_scale& y_min, - const T_shape& alpha) { - return pareto_lpdf(y, y_min, alpha); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/pareto_type_2_log.hpp b/stan/math/prim/prob/pareto_type_2_log.hpp deleted file mode 100644 index d77d7c43d13..00000000000 --- a/stan/math/prim/prob/pareto_type_2_log.hpp +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_PARETO_TYPE_2_LOG_HPP -#define STAN_MATH_PRIM_PROB_PARETO_TYPE_2_LOG_HPP - -#include -#include - -namespace stan { -namespace math { - -/** \ingroup prob_dists - * @deprecated use pareto_type_2_lpdf - */ -template -return_type_t pareto_type_2_log( - const T_y& y, const T_loc& mu, const T_scale& lambda, - const T_shape& alpha) { - return pareto_type_2_lpdf(y, mu, lambda, - alpha); -} - -/** \ingroup prob_dists - * @deprecated use pareto_type_2_lpdf - */ -template -inline return_type_t pareto_type_2_log( - const T_y& y, const T_loc& mu, const T_scale& lambda, - const T_shape& alpha) { - return pareto_type_2_lpdf(y, mu, lambda, alpha); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/poisson_binomial_log.hpp b/stan/math/prim/prob/poisson_binomial_log.hpp deleted file mode 100644 index bdb6c87ceb9..00000000000 --- a/stan/math/prim/prob/poisson_binomial_log.hpp +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_POISSON_BINOMIAL_LOG_HPP -#define STAN_MATH_PRIM_PROB_POISSON_BINOMIAL_LOG_HPP - -#include -#include - -namespace stan { -namespace math { - -/** \ingroup prob_dists - * @deprecated use poisson_binomial_lpmf - */ -template -return_type_t poisson_binomial_log(const T_y& y, - const T_theta& theta) { - return poisson_binomial_lpmf(y, theta); -} - -/** \ingroup prob_dists - * @deprecated use poisson_binomial_lpmf - */ -template -inline return_type_t poisson_binomial_log(const T_y& y, - const T_theta& theta) { - return poisson_binomial_lpmf(y, theta); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/poisson_log.hpp b/stan/math/prim/prob/poisson_log.hpp deleted file mode 100644 index 124c4f271ae..00000000000 --- a/stan/math/prim/prob/poisson_log.hpp +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_POISSON_LOG_HPP -#define STAN_MATH_PRIM_PROB_POISSON_LOG_HPP - -#include -#include - -namespace stan { -namespace math { - -/** \ingroup prob_dists - * @deprecated use poisson_lpmf - */ -template -return_type_t poisson_log(const T_n& n, const T_rate& lambda) { - return poisson_lpmf(n, lambda); -} - -/** \ingroup prob_dists - * @deprecated use poisson_lpmf - */ -template -inline return_type_t poisson_log(const T_n& n, const T_rate& lambda) { - return poisson_lpmf(n, lambda); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/poisson_log_glm_log.hpp b/stan/math/prim/prob/poisson_log_glm_log.hpp deleted file mode 100644 index cefcaa16210..00000000000 --- a/stan/math/prim/prob/poisson_log_glm_log.hpp +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_POISSON_LOG_GLM_LOG_HPP -#define STAN_MATH_PRIM_PROB_POISSON_LOG_GLM_LOG_HPP - -#include -#include - -namespace stan { -namespace math { - -/** \ingroup multivar_dists - * @deprecated use poisson_logit_glm_lpmf - */ -template -return_type_t poisson_log_glm_log(const T_y &y, - const T_x &x, - const T_alpha &alpha, - const T_beta &beta) { - return poisson_log_glm_lpmf(y, x, alpha, - beta); -} - -/** \ingroup multivar_dists - * @deprecated use poisson_logit_glm_lpmf - */ -template -inline return_type_t poisson_log_glm_log( - const T_y &y, const T_x &x, const T_alpha &alpha, const T_beta &beta) { - return poisson_log_glm_lpmf(y, x, alpha, beta); -} -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/poisson_log_log.hpp b/stan/math/prim/prob/poisson_log_log.hpp deleted file mode 100644 index a171e02b5b7..00000000000 --- a/stan/math/prim/prob/poisson_log_log.hpp +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_POISSON_LOG_LOG_HPP -#define STAN_MATH_PRIM_PROB_POISSON_LOG_LOG_HPP - -#include -#include - -namespace stan { -namespace math { - -/** \ingroup prob_dists - * @deprecated use poisson_log_lpmf - */ -template -return_type_t poisson_log_log(const T_n& n, - const T_log_rate& alpha) { - return poisson_log_lpmf(n, alpha); -} - -/** \ingroup prob_dists - * @deprecated use poisson_log_lpmf - */ -template -inline return_type_t poisson_log_log(const T_n& n, - const T_log_rate& alpha) { - return poisson_log_lpmf(n, alpha); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/rayleigh_log.hpp b/stan/math/prim/prob/rayleigh_log.hpp deleted file mode 100644 index 0fa7e3578ec..00000000000 --- a/stan/math/prim/prob/rayleigh_log.hpp +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_RAYLEIGH_LOG_HPP -#define STAN_MATH_PRIM_PROB_RAYLEIGH_LOG_HPP - -#include -#include - -namespace stan { -namespace math { - -/** \ingroup prob_dists - * @deprecated use rayleigh_lpdf - */ -template -return_type_t rayleigh_log(const T_y& y, const T_scale& sigma) { - return rayleigh_lpdf(y, sigma); -} - -/** \ingroup prob_dists - * @deprecated use rayleigh_lpdf - */ -template -inline return_type_t rayleigh_log(const T_y& y, - const T_scale& sigma) { - return rayleigh_lpdf(y, sigma); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/scaled_inv_chi_square_log.hpp b/stan/math/prim/prob/scaled_inv_chi_square_log.hpp deleted file mode 100644 index 02944dbe8e3..00000000000 --- a/stan/math/prim/prob/scaled_inv_chi_square_log.hpp +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_SCALED_INV_CHI_SQUARE_LOG_HPP -#define STAN_MATH_PRIM_PROB_SCALED_INV_CHI_SQUARE_LOG_HPP - -#include -#include - -namespace stan { -namespace math { - -/** \ingroup prob_dists - * The log of a scaled inverse chi-squared density for y with the - * specified degrees of freedom parameter and scale parameter. - * - \f{eqnarray*}{ - y &\sim& \mbox{\sf{Inv-}}\chi^2(\nu, s^2) \\ - \log (p (y \, |\, \nu, s)) &=& \log \left( \frac{(\nu / 2)^{\nu / 2}}{\Gamma - (\nu / 2)} s^\nu y^{- (\nu / 2 + 1)} \exp^{-\nu s^2 / (2y)} \right) \\ - &=& \frac{\nu}{2} \log(\frac{\nu}{2}) - \log (\Gamma (\nu / 2)) + \nu \log(s) - - (\frac{\nu}{2} + 1) \log(y) - \frac{\nu s^2}{2y} \\ & & \mathrm{ where } \; y > - 0 \f} - * - * @deprecated use scaled_inv_chi_square_lpdf - * - * @param y A scalar variable. - * @param nu Degrees of freedom. - * @param s Scale parameter. - * @throw std::domain_error if nu is not greater than 0 - * @throw std::domain_error if s is not greater than 0. - * @throw std::domain_error if y is not greater than 0. - * @tparam T_y Type of scalar. - * @tparam T_dof Type of degrees of freedom. - */ -template -return_type_t scaled_inv_chi_square_log(const T_y& y, - const T_dof& nu, - const T_scale& s) { - return scaled_inv_chi_square_lpdf(y, nu, s); -} - -/** \ingroup prob_dists - * @deprecated use scaled_inv_chi_square_lpdf - */ -template -inline return_type_t scaled_inv_chi_square_log( - const T_y& y, const T_dof& nu, const T_scale& s) { - return scaled_inv_chi_square_lpdf(y, nu, s); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/skew_double_exponential_log.hpp b/stan/math/prim/prob/skew_double_exponential_log.hpp deleted file mode 100644 index 25f083bcadf..00000000000 --- a/stan/math/prim/prob/skew_double_exponential_log.hpp +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_SKEW_DOUBLE_EXPONENTIAL_LOG_HPP -#define STAN_MATH_PRIM_PROB_SKEW_DOUBLE_EXPONENTIAL_LOG_HPP - -#include -#include - -namespace stan { -namespace math { - -/** \ingroup prob_dists - * @deprecated use skew_double_exponential_log - */ -template -return_type_t skew_double_exponential_log( - const T_y& y, const T_loc& mu, const T_scale& sigma, - const T_skewness& tau) { - return skew_double_exponential_lpdf( - y, mu, sigma, tau); -} - -/** \ingroup prob_dists - * @deprecated use skew_double_exponential_log - */ -template -inline return_type_t -skew_double_exponential_log(const T_y& y, const T_loc& mu, const T_scale& sigma, - const T_skewness& tau) { - return skew_double_exponential_lpdf( - y, mu, sigma, tau); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/skew_normal_log.hpp b/stan/math/prim/prob/skew_normal_log.hpp deleted file mode 100644 index e34017ab922..00000000000 --- a/stan/math/prim/prob/skew_normal_log.hpp +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_SKEW_NORMAL_LOG_HPP -#define STAN_MATH_PRIM_PROB_SKEW_NORMAL_LOG_HPP - -#include -#include - -namespace stan { -namespace math { - -/** \ingroup prob_dists - * @deprecated use skew_normal_lpdf - */ -template -return_type_t skew_normal_log( - const T_y& y, const T_loc& mu, const T_scale& sigma, const T_shape& alpha) { - return skew_normal_lpdf(y, mu, sigma, - alpha); -} - -/** \ingroup prob_dists - * @deprecated use skew_normal_lpdf - */ -template -inline return_type_t skew_normal_log( - const T_y& y, const T_loc& mu, const T_scale& sigma, const T_shape& alpha) { - return skew_normal_lpdf(y, mu, sigma, alpha); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/std_normal_log.hpp b/stan/math/prim/prob/std_normal_log.hpp deleted file mode 100644 index f2d1643bd9c..00000000000 --- a/stan/math/prim/prob/std_normal_log.hpp +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_STD_NORMAL_LOG_HPP -#define STAN_MATH_PRIM_PROB_STD_NORMAL_LOG_HPP - -#include -#include - -namespace stan { -namespace math { - -/** \ingroup prob_dists - * The log of a standard normal density for the specified scalar(s). - * y can be either a scalar or a vector. - * - *

The result log probability is defined to be the sum of the - * log probabilities for each observation. - * - * @deprecated use std_normal_lpdf - * - * @tparam T_y Underlying type of scalar in sequence. - * @param y (Sequence of) scalar(s). - * @return The log of the product of the densities. - * @throw std::domain_error if any scalar is nan. - */ -template -return_type_t std_normal_log(const T_y& y) { - return std_normal_lpdf(y); -} - -/** \ingroup prob_dists - * @deprecated use std_normal_lpdf - */ -template -inline return_type_t std_normal_log(const T_y& y) { - return std_normal_lpdf(y); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/student_t_log.hpp b/stan/math/prim/prob/student_t_log.hpp deleted file mode 100644 index 3f3b9be8760..00000000000 --- a/stan/math/prim/prob/student_t_log.hpp +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_STUDENT_T_LOG_HPP -#define STAN_MATH_PRIM_PROB_STUDENT_T_LOG_HPP - -#include -#include - -namespace stan { -namespace math { - -/** \ingroup prob_dists - * The log of the Student-t density for the given y, nu, mean, and - * scale parameter. The scale parameter must be greater - * than 0. - * - * \f{eqnarray*}{ - y &\sim& t_{\nu} (\mu, \sigma^2) \\ - \log (p (y \, |\, \nu, \mu, \sigma) ) &=& \log \left( \frac{\Gamma((\nu + 1) - /2)} - {\Gamma(\nu/2)\sqrt{\nu \pi} \sigma} \left( 1 + \frac{1}{\nu} (\frac{y - - \mu}{\sigma})^2 \right)^{-(\nu + 1)/2} \right) \\ - &=& \log( \Gamma( (\nu+1)/2 )) - \log (\Gamma (\nu/2) - \frac{1}{2} \log(\nu - \pi) - \log(\sigma) - -\frac{\nu + 1}{2} \log (1 + \frac{1}{\nu} (\frac{y - \mu}{\sigma})^2) - \f} - * - * @deprecated use student_t_lpdf - * - * @param y A scalar variable. - * @param nu Degrees of freedom. - * @param mu The mean of the Student-t distribution. - * @param sigma The scale parameter of the Student-t distribution. - * @return The log of the Student-t density at y. - * @throw std::domain_error if sigma is not greater than 0. - * @throw std::domain_error if nu is not greater than 0. - * @tparam T_y Type of scalar. - * @tparam T_dof Type of degrees of freedom. - * @tparam T_loc Type of location. - * @tparam T_scale Type of scale. - */ -template -return_type_t student_t_log(const T_y& y, - const T_dof& nu, - const T_loc& mu, - const T_scale& sigma) { - return student_t_lpdf(y, nu, mu, sigma); -} - -/** \ingroup prob_dists - * @deprecated use student_t_lpdf - */ -template -inline return_type_t student_t_log( - const T_y& y, const T_dof& nu, const T_loc& mu, const T_scale& sigma) { - return student_t_lpdf(y, nu, mu, sigma); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/uniform_log.hpp b/stan/math/prim/prob/uniform_log.hpp deleted file mode 100644 index 72cc888b7e5..00000000000 --- a/stan/math/prim/prob/uniform_log.hpp +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_UNIFORM_LOG_HPP -#define STAN_MATH_PRIM_PROB_UNIFORM_LOG_HPP - -#include -#include - -namespace stan { -namespace math { - -/** \ingroup prob_dists - * The log of a uniform density for the given - * y, lower, and upper bound. - * - \f{eqnarray*}{ - y &\sim& \mbox{\sf{U}}(\alpha, \beta) \\ - \log (p (y \, |\, \alpha, \beta)) &=& \log \left( \frac{1}{\beta-\alpha} - \right) \\ - &=& \log (1) - \log (\beta - \alpha) \\ - &=& -\log (\beta - \alpha) \\ - & & \mathrm{ where } \; y \in [\alpha, \beta], \log(0) \; \mathrm{otherwise} - \f} - * - * @deprecated use uniform_lpdf - * - * @param y A scalar variable. - * @param alpha Lower bound. - * @param beta Upper bound. - * @throw std::invalid_argument if the lower bound is greater than - * or equal to the lower bound - * @tparam T_y Type of scalar. - * @tparam T_low Type of lower bound. - * @tparam T_high Type of upper bound. - */ -template -return_type_t uniform_log(const T_y& y, const T_low& alpha, - const T_high& beta) { - return uniform_lpdf(y, alpha, beta); -} - -/** \ingroup prob_dists - * @deprecated use uniform_lpdf - */ -template -inline return_type_t uniform_log(const T_y& y, - const T_low& alpha, - const T_high& beta) { - return uniform_lpdf(y, alpha, beta); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/von_mises_log.hpp b/stan/math/prim/prob/von_mises_log.hpp deleted file mode 100644 index 78a290c13ae..00000000000 --- a/stan/math/prim/prob/von_mises_log.hpp +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_VON_MISES_LOG_HPP -#define STAN_MATH_PRIM_PROB_VON_MISES_LOG_HPP - -#include -#include - -namespace stan { -namespace math { - -/** \ingroup prob_dists - * @deprecated use von_mises_lpdf - */ -template -return_type_t von_mises_log(T_y const& y, T_loc const& mu, - T_scale const& kappa) { - return von_mises_lpdf(y, mu, kappa); -} - -/** \ingroup prob_dists - * @deprecated use von_mises_lpdf - */ -template -inline return_type_t von_mises_log(T_y const& y, - T_loc const& mu, - T_scale const& kappa) { - return von_mises_lpdf(y, mu, kappa); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/weibull_log.hpp b/stan/math/prim/prob/weibull_log.hpp deleted file mode 100644 index eff1280c70a..00000000000 --- a/stan/math/prim/prob/weibull_log.hpp +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_WEIBULL_LOG_HPP -#define STAN_MATH_PRIM_PROB_WEIBULL_LOG_HPP - -#include -#include - -namespace stan { -namespace math { - -/** \ingroup prob_dists - * @deprecated use weibull_lpdf - */ -template -return_type_t weibull_log(const T_y& y, - const T_shape& alpha, - const T_scale& sigma) { - return weibull_lpdf(y, alpha, sigma); -} - -/** \ingroup prob_dists - * @deprecated use weibull_lpdf - */ -template -inline return_type_t weibull_log(const T_y& y, - const T_shape& alpha, - const T_scale& sigma) { - return weibull_lpdf(y, alpha, sigma); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/wiener_log.hpp b/stan/math/prim/prob/wiener_log.hpp deleted file mode 100644 index 4311c079055..00000000000 --- a/stan/math/prim/prob/wiener_log.hpp +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_WIENER_LOG_HPP -#define STAN_MATH_PRIM_PROB_WIENER_LOG_HPP - -#include -#include - -namespace stan { -namespace math { - -/** \ingroup prob_dists - * The log of the first passage time density function for a (Wiener) - * drift diffusion model for the given \f$y\f$, - * boundary separation \f$\alpha\f$, nondecision time \f$\tau\f$, - * relative bias \f$\beta\f$, and drift rate \f$\delta\f$. - * \f$\alpha\f$ and \f$\tau\f$ must be greater than 0, and - * \f$\beta\f$ must be between 0 and 1. \f$y\f$ should contain - * reaction times in seconds (strictly positive) with - * upper-boundary responses. - * - * @deprecated use wiener_lpdf - * - * @param y A scalar variate. - * @param alpha The boundary separation. - * @param tau The nondecision time. - * @param beta The relative bias. - * @param delta The drift rate. - * @return The log of the Wiener first passage time density of - * the specified arguments. - */ -template -return_type_t wiener_log( - const T_y& y, const T_alpha& alpha, const T_tau& tau, const T_beta& beta, - const T_delta& delta) { - return wiener_lpdf( - y, alpha, tau, beta, delta); -} - -/** \ingroup prob_dists - * @deprecated use wiener_lpdf - */ -template -inline return_type_t wiener_log( - const T_y& y, const T_alpha& alpha, const T_tau& tau, const T_beta& beta, - const T_delta& delta) { - return wiener_lpdf(y, alpha, tau, beta, - delta); -} - -} // namespace math -} // namespace stan -#endif diff --git a/stan/math/prim/prob/wishart_log.hpp b/stan/math/prim/prob/wishart_log.hpp deleted file mode 100644 index c4640f94678..00000000000 --- a/stan/math/prim/prob/wishart_log.hpp +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef STAN_MATH_PRIM_PROB_WISHART_LOG_HPP -#define STAN_MATH_PRIM_PROB_WISHART_LOG_HPP - -#include -#include -#include - -namespace stan { -namespace math { - -/** \ingroup multivar_dists - * The log of the Wishart density for the given W, degrees of freedom, - * and scale matrix. - * - * The scale matrix, S, must be k x k, symmetric, and semi-positive definite. - * Dimension, k, is implicit. - * nu must be greater than k-1 - * - * \f{eqnarray*}{ - W &\sim& \mbox{\sf{Wishart}}_{\nu} (S) \\ - \log (p (W \, |\, \nu, S) ) &=& \log \left( \left(2^{\nu k/2} \pi^{k (k-1) /4} - \prod_{i=1}^k{\Gamma (\frac{\nu + 1 - i}{2})} \right)^{-1} \times \left| S - \right|^{-\nu/2} \left| W \right|^{(\nu - k - 1) / 2} - \times \exp (-\frac{1}{2} \mbox{tr} (S^{-1} W)) \right) \\ - &=& -\frac{\nu k}{2}\log(2) - \frac{k (k-1)}{4} \log(\pi) - \sum_{i=1}^{k}{\log - (\Gamma (\frac{\nu+1-i}{2}))} - -\frac{\nu}{2} \log(\det(S)) + \frac{\nu-k-1}{2}\log (\det(W)) - \frac{1}{2} - \mbox{tr} (S^{-1}W) \f} - * - * @deprecated use wishart_lpdf - * - * @param W A scalar matrix - * @param nu Degrees of freedom - * @param S The scale matrix - * @return The log of the Wishart density at W given nu and S. - * @throw std::domain_error if nu is not greater than k-1 - * @throw std::domain_error if S is not square, not symmetric, or not - semi-positive definite. - * @tparam T_y Type of matrix. - * @tparam T_dof Type of degrees of freedom. - * @tparam T_scale Type of scale. - */ -template -return_type_t wishart_log(const T_y& W, const T_dof& nu, - const T_scale& S) { - return wishart_lpdf(W, nu, S); -} - -/** \ingroup multivar_dists - * @deprecated use wishart_lpdf - */ -template -inline return_type_t wishart_log(const T_y& W, - const T_dof& nu, - const T_scale& S) { - return wishart_lpdf(W, nu, S); -} - -} // namespace math -} // namespace stan -#endif From 30d1181e270a704bb2fbfcd5b50a1aee0fb7cdbb Mon Sep 17 00:00:00 2001 From: Daniel Lee Date: Wed, 3 Jan 2024 00:57:36 -0500 Subject: [PATCH 23/52] updating tests that called _log() probability functions --- stan/math/prim/prob.hpp | 67 -------- .../math/prim/prob/lkj_corr_cholesky_lpdf.hpp | 1 - stan/math/prim/prob/logistic_cdf.hpp | 8 +- stan/math/prim/prob/logistic_lccdf.hpp | 8 +- stan/math/prim/prob/logistic_lcdf.hpp | 8 +- stan/math/prim/prob/multi_student_t_lpdf.hpp | 1 - test/prob/bernoulli/bernoulli_logit_test.hpp | 6 +- test/prob/bernoulli/bernoulli_test.hpp | 6 +- test/prob/beta/beta_test.hpp | 6 +- .../prob/beta_binomial/beta_binomial_test.hpp | 6 +- test/prob/binomial/binomial_logit_test.hpp | 6 +- test/prob/binomial/binomial_test.hpp | 6 +- test/prob/cauchy/cauchy_test.hpp | 6 +- test/prob/chi_square/chi_square_test.hpp | 6 +- .../double_exponential_test.hpp | 6 +- .../exp_mod_normal/exp_mod_normal_test.hpp | 6 +- test/prob/exponential/exponential_test.hpp | 6 +- test/prob/frechet/frechet_test.hpp | 6 +- test/prob/gamma/gamma_test.hpp | 6 +- test/prob/gumbel/gumbel_test.hpp | 6 +- .../hypergeometric/hypergeometric_test.hpp | 6 +- .../inv_chi_square/inv_chi_square_test.hpp | 6 +- test/prob/inv_gamma/inv_gamma_test.hpp | 6 +- test/prob/logistic/logistic_test.hpp | 6 +- test/prob/lognormal/lognormal_test.hpp | 6 +- test/prob/neg_binomial/neg_binomial_test.hpp | 6 +- .../neg_binomial_2_log_test.hpp | 6 +- .../neg_binomial_2/neg_binomial_2_test.hpp | 6 +- test/prob/normal/normal_test.hpp | 6 +- test/prob/pareto/pareto_test.hpp | 6 +- .../prob/pareto_type_2/pareto_type_2_test.hpp | 6 +- test/prob/poisson/poisson_log_test.hpp | 6 +- test/prob/poisson/poisson_test.hpp | 6 +- test/prob/rayleigh/rayleigh_test.hpp | 6 +- .../scaled_inv_chi_square_test.hpp | 6 +- test/prob/skew_normal/skew_normal_test.hpp | 6 +- test/prob/student_t/student_t_test.hpp | 6 +- test/prob/uniform/uniform_test.hpp | 6 +- test/prob/von_mises/von_mises_test.hpp | 6 +- test/prob/weibull/weibull_test.hpp | 6 +- test/prob/wiener/wiener_test.hpp | 8 +- test/sig_utils.py | 9 - .../math/fwd/prob/categorical_logit_test.cpp | 36 ++-- test/unit/math/fwd/prob/categorical_test.cpp | 32 ++-- test/unit/math/fwd/prob/dirichlet_test.cpp | 18 +- .../math/fwd/prob/gaussian_dlm_obs_test.cpp | 16 +- test/unit/math/fwd/prob/inv_wishart_test.cpp | 12 +- test/unit/math/fwd/prob/lkj_corr_test.cpp | 32 ++-- .../math/fwd/prob/multi_gp_cholesky_test.cpp | 13 +- test/unit/math/fwd/prob/multi_gp_test.cpp | 12 +- .../fwd/prob/multi_normal_cholesky_test.cpp | 8 +- .../math/fwd/prob/multi_normal_prec_test.cpp | 8 +- test/unit/math/fwd/prob/multi_normal_test.cpp | 8 +- .../math/fwd/prob/multi_student_t_test.cpp | 8 +- test/unit/math/fwd/prob/multinomial_test.cpp | 8 +- test/unit/math/fwd/prob/wishart_test.cpp | 8 +- test/unit/math/mix/functor/autodiff_test.cpp | 2 +- .../math/mix/prob/categorical_logit_test.cpp | 46 ++--- test/unit/math/mix/prob/categorical_test.cpp | 32 ++-- test/unit/math/mix/prob/dirichlet_test.cpp | 69 ++++---- .../math/mix/prob/gaussian_dlm_obs_test.cpp | 16 +- test/unit/math/mix/prob/inv_wishart_test.cpp | 14 +- test/unit/math/mix/prob/lkj_corr_test.cpp | 32 ++-- .../math/mix/prob/multi_gp_cholesky_test.cpp | 12 +- test/unit/math/mix/prob/multi_gp_test.cpp | 12 +- .../mix/prob/multi_normal_cholesky_test.cpp | 8 +- .../math/mix/prob/multi_normal_prec_test.cpp | 8 +- test/unit/math/mix/prob/multi_normal_test.cpp | 4 +- .../math/mix/prob/multi_student_t_test.cpp | 8 +- test/unit/math/mix/prob/multinomial_test.cpp | 9 +- test/unit/math/mix/prob/wishart_test.cpp | 9 +- .../math/prim/prob/categorical_logit_test.cpp | 38 ++-- test/unit/math/prim/prob/categorical_test.cpp | 44 ++--- test/unit/math/prim/prob/dirichlet_test.cpp | 50 +++--- .../math/prim/prob/gaussian_dlm_obs_test.cpp | 162 +++++++++--------- test/unit/math/prim/prob/inv_wishart_test.cpp | 38 ++-- test/unit/math/prim/prob/lkj_corr_test.cpp | 28 +-- .../math/prim/prob/multi_gp_cholesky_test.cpp | 18 +- test/unit/math/prim/prob/multi_gp_test.cpp | 22 +-- .../prim/prob/multi_normal_cholesky_test.cpp | 28 +-- .../math/prim/prob/multi_normal_prec_test.cpp | 30 ++-- .../unit/math/prim/prob/multi_normal_test.cpp | 56 +++--- .../math/prim/prob/multi_student_t_test.cpp | 92 +++++----- .../math/prim/prob/multinomial_logit_test.cpp | 24 +-- test/unit/math/prim/prob/multinomial_test.cpp | 28 +-- .../prim/prob/neg_binomial_2_log_test.cpp | 26 --- .../math/prim/prob/neg_binomial_2_test.cpp | 2 +- .../unit/math/prim/prob/neg_binomial_test.cpp | 4 +- .../math/prim/prob/ordered_logistic_test.cpp | 73 ++++---- .../math/prim/prob/ordered_probit_test.cpp | 64 +++---- test/unit/math/prim/prob/poisson_test.cpp | 18 -- test/unit/math/prim/prob/wiener_test.cpp | 8 +- test/unit/math/prim/prob/wishart_test.cpp | 42 ++--- .../math/rev/fun/cholesky_decompose_test.cpp | 4 +- test/unit/math/rev/prob/categorical2_test.cpp | 20 +-- test/unit/math/rev/prob/dirichlet2_test.cpp | 76 ++++---- test/unit/math/rev/prob/inv_wishart2_test.cpp | 71 ++++---- .../prob/lkj_corr_cholesky_test_functors.hpp | 12 +- test/unit/math/rev/prob/lkj_corr_test.cpp | 18 +- test/unit/math/rev/prob/multi_gp2_test.cpp | 53 +++--- .../math/rev/prob/multi_gp_cholesky2_test.cpp | 90 +++++----- .../unit/math/rev/prob/multi_normal2_test.cpp | 97 +++++------ .../rev/prob/multi_normal_cholesky2_test.cpp | 10 +- .../rev/prob/multi_normal_cholesky_test.cpp | 30 ++-- .../math/rev/prob/multi_normal_prec2_test.cpp | 88 +++++----- .../math/rev/prob/multi_normal_prec_test.cpp | 31 ++-- .../math/rev/prob/multi_student_t2_test.cpp | 142 +++++++-------- test/unit/math/rev/prob/multinomial_test.cpp | 12 +- .../math/rev/prob/neg_binomial_2_test.cpp | 26 +-- test/unit/math/rev/prob/normal_log_test.cpp | 4 +- test/unit/math/rev/prob/wishart_test.cpp | 67 ++++---- test/unit/math_include_test.cpp | 2 +- 112 files changed, 1229 insertions(+), 1333 deletions(-) diff --git a/stan/math/prim/prob.hpp b/stan/math/prim/prob.hpp index 70aafe82422..9466bea1450 100644 --- a/stan/math/prim/prob.hpp +++ b/stan/math/prim/prob.hpp @@ -6,11 +6,8 @@ #include #include #include -#include -#include #include #include -#include #include #include #include @@ -20,7 +17,6 @@ #include #include #include -#include #include #include #include @@ -28,13 +24,11 @@ #include #include #include -#include #include #include #include #include #include -#include #include #include #include @@ -43,15 +37,11 @@ #include #include #include -#include -#include #include #include #include #include -#include #include -#include #include #include #include @@ -61,7 +51,6 @@ #include #include #include -#include #include #include #include @@ -69,12 +58,9 @@ #include #include #include -#include #include #include -#include #include -#include #include #include #include @@ -83,7 +69,6 @@ #include #include #include -#include #include #include #include @@ -91,7 +76,6 @@ #include #include #include -#include #include #include #include @@ -99,7 +83,6 @@ #include #include #include -#include #include #include #include @@ -107,7 +90,6 @@ #include #include #include -#include #include #include #include @@ -115,7 +97,6 @@ #include #include #include -#include #include #include #include @@ -123,10 +104,8 @@ #include #include #include -#include #include #include -#include #include #include #include @@ -134,13 +113,11 @@ #include #include #include -#include #include #include #include #include #include -#include #include #include #include @@ -148,7 +125,6 @@ #include #include #include -#include #include #include #include @@ -156,32 +132,25 @@ #include #include #include -#include #include #include #include #include -#include #include #include -#include #include #include -#include #include #include -#include #include #include #include #include #include #include -#include #include #include #include -#include #include #include #include @@ -189,34 +158,24 @@ #include #include #include -#include #include #include -#include #include #include -#include #include -#include #include -#include #include #include -#include #include -#include #include #include #include #include #include -#include #include #include -#include #include #include -#include #include #include #include @@ -224,10 +183,7 @@ #include #include #include -#include -#include #include -#include #include #include #include @@ -237,26 +193,20 @@ #include #include #include -#include #include #include #include #include #include -#include #include #include #include -#include #include #include -#include #include #include -#include #include #include -#include #include #include #include @@ -264,7 +214,6 @@ #include #include #include -#include #include #include #include @@ -272,7 +221,6 @@ #include #include #include -#include #include #include #include @@ -280,7 +228,6 @@ #include #include #include -#include #include #include #include @@ -288,10 +235,7 @@ #include #include #include -#include -#include #include -#include #include #include #include @@ -301,7 +245,6 @@ #include #include #include -#include #include #include #include @@ -309,7 +252,6 @@ #include #include #include -#include #include #include #include @@ -318,14 +260,12 @@ #include #include #include -#include #include #include #include #include #include #include -#include #include #include #include @@ -333,7 +273,6 @@ #include #include #include -#include #include #include #include @@ -342,7 +281,6 @@ #include #include #include -#include #include #include #include @@ -350,10 +288,8 @@ #include #include #include -#include #include #include -#include #include #include #include @@ -366,14 +302,11 @@ #include #include #include -#include #include #include -#include #include #include #include -#include #include #include diff --git a/stan/math/prim/prob/lkj_corr_cholesky_lpdf.hpp b/stan/math/prim/prob/lkj_corr_cholesky_lpdf.hpp index 878541a8502..97233e2c6ee 100644 --- a/stan/math/prim/prob/lkj_corr_cholesky_lpdf.hpp +++ b/stan/math/prim/prob/lkj_corr_cholesky_lpdf.hpp @@ -7,7 +7,6 @@ #include #include #include -#include namespace stan { namespace math { diff --git a/stan/math/prim/prob/logistic_cdf.hpp b/stan/math/prim/prob/logistic_cdf.hpp index 9250b6036d3..eef0d128958 100644 --- a/stan/math/prim/prob/logistic_cdf.hpp +++ b/stan/math/prim/prob/logistic_cdf.hpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include @@ -78,16 +78,16 @@ return_type_t logistic_cdf(const T_y& y, const T_loc& mu, if (!is_constant_all::value) { partials<0>(ops_partials)[n] - += exp(logistic_log(y_dbl, mu_dbl, sigma_dbl)) / Pn; + += exp(logistic_lpdf(y_dbl, mu_dbl, sigma_dbl)) / Pn; } if (!is_constant_all::value) { partials<1>(ops_partials)[n] - += -exp(logistic_log(y_dbl, mu_dbl, sigma_dbl)) / Pn; + += -exp(logistic_lpdf(y_dbl, mu_dbl, sigma_dbl)) / Pn; } if (!is_constant_all::value) { partials<2>(ops_partials)[n] += -(y_dbl - mu_dbl) * sigma_inv_vec - * exp(logistic_log(y_dbl, mu_dbl, sigma_dbl)) / Pn; + * exp(logistic_lpdf(y_dbl, mu_dbl, sigma_dbl)) / Pn; } } diff --git a/stan/math/prim/prob/logistic_lccdf.hpp b/stan/math/prim/prob/logistic_lccdf.hpp index 95bb142fc39..25763a63b34 100644 --- a/stan/math/prim/prob/logistic_lccdf.hpp +++ b/stan/math/prim/prob/logistic_lccdf.hpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include @@ -79,16 +79,16 @@ return_type_t logistic_lccdf(const T_y& y, const T_loc& mu, if (!is_constant_all::value) { partials<0>(ops_partials)[n] - -= exp(logistic_log(y_dbl, mu_dbl, sigma_dbl)) / Pn; + -= exp(logistic_lpdf(y_dbl, mu_dbl, sigma_dbl)) / Pn; } if (!is_constant_all::value) { partials<1>(ops_partials)[n] - -= -exp(logistic_log(y_dbl, mu_dbl, sigma_dbl)) / Pn; + -= -exp(logistic_lpdf(y_dbl, mu_dbl, sigma_dbl)) / Pn; } if (!is_constant_all::value) { partials<2>(ops_partials)[n] -= -(y_dbl - mu_dbl) * sigma_inv_vec - * exp(logistic_log(y_dbl, mu_dbl, sigma_dbl)) / Pn; + * exp(logistic_lpdf(y_dbl, mu_dbl, sigma_dbl)) / Pn; } } return ops_partials.build(P); diff --git a/stan/math/prim/prob/logistic_lcdf.hpp b/stan/math/prim/prob/logistic_lcdf.hpp index 0b221124667..ce86d2d381c 100644 --- a/stan/math/prim/prob/logistic_lcdf.hpp +++ b/stan/math/prim/prob/logistic_lcdf.hpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include @@ -78,16 +78,16 @@ return_type_t logistic_lcdf(const T_y& y, const T_loc& mu, if (!is_constant_all::value) { partials<0>(ops_partials)[n] - += exp(logistic_log(y_dbl, mu_dbl, sigma_dbl)) / Pn; + += exp(logistic_lpdf(y_dbl, mu_dbl, sigma_dbl)) / Pn; } if (!is_constant_all::value) { partials<1>(ops_partials)[n] - += -exp(logistic_log(y_dbl, mu_dbl, sigma_dbl)) / Pn; + += -exp(logistic_lpdf(y_dbl, mu_dbl, sigma_dbl)) / Pn; } if (!is_constant_all::value) { partials<2>(ops_partials)[n] += -(y_dbl - mu_dbl) * sigma_inv_vec - * exp(logistic_log(y_dbl, mu_dbl, sigma_dbl)) / Pn; + * exp(logistic_lpdf(y_dbl, mu_dbl, sigma_dbl)) / Pn; } } return ops_partials.build(P); diff --git a/stan/math/prim/prob/multi_student_t_lpdf.hpp b/stan/math/prim/prob/multi_student_t_lpdf.hpp index a5eaef677bc..ef7111d3ba7 100644 --- a/stan/math/prim/prob/multi_student_t_lpdf.hpp +++ b/stan/math/prim/prob/multi_student_t_lpdf.hpp @@ -13,7 +13,6 @@ #include #include #include -#include #include #include diff --git a/test/prob/bernoulli/bernoulli_logit_test.hpp b/test/prob/bernoulli/bernoulli_logit_test.hpp index 621ff94a57a..f3bb91bfffe 100644 --- a/test/prob/bernoulli/bernoulli_logit_test.hpp +++ b/test/prob/bernoulli/bernoulli_logit_test.hpp @@ -1,5 +1,5 @@ // Arguments: Ints, Doubles -#include +#include #include #include @@ -67,7 +67,7 @@ class AgradDistributionsBernoulliLogistic : public AgradDistributionTest { stan::return_type_t log_prob(const T_n& n, const T_prob& theta, const T2&, const T3&, const T4&, const T5&) { - return stan::math::bernoulli_logit_log(n, theta); + return stan::math::bernoulli_logit_lpmf(n, theta); } template log_prob(const T_n& n, const T_prob& theta, const T2&, const T3&, const T4&, const T5&) { - return stan::math::bernoulli_logit_log(n, theta); + return stan::math::bernoulli_logit_lpmf(n, theta); } template +#include #include #include @@ -55,7 +55,7 @@ class AgradDistributionsBernoulli : public AgradDistributionTest { stan::return_type_t log_prob(const T_n& n, const T_prob& theta, const T2&, const T3&, const T4&, const T5&) { - return stan::math::bernoulli_log(n, theta); + return stan::math::bernoulli_lpmf(n, theta); } template log_prob(const T_n& n, const T_prob& theta, const T2&, const T3&, const T4&, const T5&) { - return stan::math::bernoulli_log(n, theta); + return stan::math::bernoulli_lpmf(n, theta); } template +#include #include #include @@ -68,7 +68,7 @@ class AgradDistributionsBeta : public AgradDistributionTest { const T_scale2& beta, const T3&, const T4&, const T5&) { - return stan::math::beta_log(y, alpha, beta); + return stan::math::beta_lpdf(y, alpha, beta); } template (y, alpha, beta); + return stan::math::beta_lpdf(y, alpha, beta); } template +#include #include #include @@ -63,7 +63,7 @@ class AgradDistributionsBetaBinomial : public AgradDistributionTest { const T_size1& alpha, const T_size2& beta, const T4&, const T5&) { - return stan::math::beta_binomial_log(n, N, alpha, beta); + return stan::math::beta_binomial_lpmf(n, N, alpha, beta); } template (n, N, alpha, beta); + return stan::math::beta_binomial_lpmf(n, N, alpha, beta); } template +#include using stan::math::var; using std::numeric_limits; @@ -44,7 +44,7 @@ class AgradDistributionsBinomialLogit : public AgradDistributionTest { stan::return_type_t log_prob(const T_n& n, const T_N& N, const T_prob& alpha, const T3&, const T4&, const T5&) { - return stan::math::binomial_logit_log(n, N, alpha); + return stan::math::binomial_logit_lpmf(n, N, alpha); } template log_prob(const T_n& n, const T_N& N, const T_prob& alpha, const T3&, const T4&, const T5&) { - return stan::math::binomial_logit_log(n, N, alpha); + return stan::math::binomial_logit_lpmf(n, N, alpha); } template +#include using stan::math::var; using std::numeric_limits; @@ -46,7 +46,7 @@ class AgradDistributionsBinomial : public AgradDistributionTest { stan::return_type_t log_prob(const T_n& n, const T_N& N, const T_prob& theta, const T3&, const T4&, const T5&) { - return stan::math::binomial_log(n, N, theta); + return stan::math::binomial_lpmf(n, N, theta); } template log_prob(const T_n& n, const T_N& N, const T_prob& theta, const T3&, const T4&, const T5&) { - return stan::math::binomial_log(n, N, theta); + return stan::math::binomial_lpmf(n, N, theta); } template +#include #include #include #include @@ -64,7 +64,7 @@ class AgradDistributionsCauchy : public AgradDistributionTest { const T_scale& sigma, const T3&, const T4&, const T5&) { - return stan::math::cauchy_log(y, mu, sigma); + return stan::math::cauchy_lpdf(y, mu, sigma); } template (y, mu, sigma); + return stan::math::cauchy_lpdf(y, mu, sigma); } template +#include #include #include @@ -43,7 +43,7 @@ class AgradDistributionsChiSquare : public AgradDistributionTest { stan::return_type_t log_prob(const T_y& y, const T_dof& nu, const T2&, const T3&, const T4&, const T5&) { - return stan::math::chi_square_log(y, nu); + return stan::math::chi_square_lpdf(y, nu); } template log_prob(const T_y& y, const T_dof& nu, const T2&, const T3&, const T4&, const T5&) { - return stan::math::chi_square_log(y, nu); + return stan::math::chi_square_lpdf(y, nu); } template +#include #include using stan::math::var; @@ -89,7 +89,7 @@ class AgradDistributionsDoubleExponential : public AgradDistributionTest { const T_scale& sigma, const T3&, const T4&, const T5&) { - return stan::math::double_exponential_log(y, mu, sigma); + return stan::math::double_exponential_lpdf(y, mu, sigma); } template (y, mu, sigma); + return stan::math::double_exponential_lpdf(y, mu, sigma); } template +#include #include #include #include @@ -79,7 +79,7 @@ class AgradDistributionExpModNormal : public AgradDistributionTest { stan::return_type_t log_prob( const T_y& y, const T_loc& mu, const T_scale& sigma, const T_inv_scale& lambda, const T4&, const T5&) { - return stan::math::exp_mod_normal_log(y, mu, sigma, lambda); + return stan::math::exp_mod_normal_lpdf(y, mu, sigma, lambda); } template log_prob( const T_y& y, const T_loc& mu, const T_scale& sigma, const T_inv_scale& lambda, const T4&, const T5&) { - return stan::math::exp_mod_normal_log(y, mu, sigma, lambda); + return stan::math::exp_mod_normal_lpdf(y, mu, sigma, lambda); } template +#include #include using stan::math::var; @@ -56,7 +56,7 @@ class AgradDistributionsExponential : public AgradDistributionTest { const T_inv_scale& beta, const T2&, const T3&, const T4&, const T5&) { - return stan::math::exponential_log(y, beta); + return stan::math::exponential_lpdf(y, beta); } template (y, beta); + return stan::math::exponential_lpdf(y, beta); } template +#include #include #include #include @@ -58,7 +58,7 @@ class AgradDistributionsFrechet : public AgradDistributionTest { const T_scale& sigma, const T3&, const T4&, const T5&) { - return stan::math::frechet_log(y, alpha, sigma); + return stan::math::frechet_lpdf(y, alpha, sigma); } template (y, alpha, sigma); + return stan::math::frechet_lpdf(y, alpha, sigma); } template +#include #include #include @@ -67,7 +67,7 @@ class AgradDistributionsGamma : public AgradDistributionTest { stan::return_type_t log_prob( const T_y& y, const T_shape& alpha, const T_inv_scale& beta, const T3&, const T4&, const T5&) { - return stan::math::gamma_log(y, alpha, beta); + return stan::math::gamma_lpdf(y, alpha, beta); } template log_prob( const T_y& y, const T_shape& alpha, const T_inv_scale& beta, const T3&, const T4&, const T5&) { - return stan::math::gamma_log(y, alpha, beta); + return stan::math::gamma_lpdf(y, alpha, beta); } template +#include #include #include @@ -72,7 +72,7 @@ class AgradDistributionGumbel : public AgradDistributionTest { const T_scale& beta, const T3&, const T4&, const T5&) { - return stan::math::gumbel_log(y, mu, beta); + return stan::math::gumbel_lpdf(y, mu, beta); } template (y, mu, beta); + return stan::math::gumbel_lpdf(y, mu, beta); } template +#include #include using stan::math::var; @@ -51,14 +51,14 @@ class AgradDistributionsHypergeometric : public AgradDistributionTest { stan::return_type_t log_prob(const T_n& n, const T_N& N, const T_a& a, const T_b& b, const T4&, const T5&) { - return stan::math::hypergeometric_log(n, N, a, b); + return stan::math::hypergeometric_lpmf(n, N, a, b); } template double log_prob(const T_n& n, const T_N& N, const T_a& a, const T_b& b, const T4&, const T5&) { - return stan::math::hypergeometric_log(n, N, a, b); + return stan::math::hypergeometric_lpmf(n, N, a, b); } template +#include #include #include #include @@ -44,7 +44,7 @@ class AgradDistributionsInvChiSquare : public AgradDistributionTest { stan::return_type_t log_prob(const T_y& y, const T_dof& nu, const T2&, const T3&, const T4&, const T5&) { - return stan::math::inv_chi_square_log(y, nu); + return stan::math::inv_chi_square_lpdf(y, nu); } template log_prob(const T_y& y, const T_dof& nu, const T2&, const T3&, const T4&, const T5&) { - return stan::math::inv_chi_square_log(y, nu); + return stan::math::inv_chi_square_lpdf(y, nu); } template +#include #include #include @@ -63,7 +63,7 @@ class AgradDistributionsInvGamma : public AgradDistributionTest { const T_scale& beta, const T3&, const T4&, const T5&) { - return stan::math::inv_gamma_log(y, alpha, beta); + return stan::math::inv_gamma_lpdf(y, alpha, beta); } template (y, alpha, beta); + return stan::math::inv_gamma_lpdf(y, alpha, beta); } template +#include #include #include @@ -57,7 +57,7 @@ class AgradDistributionsLogistic : public AgradDistributionTest { const T_scale& sigma, const T3&, const T4&, const T5&) { - return stan::math::logistic_log(y, mu, sigma); + return stan::math::logistic_lpdf(y, mu, sigma); } template (y, mu, sigma); + return stan::math::logistic_lpdf(y, mu, sigma); } template +#include #include #include #include @@ -58,7 +58,7 @@ class AgradDistributionsLognormal : public AgradDistributionTest { const T_scale& sigma, const T3&, const T4&, const T5&) { - return stan::math::lognormal_log(y, mu, sigma); + return stan::math::lognormal_lpdf(y, mu, sigma); } template (y, mu, sigma); + return stan::math::lognormal_lpdf(y, mu, sigma); } template +#include #include #include #include @@ -56,7 +56,7 @@ class AgradDistributionsNegBinomial : public AgradDistributionTest { const T_inv_scale& beta, const T3&, const T4&, const T5&) { - return stan::math::neg_binomial_log(n, alpha, beta); + return stan::math::neg_binomial_lpmf(n, alpha, beta); } template (n, alpha, beta); + return stan::math::neg_binomial_lpmf(n, alpha, beta); } template +#include #include #include #include @@ -54,7 +54,7 @@ class AgradDistributionsNegBinomial2Log : public AgradDistributionTest { stan::return_type_t log_prob( const T_n& n, const T_log_location& eta, const T_inv_scale& phi, const T3&, const T4&, const T5&) { - return stan::math::neg_binomial_2_log_log(n, eta, phi); + return stan::math::neg_binomial_2_log_lpmf(n, eta, phi); } template log_prob( const T_n& n, const T_log_location& eta, const T_inv_scale& phi, const T3&, const T4&, const T5&) { - return stan::math::neg_binomial_2_log_log(n, eta, phi); + return stan::math::neg_binomial_2_log_lpmf(n, eta, phi); } template +#include #include #include #include @@ -54,7 +54,7 @@ class AgradDistributionsNegBinomial2 : public AgradDistributionTest { const T_inv_scale& phi, const T3&, const T4&, const T5&) { - return stan::math::neg_binomial_2_log(n, mu, phi); + return stan::math::neg_binomial_2_lpmf(n, mu, phi); } template (n, mu, phi); + return stan::math::neg_binomial_2_lpmf(n, mu, phi); } template +#include #include #include @@ -66,7 +66,7 @@ class AgradDistributionNormal : public AgradDistributionTest { const T_scale& sigma, const T3&, const T4&, const T5&) { - return stan::math::normal_log(y, mu, sigma); + return stan::math::normal_lpdf(y, mu, sigma); } template (y, mu, sigma); + return stan::math::normal_lpdf(y, mu, sigma); } template +#include #include #include #include @@ -64,7 +64,7 @@ class AgradDistributionsPareto : public AgradDistributionTest { const T_shape& alpha, const T3&, const T4&, const T5&) { - return stan::math::pareto_log(y, y_min, alpha); + return stan::math::pareto_lpdf(y, y_min, alpha); } template (y, y_min, alpha); + return stan::math::pareto_lpdf(y, y_min, alpha); } template +#include #include #include @@ -65,7 +65,7 @@ class AgradDistributionParetoType2 : public AgradDistributionTest { stan::return_type_t log_prob( const T_y& y, const T_loc& mu, const T_scale& lambda, const T_shape& alpha, const T4&, const T5&) { - return stan::math::pareto_type_2_log(y, mu, lambda, alpha); + return stan::math::pareto_type_2_lpdf(y, mu, lambda, alpha); } template log_prob( const T_y& y, const T_loc& mu, const T_scale& lambda, const T_shape& alpha, const T4&, const T5&) { - return stan::math::pareto_type_2_log(y, mu, lambda, alpha); + return stan::math::pareto_type_2_lpdf(y, mu, lambda, alpha); } template +#include #include #include #include @@ -46,7 +46,7 @@ class AgradDistributionsPoisson : public AgradDistributionTest { stan::return_type_t log_prob(const T_n& n, const T_rate& alpha, const T2&, const T3&, const T4&, const T5&) { - return stan::math::poisson_log_log(n, alpha); + return stan::math::poisson_log_lpmf(n, alpha); } template log_prob(const T_n& n, const T_rate& alpha, const T2&, const T3&, const T4&, const T5&) { - return stan::math::poisson_log_log(n, alpha); + return stan::math::poisson_log_lpmf(n, alpha); } template +#include #include #include #include @@ -48,7 +48,7 @@ class AgradDistributionsPoisson : public AgradDistributionTest { stan::return_type_t log_prob(const T_n& n, const T_rate& lambda, const T2&, const T3&, const T4&, const T5&) { - return stan::math::poisson_log(n, lambda); + return stan::math::poisson_lpmf(n, lambda); } template log_prob(const T_n& n, const T_rate& lambda, const T2&, const T3&, const T4&, const T5&) { - return stan::math::poisson_log(n, lambda); + return stan::math::poisson_lpmf(n, lambda); } template +#include #include using stan::math::var; @@ -56,7 +56,7 @@ class AgradDistributionRayleigh : public AgradDistributionTest { stan::return_type_t log_prob(const T_y& y, const T_scale& sigma, const T2&, const T3&, const T4&, const T5&) { - return stan::math::rayleigh_log(y, sigma); + return stan::math::rayleigh_lpdf(y, sigma); } template log_prob(const T_y& y, const T_scale& sigma, const T2&, const T3&, const T4&, const T5&) { - return stan::math::rayleigh_log(y, sigma); + return stan::math::rayleigh_lpdf(y, sigma); } template +#include #include #include #include @@ -60,7 +60,7 @@ class AgradDistributionsScaledInvChiSquare : public AgradDistributionTest { const T_dof& nu, const T_scale& s, const T3&, const T4&, const T5&) { - return stan::math::scaled_inv_chi_square_log(y, nu, s); + return stan::math::scaled_inv_chi_square_lpdf(y, nu, s); } template (y, nu, s); + return stan::math::scaled_inv_chi_square_lpdf(y, nu, s); } template +#include #include #include #include @@ -76,7 +76,7 @@ class AgradDistributionSkewNormal : public AgradDistributionTest { stan::return_type_t log_prob( const T_y& y, const T_loc& mu, const T_scale& sigma, const T_shape& alpha, const T4&, const T5&) { - return stan::math::skew_normal_log(y, mu, sigma, alpha); + return stan::math::skew_normal_lpdf(y, mu, sigma, alpha); } template log_prob( const T_y& y, const T_loc& mu, const T_scale& sigma, const T_shape& alpha, const T4&, const T5&) { - return stan::math::skew_normal_log(y, mu, sigma, alpha); + return stan::math::skew_normal_lpdf(y, mu, sigma, alpha); } template +#include #include #include #include @@ -73,7 +73,7 @@ class AgradDistributionsStudentT : public AgradDistributionTest { stan::return_type_t log_prob( const T_y& y, const T_dof& nu, const T_loc& mu, const T_scale& sigma, const T4&, const T5&) { - return stan::math::student_t_log(y, nu, mu, sigma); + return stan::math::student_t_lpdf(y, nu, mu, sigma); } template log_prob( const T_y& y, const T_dof& nu, const T_loc& mu, const T_scale& sigma, const T4&, const T5&) { - return stan::math::student_t_log(y, nu, mu, sigma); + return stan::math::student_t_lpdf(y, nu, mu, sigma); } template +#include #include #include @@ -47,7 +47,7 @@ class AgradDistributionsUniform : public AgradDistributionTest { const T_high& beta, const T3&, const T4&, const T5&) { - return stan::math::uniform_log(y, alpha, beta); + return stan::math::uniform_lpdf(y, alpha, beta); } template (y, alpha, beta); + return stan::math::uniform_lpdf(y, alpha, beta); } template +#include #include #include #include > @@ -72,7 +72,7 @@ class AgradDistributionVonMises : public AgradDistributionTest { const T_scale& kappa, const T3&, const T4&, const T5&) { - return stan::math::von_mises_log(y, mu, kappa); + return stan::math::von_mises_lpdf(y, mu, kappa); } template (y, mu, kappa); + return stan::math::von_mises_lpdf(y, mu, kappa); } template +#include #include #include #include @@ -58,7 +58,7 @@ class AgradDistributionsWeibull : public AgradDistributionTest { const T_scale& sigma, const T3&, const T4&, const T5&) { - return stan::math::weibull_log(y, alpha, sigma); + return stan::math::weibull_lpdf(y, alpha, sigma); } template (y, alpha, sigma); + return stan::math::weibull_lpdf(y, alpha, sigma); } template +#include #include #include @@ -80,7 +80,7 @@ class AgradDistributionWiener : public AgradDistributionTest { stan::return_type_t log_prob( const T_y& y, const T_alpha& alpha, const T_tau& tau, const T_beta& beta, const T_delta& delta, const T5&) { - return stan::math::wiener_log(y, alpha, tau, beta, delta); + return stan::math::wiener_lpdf(y, alpha, tau, beta, delta); } template log_prob( const T_y& y, const T_alpha& alpha, const T_tau& tau, const T_beta& beta, const T_delta& delta, const T5&) { - return stan::math::wiener_log(y, alpha, tau, beta, delta); + return stan::math::wiener_lpdf(y, alpha, tau, beta, delta); } template log_prob_function(const T_y& y, const T_alpha& alpha, const T_tau& tau, const T_beta& beta, const T_delta& delta, const T5&) { - return stan::math::wiener_log(y, alpha, tau, beta, delta); + return stan::math::wiener_lpdf(y, alpha, tau, beta, delta); } }; diff --git a/test/sig_utils.py b/test/sig_utils.py index 73c52f83a90..e7ad8dd4429 100644 --- a/test/sig_utils.py +++ b/test/sig_utils.py @@ -76,35 +76,28 @@ def get_cpp_type(stan_type): "algebra_solver": [None, None, None, None, None, None, None, 10], "algebra_solver_newton": [None, None, None, None, None, None, None, 10], "log1m_exp": [-0.6], - "categorical_log": [None, simplex], "categorical_rng": [simplex, None], "categorical_lpmf": [None, simplex], "cholesky_decompose": [pos_definite, None], "csr_to_dense_matrix": [1, 1, None, [1], [1, 2]], "csr_matrix_times_vector": [1, 1, None, [1], [1, 2], None], "distance": [0.6, 0.4], - "dirichlet_log": [simplex, None], "dirichlet_lpdf": [simplex, None], "hmm_hidden_state_prob": [None, simplex, simplex], "hmm_latent_rng": [None, simplex, simplex, None], "hmm_marginal": [None, simplex, simplex], "lambert_wm1": [-0.3], "lkj_corr_lpdf": [1, None], - "lkj_corr_log": [1, None], "log_diff_exp": [3, None], "log_inv_logit_diff": [1.2, 0.4], "mdivide_left_spd": [pos_definite, None], - "multinomial_log": [None, simplex], "multinomial_lpmf": [None, simplex], "multinomial_rng": [simplex, None, None], "multi_normal_lpdf": [None, None, pos_definite], - "multi_normal_log": [None, None, pos_definite], "multi_normal_rng": [None, pos_definite], "multi_normal_prec_lpdf": [None, None, pos_definite], - "multi_normal_prec_log": [None, None, pos_definite], "multi_normal_prec_rng": [None, pos_definite], "multi_student_t_lpdf": [None, None, None, pos_definite], - "multi_student_t_log": [None, None, None, pos_definite], "multi_student_t_rng": [None, None, pos_definite], "ode_adams_tol": [None, None, 0.2, 0.4, None, None, 10, None, None, None], "ode_adams": [None, None, 0.2, 0.4, None, None, None], @@ -137,10 +130,8 @@ def get_cpp_type(stan_type): "uniform_cdf_log": [None, 0.2, 0.9], "uniform_lccdf": [None, 0.2, 0.9], "uniform_lcdf": [None, 0.2, 0.9], - "uniform_log": [None, 0.2, 0.9], "uniform_lpdf": [None, 0.2, 0.9], "uniform_rng": [0.2, 1.9, None], - "wiener_log": [0.8, None, 0.4, None, None], "wiener_lpdf": [0.8, None, 0.4, None, None], } diff --git a/test/unit/math/fwd/prob/categorical_logit_test.cpp b/test/unit/math/fwd/prob/categorical_logit_test.cpp index 83071b4158f..c0131c41d6d 100644 --- a/test/unit/math/fwd/prob/categorical_logit_test.cpp +++ b/test/unit/math/fwd/prob/categorical_logit_test.cpp @@ -14,17 +14,17 @@ TEST(ProbDistributionsCategoricalLogit, fvar_double) { theta(i).d_ = i; Matrix, Dynamic, 1> theta_log_softmax = log_softmax(theta); EXPECT_FLOAT_EQ(theta_log_softmax[0].val_, - stan::math::categorical_logit_log(1, theta).val_); + stan::math::categorical_logit_lpmf(1, theta).val_); EXPECT_FLOAT_EQ(theta_log_softmax[1].val_, - stan::math::categorical_logit_log(2, theta).val_); + stan::math::categorical_logit_lpmf(2, theta).val_); EXPECT_FLOAT_EQ(theta_log_softmax[2].val_, - stan::math::categorical_logit_log(3, theta).val_); + stan::math::categorical_logit_lpmf(3, theta).val_); EXPECT_FLOAT_EQ(theta_log_softmax[0].d_, - stan::math::categorical_logit_log(1, theta).d_); + stan::math::categorical_logit_lpmf(1, theta).d_); EXPECT_FLOAT_EQ(theta_log_softmax[1].d_, - stan::math::categorical_logit_log(2, theta).d_); + stan::math::categorical_logit_lpmf(2, theta).d_); EXPECT_FLOAT_EQ(theta_log_softmax[2].d_, - stan::math::categorical_logit_log(3, theta).d_); + stan::math::categorical_logit_lpmf(3, theta).d_); } TEST(ProbDistributionsCategoricalLogit, fvar_double_vectorized) { @@ -38,7 +38,7 @@ TEST(ProbDistributionsCategoricalLogit, fvar_double_vectorized) { theta(i).d_ = i; std::vector ns(0); - EXPECT_FLOAT_EQ(0.0, stan::math::categorical_logit_log(ns, theta).val_); + EXPECT_FLOAT_EQ(0.0, stan::math::categorical_logit_lpmf(ns, theta).val_); Matrix, Dynamic, 1> theta_log_softmax = log_softmax(theta); @@ -48,10 +48,10 @@ TEST(ProbDistributionsCategoricalLogit, fvar_double_vectorized) { ms[2] = 1; EXPECT_FLOAT_EQ(theta_log_softmax[0].val_ + theta_log_softmax[1].val_ + theta_log_softmax[0].val_, - stan::math::categorical_logit_log(ms, theta).val_); + stan::math::categorical_logit_lpmf(ms, theta).val_); EXPECT_FLOAT_EQ(theta_log_softmax[0].d_ + theta_log_softmax[1].d_ + theta_log_softmax[0].d_, - stan::math::categorical_logit_log(ms, theta).d_); + stan::math::categorical_logit_lpmf(ms, theta).d_); } TEST(ProbDistributionsCategoricalLogit, fvar_fvar_double) { @@ -66,17 +66,17 @@ TEST(ProbDistributionsCategoricalLogit, fvar_fvar_double) { Matrix >, Dynamic, 1> theta_log_softmax = log_softmax(theta); EXPECT_FLOAT_EQ(theta_log_softmax[0].val_.val_, - stan::math::categorical_logit_log(1, theta).val_.val_); + stan::math::categorical_logit_lpmf(1, theta).val_.val_); EXPECT_FLOAT_EQ(theta_log_softmax[1].val_.val_, - stan::math::categorical_logit_log(2, theta).val_.val_); + stan::math::categorical_logit_lpmf(2, theta).val_.val_); EXPECT_FLOAT_EQ(theta_log_softmax[2].val_.val_, - stan::math::categorical_logit_log(3, theta).val_.val_); + stan::math::categorical_logit_lpmf(3, theta).val_.val_); EXPECT_FLOAT_EQ(theta_log_softmax[0].d_.val_, - stan::math::categorical_logit_log(1, theta).d_.val_); + stan::math::categorical_logit_lpmf(1, theta).d_.val_); EXPECT_FLOAT_EQ(theta_log_softmax[1].d_.val_, - stan::math::categorical_logit_log(2, theta).d_.val_); + stan::math::categorical_logit_lpmf(2, theta).d_.val_); EXPECT_FLOAT_EQ(theta_log_softmax[2].d_.val_, - stan::math::categorical_logit_log(3, theta).d_.val_); + stan::math::categorical_logit_lpmf(3, theta).d_.val_); } TEST(ProbDistributionsCategoricalLogit, fvar_fvar_double_vectorized) { @@ -90,7 +90,7 @@ TEST(ProbDistributionsCategoricalLogit, fvar_fvar_double_vectorized) { theta(i).d_.val_ = i; std::vector ns(0); - EXPECT_FLOAT_EQ(0.0, stan::math::categorical_logit_log(ns, theta).val_.val_); + EXPECT_FLOAT_EQ(0.0, stan::math::categorical_logit_lpmf(ns, theta).val_.val_); Matrix >, Dynamic, 1> theta_log_softmax = log_softmax(theta); @@ -102,8 +102,8 @@ TEST(ProbDistributionsCategoricalLogit, fvar_fvar_double_vectorized) { EXPECT_FLOAT_EQ(theta_log_softmax[0].val_.val_ + theta_log_softmax[1].val_.val_ + theta_log_softmax[0].val_.val_, - stan::math::categorical_logit_log(ms, theta).val_.val_); + stan::math::categorical_logit_lpmf(ms, theta).val_.val_); EXPECT_FLOAT_EQ(theta_log_softmax[0].d_.val_ + theta_log_softmax[1].d_.val_ + theta_log_softmax[0].d_.val_, - stan::math::categorical_logit_log(ms, theta).d_.val_); + stan::math::categorical_logit_lpmf(ms, theta).d_.val_); } diff --git a/test/unit/math/fwd/prob/categorical_test.cpp b/test/unit/math/fwd/prob/categorical_test.cpp index 99562998d15..f7700bc9389 100644 --- a/test/unit/math/fwd/prob/categorical_test.cpp +++ b/test/unit/math/fwd/prob/categorical_test.cpp @@ -13,12 +13,12 @@ TEST(ProbDistributionsCategorical, fvar_double) { for (int i = 0; i < 3; i++) theta(i).d_ = 1.0; - EXPECT_FLOAT_EQ(std::log(0.3), stan::math::categorical_log(1, theta).val_); - EXPECT_FLOAT_EQ(std::log(0.5), stan::math::categorical_log(2, theta).val_); - EXPECT_FLOAT_EQ(std::log(0.2), stan::math::categorical_log(3, theta).val_); - EXPECT_FLOAT_EQ(1.0 / 0.3, stan::math::categorical_log(1, theta).d_); - EXPECT_FLOAT_EQ(1.0 / 0.5, stan::math::categorical_log(2, theta).d_); - EXPECT_FLOAT_EQ(1.0 / 0.2, stan::math::categorical_log(3, theta).d_); + EXPECT_FLOAT_EQ(std::log(0.3), stan::math::categorical_lpmf(1, theta).val_); + EXPECT_FLOAT_EQ(std::log(0.5), stan::math::categorical_lpmf(2, theta).val_); + EXPECT_FLOAT_EQ(std::log(0.2), stan::math::categorical_lpmf(3, theta).val_); + EXPECT_FLOAT_EQ(1.0 / 0.3, stan::math::categorical_lpmf(1, theta).d_); + EXPECT_FLOAT_EQ(1.0 / 0.5, stan::math::categorical_lpmf(2, theta).d_); + EXPECT_FLOAT_EQ(1.0 / 0.2, stan::math::categorical_lpmf(3, theta).d_); } TEST(ProbDistributionsCategorical, fvar_double_vector) { using Eigen::Dynamic; @@ -35,9 +35,9 @@ TEST(ProbDistributionsCategorical, fvar_double_vector) { xs[2] = 1; EXPECT_FLOAT_EQ(log(0.3) + log(0.2) + log(0.3), - stan::math::categorical_log(xs, theta).val_); + stan::math::categorical_lpmf(xs, theta).val_); EXPECT_FLOAT_EQ(1.0 / 0.3 + 1.0 / 0.2 + 1.0 / 0.3, - stan::math::categorical_log(xs, theta).d_); + stan::math::categorical_lpmf(xs, theta).d_); } TEST(ProbDistributionsCategorical, fvar_fvar_double) { @@ -50,14 +50,14 @@ TEST(ProbDistributionsCategorical, fvar_fvar_double) { theta(i).d_.val_ = 1.0; EXPECT_FLOAT_EQ(std::log(0.3), - stan::math::categorical_log(1, theta).val_.val_); + stan::math::categorical_lpmf(1, theta).val_.val_); EXPECT_FLOAT_EQ(std::log(0.5), - stan::math::categorical_log(2, theta).val_.val_); + stan::math::categorical_lpmf(2, theta).val_.val_); EXPECT_FLOAT_EQ(std::log(0.2), - stan::math::categorical_log(3, theta).val_.val_); - EXPECT_FLOAT_EQ(1.0 / 0.3, stan::math::categorical_log(1, theta).d_.val_); - EXPECT_FLOAT_EQ(1.0 / 0.5, stan::math::categorical_log(2, theta).d_.val_); - EXPECT_FLOAT_EQ(1.0 / 0.2, stan::math::categorical_log(3, theta).d_.val_); + stan::math::categorical_lpmf(3, theta).val_.val_); + EXPECT_FLOAT_EQ(1.0 / 0.3, stan::math::categorical_lpmf(1, theta).d_.val_); + EXPECT_FLOAT_EQ(1.0 / 0.5, stan::math::categorical_lpmf(2, theta).d_.val_); + EXPECT_FLOAT_EQ(1.0 / 0.2, stan::math::categorical_lpmf(3, theta).d_.val_); } TEST(ProbDistributionsCategorical, fvar_fvar_double_vector) { using Eigen::Dynamic; @@ -74,7 +74,7 @@ TEST(ProbDistributionsCategorical, fvar_fvar_double_vector) { xs[2] = 1; EXPECT_FLOAT_EQ(log(0.3) + log(0.2) + log(0.3), - stan::math::categorical_log(xs, theta).val_.val_); + stan::math::categorical_lpmf(xs, theta).val_.val_); EXPECT_FLOAT_EQ(1.0 / 0.3 + 1.0 / 0.2 + 1.0 / 0.3, - stan::math::categorical_log(xs, theta).d_.val_); + stan::math::categorical_lpmf(xs, theta).d_.val_); } diff --git a/test/unit/math/fwd/prob/dirichlet_test.cpp b/test/unit/math/fwd/prob/dirichlet_test.cpp index 8edb32581a3..fc844a4f2ec 100644 --- a/test/unit/math/fwd/prob/dirichlet_test.cpp +++ b/test/unit/math/fwd/prob/dirichlet_test.cpp @@ -17,8 +17,8 @@ TEST(ProbDistributions, fvar_double) { alpha(i).d_ = 1.0; } - EXPECT_FLOAT_EQ(0.6931472, stan::math::dirichlet_log(theta, alpha).val_); - EXPECT_FLOAT_EQ(0.99344212, stan::math::dirichlet_log(theta, alpha).d_); + EXPECT_FLOAT_EQ(0.6931472, stan::math::dirichlet_lpdf(theta, alpha).val_); + EXPECT_FLOAT_EQ(0.99344212, stan::math::dirichlet_lpdf(theta, alpha).d_); Matrix, Dynamic, 1> theta2(4, 1); theta2 << 0.01, 0.01, 0.8, 0.18; @@ -29,8 +29,8 @@ TEST(ProbDistributions, fvar_double) { alpha2(i).d_ = 1.0; } - EXPECT_FLOAT_EQ(-43.40045, stan::math::dirichlet_log(theta2, alpha2).val_); - EXPECT_FLOAT_EQ(2017.2858, stan::math::dirichlet_log(theta2, alpha2).d_); + EXPECT_FLOAT_EQ(-43.40045, stan::math::dirichlet_lpdf(theta2, alpha2).val_); + EXPECT_FLOAT_EQ(2017.2858, stan::math::dirichlet_lpdf(theta2, alpha2).d_); } TEST(ProbDistributions, fvar_fvar_double) { @@ -47,8 +47,9 @@ TEST(ProbDistributions, fvar_fvar_double) { alpha(i).d_ = 1.0; } - EXPECT_FLOAT_EQ(0.6931472, stan::math::dirichlet_log(theta, alpha).val_.val_); - EXPECT_FLOAT_EQ(0.99344212, stan::math::dirichlet_log(theta, alpha).d_.val_); + EXPECT_FLOAT_EQ(0.6931472, + stan::math::dirichlet_lpdf(theta, alpha).val_.val_); + EXPECT_FLOAT_EQ(0.99344212, stan::math::dirichlet_lpdf(theta, alpha).d_.val_); Matrix >, Dynamic, 1> theta2(4, 1); theta2 << 0.01, 0.01, 0.8, 0.18; @@ -60,6 +61,7 @@ TEST(ProbDistributions, fvar_fvar_double) { } EXPECT_FLOAT_EQ(-43.40045, - stan::math::dirichlet_log(theta2, alpha2).val_.val_); - EXPECT_FLOAT_EQ(2017.2858, stan::math::dirichlet_log(theta2, alpha2).d_.val_); + stan::math::dirichlet_lpdf(theta2, alpha2).val_.val_); + EXPECT_FLOAT_EQ(2017.2858, + stan::math::dirichlet_lpdf(theta2, alpha2).d_.val_); } diff --git a/test/unit/math/fwd/prob/gaussian_dlm_obs_test.cpp b/test/unit/math/fwd/prob/gaussian_dlm_obs_test.cpp index 1e67b0da2c9..c15558c4920 100644 --- a/test/unit/math/fwd/prob/gaussian_dlm_obs_test.cpp +++ b/test/unit/math/fwd/prob/gaussian_dlm_obs_test.cpp @@ -6,7 +6,7 @@ TEST(ProbDistributionsGaussianDLM, LoglikeUU_fvar_double) { using Eigen::Matrix; using Eigen::MatrixXd; using stan::math::fvar; - using stan::math::gaussian_dlm_obs_log; + using stan::math::gaussian_dlm_obs_lpdf; Eigen::Matrix, Eigen::Dynamic, Eigen::Dynamic> FF(1, 1); FF << fvar(0.585528817843856, 1.0); @@ -31,7 +31,7 @@ TEST(ProbDistributionsGaussianDLM, LoglikeUU_fvar_double) { fvar(1.17332931763075, 1.0); double ll_expected = -16.2484978375184; - fvar lp_ref = gaussian_dlm_obs_log(y, FF, GG, V, W, m0, C0); + fvar lp_ref = gaussian_dlm_obs_lpdf(y, FF, GG, V, W, m0, C0); EXPECT_FLOAT_EQ(ll_expected, lp_ref.val_); EXPECT_FLOAT_EQ(-3.8427677, lp_ref.d_); } @@ -41,7 +41,7 @@ TEST(ProbDistributionsGaussianDLM, LoglikeMM_fvar_double) { using Eigen::Matrix; using Eigen::MatrixXd; using stan::math::fvar; - using stan::math::gaussian_dlm_obs_log; + using stan::math::gaussian_dlm_obs_lpdf; Eigen::Matrix, Eigen::Dynamic, Eigen::Dynamic> FF(2, 3); FF << fvar(0.585528817843856, 1.0), @@ -96,7 +96,7 @@ TEST(ProbDistributionsGaussianDLM, LoglikeMM_fvar_double) { fvar(0.746844140961399, 1.0); double ll_expected = -85.2615847497409; - fvar lp_ref = gaussian_dlm_obs_log(y, FF, GG, V, W, m0, C0); + fvar lp_ref = gaussian_dlm_obs_lpdf(y, FF, GG, V, W, m0, C0); // the error adds up in the multivariate version due to the inversion. EXPECT_NEAR(ll_expected, lp_ref.val_, 1e-4); EXPECT_NEAR(18.89044287309947, lp_ref.d_, 1e-4); @@ -107,7 +107,7 @@ TEST(ProbDistributionsGaussianDLM, LoglikeUU_fvar_fvar_double) { using Eigen::Matrix; using Eigen::MatrixXd; using stan::math::fvar; - using stan::math::gaussian_dlm_obs_log; + using stan::math::gaussian_dlm_obs_lpdf; Eigen::Matrix >, Eigen::Dynamic, Eigen::Dynamic> FF(1, 1); FF << fvar >(0.585528817843856, 1.0); @@ -134,7 +134,7 @@ TEST(ProbDistributionsGaussianDLM, LoglikeUU_fvar_fvar_double) { fvar >(1.17332931763075, 1.0); double ll_expected = -16.2484978375184; - fvar > lp_ref = gaussian_dlm_obs_log(y, FF, GG, V, W, m0, C0); + fvar > lp_ref = gaussian_dlm_obs_lpdf(y, FF, GG, V, W, m0, C0); EXPECT_FLOAT_EQ(ll_expected, lp_ref.val_.val_); EXPECT_FLOAT_EQ(-3.8427677, lp_ref.d_.val_); } @@ -144,7 +144,7 @@ TEST(ProbDistributionsGaussianDLM, LoglikeMM_fvar_fvar_double) { using Eigen::Matrix; using Eigen::MatrixXd; using stan::math::fvar; - using stan::math::gaussian_dlm_obs_log; + using stan::math::gaussian_dlm_obs_lpdf; Eigen::Matrix >, Eigen::Dynamic, Eigen::Dynamic> FF(2, 3); FF << fvar >(0.585528817843856, 1.0), @@ -212,7 +212,7 @@ TEST(ProbDistributionsGaussianDLM, LoglikeMM_fvar_fvar_double) { fvar >(0.746844140961399, 1.0); double ll_expected = -85.2615847497409; - fvar > lp_ref = gaussian_dlm_obs_log(y, FF, GG, V, W, m0, C0); + fvar > lp_ref = gaussian_dlm_obs_lpdf(y, FF, GG, V, W, m0, C0); // the error adds up in the multivariate version due to the inversion. EXPECT_NEAR(ll_expected, lp_ref.val_.val_, 1e-4); EXPECT_NEAR(18.89044287309947, lp_ref.d_.val_, 1e-4); diff --git a/test/unit/math/fwd/prob/inv_wishart_test.cpp b/test/unit/math/fwd/prob/inv_wishart_test.cpp index d4b7889d76e..f996bf1a1bd 100644 --- a/test/unit/math/fwd/prob/inv_wishart_test.cpp +++ b/test/unit/math/fwd/prob/inv_wishart_test.cpp @@ -9,7 +9,7 @@ TEST(ProbDistributionsInvWishart, fvar_double) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::fvar; - using stan::math::inv_wishart_log; + using stan::math::inv_wishart_lpdf; Matrix, Dynamic, Dynamic> Y(3, 3); Y << 12.147233, -11.9036079, 1.091046, -11.9036079, 16.7585782, 0.8530256, @@ -28,16 +28,16 @@ TEST(ProbDistributionsInvWishart, fvar_double) { Sigma(i, j).d_ = 1.0; } - EXPECT_NEAR(log_p, stan::math::inv_wishart_log(Y, dof, Sigma).val_, 0.01); + EXPECT_NEAR(log_p, stan::math::inv_wishart_lpdf(Y, dof, Sigma).val_, 0.01); EXPECT_NEAR(-1.4893348387330674, - stan::math::inv_wishart_log(Y, dof, Sigma).d_, 0.01); + stan::math::inv_wishart_lpdf(Y, dof, Sigma).d_, 0.01); } TEST(ProbDistributionsInvWishart, fvar_fvar_double) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::fvar; - using stan::math::inv_wishart_log; + using stan::math::inv_wishart_lpdf; Matrix >, Dynamic, Dynamic> Y(3, 3); Y << 12.147233, -11.9036079, 1.0910458, -11.9036079, 16.7585782, 0.8530256, @@ -56,8 +56,8 @@ TEST(ProbDistributionsInvWishart, fvar_fvar_double) { Sigma(i, j).d_ = 1.0; } - EXPECT_NEAR(log_p, stan::math::inv_wishart_log(Y, dof, Sigma).val_.val_, + EXPECT_NEAR(log_p, stan::math::inv_wishart_lpdf(Y, dof, Sigma).val_.val_, 0.01); EXPECT_NEAR(-1.4893348387330674, - stan::math::inv_wishart_log(Y, dof, Sigma).d_.val_, 0.01); + stan::math::inv_wishart_lpdf(Y, dof, Sigma).d_.val_, 0.01); } diff --git a/test/unit/math/fwd/prob/lkj_corr_test.cpp b/test/unit/math/fwd/prob/lkj_corr_test.cpp index 6063bedc0c6..820dd5fdc74 100644 --- a/test/unit/math/fwd/prob/lkj_corr_test.cpp +++ b/test/unit/math/fwd/prob/lkj_corr_test.cpp @@ -14,12 +14,12 @@ TEST(ProbDistributionsLkjCorr, fvar_double) { Sigma(i).d_ = 1.0; fvar eta = stan::math::uniform_rng(0, 2, rng); fvar f = stan::math::do_lkj_constant(eta, K); - EXPECT_FLOAT_EQ(f.val_, stan::math::lkj_corr_log(Sigma, eta).val_); - EXPECT_FLOAT_EQ(2.5177896, stan::math::lkj_corr_log(Sigma, eta).d_); + EXPECT_FLOAT_EQ(f.val_, stan::math::lkj_corr_lpdf(Sigma, eta).val_); + EXPECT_FLOAT_EQ(2.5177896, stan::math::lkj_corr_lpdf(Sigma, eta).d_); eta = 1.0; f = stan::math::do_lkj_constant(eta, K); - EXPECT_FLOAT_EQ(f.val_, stan::math::lkj_corr_log(Sigma, eta).val_); - EXPECT_FLOAT_EQ(f.d_, stan::math::lkj_corr_log(Sigma, eta).d_); + EXPECT_FLOAT_EQ(f.val_, stan::math::lkj_corr_lpdf(Sigma, eta).val_); + EXPECT_FLOAT_EQ(f.d_, stan::math::lkj_corr_lpdf(Sigma, eta).d_); } TEST(ProbDistributionsLkjCorrCholesky, fvar_double) { @@ -33,12 +33,12 @@ TEST(ProbDistributionsLkjCorrCholesky, fvar_double) { Sigma(i).d_ = 1.0; fvar eta = stan::math::uniform_rng(0, 2, rng); fvar f = stan::math::do_lkj_constant(eta, K); - EXPECT_FLOAT_EQ(f.val_, stan::math::lkj_corr_cholesky_log(Sigma, eta).val_); - EXPECT_FLOAT_EQ(6.7766843, stan::math::lkj_corr_cholesky_log(Sigma, eta).d_); + EXPECT_FLOAT_EQ(f.val_, stan::math::lkj_corr_cholesky_lpdf(Sigma, eta).val_); + EXPECT_FLOAT_EQ(6.7766843, stan::math::lkj_corr_cholesky_lpdf(Sigma, eta).d_); eta = 1.0; f = stan::math::do_lkj_constant(eta, K); - EXPECT_FLOAT_EQ(f.val_, stan::math::lkj_corr_cholesky_log(Sigma, eta).val_); - EXPECT_FLOAT_EQ(3, stan::math::lkj_corr_cholesky_log(Sigma, eta).d_); + EXPECT_FLOAT_EQ(f.val_, stan::math::lkj_corr_cholesky_lpdf(Sigma, eta).val_); + EXPECT_FLOAT_EQ(3, stan::math::lkj_corr_cholesky_lpdf(Sigma, eta).d_); } TEST(ProbDistributionsLkjCorr, fvar_fvar_double) { @@ -53,12 +53,12 @@ TEST(ProbDistributionsLkjCorr, fvar_fvar_double) { Sigma(i).d_.val_ = 1.0; fvar > eta = stan::math::uniform_rng(0, 2, rng); fvar > f = stan::math::do_lkj_constant(eta, K); - EXPECT_FLOAT_EQ(f.val_.val_, stan::math::lkj_corr_log(Sigma, eta).val_.val_); - EXPECT_FLOAT_EQ(2.5177896, stan::math::lkj_corr_log(Sigma, eta).d_.val_); + EXPECT_FLOAT_EQ(f.val_.val_, stan::math::lkj_corr_lpdf(Sigma, eta).val_.val_); + EXPECT_FLOAT_EQ(2.5177896, stan::math::lkj_corr_lpdf(Sigma, eta).d_.val_); eta = 1.0; f = stan::math::do_lkj_constant(eta, K); - EXPECT_FLOAT_EQ(f.val_.val_, stan::math::lkj_corr_log(Sigma, eta).val_.val_); - EXPECT_FLOAT_EQ(f.d_.val_, stan::math::lkj_corr_log(Sigma, eta).d_.val_); + EXPECT_FLOAT_EQ(f.val_.val_, stan::math::lkj_corr_lpdf(Sigma, eta).val_.val_); + EXPECT_FLOAT_EQ(f.d_.val_, stan::math::lkj_corr_lpdf(Sigma, eta).d_.val_); } TEST(ProbDistributionsLkjCorrCholesky, fvar_fvar_double) { @@ -74,12 +74,12 @@ TEST(ProbDistributionsLkjCorrCholesky, fvar_fvar_double) { fvar > eta = stan::math::uniform_rng(0, 2, rng); fvar > f = stan::math::do_lkj_constant(eta, K); EXPECT_FLOAT_EQ(f.val_.val_, - stan::math::lkj_corr_cholesky_log(Sigma, eta).val_.val_); + stan::math::lkj_corr_cholesky_lpdf(Sigma, eta).val_.val_); EXPECT_FLOAT_EQ(6.7766843, - stan::math::lkj_corr_cholesky_log(Sigma, eta).d_.val_); + stan::math::lkj_corr_cholesky_lpdf(Sigma, eta).d_.val_); eta = 1.0; f = stan::math::do_lkj_constant(eta, K); EXPECT_FLOAT_EQ(f.val_.val_, - stan::math::lkj_corr_cholesky_log(Sigma, eta).val_.val_); - EXPECT_FLOAT_EQ(3, stan::math::lkj_corr_cholesky_log(Sigma, eta).d_.val_); + stan::math::lkj_corr_cholesky_lpdf(Sigma, eta).val_.val_); + EXPECT_FLOAT_EQ(3, stan::math::lkj_corr_cholesky_lpdf(Sigma, eta).d_.val_); } diff --git a/test/unit/math/fwd/prob/multi_gp_cholesky_test.cpp b/test/unit/math/fwd/prob/multi_gp_cholesky_test.cpp index 8cc30648e10..5a3f4a67715 100644 --- a/test/unit/math/fwd/prob/multi_gp_cholesky_test.cpp +++ b/test/unit/math/fwd/prob/multi_gp_cholesky_test.cpp @@ -36,11 +36,12 @@ TEST(ProbDistributionsMultiGPCholesky, fvar_double) { for (size_t i = 0; i < 3; i++) { Matrix, Dynamic, 1> cy(y.row(i).transpose()); Matrix, Dynamic, Dynamic> cSigma((1.0 / w[i]) * Sigma); - lp_ref += stan::math::multi_normal_log(cy, mu, cSigma); + lp_ref += stan::math::multi_normal_lpdf(cy, mu, cSigma); } - EXPECT_FLOAT_EQ(lp_ref.val_, stan::math::multi_gp_cholesky_log(y, L, w).val_); - EXPECT_FLOAT_EQ(-74.572952, stan::math::multi_gp_cholesky_log(y, L, w).d_); + EXPECT_FLOAT_EQ(lp_ref.val_, + stan::math::multi_gp_cholesky_lpdf(y, L, w).val_); + EXPECT_FLOAT_EQ(-74.572952, stan::math::multi_gp_cholesky_lpdf(y, L, w).d_); } TEST(ProbDistributionsMultiGPCholesky, fvar_fvar_double) { @@ -78,11 +79,11 @@ TEST(ProbDistributionsMultiGPCholesky, fvar_fvar_double) { for (size_t i = 0; i < 3; i++) { Matrix >, Dynamic, 1> cy(y.row(i).transpose()); Matrix >, Dynamic, Dynamic> cSigma((1.0 / w[i]) * Sigma); - lp_ref += stan::math::multi_normal_log(cy, mu, cSigma); + lp_ref += stan::math::multi_normal_lpdf(cy, mu, cSigma); } EXPECT_FLOAT_EQ(lp_ref.val_.val_, - stan::math::multi_gp_cholesky_log(y, L, w).val_.val_); + stan::math::multi_gp_cholesky_lpdf(y, L, w).val_.val_); EXPECT_FLOAT_EQ(-74.572952, - stan::math::multi_gp_cholesky_log(y, L, w).d_.val_); + stan::math::multi_gp_cholesky_lpdf(y, L, w).d_.val_); } diff --git a/test/unit/math/fwd/prob/multi_gp_test.cpp b/test/unit/math/fwd/prob/multi_gp_test.cpp index 3a359e0c0e8..3ed09a355f0 100644 --- a/test/unit/math/fwd/prob/multi_gp_test.cpp +++ b/test/unit/math/fwd/prob/multi_gp_test.cpp @@ -34,11 +34,11 @@ TEST(ProbDistributionsMultiGP, fvar_double) { for (size_t i = 0; i < 3; i++) { Matrix, Dynamic, 1> cy(y.row(i).transpose()); Matrix, Dynamic, Dynamic> cSigma((1.0 / w[i]) * Sigma); - lp_ref += stan::math::multi_normal_log(cy, mu, cSigma); + lp_ref += stan::math::multi_normal_lpdf(cy, mu, cSigma); } - EXPECT_FLOAT_EQ(lp_ref.val_, stan::math::multi_gp_log(y, Sigma, w).val_); - EXPECT_FLOAT_EQ(-74.572952, stan::math::multi_gp_log(y, Sigma, w).d_); + EXPECT_FLOAT_EQ(lp_ref.val_, stan::math::multi_gp_lpdf(y, Sigma, w).val_); + EXPECT_FLOAT_EQ(-74.572952, stan::math::multi_gp_lpdf(y, Sigma, w).d_); } TEST(ProbDistributionsMultiGP, fvar_fvar_double) { @@ -74,10 +74,10 @@ TEST(ProbDistributionsMultiGP, fvar_fvar_double) { for (size_t i = 0; i < 3; i++) { Matrix >, Dynamic, 1> cy(y.row(i).transpose()); Matrix >, Dynamic, Dynamic> cSigma((1.0 / w[i]) * Sigma); - lp_ref += stan::math::multi_normal_log(cy, mu, cSigma); + lp_ref += stan::math::multi_normal_lpdf(cy, mu, cSigma); } EXPECT_FLOAT_EQ(lp_ref.val_.val_, - stan::math::multi_gp_log(y, Sigma, w).val_.val_); - EXPECT_FLOAT_EQ(-74.572952, stan::math::multi_gp_log(y, Sigma, w).d_.val_); + stan::math::multi_gp_lpdf(y, Sigma, w).val_.val_); + EXPECT_FLOAT_EQ(-74.572952, stan::math::multi_gp_lpdf(y, Sigma, w).d_.val_); } diff --git a/test/unit/math/fwd/prob/multi_normal_cholesky_test.cpp b/test/unit/math/fwd/prob/multi_normal_cholesky_test.cpp index af2767268c8..13a0825c06c 100644 --- a/test/unit/math/fwd/prob/multi_normal_cholesky_test.cpp +++ b/test/unit/math/fwd/prob/multi_normal_cholesky_test.cpp @@ -25,9 +25,9 @@ TEST(ProbDistributionsMultiNormalCholesky, fvar_double) { Matrix, Dynamic, Dynamic> L = Sigma.llt().matrixL(); EXPECT_FLOAT_EQ(-11.73908, - stan::math::multi_normal_cholesky_log(y, mu, L).val_); + stan::math::multi_normal_cholesky_lpdf(y, mu, L).val_); EXPECT_FLOAT_EQ(0.54899865, - stan::math::multi_normal_cholesky_log(y, mu, L).d_); + stan::math::multi_normal_cholesky_lpdf(y, mu, L).d_); } TEST(ProbDistributionsMultiNormalCholesky, fvar_fvar_double) { @@ -52,7 +52,7 @@ TEST(ProbDistributionsMultiNormalCholesky, fvar_fvar_double) { Matrix >, Dynamic, Dynamic> L = Sigma.llt().matrixL(); EXPECT_FLOAT_EQ(-11.73908, - stan::math::multi_normal_cholesky_log(y, mu, L).val_.val_); + stan::math::multi_normal_cholesky_lpdf(y, mu, L).val_.val_); EXPECT_FLOAT_EQ(0.54899865, - stan::math::multi_normal_cholesky_log(y, mu, L).d_.val_); + stan::math::multi_normal_cholesky_lpdf(y, mu, L).d_.val_); } diff --git a/test/unit/math/fwd/prob/multi_normal_prec_test.cpp b/test/unit/math/fwd/prob/multi_normal_prec_test.cpp index 167540bd220..78854d5df18 100644 --- a/test/unit/math/fwd/prob/multi_normal_prec_test.cpp +++ b/test/unit/math/fwd/prob/multi_normal_prec_test.cpp @@ -22,8 +22,8 @@ TEST(ProbDistributionsMultiNormalPrec, fvar_double) { } Matrix, Dynamic, Dynamic> L = Sigma.inverse(); - EXPECT_FLOAT_EQ(-11.73908, stan::math::multi_normal_prec_log(y, mu, L).val_); - EXPECT_FLOAT_EQ(0.54899865, stan::math::multi_normal_prec_log(y, mu, L).d_); + EXPECT_FLOAT_EQ(-11.73908, stan::math::multi_normal_prec_lpdf(y, mu, L).val_); + EXPECT_FLOAT_EQ(0.54899865, stan::math::multi_normal_prec_lpdf(y, mu, L).d_); } TEST(ProbDistributionsMultiNormalPrec, fvar_fvar_double) { @@ -48,7 +48,7 @@ TEST(ProbDistributionsMultiNormalPrec, fvar_fvar_double) { Matrix >, Dynamic, Dynamic> L = Sigma.inverse(); EXPECT_FLOAT_EQ(-11.73908, - stan::math::multi_normal_prec_log(y, mu, L).val_.val_); + stan::math::multi_normal_prec_lpdf(y, mu, L).val_.val_); EXPECT_FLOAT_EQ(0.54899865, - stan::math::multi_normal_prec_log(y, mu, L).d_.val_); + stan::math::multi_normal_prec_lpdf(y, mu, L).d_.val_); } diff --git a/test/unit/math/fwd/prob/multi_normal_test.cpp b/test/unit/math/fwd/prob/multi_normal_test.cpp index 15ce1d2a565..1f247efcf0e 100644 --- a/test/unit/math/fwd/prob/multi_normal_test.cpp +++ b/test/unit/math/fwd/prob/multi_normal_test.cpp @@ -21,8 +21,8 @@ TEST(ProbDistributionsMultiNormal, fvar_double) { for (int j = 0; j < 3; j++) Sigma(i, j).d_ = 1.0; } - EXPECT_FLOAT_EQ(-11.73908, stan::math::multi_normal_log(y, mu, Sigma).val_); - EXPECT_FLOAT_EQ(0.54899865, stan::math::multi_normal_log(y, mu, Sigma).d_); + EXPECT_FLOAT_EQ(-11.73908, stan::math::multi_normal_lpdf(y, mu, Sigma).val_); + EXPECT_FLOAT_EQ(0.54899865, stan::math::multi_normal_lpdf(y, mu, Sigma).d_); } TEST(ProbDistributionsMultiNormal, fvar_fvar_double) { @@ -44,7 +44,7 @@ TEST(ProbDistributionsMultiNormal, fvar_fvar_double) { Sigma(i, j).d_ = 1.0; } EXPECT_FLOAT_EQ(-11.73908, - stan::math::multi_normal_log(y, mu, Sigma).val_.val_); + stan::math::multi_normal_lpdf(y, mu, Sigma).val_.val_); EXPECT_FLOAT_EQ(0.54899865, - stan::math::multi_normal_log(y, mu, Sigma).d_.val_); + stan::math::multi_normal_lpdf(y, mu, Sigma).d_.val_); } diff --git a/test/unit/math/fwd/prob/multi_student_t_test.cpp b/test/unit/math/fwd/prob/multi_student_t_test.cpp index e0360b2e251..f57b8c0609a 100644 --- a/test/unit/math/fwd/prob/multi_student_t_test.cpp +++ b/test/unit/math/fwd/prob/multi_student_t_test.cpp @@ -7,7 +7,7 @@ TEST(ProbDistributionsMultiStudentT, fvar_double) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::fvar; - using stan::math::multi_student_t_log; + using stan::math::multi_student_t_lpdf; using std::vector; Matrix, Dynamic, 1> y(3, 1); y << 2.0, -2.0, 11.0; @@ -24,7 +24,7 @@ TEST(ProbDistributionsMultiStudentT, fvar_double) { Sigma(i, j).d_ = 1.0; } - fvar lp = multi_student_t_log(y, nu, mu, Sigma); + fvar lp = multi_student_t_lpdf(y, nu, mu, Sigma); EXPECT_NEAR(-10.1246, lp.val_, 0.0001); EXPECT_NEAR(-0.0411685, lp.d_, 0.0001); } @@ -33,7 +33,7 @@ TEST(ProbDistributionsMultiStudentT, fvar_fvar_double) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::fvar; - using stan::math::multi_student_t_log; + using stan::math::multi_student_t_lpdf; using std::vector; Matrix >, Dynamic, 1> y(3, 1); y << 2.0, -2.0, 11.0; @@ -50,7 +50,7 @@ TEST(ProbDistributionsMultiStudentT, fvar_fvar_double) { Sigma(i, j).d_.val_ = 1.0; } - fvar > lp = multi_student_t_log(y, nu, mu, Sigma); + fvar > lp = multi_student_t_lpdf(y, nu, mu, Sigma); EXPECT_NEAR(-10.1246, lp.val_.val_, 0.0001); EXPECT_NEAR(-0.0411685, lp.d_.val_, 0.0001); } diff --git a/test/unit/math/fwd/prob/multinomial_test.cpp b/test/unit/math/fwd/prob/multinomial_test.cpp index bb5a975f576..ab55eee58a8 100644 --- a/test/unit/math/fwd/prob/multinomial_test.cpp +++ b/test/unit/math/fwd/prob/multinomial_test.cpp @@ -17,8 +17,8 @@ TEST(ProbDistributionsMultinomial, fvar_double) { for (int i = 0; i < 3; i++) theta(i).d_ = 1.0; - EXPECT_FLOAT_EQ(-2.002481, stan::math::multinomial_log(ns, theta).val_); - EXPECT_FLOAT_EQ(17.666666, stan::math::multinomial_log(ns, theta).d_); + EXPECT_FLOAT_EQ(-2.002481, stan::math::multinomial_lpmf(ns, theta).val_); + EXPECT_FLOAT_EQ(17.666666, stan::math::multinomial_lpmf(ns, theta).d_); } TEST(ProbDistributionsMultinomial, fvar_fvar_double) { @@ -34,6 +34,6 @@ TEST(ProbDistributionsMultinomial, fvar_fvar_double) { for (int i = 0; i < 3; i++) theta(i).d_.val_ = 1.0; - EXPECT_FLOAT_EQ(-2.002481, stan::math::multinomial_log(ns, theta).val_.val_); - EXPECT_FLOAT_EQ(17.666666, stan::math::multinomial_log(ns, theta).d_.val_); + EXPECT_FLOAT_EQ(-2.002481, stan::math::multinomial_lpmf(ns, theta).val_.val_); + EXPECT_FLOAT_EQ(17.666666, stan::math::multinomial_lpmf(ns, theta).d_.val_); } diff --git a/test/unit/math/fwd/prob/wishart_test.cpp b/test/unit/math/fwd/prob/wishart_test.cpp index b0dc20e74ce..ae9bd5ed936 100644 --- a/test/unit/math/fwd/prob/wishart_test.cpp +++ b/test/unit/math/fwd/prob/wishart_test.cpp @@ -24,8 +24,8 @@ TEST(ProbDistributionsWishart, fvar_double) { // computed with MCMCpack in R double lp = log(8.658e-07); - EXPECT_NEAR(lp, stan::math::wishart_log(Y, dof, Sigma).val_, 0.01); - EXPECT_NEAR(-0.76893887, stan::math::wishart_log(Y, dof, Sigma).d_, 0.01); + EXPECT_NEAR(lp, stan::math::wishart_lpdf(Y, dof, Sigma).val_, 0.01); + EXPECT_NEAR(-0.76893887, stan::math::wishart_lpdf(Y, dof, Sigma).d_, 0.01); } TEST(ProbDistributionsWishart, fvar_fvar_double) { @@ -48,7 +48,7 @@ TEST(ProbDistributionsWishart, fvar_fvar_double) { // computed with MCMCpack in R double lp = log(8.658e-07); - EXPECT_NEAR(lp, stan::math::wishart_log(Y, dof, Sigma).val_.val_, 0.01); - EXPECT_NEAR(-0.76893887, stan::math::wishart_log(Y, dof, Sigma).d_.val_, + EXPECT_NEAR(lp, stan::math::wishart_lpdf(Y, dof, Sigma).val_.val_, 0.01); + EXPECT_NEAR(-0.76893887, stan::math::wishart_lpdf(Y, dof, Sigma).d_.val_, 0.01); } diff --git a/test/unit/math/mix/functor/autodiff_test.cpp b/test/unit/math/mix/functor/autodiff_test.cpp index 8a26dceb70b..9780b3f5c53 100644 --- a/test/unit/math/mix/functor/autodiff_test.cpp +++ b/test/unit/math/mix/functor/autodiff_test.cpp @@ -38,7 +38,7 @@ struct norm_functor { template inline T operator()( const Eigen::Matrix& inp_vec) const { - return stan::math::normal_log(inp_vec(0), inp_vec(1), inp_vec(2)); + return stan::math::normal_lpdf(inp_vec(0), inp_vec(1), inp_vec(2)); } }; diff --git a/test/unit/math/mix/prob/categorical_logit_test.cpp b/test/unit/math/mix/prob/categorical_logit_test.cpp index 8c1d1d7c10d..efd4e01efd3 100644 --- a/test/unit/math/mix/prob/categorical_logit_test.cpp +++ b/test/unit/math/mix/prob/categorical_logit_test.cpp @@ -15,17 +15,17 @@ TEST(ProbDistributionsCategoricalLogit, fvar_var) { theta(i).d_ = i; Matrix, Dynamic, 1> theta_log_softmax = log_softmax(theta); EXPECT_FLOAT_EQ(theta_log_softmax[0].val_.val(), - stan::math::categorical_logit_log(1, theta).val_.val()); + stan::math::categorical_logit_lpmf(1, theta).val_.val()); EXPECT_FLOAT_EQ(theta_log_softmax[1].val_.val(), - stan::math::categorical_logit_log(2, theta).val_.val()); + stan::math::categorical_logit_lpmf(2, theta).val_.val()); EXPECT_FLOAT_EQ(theta_log_softmax[2].val_.val(), - stan::math::categorical_logit_log(3, theta).val_.val()); + stan::math::categorical_logit_lpmf(3, theta).val_.val()); EXPECT_FLOAT_EQ(theta_log_softmax[0].d_.val(), - stan::math::categorical_logit_log(1, theta).d_.val()); + stan::math::categorical_logit_lpmf(1, theta).d_.val()); EXPECT_FLOAT_EQ(theta_log_softmax[1].d_.val(), - stan::math::categorical_logit_log(2, theta).d_.val()); + stan::math::categorical_logit_lpmf(2, theta).d_.val()); EXPECT_FLOAT_EQ(theta_log_softmax[2].d_.val(), - stan::math::categorical_logit_log(3, theta).d_.val()); + stan::math::categorical_logit_lpmf(3, theta).d_.val()); } TEST(ProbDistributionsCategoricalLogit, fvar_var_vectorized) { @@ -40,7 +40,8 @@ TEST(ProbDistributionsCategoricalLogit, fvar_var_vectorized) { theta(i).d_ = i; std::vector ns(0); - EXPECT_FLOAT_EQ(0.0, stan::math::categorical_logit_log(ns, theta).val_.val()); + EXPECT_FLOAT_EQ(0.0, + stan::math::categorical_logit_lpmf(ns, theta).val_.val()); Matrix, Dynamic, 1> theta_log_softmax = log_softmax(theta); @@ -51,10 +52,10 @@ TEST(ProbDistributionsCategoricalLogit, fvar_var_vectorized) { EXPECT_FLOAT_EQ(theta_log_softmax[0].val_.val() + theta_log_softmax[1].val_.val() + theta_log_softmax[0].val_.val(), - stan::math::categorical_logit_log(ms, theta).val_.val()); + stan::math::categorical_logit_lpmf(ms, theta).val_.val()); EXPECT_FLOAT_EQ(theta_log_softmax[0].d_.val() + theta_log_softmax[1].d_.val() + theta_log_softmax[0].d_.val(), - stan::math::categorical_logit_log(ms, theta).d_.val()); + stan::math::categorical_logit_lpmf(ms, theta).d_.val()); } TEST(ProbDistributionsCategoricalLogit, fvar_fvar_var) { @@ -69,17 +70,17 @@ TEST(ProbDistributionsCategoricalLogit, fvar_fvar_var) { theta(i).d_.val_ = i; Matrix >, Dynamic, 1> theta_log_softmax = log_softmax(theta); EXPECT_FLOAT_EQ(theta_log_softmax[0].val_.val_.val(), - stan::math::categorical_logit_log(1, theta).val_.val_.val()); + stan::math::categorical_logit_lpmf(1, theta).val_.val_.val()); EXPECT_FLOAT_EQ(theta_log_softmax[1].val_.val_.val(), - stan::math::categorical_logit_log(2, theta).val_.val_.val()); + stan::math::categorical_logit_lpmf(2, theta).val_.val_.val()); EXPECT_FLOAT_EQ(theta_log_softmax[2].val_.val_.val(), - stan::math::categorical_logit_log(3, theta).val_.val_.val()); + stan::math::categorical_logit_lpmf(3, theta).val_.val_.val()); EXPECT_FLOAT_EQ(theta_log_softmax[0].d_.val_.val(), - stan::math::categorical_logit_log(1, theta).d_.val_.val()); + stan::math::categorical_logit_lpmf(1, theta).d_.val_.val()); EXPECT_FLOAT_EQ(theta_log_softmax[1].d_.val_.val(), - stan::math::categorical_logit_log(2, theta).d_.val_.val()); + stan::math::categorical_logit_lpmf(2, theta).d_.val_.val()); EXPECT_FLOAT_EQ(theta_log_softmax[2].d_.val_.val(), - stan::math::categorical_logit_log(3, theta).d_.val_.val()); + stan::math::categorical_logit_lpmf(3, theta).d_.val_.val()); } TEST(ProbDistributionsCategoricalLogit, fvar_fvar_var_vectorized) { @@ -94,8 +95,8 @@ TEST(ProbDistributionsCategoricalLogit, fvar_fvar_var_vectorized) { theta(i).d_.val_ = i; std::vector ns(0); - EXPECT_FLOAT_EQ(0.0, - stan::math::categorical_logit_log(ns, theta).val_.val_.val()); + EXPECT_FLOAT_EQ( + 0.0, stan::math::categorical_logit_lpmf(ns, theta).val_.val_.val()); Matrix >, Dynamic, 1> theta_log_softmax = log_softmax(theta); @@ -103,12 +104,13 @@ TEST(ProbDistributionsCategoricalLogit, fvar_fvar_var_vectorized) { ms[0] = 1; ms[1] = 2; ms[2] = 1; - EXPECT_FLOAT_EQ(theta_log_softmax[0].val_.val_.val() - + theta_log_softmax[1].val_.val_.val() - + theta_log_softmax[0].val_.val_.val(), - stan::math::categorical_logit_log(ms, theta).val_.val_.val()); + EXPECT_FLOAT_EQ( + theta_log_softmax[0].val_.val_.val() + + theta_log_softmax[1].val_.val_.val() + + theta_log_softmax[0].val_.val_.val(), + stan::math::categorical_logit_lpmf(ms, theta).val_.val_.val()); EXPECT_FLOAT_EQ(theta_log_softmax[0].d_.val_.val() + theta_log_softmax[1].d_.val_.val() + theta_log_softmax[0].d_.val_.val(), - stan::math::categorical_logit_log(ms, theta).d_.val_.val()); + stan::math::categorical_logit_lpmf(ms, theta).d_.val_.val()); } diff --git a/test/unit/math/mix/prob/categorical_test.cpp b/test/unit/math/mix/prob/categorical_test.cpp index 01d24102956..0e6024b5387 100644 --- a/test/unit/math/mix/prob/categorical_test.cpp +++ b/test/unit/math/mix/prob/categorical_test.cpp @@ -15,14 +15,14 @@ TEST(ProbDistributionsCategorical, fvar_var) { theta(i).d_ = 1.0; EXPECT_FLOAT_EQ(std::log(0.3), - stan::math::categorical_log(1, theta).val_.val()); + stan::math::categorical_lpmf(1, theta).val_.val()); EXPECT_FLOAT_EQ(std::log(0.5), - stan::math::categorical_log(2, theta).val_.val()); + stan::math::categorical_lpmf(2, theta).val_.val()); EXPECT_FLOAT_EQ(std::log(0.2), - stan::math::categorical_log(3, theta).val_.val()); - EXPECT_FLOAT_EQ(1.0 / 0.3, stan::math::categorical_log(1, theta).d_.val()); - EXPECT_FLOAT_EQ(1.0 / 0.5, stan::math::categorical_log(2, theta).d_.val()); - EXPECT_FLOAT_EQ(1.0 / 0.2, stan::math::categorical_log(3, theta).d_.val()); + stan::math::categorical_lpmf(3, theta).val_.val()); + EXPECT_FLOAT_EQ(1.0 / 0.3, stan::math::categorical_lpmf(1, theta).d_.val()); + EXPECT_FLOAT_EQ(1.0 / 0.5, stan::math::categorical_lpmf(2, theta).d_.val()); + EXPECT_FLOAT_EQ(1.0 / 0.2, stan::math::categorical_lpmf(3, theta).d_.val()); } TEST(ProbDistributionsCategorical, fvar_var_vector) { using Eigen::Dynamic; @@ -40,9 +40,9 @@ TEST(ProbDistributionsCategorical, fvar_var_vector) { xs[2] = 1; EXPECT_FLOAT_EQ(log(0.3) + log(0.2) + log(0.3), - stan::math::categorical_log(xs, theta).val_.val()); + stan::math::categorical_lpmf(xs, theta).val_.val()); EXPECT_FLOAT_EQ(1.0 / 0.3 + 1.0 / 0.2 + 1.0 / 0.3, - stan::math::categorical_log(xs, theta).d_.val()); + stan::math::categorical_lpmf(xs, theta).d_.val()); } TEST(ProbDistributionsCategorical, fvar_fvar_var) { @@ -56,17 +56,17 @@ TEST(ProbDistributionsCategorical, fvar_fvar_var) { theta(i).d_.val_ = 1.0; EXPECT_FLOAT_EQ(std::log(0.3), - stan::math::categorical_log(1, theta).val_.val_.val()); + stan::math::categorical_lpmf(1, theta).val_.val_.val()); EXPECT_FLOAT_EQ(std::log(0.5), - stan::math::categorical_log(2, theta).val_.val_.val()); + stan::math::categorical_lpmf(2, theta).val_.val_.val()); EXPECT_FLOAT_EQ(std::log(0.2), - stan::math::categorical_log(3, theta).val_.val_.val()); + stan::math::categorical_lpmf(3, theta).val_.val_.val()); EXPECT_FLOAT_EQ(1.0 / 0.3, - stan::math::categorical_log(1, theta).d_.val_.val()); + stan::math::categorical_lpmf(1, theta).d_.val_.val()); EXPECT_FLOAT_EQ(1.0 / 0.5, - stan::math::categorical_log(2, theta).d_.val_.val()); + stan::math::categorical_lpmf(2, theta).d_.val_.val()); EXPECT_FLOAT_EQ(1.0 / 0.2, - stan::math::categorical_log(3, theta).d_.val_.val()); + stan::math::categorical_lpmf(3, theta).d_.val_.val()); } TEST(ProbDistributionsCategorical, fvar_fvar_var_vector) { using Eigen::Dynamic; @@ -84,7 +84,7 @@ TEST(ProbDistributionsCategorical, fvar_fvar_var_vector) { xs[2] = 1; EXPECT_FLOAT_EQ(log(0.3) + log(0.2) + log(0.3), - stan::math::categorical_log(xs, theta).val_.val_.val()); + stan::math::categorical_lpmf(xs, theta).val_.val_.val()); EXPECT_FLOAT_EQ(1.0 / 0.3 + 1.0 / 0.2 + 1.0 / 0.3, - stan::math::categorical_log(xs, theta).d_.val_.val()); + stan::math::categorical_lpmf(xs, theta).d_.val_.val()); } diff --git a/test/unit/math/mix/prob/dirichlet_test.cpp b/test/unit/math/mix/prob/dirichlet_test.cpp index 8c014167bf3..cfddbddbaad 100644 --- a/test/unit/math/mix/prob/dirichlet_test.cpp +++ b/test/unit/math/mix/prob/dirichlet_test.cpp @@ -52,8 +52,9 @@ TEST(ProbDistributions, fvar_var) { } EXPECT_FLOAT_EQ(0.6931472, - stan::math::dirichlet_log(theta, alpha).val_.val()); - EXPECT_FLOAT_EQ(0.99344212, stan::math::dirichlet_log(theta, alpha).d_.val()); + stan::math::dirichlet_lpdf(theta, alpha).val_.val()); + EXPECT_FLOAT_EQ(0.99344212, + stan::math::dirichlet_lpdf(theta, alpha).d_.val()); Matrix, Dynamic, 1> theta2(4, 1); theta2 << 0.01, 0.01, 0.8, 0.18; @@ -65,15 +66,15 @@ TEST(ProbDistributions, fvar_var) { } EXPECT_FLOAT_EQ(-43.40045, - stan::math::dirichlet_log(theta2, alpha2).val_.val()); + stan::math::dirichlet_lpdf(theta2, alpha2).val_.val()); EXPECT_FLOAT_EQ(2017.2858, - stan::math::dirichlet_log(theta2, alpha2).d_.val()); + stan::math::dirichlet_lpdf(theta2, alpha2).d_.val()); } TEST(ProbDistributions, fvar_varVectorized) { using Eigen::Dynamic; using Eigen::Matrix; - using stan::math::dirichlet_log; + using stan::math::dirichlet_lpdf; using stan::math::fvar; using stan::math::var; @@ -98,29 +99,29 @@ TEST(ProbDistributions, fvar_varVectorized) { alpha_vec[2] = alpha3; Matrix, Dynamic, 1> result(3); - result[0] = dirichlet_log(theta1, alpha1); - result[1] = dirichlet_log(theta2, alpha2); - result[2] = dirichlet_log(theta3, alpha3); + result[0] = dirichlet_lpdf(theta1, alpha1); + result[1] = dirichlet_lpdf(theta2, alpha2); + result[2] = dirichlet_lpdf(theta3, alpha3); - fvar out = dirichlet_log(theta_vec, alpha_vec); + fvar out = dirichlet_lpdf(theta_vec, alpha_vec); EXPECT_FLOAT_EQ(result.val().val().sum(), out.val_.val()); EXPECT_FLOAT_EQ(result.d().val().sum(), out.d_.val()); - result[0] = dirichlet_log(theta1, alpha1); - result[1] = dirichlet_log(theta2, alpha1); - result[2] = dirichlet_log(theta3, alpha1); + result[0] = dirichlet_lpdf(theta1, alpha1); + result[1] = dirichlet_lpdf(theta2, alpha1); + result[2] = dirichlet_lpdf(theta3, alpha1); - out = dirichlet_log(theta_vec, alpha1); + out = dirichlet_lpdf(theta_vec, alpha1); EXPECT_FLOAT_EQ(result.val().val().sum(), out.val_.val()); EXPECT_FLOAT_EQ(result.d().val().sum(), out.d_.val()); - result[0] = dirichlet_log(theta1, alpha1); - result[1] = dirichlet_log(theta1, alpha2); - result[2] = dirichlet_log(theta1, alpha3); + result[0] = dirichlet_lpdf(theta1, alpha1); + result[1] = dirichlet_lpdf(theta1, alpha2); + result[2] = dirichlet_lpdf(theta1, alpha3); - out = dirichlet_log(theta1, alpha_vec); + out = dirichlet_lpdf(theta1, alpha_vec); EXPECT_FLOAT_EQ(result.val().val().sum(), out.val_.val()); EXPECT_FLOAT_EQ(result.d().val().sum(), out.d_.val()); @@ -142,9 +143,9 @@ TEST(ProbDistributions, fvar_fvar_var) { } EXPECT_FLOAT_EQ(0.6931472, - stan::math::dirichlet_log(theta, alpha).val_.val_.val()); + stan::math::dirichlet_lpdf(theta, alpha).val_.val_.val()); EXPECT_FLOAT_EQ(0.99344212, - stan::math::dirichlet_log(theta, alpha).d_.val_.val()); + stan::math::dirichlet_lpdf(theta, alpha).d_.val_.val()); Matrix>, Dynamic, 1> theta2(4, 1); theta2 << 0.01, 0.01, 0.8, 0.18; @@ -156,15 +157,15 @@ TEST(ProbDistributions, fvar_fvar_var) { } EXPECT_FLOAT_EQ(-43.40045, - stan::math::dirichlet_log(theta2, alpha2).val_.val_.val()); + stan::math::dirichlet_lpdf(theta2, alpha2).val_.val_.val()); EXPECT_FLOAT_EQ(2017.2858, - stan::math::dirichlet_log(theta2, alpha2).d_.val_.val()); + stan::math::dirichlet_lpdf(theta2, alpha2).d_.val_.val()); } TEST(ProbDistributions, fvar_fvar_varVectorized) { using Eigen::Dynamic; using Eigen::Matrix; - using stan::math::dirichlet_log; + using stan::math::dirichlet_lpdf; using stan::math::fvar; using stan::math::var; @@ -189,29 +190,29 @@ TEST(ProbDistributions, fvar_fvar_varVectorized) { alpha_vec[2] = alpha3; Matrix>, Dynamic, 1> result(3); - result[0] = dirichlet_log(theta1, alpha1); - result[1] = dirichlet_log(theta2, alpha2); - result[2] = dirichlet_log(theta3, alpha3); + result[0] = dirichlet_lpdf(theta1, alpha1); + result[1] = dirichlet_lpdf(theta2, alpha2); + result[2] = dirichlet_lpdf(theta3, alpha3); - fvar> out = dirichlet_log(theta_vec, alpha_vec); + fvar> out = dirichlet_lpdf(theta_vec, alpha_vec); EXPECT_FLOAT_EQ(result.val().val().val().sum(), out.val_.val_.val()); EXPECT_FLOAT_EQ(result.d().val().val().sum(), out.d_.val_.val()); - result[0] = dirichlet_log(theta1, alpha1); - result[1] = dirichlet_log(theta2, alpha1); - result[2] = dirichlet_log(theta3, alpha1); + result[0] = dirichlet_lpdf(theta1, alpha1); + result[1] = dirichlet_lpdf(theta2, alpha1); + result[2] = dirichlet_lpdf(theta3, alpha1); - out = dirichlet_log(theta_vec, alpha1); + out = dirichlet_lpdf(theta_vec, alpha1); EXPECT_FLOAT_EQ(result.val().val().val().sum(), out.val_.val_.val()); EXPECT_FLOAT_EQ(result.d().val().val().sum(), out.d_.val_.val()); - result[0] = dirichlet_log(theta1, alpha1); - result[1] = dirichlet_log(theta1, alpha2); - result[2] = dirichlet_log(theta1, alpha3); + result[0] = dirichlet_lpdf(theta1, alpha1); + result[1] = dirichlet_lpdf(theta1, alpha2); + result[2] = dirichlet_lpdf(theta1, alpha3); - out = dirichlet_log(theta1, alpha_vec); + out = dirichlet_lpdf(theta1, alpha_vec); EXPECT_FLOAT_EQ(result.val().val().val().sum(), out.val_.val_.val()); EXPECT_FLOAT_EQ(result.d().val().val().sum(), out.d_.val_.val()); diff --git a/test/unit/math/mix/prob/gaussian_dlm_obs_test.cpp b/test/unit/math/mix/prob/gaussian_dlm_obs_test.cpp index 5c9c0370709..831c77235b4 100644 --- a/test/unit/math/mix/prob/gaussian_dlm_obs_test.cpp +++ b/test/unit/math/mix/prob/gaussian_dlm_obs_test.cpp @@ -6,7 +6,7 @@ TEST(ProbDistributionsGaussianDLM, LoglikeUU_fvar_var) { using Eigen::Matrix; using Eigen::MatrixXd; using stan::math::fvar; - using stan::math::gaussian_dlm_obs_log; + using stan::math::gaussian_dlm_obs_lpdf; using stan::math::var; Eigen::Matrix, Eigen::Dynamic, Eigen::Dynamic> FF(1, 1); @@ -29,7 +29,7 @@ TEST(ProbDistributionsGaussianDLM, LoglikeUU_fvar_var) { fvar(-0.435458550812876, 1.0), fvar(1.17332931763075, 1.0); double ll_expected = -16.2484978375184; - fvar lp_ref = gaussian_dlm_obs_log(y, FF, GG, V, W, m0, C0); + fvar lp_ref = gaussian_dlm_obs_lpdf(y, FF, GG, V, W, m0, C0); EXPECT_FLOAT_EQ(ll_expected, lp_ref.val_.val()); EXPECT_FLOAT_EQ(-3.8427677, lp_ref.d_.val()); } @@ -39,7 +39,7 @@ TEST(ProbDistributionsGaussianDLM, LoglikeMM_fvar_var) { using Eigen::Matrix; using Eigen::MatrixXd; using stan::math::fvar; - using stan::math::gaussian_dlm_obs_log; + using stan::math::gaussian_dlm_obs_lpdf; using stan::math::var; Eigen::Matrix, Eigen::Dynamic, Eigen::Dynamic> FF(2, 3); @@ -81,7 +81,7 @@ TEST(ProbDistributionsGaussianDLM, LoglikeMM_fvar_var) { fvar(1.32299515908216, 1.0), fvar(0.746844140961399, 1.0); double ll_expected = -85.2615847497409; - fvar lp_ref = gaussian_dlm_obs_log(y, FF, GG, V, W, m0, C0); + fvar lp_ref = gaussian_dlm_obs_lpdf(y, FF, GG, V, W, m0, C0); // the error adds up in the multivariate version due to the inversion. EXPECT_NEAR(ll_expected, lp_ref.val_.val(), 1e-4); EXPECT_NEAR(18.89044287309947, lp_ref.d_.val(), 1e-4); @@ -92,7 +92,7 @@ TEST(ProbDistributionsGaussianDLM, LoglikeUU_fvar_fvar_var) { using Eigen::Matrix; using Eigen::MatrixXd; using stan::math::fvar; - using stan::math::gaussian_dlm_obs_log; + using stan::math::gaussian_dlm_obs_lpdf; using stan::math::var; Eigen::Matrix >, Eigen::Dynamic, Eigen::Dynamic> FF(1, 1); @@ -120,7 +120,7 @@ TEST(ProbDistributionsGaussianDLM, LoglikeUU_fvar_fvar_var) { fvar >(1.17332931763075, 1.0); double ll_expected = -16.2484978375184; - fvar > lp_ref = gaussian_dlm_obs_log(y, FF, GG, V, W, m0, C0); + fvar > lp_ref = gaussian_dlm_obs_lpdf(y, FF, GG, V, W, m0, C0); EXPECT_FLOAT_EQ(ll_expected, lp_ref.val_.val_.val()); EXPECT_FLOAT_EQ(-3.8427677, lp_ref.d_.val_.val()); } @@ -130,7 +130,7 @@ TEST(ProbDistributionsGaussianDLM, LoglikeMM_fvar_fvar_var) { using Eigen::Matrix; using Eigen::MatrixXd; using stan::math::fvar; - using stan::math::gaussian_dlm_obs_log; + using stan::math::gaussian_dlm_obs_lpdf; using stan::math::var; Eigen::Matrix >, Eigen::Dynamic, Eigen::Dynamic> FF(2, 3); @@ -199,7 +199,7 @@ TEST(ProbDistributionsGaussianDLM, LoglikeMM_fvar_fvar_var) { fvar >(0.746844140961399, 1.0); double ll_expected = -85.2615847497409; - fvar > lp_ref = gaussian_dlm_obs_log(y, FF, GG, V, W, m0, C0); + fvar > lp_ref = gaussian_dlm_obs_lpdf(y, FF, GG, V, W, m0, C0); // the error adds up in the multivariate version due to the inversion. EXPECT_NEAR(ll_expected, lp_ref.val_.val_.val(), 1e-4); EXPECT_NEAR(18.89044287309947, lp_ref.d_.val_.val(), 1e-4); diff --git a/test/unit/math/mix/prob/inv_wishart_test.cpp b/test/unit/math/mix/prob/inv_wishart_test.cpp index d4da0b7babc..5f65fe23c27 100644 --- a/test/unit/math/mix/prob/inv_wishart_test.cpp +++ b/test/unit/math/mix/prob/inv_wishart_test.cpp @@ -38,7 +38,7 @@ TEST(ProbDistributionsInvWishart, fvar_var) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::fvar; - using stan::math::inv_wishart_log; + using stan::math::inv_wishart_lpdf; using stan::math::var; Matrix, Dynamic, Dynamic> Y(3, 3); @@ -58,10 +58,10 @@ TEST(ProbDistributionsInvWishart, fvar_var) { Sigma(i, j).d_ = 1.0; } - EXPECT_NEAR(log_p, stan::math::inv_wishart_log(Y, dof, Sigma).val_.val(), + EXPECT_NEAR(log_p, stan::math::inv_wishart_lpdf(Y, dof, Sigma).val_.val(), 0.01); EXPECT_NEAR(-1.4893348387330674, - stan::math::inv_wishart_log(Y, dof, Sigma).d_.val(), 0.01); + stan::math::inv_wishart_lpdf(Y, dof, Sigma).d_.val(), 0.01); stan::math::recover_memory(); } @@ -70,7 +70,7 @@ TEST(ProbDistributionsInvWishart, fvar_fvar_var) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::fvar; - using stan::math::inv_wishart_log; + using stan::math::inv_wishart_lpdf; using stan::math::var; Matrix >, Dynamic, Dynamic> Y(3, 3); @@ -90,10 +90,10 @@ TEST(ProbDistributionsInvWishart, fvar_fvar_var) { Sigma(i, j).d_ = 1.0; } - EXPECT_NEAR(log_p, stan::math::inv_wishart_log(Y, dof, Sigma).val_.val_.val(), - 0.01); + EXPECT_NEAR( + log_p, stan::math::inv_wishart_lpdf(Y, dof, Sigma).val_.val_.val(), 0.01); EXPECT_NEAR(-1.4893348387330674, - stan::math::inv_wishart_log(Y, dof, Sigma).d_.val_.val(), 0.01); + stan::math::inv_wishart_lpdf(Y, dof, Sigma).d_.val_.val(), 0.01); stan::math::recover_memory(); } diff --git a/test/unit/math/mix/prob/lkj_corr_test.cpp b/test/unit/math/mix/prob/lkj_corr_test.cpp index 64c65d419ea..6d93e009c58 100644 --- a/test/unit/math/mix/prob/lkj_corr_test.cpp +++ b/test/unit/math/mix/prob/lkj_corr_test.cpp @@ -19,13 +19,13 @@ TEST(ProbDistributionsLkjCorr, fvar_var) { fvar eta = stan::math::uniform_rng(0, 2, rng); fvar f = stan::math::do_lkj_constant(eta, K); EXPECT_FLOAT_EQ(f.val_.val(), - stan::math::lkj_corr_log(Sigma, eta).val_.val()); - EXPECT_FLOAT_EQ(2.5177896, stan::math::lkj_corr_log(Sigma, eta).d_.val()); + stan::math::lkj_corr_lpdf(Sigma, eta).val_.val()); + EXPECT_FLOAT_EQ(2.5177896, stan::math::lkj_corr_lpdf(Sigma, eta).d_.val()); eta = 1.0; f = stan::math::do_lkj_constant(eta, K); EXPECT_FLOAT_EQ(f.val_.val(), - stan::math::lkj_corr_log(Sigma, eta).val_.val()); - EXPECT_FLOAT_EQ(f.d_.val(), stan::math::lkj_corr_log(Sigma, eta).d_.val()); + stan::math::lkj_corr_lpdf(Sigma, eta).val_.val()); + EXPECT_FLOAT_EQ(f.d_.val(), stan::math::lkj_corr_lpdf(Sigma, eta).d_.val()); } TEST(ProbDistributionsLkjCorrCholesky, fvar_var) { @@ -41,14 +41,14 @@ TEST(ProbDistributionsLkjCorrCholesky, fvar_var) { fvar eta = stan::math::uniform_rng(0, 2, rng); fvar f = stan::math::do_lkj_constant(eta, K); EXPECT_FLOAT_EQ(f.val_.val(), - stan::math::lkj_corr_cholesky_log(Sigma, eta).val_.val()); + stan::math::lkj_corr_cholesky_lpdf(Sigma, eta).val_.val()); EXPECT_FLOAT_EQ(6.7766843, - stan::math::lkj_corr_cholesky_log(Sigma, eta).d_.val()); + stan::math::lkj_corr_cholesky_lpdf(Sigma, eta).d_.val()); eta = 1.0; f = stan::math::do_lkj_constant(eta, K); EXPECT_FLOAT_EQ(f.val_.val(), - stan::math::lkj_corr_cholesky_log(Sigma, eta).val_.val()); - EXPECT_FLOAT_EQ(3, stan::math::lkj_corr_cholesky_log(Sigma, eta).d_.val()); + stan::math::lkj_corr_cholesky_lpdf(Sigma, eta).val_.val()); + EXPECT_FLOAT_EQ(3, stan::math::lkj_corr_cholesky_lpdf(Sigma, eta).d_.val()); } TEST(ProbDistributionsLkjCorr, fvar_fvar_var) { @@ -64,15 +64,15 @@ TEST(ProbDistributionsLkjCorr, fvar_fvar_var) { fvar > eta = stan::math::uniform_rng(0, 2, rng); fvar > f = stan::math::do_lkj_constant(eta, K); EXPECT_FLOAT_EQ(f.val_.val_.val(), - stan::math::lkj_corr_log(Sigma, eta).val_.val_.val()); + stan::math::lkj_corr_lpdf(Sigma, eta).val_.val_.val()); EXPECT_FLOAT_EQ(2.5177896, - stan::math::lkj_corr_log(Sigma, eta).d_.val_.val()); + stan::math::lkj_corr_lpdf(Sigma, eta).d_.val_.val()); eta = 1.0; f = stan::math::do_lkj_constant(eta, K); EXPECT_FLOAT_EQ(f.val_.val_.val(), - stan::math::lkj_corr_log(Sigma, eta).val_.val_.val()); + stan::math::lkj_corr_lpdf(Sigma, eta).val_.val_.val()); EXPECT_FLOAT_EQ(f.d_.val_.val(), - stan::math::lkj_corr_log(Sigma, eta).d_.val_.val()); + stan::math::lkj_corr_lpdf(Sigma, eta).d_.val_.val()); } TEST(ProbDistributionsLkjCorrCholesky, fvar_fvar_var) { @@ -89,16 +89,16 @@ TEST(ProbDistributionsLkjCorrCholesky, fvar_fvar_var) { fvar > f = stan::math::do_lkj_constant(eta, K); EXPECT_FLOAT_EQ( f.val_.val_.val(), - stan::math::lkj_corr_cholesky_log(Sigma, eta).val_.val_.val()); + stan::math::lkj_corr_cholesky_lpdf(Sigma, eta).val_.val_.val()); EXPECT_FLOAT_EQ(6.7766843, - stan::math::lkj_corr_cholesky_log(Sigma, eta).d_.val_.val()); + stan::math::lkj_corr_cholesky_lpdf(Sigma, eta).d_.val_.val()); eta = 1.0; f = stan::math::do_lkj_constant(eta, K); EXPECT_FLOAT_EQ( f.val_.val_.val(), - stan::math::lkj_corr_cholesky_log(Sigma, eta).val_.val_.val()); + stan::math::lkj_corr_cholesky_lpdf(Sigma, eta).val_.val_.val()); EXPECT_FLOAT_EQ(3, - stan::math::lkj_corr_cholesky_log(Sigma, eta).d_.val_.val()); + stan::math::lkj_corr_cholesky_lpdf(Sigma, eta).d_.val_.val()); } TEST(ProbDistributionsLkjCorrCholesky, hessian) { diff --git a/test/unit/math/mix/prob/multi_gp_cholesky_test.cpp b/test/unit/math/mix/prob/multi_gp_cholesky_test.cpp index 30433c822e2..ee6ac0a6ada 100644 --- a/test/unit/math/mix/prob/multi_gp_cholesky_test.cpp +++ b/test/unit/math/mix/prob/multi_gp_cholesky_test.cpp @@ -37,13 +37,13 @@ TEST(ProbDistributionsMultiGPCholesky, fvar_var) { for (size_t i = 0; i < 3; i++) { Matrix, Dynamic, 1> cy(y.row(i).transpose()); Matrix, Dynamic, Dynamic> cSigma((1.0 / w[i]) * Sigma); - lp_ref += stan::math::multi_normal_log(cy, mu, cSigma); + lp_ref += stan::math::multi_normal_lpdf(cy, mu, cSigma); } EXPECT_FLOAT_EQ(lp_ref.val_.val(), - stan::math::multi_gp_cholesky_log(y, L, w).val_.val()); + stan::math::multi_gp_cholesky_lpdf(y, L, w).val_.val()); EXPECT_FLOAT_EQ(-74.572952, - stan::math::multi_gp_cholesky_log(y, L, w).d_.val()); + stan::math::multi_gp_cholesky_lpdf(y, L, w).d_.val()); stan::math::recover_memory(); } @@ -84,13 +84,13 @@ TEST(ProbDistributionsMultiGPCholesky, fvar_fvar_var) { for (size_t i = 0; i < 3; i++) { Matrix >, Dynamic, 1> cy(y.row(i).transpose()); Matrix >, Dynamic, Dynamic> cSigma((1.0 / w[i]) * Sigma); - lp_ref += stan::math::multi_normal_log(cy, mu, cSigma); + lp_ref += stan::math::multi_normal_lpdf(cy, mu, cSigma); } EXPECT_FLOAT_EQ(lp_ref.val_.val_.val(), - stan::math::multi_gp_cholesky_log(y, L, w).val_.val_.val()); + stan::math::multi_gp_cholesky_lpdf(y, L, w).val_.val_.val()); EXPECT_FLOAT_EQ(-74.572952, - stan::math::multi_gp_cholesky_log(y, L, w).d_.val_.val()); + stan::math::multi_gp_cholesky_lpdf(y, L, w).d_.val_.val()); stan::math::recover_memory(); } diff --git a/test/unit/math/mix/prob/multi_gp_test.cpp b/test/unit/math/mix/prob/multi_gp_test.cpp index ca0e6ed699b..91b3f7c2248 100644 --- a/test/unit/math/mix/prob/multi_gp_test.cpp +++ b/test/unit/math/mix/prob/multi_gp_test.cpp @@ -80,12 +80,12 @@ TEST(ProbDistributionsMultiGP, fvar_var) { for (size_t i = 0; i < 3; i++) { Matrix, Dynamic, 1> cy(y.row(i).transpose()); Matrix, Dynamic, Dynamic> cSigma((1.0 / w[i]) * Sigma); - lp_ref += stan::math::multi_normal_log(cy, mu, cSigma); + lp_ref += stan::math::multi_normal_lpdf(cy, mu, cSigma); } EXPECT_FLOAT_EQ(lp_ref.val_.val(), - stan::math::multi_gp_log(y, Sigma, w).val_.val()); - EXPECT_FLOAT_EQ(-74.572952, stan::math::multi_gp_log(y, Sigma, w).d_.val()); + stan::math::multi_gp_lpdf(y, Sigma, w).val_.val()); + EXPECT_FLOAT_EQ(-74.572952, stan::math::multi_gp_lpdf(y, Sigma, w).d_.val()); stan::math::recover_memory(); } @@ -124,13 +124,13 @@ TEST(ProbDistributionsMultiGP, fvar_fvar_var) { for (size_t i = 0; i < 3; i++) { Matrix >, Dynamic, 1> cy(y.row(i).transpose()); Matrix >, Dynamic, Dynamic> cSigma((1.0 / w[i]) * Sigma); - lp_ref += stan::math::multi_normal_log(cy, mu, cSigma); + lp_ref += stan::math::multi_normal_lpdf(cy, mu, cSigma); } EXPECT_FLOAT_EQ(lp_ref.val_.val_.val(), - stan::math::multi_gp_log(y, Sigma, w).val_.val_.val()); + stan::math::multi_gp_lpdf(y, Sigma, w).val_.val_.val()); EXPECT_FLOAT_EQ(-74.572952, - stan::math::multi_gp_log(y, Sigma, w).d_.val_.val()); + stan::math::multi_gp_lpdf(y, Sigma, w).d_.val_.val()); stan::math::recover_memory(); } diff --git a/test/unit/math/mix/prob/multi_normal_cholesky_test.cpp b/test/unit/math/mix/prob/multi_normal_cholesky_test.cpp index f1a637d6adf..f8aea19e3f6 100644 --- a/test/unit/math/mix/prob/multi_normal_cholesky_test.cpp +++ b/test/unit/math/mix/prob/multi_normal_cholesky_test.cpp @@ -68,9 +68,9 @@ TEST(ProbDistributionsMultiNormalCholesky, fvar_var) { Matrix, Dynamic, Dynamic> L = Sigma.llt().matrixL(); EXPECT_FLOAT_EQ(-11.73908, - stan::math::multi_normal_cholesky_log(y, mu, L).val_.val()); + stan::math::multi_normal_cholesky_lpdf(y, mu, L).val_.val()); EXPECT_FLOAT_EQ(0.54899865, - stan::math::multi_normal_cholesky_log(y, mu, L).d_.val()); + stan::math::multi_normal_cholesky_lpdf(y, mu, L).d_.val()); } TEST(ProbDistributionsMultiNormalCholesky, fvar_fvar_var) { @@ -97,8 +97,8 @@ TEST(ProbDistributionsMultiNormalCholesky, fvar_fvar_var) { Matrix >, Dynamic, Dynamic> L = Sigma.llt().matrixL(); EXPECT_FLOAT_EQ( -11.73908, - stan::math::multi_normal_cholesky_log(y, mu, L).val_.val_.val()); + stan::math::multi_normal_cholesky_lpdf(y, mu, L).val_.val_.val()); EXPECT_FLOAT_EQ( 0.54899865, - stan::math::multi_normal_cholesky_log(y, mu, L).d_.val_.val()); + stan::math::multi_normal_cholesky_lpdf(y, mu, L).d_.val_.val()); } diff --git a/test/unit/math/mix/prob/multi_normal_prec_test.cpp b/test/unit/math/mix/prob/multi_normal_prec_test.cpp index abd3a819f69..606c050af9e 100644 --- a/test/unit/math/mix/prob/multi_normal_prec_test.cpp +++ b/test/unit/math/mix/prob/multi_normal_prec_test.cpp @@ -60,9 +60,9 @@ TEST(ProbDistributionsMultiNormalPrec, fvar_var) { Matrix, Dynamic, Dynamic> L = Sigma.inverse(); EXPECT_FLOAT_EQ(-11.73908, - stan::math::multi_normal_prec_log(y, mu, L).val_.val()); + stan::math::multi_normal_prec_lpdf(y, mu, L).val_.val()); EXPECT_FLOAT_EQ(0.54899865, - stan::math::multi_normal_prec_log(y, mu, L).d_.val()); + stan::math::multi_normal_prec_lpdf(y, mu, L).d_.val()); stan::math::recover_memory(); } @@ -90,9 +90,9 @@ TEST(ProbDistributionsMultiNormalPrec, fvar_fvar_var) { Matrix >, Dynamic, Dynamic> L = Sigma.inverse(); EXPECT_FLOAT_EQ(-11.73908, - stan::math::multi_normal_prec_log(y, mu, L).val_.val_.val()); + stan::math::multi_normal_prec_lpdf(y, mu, L).val_.val_.val()); EXPECT_FLOAT_EQ(0.54899865, - stan::math::multi_normal_prec_log(y, mu, L).d_.val_.val()); + stan::math::multi_normal_prec_lpdf(y, mu, L).d_.val_.val()); stan::math::recover_memory(); } diff --git a/test/unit/math/mix/prob/multi_normal_test.cpp b/test/unit/math/mix/prob/multi_normal_test.cpp index bb1fc347d70..f5c9d507f48 100644 --- a/test/unit/math/mix/prob/multi_normal_test.cpp +++ b/test/unit/math/mix/prob/multi_normal_test.cpp @@ -67,7 +67,7 @@ TEST(ProbDistributionsMultiNormal, fvar_var) { Sigma(i, j).d_ = 1.0; } - fvar res = stan::math::multi_normal_log(y, mu, Sigma); + fvar res = stan::math::multi_normal_lpdf(y, mu, Sigma); EXPECT_FLOAT_EQ(-11.73908, res.val_.val()); EXPECT_FLOAT_EQ(0.54899865, res.d_.val()); @@ -94,7 +94,7 @@ TEST(ProbDistributionsMultiNormal, fvar_fvar_var) { Sigma(i, j).d_ = 1.0; } - fvar > res = stan::math::multi_normal_log(y, mu, Sigma); + fvar > res = stan::math::multi_normal_lpdf(y, mu, Sigma); EXPECT_FLOAT_EQ(-11.73908, res.val_.val_.val()); EXPECT_FLOAT_EQ(0.54899865, res.d_.val_.val()); diff --git a/test/unit/math/mix/prob/multi_student_t_test.cpp b/test/unit/math/mix/prob/multi_student_t_test.cpp index 232493f554b..a74881fe6da 100644 --- a/test/unit/math/mix/prob/multi_student_t_test.cpp +++ b/test/unit/math/mix/prob/multi_student_t_test.cpp @@ -62,7 +62,7 @@ TEST(ProbDistributionsMultiStudentT, fvar_var) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::fvar; - using stan::math::multi_student_t_log; + using stan::math::multi_student_t_lpdf; using stan::math::var; using std::vector; Matrix, Dynamic, 1> y(3, 1); @@ -80,7 +80,7 @@ TEST(ProbDistributionsMultiStudentT, fvar_var) { Sigma(i, j).d_ = 1.0; } - fvar lp = multi_student_t_log(y, nu, mu, Sigma); + fvar lp = multi_student_t_lpdf(y, nu, mu, Sigma); EXPECT_NEAR(-10.1246, lp.val_.val(), 0.0001); EXPECT_NEAR(-0.0411685, lp.d_.val(), 0.0001); @@ -91,7 +91,7 @@ TEST(ProbDistributionsMultiStudentT, fvar_fvar_var) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::fvar; - using stan::math::multi_student_t_log; + using stan::math::multi_student_t_lpdf; using stan::math::var; using std::vector; Matrix >, Dynamic, 1> y(3, 1); @@ -109,7 +109,7 @@ TEST(ProbDistributionsMultiStudentT, fvar_fvar_var) { Sigma(i, j).d_.val_ = 1.0; } - fvar > lp = multi_student_t_log(y, nu, mu, Sigma); + fvar > lp = multi_student_t_lpdf(y, nu, mu, Sigma); EXPECT_NEAR(-10.1246, lp.val_.val_.val(), 0.0001); EXPECT_NEAR(-0.0411685, lp.d_.val_.val(), 0.0001); diff --git a/test/unit/math/mix/prob/multinomial_test.cpp b/test/unit/math/mix/prob/multinomial_test.cpp index 9289d5d26f6..c8f706a7580 100644 --- a/test/unit/math/mix/prob/multinomial_test.cpp +++ b/test/unit/math/mix/prob/multinomial_test.cpp @@ -18,8 +18,9 @@ TEST(ProbDistributionsMultinomial, fvar_var) { for (int i = 0; i < 3; i++) theta(i).d_ = 1.0; - EXPECT_FLOAT_EQ(-2.002481, stan::math::multinomial_log(ns, theta).val_.val()); - EXPECT_FLOAT_EQ(17.666666, stan::math::multinomial_log(ns, theta).d_.val()); + EXPECT_FLOAT_EQ(-2.002481, + stan::math::multinomial_lpmf(ns, theta).val_.val()); + EXPECT_FLOAT_EQ(17.666666, stan::math::multinomial_lpmf(ns, theta).d_.val()); } TEST(ProbDistributionsMultinomial, fvar_fvar_var) { @@ -37,7 +38,7 @@ TEST(ProbDistributionsMultinomial, fvar_fvar_var) { theta(i).d_.val_ = 1.0; EXPECT_FLOAT_EQ(-2.002481, - stan::math::multinomial_log(ns, theta).val_.val_.val()); + stan::math::multinomial_lpmf(ns, theta).val_.val_.val()); EXPECT_FLOAT_EQ(17.666666, - stan::math::multinomial_log(ns, theta).d_.val_.val()); + stan::math::multinomial_lpmf(ns, theta).d_.val_.val()); } diff --git a/test/unit/math/mix/prob/wishart_test.cpp b/test/unit/math/mix/prob/wishart_test.cpp index e100e55e0e1..9dbc107c8c7 100644 --- a/test/unit/math/mix/prob/wishart_test.cpp +++ b/test/unit/math/mix/prob/wishart_test.cpp @@ -54,8 +54,8 @@ TEST(ProbDistributionsWishart, fvar_var) { // computed with MCMCpack in R double lp = log(8.658e-07); - EXPECT_NEAR(lp, stan::math::wishart_log(Y, dof, Sigma).val_.val(), 0.01); - EXPECT_NEAR(-0.76893887, stan::math::wishart_log(Y, dof, Sigma).d_.val(), + EXPECT_NEAR(lp, stan::math::wishart_lpdf(Y, dof, Sigma).val_.val(), 0.01); + EXPECT_NEAR(-0.76893887, stan::math::wishart_lpdf(Y, dof, Sigma).d_.val(), 0.01); stan::math::recover_memory(); @@ -81,9 +81,10 @@ TEST(ProbDistributionsWishart, fvar_fvar_var) { // computed with MCMCpack in R double lp = log(8.658e-07); - EXPECT_NEAR(lp, stan::math::wishart_log(Y, dof, Sigma).val_.val_.val(), 0.01); - EXPECT_NEAR(-0.76893887, stan::math::wishart_log(Y, dof, Sigma).d_.val_.val(), + EXPECT_NEAR(lp, stan::math::wishart_lpdf(Y, dof, Sigma).val_.val_.val(), 0.01); + EXPECT_NEAR(-0.76893887, + stan::math::wishart_lpdf(Y, dof, Sigma).d_.val_.val(), 0.01); stan::math::recover_memory(); } diff --git a/test/unit/math/prim/prob/categorical_logit_test.cpp b/test/unit/math/prim/prob/categorical_logit_test.cpp index 35aa5c3b949..482e00d5ab1 100644 --- a/test/unit/math/prim/prob/categorical_logit_test.cpp +++ b/test/unit/math/prim/prob/categorical_logit_test.cpp @@ -12,11 +12,11 @@ TEST(ProbDistributionsCategoricalLogit, Categorical) { Matrix theta_log_softmax = log_softmax(theta); EXPECT_FLOAT_EQ(theta_log_softmax[0], - stan::math::categorical_logit_log(1, theta)); + stan::math::categorical_logit_lpmf(1, theta)); EXPECT_FLOAT_EQ(theta_log_softmax[1], - stan::math::categorical_logit_log(2, theta)); + stan::math::categorical_logit_lpmf(2, theta)); EXPECT_FLOAT_EQ(theta_log_softmax[2], - stan::math::categorical_logit_log(3, theta)); + stan::math::categorical_logit_lpmf(3, theta)); } TEST(ProbDistributionsCategoricalLogit, CategoricalVectorized) { @@ -27,7 +27,7 @@ TEST(ProbDistributionsCategoricalLogit, CategoricalVectorized) { theta << -1, 2, -10; std::vector ns(0); - EXPECT_FLOAT_EQ(0.0, stan::math::categorical_logit_log(ns, theta)); + EXPECT_FLOAT_EQ(0.0, stan::math::categorical_logit_lpmf(ns, theta)); Matrix theta_log_softmax = log_softmax(theta); @@ -37,7 +37,7 @@ TEST(ProbDistributionsCategoricalLogit, CategoricalVectorized) { ms[2] = 1; EXPECT_FLOAT_EQ( theta_log_softmax[0] + theta_log_softmax[1] + theta_log_softmax[0], - stan::math::categorical_logit_log(ms, theta)); + stan::math::categorical_logit_lpmf(ms, theta)); } TEST(ProbDistributionsCategoricalLogit, Propto) { @@ -45,44 +45,44 @@ TEST(ProbDistributionsCategoricalLogit, Propto) { using Eigen::Matrix; Matrix theta(3, 1); theta << -1, 2, 10; - EXPECT_FLOAT_EQ(0, stan::math::categorical_logit_log(1, theta)); - EXPECT_FLOAT_EQ(0, stan::math::categorical_logit_log(3, theta)); + EXPECT_FLOAT_EQ(0, stan::math::categorical_logit_lpmf(1, theta)); + EXPECT_FLOAT_EQ(0, stan::math::categorical_logit_lpmf(3, theta)); } TEST(ProbDistributionsCategoricalLogit, error) { using Eigen::Dynamic; using Eigen::Matrix; - using stan::math::categorical_logit_log; + using stan::math::categorical_logit_lpmf; unsigned int n = 1; unsigned int N = 3; Matrix theta(N, 1); theta << 0.3, 0.5, 0.2; - EXPECT_NO_THROW(categorical_logit_log(N, theta)); - EXPECT_NO_THROW(categorical_logit_log(n, theta)); - EXPECT_NO_THROW(categorical_logit_log(2, theta)); - EXPECT_THROW(categorical_logit_log(N + 1, theta), std::domain_error); - EXPECT_THROW(categorical_logit_log(0, theta), std::domain_error); + EXPECT_NO_THROW(categorical_logit_lpmf(N, theta)); + EXPECT_NO_THROW(categorical_logit_lpmf(n, theta)); + EXPECT_NO_THROW(categorical_logit_lpmf(2, theta)); + EXPECT_THROW(categorical_logit_lpmf(N + 1, theta), std::domain_error); + EXPECT_THROW(categorical_logit_lpmf(0, theta), std::domain_error); theta(1) = std::numeric_limits::quiet_NaN(); - EXPECT_THROW(categorical_logit_log(1, theta), std::domain_error); + EXPECT_THROW(categorical_logit_lpmf(1, theta), std::domain_error); theta(1) = std::numeric_limits::infinity(); - EXPECT_THROW(categorical_logit_log(1, theta), std::domain_error); + EXPECT_THROW(categorical_logit_lpmf(1, theta), std::domain_error); std::vector ns(2); ns[0] = 1; ns[1] = 2; - EXPECT_THROW(categorical_logit_log(ns, theta), std::domain_error); + EXPECT_THROW(categorical_logit_lpmf(ns, theta), std::domain_error); theta << 0.3, 0.5, 0.2; - EXPECT_NO_THROW(categorical_logit_log(ns, theta)); + EXPECT_NO_THROW(categorical_logit_lpmf(ns, theta)); ns[0] = -1; - EXPECT_THROW(categorical_logit_log(ns, theta), std::domain_error); + EXPECT_THROW(categorical_logit_lpmf(ns, theta), std::domain_error); ns[0] = 1; ns[1] = 12; - EXPECT_THROW(categorical_logit_log(ns, theta), std::domain_error); + EXPECT_THROW(categorical_logit_lpmf(ns, theta), std::domain_error); } diff --git a/test/unit/math/prim/prob/categorical_test.cpp b/test/unit/math/prim/prob/categorical_test.cpp index 2cbeeb1f82d..6923d506870 100644 --- a/test/unit/math/prim/prob/categorical_test.cpp +++ b/test/unit/math/prim/prob/categorical_test.cpp @@ -10,16 +10,16 @@ TEST(ProbDistributionsCategorical, Categorical) { using Eigen::Matrix; Matrix theta(3, 1); theta << 0.3, 0.5, 0.2; - EXPECT_FLOAT_EQ(-1.203973, stan::math::categorical_log(1, theta)); - EXPECT_FLOAT_EQ(-0.6931472, stan::math::categorical_log(2, theta)); + EXPECT_FLOAT_EQ(-1.203973, stan::math::categorical_lpmf(1, theta)); + EXPECT_FLOAT_EQ(-0.6931472, stan::math::categorical_lpmf(2, theta)); } TEST(ProbDistributionsCategorical, Propto) { using Eigen::Dynamic; using Eigen::Matrix; Matrix theta(3, 1); theta << 0.3, 0.5, 0.2; - EXPECT_FLOAT_EQ(0.0, stan::math::categorical_log(1, theta)); - EXPECT_FLOAT_EQ(0.0, stan::math::categorical_log(2, theta)); + EXPECT_FLOAT_EQ(0.0, stan::math::categorical_lpmf(1, theta)); + EXPECT_FLOAT_EQ(0.0, stan::math::categorical_lpmf(2, theta)); } TEST(ProbDistributionsCategorical, VectorInt) { @@ -28,7 +28,7 @@ TEST(ProbDistributionsCategorical, VectorInt) { Matrix theta(3, 1); theta << 0.3, 0.5, 0.2; std::vector xs0; - EXPECT_FLOAT_EQ(0.0, stan::math::categorical_log(xs0, theta)); + EXPECT_FLOAT_EQ(0.0, stan::math::categorical_lpmf(xs0, theta)); std::vector xs(3); xs[0] = 1; @@ -36,13 +36,13 @@ TEST(ProbDistributionsCategorical, VectorInt) { xs[2] = 1; EXPECT_FLOAT_EQ(log(0.3) + log(0.2) + log(0.3), - stan::math::categorical_log(xs, theta)); + stan::math::categorical_lpmf(xs, theta)); } TEST(ProbDistributionsCategorical, error) { using Eigen::Dynamic; using Eigen::Matrix; - using stan::math::categorical_log; + using stan::math::categorical_lpmf; double nan = std::numeric_limits::quiet_NaN(); double inf = std::numeric_limits::infinity(); @@ -51,43 +51,43 @@ TEST(ProbDistributionsCategorical, error) { Matrix theta(N, 1); theta << 0.3, 0.5, 0.2; - EXPECT_NO_THROW(categorical_log(N, theta)); - EXPECT_NO_THROW(categorical_log(n, theta)); - EXPECT_NO_THROW(categorical_log(2, theta)); - EXPECT_THROW(categorical_log(N + 1, theta), std::domain_error); - EXPECT_THROW(categorical_log(0, theta), std::domain_error); + EXPECT_NO_THROW(categorical_lpmf(N, theta)); + EXPECT_NO_THROW(categorical_lpmf(n, theta)); + EXPECT_NO_THROW(categorical_lpmf(2, theta)); + EXPECT_THROW(categorical_lpmf(N + 1, theta), std::domain_error); + EXPECT_THROW(categorical_lpmf(0, theta), std::domain_error); theta(0) = nan; - EXPECT_THROW(categorical_log(n, theta), std::domain_error); + EXPECT_THROW(categorical_lpmf(n, theta), std::domain_error); theta(0) = inf; - EXPECT_THROW(categorical_log(n, theta), std::domain_error); + EXPECT_THROW(categorical_lpmf(n, theta), std::domain_error); theta(0) = -inf; - EXPECT_THROW(categorical_log(n, theta), std::domain_error); + EXPECT_THROW(categorical_lpmf(n, theta), std::domain_error); theta(0) = -1; theta(1) = 1; theta(2) = 0; - EXPECT_THROW(categorical_log(n, theta), std::domain_error); + EXPECT_THROW(categorical_lpmf(n, theta), std::domain_error); std::vector ns(3); ns[0] = 3; ns[1] = 2; ns[2] = 3; - EXPECT_THROW(categorical_log(ns, theta), std::domain_error); + EXPECT_THROW(categorical_lpmf(ns, theta), std::domain_error); theta << 0.3, 0.5, 0.2; - EXPECT_NO_THROW(categorical_log(ns, theta)); + EXPECT_NO_THROW(categorical_lpmf(ns, theta)); ns[1] = -1; - EXPECT_THROW(categorical_log(ns, theta), std::domain_error); + EXPECT_THROW(categorical_lpmf(ns, theta), std::domain_error); ns[1] = 1; ns[2] = 12; - EXPECT_THROW(categorical_log(ns, theta), std::domain_error); + EXPECT_THROW(categorical_lpmf(ns, theta), std::domain_error); } TEST(ProbDistributionsCategorical, error_check) { using Eigen::Dynamic; using Eigen::Matrix; - using stan::math::categorical_log; + using stan::math::categorical_lpmf; boost::random::mt19937 rng; Matrix theta(3, 1); @@ -99,7 +99,7 @@ TEST(ProbDistributionsCategorical, error_check) { TEST(ProbDistributionsCategorical, chiSquareGoodnessFitTest) { using Eigen::Dynamic; using Eigen::Matrix; - using stan::math::categorical_log; + using stan::math::categorical_lpmf; boost::random::mt19937 rng; int N = 10000; diff --git a/test/unit/math/prim/prob/dirichlet_test.cpp b/test/unit/math/prim/prob/dirichlet_test.cpp index 9cf7344cef4..777252a54e7 100644 --- a/test/unit/math/prim/prob/dirichlet_test.cpp +++ b/test/unit/math/prim/prob/dirichlet_test.cpp @@ -12,20 +12,20 @@ TEST(ProbDistributions, Dirichlet) { theta << 0.2, 0.3, 0.5; Matrix alpha(3, 1); alpha << 1.0, 1.0, 1.0; - EXPECT_FLOAT_EQ(0.6931472, stan::math::dirichlet_log(theta, alpha)); + EXPECT_FLOAT_EQ(0.6931472, stan::math::dirichlet_lpdf(theta, alpha)); Matrix theta2(4, 1); theta2 << 0.01, 0.01, 0.8, 0.18; Matrix alpha2(4, 1); alpha2 << 10.5, 11.5, 19.3, 5.1; - EXPECT_FLOAT_EQ(-43.40045, stan::math::dirichlet_log(theta2, alpha2)); + EXPECT_FLOAT_EQ(-43.40045, stan::math::dirichlet_lpdf(theta2, alpha2)); } TEST(ProbDistributions, DirichletVectorized) { using Eigen::Dynamic; using Eigen::Matrix; using Eigen::VectorXd; - using stan::math::dirichlet_log; + using stan::math::dirichlet_lpdf; Matrix theta1(3, 1), theta2(3, 1), theta3(3, 1); theta1 << 0.2, 0.3, 0.5; theta2 << 0.1, 0.8, 0.1; @@ -47,23 +47,23 @@ TEST(ProbDistributions, DirichletVectorized) { alpha_vec[2] = alpha3; Matrix result(3); - result[0] = dirichlet_log(theta1, alpha1); - result[1] = dirichlet_log(theta2, alpha2); - result[2] = dirichlet_log(theta3, alpha3); + result[0] = dirichlet_lpdf(theta1, alpha1); + result[1] = dirichlet_lpdf(theta2, alpha2); + result[2] = dirichlet_lpdf(theta3, alpha3); - EXPECT_FLOAT_EQ(result.sum(), dirichlet_log(theta_vec, alpha_vec)); + EXPECT_FLOAT_EQ(result.sum(), dirichlet_lpdf(theta_vec, alpha_vec)); - result[0] = dirichlet_log(theta1, alpha1); - result[1] = dirichlet_log(theta2, alpha1); - result[2] = dirichlet_log(theta3, alpha1); + result[0] = dirichlet_lpdf(theta1, alpha1); + result[1] = dirichlet_lpdf(theta2, alpha1); + result[2] = dirichlet_lpdf(theta3, alpha1); - EXPECT_FLOAT_EQ(result.sum(), dirichlet_log(theta_vec, alpha1)); + EXPECT_FLOAT_EQ(result.sum(), dirichlet_lpdf(theta_vec, alpha1)); - result[0] = dirichlet_log(theta1, alpha1); - result[1] = dirichlet_log(theta1, alpha2); - result[2] = dirichlet_log(theta1, alpha3); + result[0] = dirichlet_lpdf(theta1, alpha1); + result[1] = dirichlet_lpdf(theta1, alpha2); + result[2] = dirichlet_lpdf(theta1, alpha3); - EXPECT_FLOAT_EQ(result.sum(), dirichlet_log(theta1, alpha_vec)); + EXPECT_FLOAT_EQ(result.sum(), dirichlet_lpdf(theta1, alpha_vec)); } TEST(ProbDistributions, DirichletPropto) { @@ -74,13 +74,13 @@ TEST(ProbDistributions, DirichletPropto) { theta << 0.2, 0.3, 0.5; Matrix alpha(3, 1); alpha << 1.0, 1.0, 1.0; - EXPECT_FLOAT_EQ(0.0, stan::math::dirichlet_log(theta, alpha)); + EXPECT_FLOAT_EQ(0.0, stan::math::dirichlet_lpdf(theta, alpha)); Matrix theta2(4, 1); theta2 << 0.01, 0.01, 0.8, 0.18; Matrix alpha2(4, 1); alpha2 << 10.5, 11.5, 19.3, 5.1; - EXPECT_FLOAT_EQ(0.0, stan::math::dirichlet_log(theta2, alpha2)); + EXPECT_FLOAT_EQ(0.0, stan::math::dirichlet_lpdf(theta2, alpha2)); } TEST(ProbDistributions, DirichletBounds) { @@ -92,41 +92,41 @@ TEST(ProbDistributions, DirichletBounds) { good_theta << 0.25, 0.75; good_alpha << 2, 3; - EXPECT_NO_THROW(stan::math::dirichlet_log(good_theta, good_alpha)); + EXPECT_NO_THROW(stan::math::dirichlet_lpdf(good_theta, good_alpha)); good_theta << 1.0, 0.0; good_alpha << 2, 3; - EXPECT_NO_THROW(stan::math::dirichlet_log(good_theta, good_alpha)) + EXPECT_NO_THROW(stan::math::dirichlet_lpdf(good_theta, good_alpha)) << "elements of theta can be 0"; bad_theta << 0.25, 0.25; - EXPECT_THROW(stan::math::dirichlet_log(bad_theta, good_alpha), + EXPECT_THROW(stan::math::dirichlet_lpdf(bad_theta, good_alpha), std::domain_error) << "sum of theta is not 1"; bad_theta << -0.25, 1.25; - EXPECT_THROW(stan::math::dirichlet_log(bad_theta, good_alpha), + EXPECT_THROW(stan::math::dirichlet_lpdf(bad_theta, good_alpha), std::domain_error) << "theta has element less than 0"; bad_theta << -0.25, 1.25; - EXPECT_THROW(stan::math::dirichlet_log(bad_theta, good_alpha), + EXPECT_THROW(stan::math::dirichlet_lpdf(bad_theta, good_alpha), std::domain_error) << "theta has element less than 0"; bad_alpha << 0.0, 1.0; - EXPECT_THROW(stan::math::dirichlet_log(good_theta, bad_alpha), + EXPECT_THROW(stan::math::dirichlet_lpdf(good_theta, bad_alpha), std::domain_error) << "alpha has element equal to 0"; bad_alpha << -0.5, 1.0; - EXPECT_THROW(stan::math::dirichlet_log(good_theta, bad_alpha), + EXPECT_THROW(stan::math::dirichlet_lpdf(good_theta, bad_alpha), std::domain_error) << "alpha has element less than 0"; bad_alpha = Matrix(4, 1); bad_alpha << 1, 2, 3, 4; - EXPECT_THROW(stan::math::dirichlet_log(good_theta, bad_alpha), + EXPECT_THROW(stan::math::dirichlet_lpdf(good_theta, bad_alpha), std::invalid_argument) << "size mismatch: theta is a 2-vector, alpha is a 4-vector"; } diff --git a/test/unit/math/prim/prob/gaussian_dlm_obs_test.cpp b/test/unit/math/prim/prob/gaussian_dlm_obs_test.cpp index 9ce2466fe12..b5085229d7e 100644 --- a/test/unit/math/prim/prob/gaussian_dlm_obs_test.cpp +++ b/test/unit/math/prim/prob/gaussian_dlm_obs_test.cpp @@ -10,7 +10,7 @@ TEST(ProbDistributionsGaussianDLM, LoglikeUU) { using Eigen::Dynamic; using Eigen::Matrix; using Eigen::MatrixXd; - using stan::math::gaussian_dlm_obs_log; + using stan::math::gaussian_dlm_obs_lpdf; Eigen::Matrix FF(1, 1); FF << 0.585528817843856; Eigen::Matrix GG(1, 1); @@ -30,7 +30,7 @@ TEST(ProbDistributionsGaussianDLM, LoglikeUU) { 1.17332931763075; double ll_expected = -16.2484978375184; - double lp_ref = gaussian_dlm_obs_log(y, FF, GG, V, W, m0, C0); + double lp_ref = gaussian_dlm_obs_lpdf(y, FF, GG, V, W, m0, C0); EXPECT_FLOAT_EQ(lp_ref, ll_expected); } @@ -38,7 +38,7 @@ TEST(ProbDistributionsGaussianDLM, LoglikeMM) { using Eigen::Dynamic; using Eigen::Matrix; using Eigen::MatrixXd; - using stan::math::gaussian_dlm_obs_log; + using stan::math::gaussian_dlm_obs_lpdf; Eigen::Matrix FF(2, 3); FF << 0.585528817843856, 0.709466017509524, -0.109303314681054, -0.453497173462763, 0.605887455840394, -1.81795596770373; @@ -66,7 +66,7 @@ TEST(ProbDistributionsGaussianDLM, LoglikeMM) { -3.25066033978687, 1.32299515908216, 0.746844140961399; double ll_expected = -85.2615847497409; - double lp_ref = gaussian_dlm_obs_log(y, FF, GG, V, W, m0, C0); + double lp_ref = gaussian_dlm_obs_lpdf(y, FF, GG, V, W, m0, C0); // the error adds up in the multivariate version due to the inversion. EXPECT_NEAR(lp_ref, ll_expected, 1e-4); } @@ -75,7 +75,7 @@ TEST(ProbDistributionsGaussianDLM, LoglikeUUSeq) { using Eigen::Dynamic; using Eigen::Matrix; using Eigen::MatrixXd; - using stan::math::gaussian_dlm_obs_log; + using stan::math::gaussian_dlm_obs_lpdf; Eigen::Matrix FF(1, 1); FF << 0.585528817843856; Eigen::Matrix GG(1, 1); @@ -95,7 +95,7 @@ TEST(ProbDistributionsGaussianDLM, LoglikeUUSeq) { 1.17332931763075; double ll_expected = -16.2484978375184; - double lp_ref = gaussian_dlm_obs_log(y, FF, GG, V, W, m0, C0); + double lp_ref = gaussian_dlm_obs_lpdf(y, FF, GG, V, W, m0, C0); EXPECT_FLOAT_EQ(lp_ref, ll_expected); } @@ -103,7 +103,7 @@ TEST(ProbDistributionsGaussianDLM, LoglikeMMSeq) { using Eigen::Dynamic; using Eigen::Matrix; using Eigen::MatrixXd; - using stan::math::gaussian_dlm_obs_log; + using stan::math::gaussian_dlm_obs_lpdf; Eigen::Matrix FF(2, 3); FF << 0.585528817843856, 0.709466017509524, -0.109303314681054, -0.453497173462763, 0.605887455840394, -1.81795596770373; @@ -129,7 +129,7 @@ TEST(ProbDistributionsGaussianDLM, LoglikeMMSeq) { 0.902652349582918, -5.82732638176514, 0.861614157026216, 2.56883513585703; double ll_expected = -89.1533619880878; - double lp_ref = gaussian_dlm_obs_log(y, FF, GG, V, W, m0, C0); + double lp_ref = gaussian_dlm_obs_lpdf(y, FF, GG, V, W, m0, C0); EXPECT_FLOAT_EQ(lp_ref, ll_expected); } @@ -160,18 +160,18 @@ TEST_F(ProbDistributionsGaussianDLMInputs, PoliciesY) { using Eigen::Dynamic; using Eigen::Matrix; using Eigen::MatrixXd; - using stan::math::gaussian_dlm_obs_log; + using stan::math::gaussian_dlm_obs_lpdf; Matrix y_inf = y; y_inf(0, 0) = std::numeric_limits::infinity(); - EXPECT_THROW(gaussian_dlm_obs_log(y_inf, FF, GG, V, W, m0, C0), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y_inf, FF, GG, V, W, m0, C0), std::domain_error); - EXPECT_THROW(gaussian_dlm_obs_log(y_inf, FF, GG, V_vec, W, m0, C0), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y_inf, FF, GG, V_vec, W, m0, C0), std::domain_error); Matrix y_nan = y; y_nan(0, 0) = std::numeric_limits::quiet_NaN(); - EXPECT_THROW(gaussian_dlm_obs_log(y_nan, FF, GG, V, W, m0, C0), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y_nan, FF, GG, V, W, m0, C0), std::domain_error); - EXPECT_THROW(gaussian_dlm_obs_log(y_nan, FF, GG, V_vec, W, m0, C0), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y_nan, FF, GG, V_vec, W, m0, C0), std::domain_error); } @@ -179,29 +179,29 @@ TEST_F(ProbDistributionsGaussianDLMInputs, PoliciesF) { using Eigen::Dynamic; using Eigen::Matrix; using Eigen::MatrixXd; - using stan::math::gaussian_dlm_obs_log; + using stan::math::gaussian_dlm_obs_lpdf; Matrix FF_sz1 = MatrixXd::Random(4, 3); - EXPECT_THROW(gaussian_dlm_obs_log(y, FF_sz1, GG, V, W, m0, C0), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y, FF_sz1, GG, V, W, m0, C0), std::invalid_argument); - EXPECT_THROW(gaussian_dlm_obs_log(y, FF_sz1, GG, V_vec, W, m0, C0), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y, FF_sz1, GG, V_vec, W, m0, C0), std::invalid_argument); Matrix FF_sz2 = MatrixXd::Random(2, 4); - EXPECT_THROW(gaussian_dlm_obs_log(y, FF_sz2, GG, V, W, m0, C0), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y, FF_sz2, GG, V, W, m0, C0), std::invalid_argument); - EXPECT_THROW(gaussian_dlm_obs_log(y, FF_sz2, GG, V_vec, W, m0, C0), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y, FF_sz2, GG, V_vec, W, m0, C0), std::invalid_argument); // finite and NaN Matrix FF_inf = FF; FF_inf(0, 0) = std::numeric_limits::infinity(); - EXPECT_THROW(gaussian_dlm_obs_log(y, FF_inf, GG, V, W, m0, C0), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y, FF_inf, GG, V, W, m0, C0), std::domain_error); - EXPECT_THROW(gaussian_dlm_obs_log(y, FF_inf, GG, V_vec, W, m0, C0), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y, FF_inf, GG, V_vec, W, m0, C0), std::domain_error); Matrix FF_nan = FF; FF_nan(0, 0) = std::numeric_limits::quiet_NaN(); - EXPECT_THROW(gaussian_dlm_obs_log(y, FF_nan, GG, V, W, m0, C0), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y, FF_nan, GG, V, W, m0, C0), std::domain_error); - EXPECT_THROW(gaussian_dlm_obs_log(y, FF_nan, GG, V_vec, W, m0, C0), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y, FF_nan, GG, V_vec, W, m0, C0), std::domain_error); } @@ -209,30 +209,30 @@ TEST_F(ProbDistributionsGaussianDLMInputs, PoliciesG) { using Eigen::Dynamic; using Eigen::Matrix; using Eigen::MatrixXd; - using stan::math::gaussian_dlm_obs_log; + using stan::math::gaussian_dlm_obs_lpdf; // size Matrix GG_sz1 = MatrixXd::Random(3, 3); - EXPECT_THROW(gaussian_dlm_obs_log(y, FF, GG_sz1, V, W, m0, C0), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y, FF, GG_sz1, V, W, m0, C0), std::invalid_argument); - EXPECT_THROW(gaussian_dlm_obs_log(y, FF, GG_sz1, V_vec, W, m0, C0), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y, FF, GG_sz1, V_vec, W, m0, C0), std::invalid_argument); Matrix GG_sz2 = MatrixXd::Random(2, 3); - EXPECT_THROW(gaussian_dlm_obs_log(y, FF, GG_sz2, V, W, m0, C0), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y, FF, GG_sz2, V, W, m0, C0), std::invalid_argument); - EXPECT_THROW(gaussian_dlm_obs_log(y, FF, GG_sz2, V_vec, W, m0, C0), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y, FF, GG_sz2, V_vec, W, m0, C0), std::invalid_argument); // finite and NaN Matrix GG_inf = GG; GG_inf(0, 0) = std::numeric_limits::infinity(); - EXPECT_THROW(gaussian_dlm_obs_log(y, FF, GG_inf, V, W, m0, C0), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y, FF, GG_inf, V, W, m0, C0), std::domain_error); - EXPECT_THROW(gaussian_dlm_obs_log(y, FF, GG_inf, V_vec, W, m0, C0), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y, FF, GG_inf, V_vec, W, m0, C0), std::domain_error); Matrix GG_nan = GG; GG_nan(0, 0) = std::numeric_limits::quiet_NaN(); - EXPECT_THROW(gaussian_dlm_obs_log(y, FF, GG_nan, V, W, m0, C0), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y, FF, GG_nan, V, W, m0, C0), std::domain_error); - EXPECT_THROW(gaussian_dlm_obs_log(y, FF, GG_nan, V_vec, W, m0, C0), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y, FF, GG_nan, V_vec, W, m0, C0), std::domain_error); } @@ -240,145 +240,145 @@ TEST_F(ProbDistributionsGaussianDLMInputs, PoliciesW) { using Eigen::Dynamic; using Eigen::Matrix; using Eigen::MatrixXd; - using stan::math::gaussian_dlm_obs_log; + using stan::math::gaussian_dlm_obs_lpdf; // Not symmetric Matrix W_asym = W; W_asym(0, 1) = 1; - EXPECT_THROW(gaussian_dlm_obs_log(y, FF, GG, V, W_asym, m0, C0), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y, FF, GG, V, W_asym, m0, C0), std::domain_error); - EXPECT_THROW(gaussian_dlm_obs_log(y, FF, GG, V_vec, W_asym, m0, C0), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y, FF, GG, V_vec, W_asym, m0, C0), std::domain_error); // negative Matrix W_neg = W; W_neg(0, 0) = -1; - EXPECT_THROW(gaussian_dlm_obs_log(y, FF, GG, V, W_neg, m0, C0), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y, FF, GG, V, W_neg, m0, C0), std::domain_error); - EXPECT_THROW(gaussian_dlm_obs_log(y, FF, GG, V_vec, W_neg, m0, C0), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y, FF, GG, V_vec, W_neg, m0, C0), std::domain_error); // finite and NaN Matrix W_infinite = W; W_infinite(0, 0) = std::numeric_limits::infinity(); - EXPECT_THROW(gaussian_dlm_obs_log(y, FF, GG, V, W_infinite, m0, C0), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y, FF, GG, V, W_infinite, m0, C0), std::domain_error); - EXPECT_THROW(gaussian_dlm_obs_log(y, FF, GG, V_vec, W_infinite, m0, C0), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y, FF, GG, V_vec, W_infinite, m0, C0), std::domain_error); Matrix W_nan = W; W_nan(0, 0) = std::numeric_limits::quiet_NaN(); - EXPECT_THROW(gaussian_dlm_obs_log(y, FF, GG, V, W_nan, m0, C0), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y, FF, GG, V, W_nan, m0, C0), std::domain_error); - EXPECT_THROW(gaussian_dlm_obs_log(y, FF, GG, V_vec, W_nan, m0, C0), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y, FF, GG, V_vec, W_nan, m0, C0), std::domain_error); // wrong size Matrix W_sz = MatrixXd::Identity(4, 4); - EXPECT_THROW(gaussian_dlm_obs_log(y, FF, GG, V, W_sz, m0, C0), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y, FF, GG, V, W_sz, m0, C0), std::invalid_argument); - EXPECT_THROW(gaussian_dlm_obs_log(y, FF, GG, V_vec, W_sz, m0, C0), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y, FF, GG, V_vec, W_sz, m0, C0), std::invalid_argument); // not square Matrix W_notsq = MatrixXd::Identity(2, 3); - EXPECT_THROW(gaussian_dlm_obs_log(y, FF, GG, V, W_notsq, m0, C0), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y, FF, GG, V, W_notsq, m0, C0), std::invalid_argument); - EXPECT_THROW(gaussian_dlm_obs_log(y, FF, GG, V_vec, W_notsq, m0, C0), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y, FF, GG, V_vec, W_notsq, m0, C0), std::invalid_argument); // positive semi-definite is okay Matrix W_psd = MatrixXd::Zero(2, 2); W_psd(0, 0) = 1.0; - EXPECT_NO_THROW(gaussian_dlm_obs_log(y, FF, GG, V, W_psd, m0, C0)); - EXPECT_NO_THROW(gaussian_dlm_obs_log(y, FF, GG, V_vec, W_psd, m0, C0)); + EXPECT_NO_THROW(gaussian_dlm_obs_lpdf(y, FF, GG, V, W_psd, m0, C0)); + EXPECT_NO_THROW(gaussian_dlm_obs_lpdf(y, FF, GG, V_vec, W_psd, m0, C0)); } TEST_F(ProbDistributionsGaussianDLMInputs, PoliciesVMatrix) { using Eigen::Dynamic; using Eigen::Matrix; using Eigen::MatrixXd; - using stan::math::gaussian_dlm_obs_log; + using stan::math::gaussian_dlm_obs_lpdf; // Not symmetric Matrix V_asym = V; V_asym(0, 2) = 1; - EXPECT_THROW(gaussian_dlm_obs_log(y, FF, GG, V_asym, W, m0, C0), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y, FF, GG, V_asym, W, m0, C0), std::domain_error); // negative Matrix V_neg = V; V_neg(0, 2) = -1; - EXPECT_THROW(gaussian_dlm_obs_log(y, FF, GG, V_neg, W, m0, C0), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y, FF, GG, V_neg, W, m0, C0), std::domain_error); // finite and NaN Matrix V_infinite = V; V_infinite(0, 0) = std::numeric_limits::infinity(); - EXPECT_THROW(gaussian_dlm_obs_log(y, FF, GG, V_infinite, W, m0, C0), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y, FF, GG, V_infinite, W, m0, C0), std::domain_error); Matrix V_nan = V; V_nan(0, 0) = std::numeric_limits::quiet_NaN(); - EXPECT_THROW(gaussian_dlm_obs_log(y, FF, GG, V_nan, W, m0, C0), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y, FF, GG, V_nan, W, m0, C0), std::domain_error); // wrong size Matrix V2 = MatrixXd::Identity(2, 2); - EXPECT_THROW(gaussian_dlm_obs_log(y, FF, GG, V2, W, m0, C0), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y, FF, GG, V2, W, m0, C0), std::invalid_argument); // not square Matrix V3 = MatrixXd::Identity(2, 3); - EXPECT_THROW(gaussian_dlm_obs_log(y, FF, GG, V3, W, m0, C0), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y, FF, GG, V3, W, m0, C0), std::invalid_argument); // positive semi-definite is okay Matrix V_psd = MatrixXd::Zero(3, 3); V_psd(0, 0) = 1.0; - EXPECT_NO_THROW(gaussian_dlm_obs_log(y, FF, GG, V_psd, W, m0, C0)); + EXPECT_NO_THROW(gaussian_dlm_obs_lpdf(y, FF, GG, V_psd, W, m0, C0)); } TEST_F(ProbDistributionsGaussianDLMInputs, PoliciesVVector) { using Eigen::Dynamic; using Eigen::Matrix; using Eigen::MatrixXd; - using stan::math::gaussian_dlm_obs_log; + using stan::math::gaussian_dlm_obs_lpdf; // negative Matrix V_neg = V_vec; V_neg(0) = -1; - EXPECT_THROW(gaussian_dlm_obs_log(y, FF, GG, V_neg, W, m0, C0), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y, FF, GG, V_neg, W, m0, C0), std::invalid_argument); // finite and NaN Matrix V_infinite = V_vec; V_infinite(0) = std::numeric_limits::infinity(); - EXPECT_THROW(gaussian_dlm_obs_log(y, FF, GG, V_infinite, W, m0, C0), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y, FF, GG, V_infinite, W, m0, C0), std::domain_error); Matrix V_nan = V_vec; V_nan(0) = std::numeric_limits::quiet_NaN(); - EXPECT_THROW(gaussian_dlm_obs_log(y, FF, GG, V_nan, W, m0, C0), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y, FF, GG, V_nan, W, m0, C0), std::domain_error); // wrong size Matrix V_badsz = Matrix::Constant(2, 1.0); - EXPECT_THROW(gaussian_dlm_obs_log(y, FF, GG, V_badsz, W, m0, C0), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y, FF, GG, V_badsz, W, m0, C0), std::invalid_argument); // positive semi-definite is okay Matrix V_psd = Matrix::Zero(3); V_psd(0) = 1.0; - EXPECT_NO_THROW(gaussian_dlm_obs_log(y, FF, GG, V_psd, W, m0, C0)); + EXPECT_NO_THROW(gaussian_dlm_obs_lpdf(y, FF, GG, V_psd, W, m0, C0)); } TEST_F(ProbDistributionsGaussianDLMInputs, Policiesm0) { using Eigen::Dynamic; using Eigen::Matrix; using Eigen::MatrixXd; - using stan::math::gaussian_dlm_obs_log; + using stan::math::gaussian_dlm_obs_lpdf; // m0 // size Matrix m0_sz = Matrix::Zero(4, 1); - EXPECT_THROW(gaussian_dlm_obs_log(y, FF, GG, V, W, m0_sz, C0), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y, FF, GG, V, W, m0_sz, C0), std::invalid_argument); - EXPECT_THROW(gaussian_dlm_obs_log(y, FF, GG, V_vec, W, m0_sz, C0), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y, FF, GG, V_vec, W, m0_sz, C0), std::invalid_argument); // finite and NaN Matrix m0_inf = m0; m0_inf(0) = std::numeric_limits::infinity(); - EXPECT_THROW(gaussian_dlm_obs_log(y, FF, GG, V, W, m0_inf, C0), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y, FF, GG, V, W, m0_inf, C0), std::domain_error); - EXPECT_THROW(gaussian_dlm_obs_log(y, FF, GG, V_vec, W, m0_inf, C0), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y, FF, GG, V_vec, W, m0_inf, C0), std::domain_error); Matrix m0_nan = m0; m0_nan(0) = std::numeric_limits::quiet_NaN(); - EXPECT_THROW(gaussian_dlm_obs_log(y, FF, GG, V, W, m0_nan, C0), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y, FF, GG, V, W, m0_nan, C0), std::domain_error); - EXPECT_THROW(gaussian_dlm_obs_log(y, FF, GG, V_vec, W, m0_nan, C0), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y, FF, GG, V_vec, W, m0_nan, C0), std::domain_error); } @@ -386,53 +386,53 @@ TEST_F(ProbDistributionsGaussianDLMInputs, PoliciesC0) { using Eigen::Dynamic; using Eigen::Matrix; using Eigen::MatrixXd; - using stan::math::gaussian_dlm_obs_log; + using stan::math::gaussian_dlm_obs_lpdf; // size Matrix C0_sz = MatrixXd::Identity(3, 3); - EXPECT_THROW(gaussian_dlm_obs_log(y, FF, GG, V, W, m0, C0_sz), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y, FF, GG, V, W, m0, C0_sz), std::invalid_argument); - EXPECT_THROW(gaussian_dlm_obs_log(y, FF, GG, V_vec, W, m0, C0_sz), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y, FF, GG, V_vec, W, m0, C0_sz), std::invalid_argument); // negative Matrix C0_neg = C0; C0_neg(0, 0) = -1; - EXPECT_THROW(gaussian_dlm_obs_log(y, FF, GG, V, W, m0, C0_neg), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y, FF, GG, V, W, m0, C0_neg), std::domain_error); - EXPECT_THROW(gaussian_dlm_obs_log(y, FF, GG, V_vec, W, m0, C0_neg), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y, FF, GG, V_vec, W, m0, C0_neg), std::domain_error); // asymmetric Matrix C0_asym = C0; C0_asym(0, 1) = 1; - EXPECT_THROW(gaussian_dlm_obs_log(y, FF, GG, V, W, m0, C0_asym), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y, FF, GG, V, W, m0, C0_asym), std::domain_error); - EXPECT_THROW(gaussian_dlm_obs_log(y, FF, GG, V_vec, W, m0, C0_neg), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y, FF, GG, V_vec, W, m0, C0_neg), std::domain_error); // not square Matrix C0_notsq = MatrixXd::Identity(3, 2); - EXPECT_THROW(gaussian_dlm_obs_log(y, FF, GG, V, W, m0, C0_notsq), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y, FF, GG, V, W, m0, C0_notsq), std::invalid_argument); - EXPECT_THROW(gaussian_dlm_obs_log(y, FF, GG, V_vec, W, m0, C0_notsq), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y, FF, GG, V_vec, W, m0, C0_notsq), std::invalid_argument); // positive semi-definite is okay Matrix C0_psd = MatrixXd::Zero(2, 2); C0_psd(0, 0) = 1.0; - EXPECT_NO_THROW(gaussian_dlm_obs_log(y, FF, GG, V, W, m0, C0_psd)); - EXPECT_NO_THROW(gaussian_dlm_obs_log(y, FF, GG, V_vec, W, m0, C0_psd)); + EXPECT_NO_THROW(gaussian_dlm_obs_lpdf(y, FF, GG, V, W, m0, C0_psd)); + EXPECT_NO_THROW(gaussian_dlm_obs_lpdf(y, FF, GG, V_vec, W, m0, C0_psd)); } TEST_F(ProbDistributionsGaussianDLMInputs, PoliciesQ0) { using Eigen::Dynamic; using Eigen::Matrix; using Eigen::MatrixXd; - using stan::math::gaussian_dlm_obs_log; + using stan::math::gaussian_dlm_obs_lpdf; // Not positive definite Matrix W_0 = W * 0; Matrix V_0 = V * 0; Matrix V_vec_0 = V_vec * 0; Matrix C0_0 = C0 * 0; - EXPECT_THROW(gaussian_dlm_obs_log(y, FF, GG, V_0, W_0, m0, C0_0), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y, FF, GG, V_0, W_0, m0, C0_0), std::domain_error); - EXPECT_THROW(gaussian_dlm_obs_log(y, FF, GG, V_vec_0, W_0, m0, C0_0), + EXPECT_THROW(gaussian_dlm_obs_lpdf(y, FF, GG, V_vec_0, W_0, m0, C0_0), std::domain_error); } diff --git a/test/unit/math/prim/prob/inv_wishart_test.cpp b/test/unit/math/prim/prob/inv_wishart_test.cpp index e7871b6c8ef..58f00da356d 100644 --- a/test/unit/math/prim/prob/inv_wishart_test.cpp +++ b/test/unit/math/prim/prob/inv_wishart_test.cpp @@ -9,7 +9,7 @@ TEST(ProbDistributionsInvWishart, inv_wishart_symmetry) { using Eigen::Matrix; using Eigen::MatrixXd; - using stan::math::inv_wishart_log; + using stan::math::inv_wishart_lpdf; MatrixXd Sigma(4, 4); MatrixXd Sigma_non_sym(4, 4); @@ -34,9 +34,9 @@ TEST(ProbDistributionsInvWishart, inv_wishart_symmetry) { unsigned int dof = 5; - EXPECT_NO_THROW(inv_wishart_log(Y, dof, Sigma)); - EXPECT_THROW(inv_wishart_log(Y_non_sym, dof, Sigma), std::domain_error); - EXPECT_THROW(inv_wishart_log(Y, dof, Sigma_non_sym), std::domain_error); + EXPECT_NO_THROW(inv_wishart_lpdf(Y, dof, Sigma)); + EXPECT_THROW(inv_wishart_lpdf(Y_non_sym, dof, Sigma), std::domain_error); + EXPECT_THROW(inv_wishart_lpdf(Y, dof, Sigma_non_sym), std::domain_error); } TEST(ProbDistributionsInvWishart, inv_wishart_pos_def) { @@ -44,7 +44,7 @@ TEST(ProbDistributionsInvWishart, inv_wishart_pos_def) { using Eigen::Matrix; using Eigen::MatrixXd; - using stan::math::inv_wishart_log; + using stan::math::inv_wishart_lpdf; MatrixXd Sigma(2, 2); MatrixXd Sigma_non_pos_def(2, 2); @@ -58,16 +58,16 @@ TEST(ProbDistributionsInvWishart, inv_wishart_pos_def) { unsigned int dof = 5; - EXPECT_NO_THROW(inv_wishart_log(Y, dof, Sigma)); - EXPECT_THROW(inv_wishart_log(Y_non_pos_def, dof, Sigma), std::domain_error); - EXPECT_THROW(inv_wishart_log(Y, dof, Sigma_non_pos_def), std::domain_error); + EXPECT_NO_THROW(inv_wishart_lpdf(Y, dof, Sigma)); + EXPECT_THROW(inv_wishart_lpdf(Y_non_pos_def, dof, Sigma), std::domain_error); + EXPECT_THROW(inv_wishart_lpdf(Y, dof, Sigma_non_pos_def), std::domain_error); } TEST(ProbDistributionsInvWishart, InvWishart) { using Eigen::Dynamic; using Eigen::Matrix; - using stan::math::inv_wishart_log; + using stan::math::inv_wishart_lpdf; Matrix Y(3, 3); Y << 12.147233, -11.903608, 1.0910458, -11.903608, 16.7585782, 0.8530256, 1.0910458, 0.8530256, 2.5786609; @@ -79,13 +79,13 @@ TEST(ProbDistributionsInvWishart, InvWishart) { double dof = 4.0; double log_p = log(2.008407e-08); - EXPECT_NEAR(log_p, stan::math::inv_wishart_log(Y, dof, Sigma), 0.01); + EXPECT_NEAR(log_p, stan::math::inv_wishart_lpdf(Y, dof, Sigma), 0.01); } TEST(ProbDistributionsInvWishart, Propto) { using Eigen::Dynamic; using Eigen::Matrix; - using stan::math::inv_wishart_log; + using stan::math::inv_wishart_lpdf; Matrix Y(3, 3); Y << 12.147233, -11.903608, 1.091046, -11.903608, 16.7585782, 0.8530256, 1.091046, 0.8530256, 2.5786609; @@ -96,13 +96,13 @@ TEST(ProbDistributionsInvWishart, Propto) { double dof = 4.0; - EXPECT_FLOAT_EQ(0.0, stan::math::inv_wishart_log(Y, dof, Sigma)); + EXPECT_FLOAT_EQ(0.0, stan::math::inv_wishart_lpdf(Y, dof, Sigma)); } TEST(ProbDistributionsInvWishart, Error) { using Eigen::Dynamic; using Eigen::Matrix; - using stan::math::inv_wishart_log; + using stan::math::inv_wishart_lpdf; Matrix Sigma; Matrix Y; double nu; @@ -112,28 +112,28 @@ TEST(ProbDistributionsInvWishart, Error) { Sigma.setIdentity(); Y.setIdentity(); nu = 1; - EXPECT_NO_THROW(inv_wishart_log(Y, nu, Sigma)); + EXPECT_NO_THROW(inv_wishart_lpdf(Y, nu, Sigma)); nu = 5; Sigma.resize(2, 1); - EXPECT_THROW(inv_wishart_log(Y, nu, Sigma), std::invalid_argument); + EXPECT_THROW(inv_wishart_lpdf(Y, nu, Sigma), std::invalid_argument); nu = 5; Sigma.resize(2, 2); Y.resize(2, 1); - EXPECT_THROW(inv_wishart_log(Y, nu, Sigma), std::invalid_argument); + EXPECT_THROW(inv_wishart_lpdf(Y, nu, Sigma), std::invalid_argument); nu = 5; Sigma.resize(2, 2); Y.resize(3, 3); - EXPECT_THROW(inv_wishart_log(Y, nu, Sigma), std::invalid_argument); + EXPECT_THROW(inv_wishart_lpdf(Y, nu, Sigma), std::invalid_argument); Sigma.resize(3, 3); Sigma.setIdentity(); Y.resize(3, 3); Y.setIdentity(); nu = 3; - EXPECT_NO_THROW(inv_wishart_log(Y, nu, Sigma)); + EXPECT_NO_THROW(inv_wishart_lpdf(Y, nu, Sigma)); nu = 2; - EXPECT_THROW(inv_wishart_log(Y, nu, Sigma), std::domain_error); + EXPECT_THROW(inv_wishart_lpdf(Y, nu, Sigma), std::domain_error); } diff --git a/test/unit/math/prim/prob/lkj_corr_test.cpp b/test/unit/math/prim/prob/lkj_corr_test.cpp index 49d0400aa18..220f19eb828 100644 --- a/test/unit/math/prim/prob/lkj_corr_test.cpp +++ b/test/unit/math/prim/prob/lkj_corr_test.cpp @@ -11,10 +11,10 @@ TEST(ProbDistributionsLkjCorr, testIdentity) { Sigma.diagonal().setOnes(); double eta = stan::math::uniform_rng(0, 2, rng); double f = stan::math::do_lkj_constant(eta, K); - EXPECT_FLOAT_EQ(f, stan::math::lkj_corr_log(Sigma, eta)); + EXPECT_FLOAT_EQ(f, stan::math::lkj_corr_lpdf(Sigma, eta)); eta = 1.0; f = stan::math::do_lkj_constant(eta, K); - EXPECT_FLOAT_EQ(f, stan::math::lkj_corr_log(Sigma, eta)); + EXPECT_FLOAT_EQ(f, stan::math::lkj_corr_lpdf(Sigma, eta)); } TEST(ProbDistributionsLkjCorr, testHalf) { @@ -26,10 +26,10 @@ TEST(ProbDistributionsLkjCorr, testHalf) { double eta = stan::math::uniform_rng(0, 2, rng); double f = stan::math::do_lkj_constant(eta, K); EXPECT_FLOAT_EQ(f + (eta - 1.0) * log(0.3125), - stan::math::lkj_corr_log(Sigma, eta)); + stan::math::lkj_corr_lpdf(Sigma, eta)); eta = 1.0; f = stan::math::do_lkj_constant(eta, K); - EXPECT_FLOAT_EQ(f, stan::math::lkj_corr_log(Sigma, eta)); + EXPECT_FLOAT_EQ(f, stan::math::lkj_corr_lpdf(Sigma, eta)); } TEST(ProbDistributionsLkjCorr, Sigma) { @@ -39,18 +39,18 @@ TEST(ProbDistributionsLkjCorr, Sigma) { Sigma.setZero(); Sigma.diagonal().setOnes(); double eta = stan::math::uniform_rng(0, 2, rng); - EXPECT_NO_THROW(stan::math::lkj_corr_log(Sigma, eta)); + EXPECT_NO_THROW(stan::math::lkj_corr_lpdf(Sigma, eta)); - EXPECT_THROW(stan::math::lkj_corr_log(Sigma, -eta), std::domain_error); + EXPECT_THROW(stan::math::lkj_corr_lpdf(Sigma, -eta), std::domain_error); Sigma = Sigma * -1.0; - EXPECT_THROW(stan::math::lkj_corr_log(Sigma, eta), std::domain_error); + EXPECT_THROW(stan::math::lkj_corr_lpdf(Sigma, eta), std::domain_error); Sigma = Sigma * (0.0 / 0.0); - EXPECT_THROW(stan::math::lkj_corr_log(Sigma, eta), std::domain_error); + EXPECT_THROW(stan::math::lkj_corr_lpdf(Sigma, eta), std::domain_error); Sigma.setConstant(0.5); Sigma.diagonal().setOnes(); - EXPECT_THROW(stan::math::lkj_corr_cholesky_log(Sigma, eta), + EXPECT_THROW(stan::math::lkj_corr_cholesky_lpdf(Sigma, eta), std::domain_error); } @@ -108,10 +108,10 @@ TEST(ProbDistributionsLkjCorrCholesky, testIdentity) { Sigma.diagonal().setOnes(); double eta = stan::math::uniform_rng(0, 2, rng); double f = stan::math::do_lkj_constant(eta, K); - EXPECT_FLOAT_EQ(f, stan::math::lkj_corr_cholesky_log(Sigma, eta)); + EXPECT_FLOAT_EQ(f, stan::math::lkj_corr_cholesky_lpdf(Sigma, eta)); eta = 1.0; f = stan::math::do_lkj_constant(eta, K); - EXPECT_FLOAT_EQ(f, stan::math::lkj_corr_cholesky_log(Sigma, eta)); + EXPECT_FLOAT_EQ(f, stan::math::lkj_corr_cholesky_lpdf(Sigma, eta)); } TEST(ProbDistributionsLkjCorrCholesky, testHalf) { @@ -123,9 +123,9 @@ TEST(ProbDistributionsLkjCorrCholesky, testHalf) { Eigen::MatrixXd L = Sigma.llt().matrixL(); double eta = stan::math::uniform_rng(0, 2, rng); double f = stan::math::do_lkj_constant(eta, K); - EXPECT_FLOAT_EQ(stan::math::lkj_corr_log(Sigma, eta) - 0.4904146, - stan::math::lkj_corr_cholesky_log(L, eta)); + EXPECT_FLOAT_EQ(stan::math::lkj_corr_lpdf(Sigma, eta) - 0.4904146, + stan::math::lkj_corr_cholesky_lpdf(L, eta)); eta = 1.0; f = stan::math::do_lkj_constant(eta, K); - EXPECT_FLOAT_EQ(f - 0.4904146, stan::math::lkj_corr_cholesky_log(L, eta)); + EXPECT_FLOAT_EQ(f - 0.4904146, stan::math::lkj_corr_cholesky_lpdf(L, eta)); } diff --git a/test/unit/math/prim/prob/multi_gp_cholesky_test.cpp b/test/unit/math/prim/prob/multi_gp_cholesky_test.cpp index b200ccc061f..45ed966db9d 100644 --- a/test/unit/math/prim/prob/multi_gp_cholesky_test.cpp +++ b/test/unit/math/prim/prob/multi_gp_cholesky_test.cpp @@ -24,10 +24,10 @@ TEST(ProbDistributionsMultiGPCholesky, MultiGPCholesky) { for (size_t i = 0; i < 3; i++) { Matrix cy(y.row(i).transpose()); Matrix cSigma((1.0 / w[i]) * Sigma); - lp_ref += stan::math::multi_normal_log(cy, mu, cSigma); + lp_ref += stan::math::multi_normal_lpdf(cy, mu, cSigma); } - EXPECT_FLOAT_EQ(lp_ref, stan::math::multi_gp_cholesky_log(y, L, w)); + EXPECT_FLOAT_EQ(lp_ref, stan::math::multi_gp_cholesky_lpdf(y, L, w)); } TEST(ProbDistributionsMultiGPCholesky, ErrorL) { @@ -65,15 +65,15 @@ TEST(ProbDistributionsMultiGPCholesky, ErrorW) { // negative w w(0, 0) = -2.5; - EXPECT_THROW(stan::math::multi_gp_cholesky_log(y, L, w), std::domain_error); + EXPECT_THROW(stan::math::multi_gp_cholesky_lpdf(y, L, w), std::domain_error); // non-finite values w(0, 0) = std::numeric_limits::infinity(); - EXPECT_THROW(stan::math::multi_gp_cholesky_log(y, L, w), std::domain_error); + EXPECT_THROW(stan::math::multi_gp_cholesky_lpdf(y, L, w), std::domain_error); w(0, 0) = -std::numeric_limits::infinity(); - EXPECT_THROW(stan::math::multi_gp_cholesky_log(y, L, w), std::domain_error); + EXPECT_THROW(stan::math::multi_gp_cholesky_lpdf(y, L, w), std::domain_error); w(0, 0) = std::numeric_limits::quiet_NaN(); - EXPECT_THROW(stan::math::multi_gp_cholesky_log(y, L, w), std::domain_error); + EXPECT_THROW(stan::math::multi_gp_cholesky_lpdf(y, L, w), std::domain_error); } TEST(ProbDistributionsMultiGPCholesky, ErrorY) { @@ -94,9 +94,9 @@ TEST(ProbDistributionsMultiGPCholesky, ErrorY) { // non-finite values y(0, 0) = std::numeric_limits::infinity(); - EXPECT_THROW(stan::math::multi_gp_cholesky_log(y, L, w), std::domain_error); + EXPECT_THROW(stan::math::multi_gp_cholesky_lpdf(y, L, w), std::domain_error); y(0, 0) = -std::numeric_limits::infinity(); - EXPECT_THROW(stan::math::multi_gp_cholesky_log(y, L, w), std::domain_error); + EXPECT_THROW(stan::math::multi_gp_cholesky_lpdf(y, L, w), std::domain_error); y(0, 0) = std::numeric_limits::quiet_NaN(); - EXPECT_THROW(stan::math::multi_gp_cholesky_log(y, L, w), std::domain_error); + EXPECT_THROW(stan::math::multi_gp_cholesky_lpdf(y, L, w), std::domain_error); } diff --git a/test/unit/math/prim/prob/multi_gp_test.cpp b/test/unit/math/prim/prob/multi_gp_test.cpp index 0943f311a0e..c795b01a8e3 100644 --- a/test/unit/math/prim/prob/multi_gp_test.cpp +++ b/test/unit/math/prim/prob/multi_gp_test.cpp @@ -23,10 +23,10 @@ TEST(ProbDistributionsMultiGP, MultiGP) { for (size_t i = 0; i < 3; i++) { Matrix cy(y.row(i).transpose()); Matrix cSigma((1.0 / w[i]) * Sigma); - lp_ref += stan::math::multi_normal_log(cy, mu, cSigma); + lp_ref += stan::math::multi_normal_lpdf(cy, mu, cSigma); } - EXPECT_FLOAT_EQ(lp_ref, stan::math::multi_gp_log(y, Sigma, w)); + EXPECT_FLOAT_EQ(lp_ref, stan::math::multi_gp_lpdf(y, Sigma, w)); } TEST(ProbDistributionsMultiGP, ErrorSigma) { @@ -45,12 +45,12 @@ TEST(ProbDistributionsMultiGP, ErrorSigma) { // non-symmetric Sigma(0, 1) = -2.5; - EXPECT_THROW(stan::math::multi_gp_log(y, Sigma, w), std::domain_error); + EXPECT_THROW(stan::math::multi_gp_lpdf(y, Sigma, w), std::domain_error); Sigma(0, 1) = Sigma(1, 0); // non-spd Sigma(0, 0) = -3.0; - EXPECT_THROW(stan::math::multi_gp_log(y, Sigma, w), std::domain_error); + EXPECT_THROW(stan::math::multi_gp_lpdf(y, Sigma, w), std::domain_error); Sigma(0, 1) = 9.0; } @@ -70,15 +70,15 @@ TEST(ProbDistributionsMultiGP, ErrorW) { // negative w w(0, 0) = -2.5; - EXPECT_THROW(stan::math::multi_gp_log(y, Sigma, w), std::domain_error); + EXPECT_THROW(stan::math::multi_gp_lpdf(y, Sigma, w), std::domain_error); // non-finite values w(0, 0) = std::numeric_limits::infinity(); - EXPECT_THROW(stan::math::multi_gp_log(y, Sigma, w), std::domain_error); + EXPECT_THROW(stan::math::multi_gp_lpdf(y, Sigma, w), std::domain_error); w(0, 0) = -std::numeric_limits::infinity(); - EXPECT_THROW(stan::math::multi_gp_log(y, Sigma, w), std::domain_error); + EXPECT_THROW(stan::math::multi_gp_lpdf(y, Sigma, w), std::domain_error); w(0, 0) = std::numeric_limits::quiet_NaN(); - EXPECT_THROW(stan::math::multi_gp_log(y, Sigma, w), std::domain_error); + EXPECT_THROW(stan::math::multi_gp_lpdf(y, Sigma, w), std::domain_error); } TEST(ProbDistributionsMultiGP, ErrorY) { @@ -97,9 +97,9 @@ TEST(ProbDistributionsMultiGP, ErrorY) { // non-finite values y(0, 0) = std::numeric_limits::infinity(); - EXPECT_THROW(stan::math::multi_gp_log(y, Sigma, w), std::domain_error); + EXPECT_THROW(stan::math::multi_gp_lpdf(y, Sigma, w), std::domain_error); y(0, 0) = -std::numeric_limits::infinity(); - EXPECT_THROW(stan::math::multi_gp_log(y, Sigma, w), std::domain_error); + EXPECT_THROW(stan::math::multi_gp_lpdf(y, Sigma, w), std::domain_error); y(0, 0) = std::numeric_limits::quiet_NaN(); - EXPECT_THROW(stan::math::multi_gp_log(y, Sigma, w), std::domain_error); + EXPECT_THROW(stan::math::multi_gp_lpdf(y, Sigma, w), std::domain_error); } diff --git a/test/unit/math/prim/prob/multi_normal_cholesky_test.cpp b/test/unit/math/prim/prob/multi_normal_cholesky_test.cpp index 798741f3b0d..03e5c9e089a 100644 --- a/test/unit/math/prim/prob/multi_normal_cholesky_test.cpp +++ b/test/unit/math/prim/prob/multi_normal_cholesky_test.cpp @@ -16,7 +16,7 @@ TEST(ProbDistributionsMultiNormalCholesky, NotVectorized) { Matrix Sigma(3, 3); Sigma << 9.0, -3.0, 0.0, -3.0, 4.0, 0.0, 0.0, 0.0, 5.0; Matrix L = Sigma.llt().matrixL(); - EXPECT_FLOAT_EQ(-11.73908, stan::math::multi_normal_cholesky_log(y, mu, L)); + EXPECT_FLOAT_EQ(-11.73908, stan::math::multi_normal_cholesky_lpdf(y, mu, L)); EXPECT_NO_THROW(stan::math::multi_normal_cholesky_rng(mu, L, rng)); } TEST(ProbDistributionsMultiNormalCholesky, Vectorized) { @@ -54,33 +54,33 @@ TEST(ProbDistributionsMultiNormalCholesky, Vectorized) { // y and mu vectorized EXPECT_FLOAT_EQ(-11.928077 - 6.5378327, - stan::math::multi_normal_cholesky_log(vec_y, vec_mu, L)); + stan::math::multi_normal_cholesky_lpdf(vec_y, vec_mu, L)); EXPECT_FLOAT_EQ(-11.928077 - 6.5378327, - stan::math::multi_normal_cholesky_log(vec_y_t, vec_mu, L)); + stan::math::multi_normal_cholesky_lpdf(vec_y_t, vec_mu, L)); EXPECT_FLOAT_EQ(-11.928077 - 6.5378327, - stan::math::multi_normal_cholesky_log(vec_y, vec_mu_t, L)); + stan::math::multi_normal_cholesky_lpdf(vec_y, vec_mu_t, L)); EXPECT_FLOAT_EQ(-11.928077 - 6.5378327, - stan::math::multi_normal_cholesky_log(vec_y_t, vec_mu_t, L)); + stan::math::multi_normal_cholesky_lpdf(vec_y_t, vec_mu_t, L)); // y vectorized EXPECT_FLOAT_EQ(-10.44027 - 6.537833, - stan::math::multi_normal_cholesky_log(vec_y, mu, L)); + stan::math::multi_normal_cholesky_lpdf(vec_y, mu, L)); EXPECT_FLOAT_EQ(-10.44027 - 6.537833, - stan::math::multi_normal_cholesky_log(vec_y_t, mu, L)); + stan::math::multi_normal_cholesky_lpdf(vec_y_t, mu, L)); EXPECT_FLOAT_EQ(-10.44027 - 6.537833, - stan::math::multi_normal_cholesky_log(vec_y, mu_t, L)); + stan::math::multi_normal_cholesky_lpdf(vec_y, mu_t, L)); EXPECT_FLOAT_EQ(-10.44027 - 6.537833, - stan::math::multi_normal_cholesky_log(vec_y_t, mu_t, L)); + stan::math::multi_normal_cholesky_lpdf(vec_y_t, mu_t, L)); // mu vectorized EXPECT_FLOAT_EQ(-6.26954 - 6.537833, - stan::math::multi_normal_cholesky_log(y, vec_mu, L)); + stan::math::multi_normal_cholesky_lpdf(y, vec_mu, L)); EXPECT_FLOAT_EQ(-6.26954 - 6.537833, - stan::math::multi_normal_cholesky_log(y_t, vec_mu, L)); + stan::math::multi_normal_cholesky_lpdf(y_t, vec_mu, L)); EXPECT_FLOAT_EQ(-6.26954 - 6.537833, - stan::math::multi_normal_cholesky_log(y, vec_mu_t, L)); + stan::math::multi_normal_cholesky_lpdf(y, vec_mu_t, L)); EXPECT_FLOAT_EQ(-6.26954 - 6.537833, - stan::math::multi_normal_cholesky_log(y_t, vec_mu_t, L)); + stan::math::multi_normal_cholesky_lpdf(y_t, vec_mu_t, L)); EXPECT_NO_THROW(stan::math::multi_normal_cholesky_rng(vec_mu, L, rng)); EXPECT_NO_THROW(stan::math::multi_normal_cholesky_rng(vec_mu_t, L, rng)); } @@ -97,7 +97,7 @@ TEST(ProbDistributionsMultiNormalCholesky, MultiNormalOneRow) { Matrix Sigma(3, 3); Sigma << 9.0, -3.0, 0.0, -3.0, 4.0, 0.0, 0.0, 0.0, 5.0; Matrix L = Sigma.llt().matrixL(); - EXPECT_FLOAT_EQ(-11.73908, stan::math::multi_normal_cholesky_log(y, mu, L)); + EXPECT_FLOAT_EQ(-11.73908, stan::math::multi_normal_cholesky_lpdf(y, mu, L)); EXPECT_NO_THROW(stan::math::multi_normal_cholesky_rng(mu, L, rng)); } diff --git a/test/unit/math/prim/prob/multi_normal_prec_test.cpp b/test/unit/math/prim/prob/multi_normal_prec_test.cpp index 19cbb078461..7d19c8dee08 100644 --- a/test/unit/math/prim/prob/multi_normal_prec_test.cpp +++ b/test/unit/math/prim/prob/multi_normal_prec_test.cpp @@ -13,7 +13,7 @@ TEST(ProbDistributionsMultiNormalPrec, NotVectorized) { Matrix Sigma(3, 3); Sigma << 9.0, -3.0, 0.0, -3.0, 4.0, 0.0, 0.0, 0.0, 5.0; Matrix L = Sigma.inverse(); - EXPECT_FLOAT_EQ(-11.73908, stan::math::multi_normal_prec_log(y, mu, L)); + EXPECT_FLOAT_EQ(-11.73908, stan::math::multi_normal_prec_lpdf(y, mu, L)); } TEST(ProbDistributionsMultiNormalPrec, Vectorized) { @@ -50,33 +50,33 @@ TEST(ProbDistributionsMultiNormalPrec, Vectorized) { // y and mu vectorized EXPECT_FLOAT_EQ(-11.928077 - 6.5378327, - stan::math::multi_normal_prec_log(vec_y, vec_mu, Sigma)); + stan::math::multi_normal_prec_lpdf(vec_y, vec_mu, Sigma)); EXPECT_FLOAT_EQ(-11.928077 - 6.5378327, - stan::math::multi_normal_prec_log(vec_y_t, vec_mu, Sigma)); + stan::math::multi_normal_prec_lpdf(vec_y_t, vec_mu, Sigma)); EXPECT_FLOAT_EQ(-11.928077 - 6.5378327, - stan::math::multi_normal_prec_log(vec_y, vec_mu_t, Sigma)); + stan::math::multi_normal_prec_lpdf(vec_y, vec_mu_t, Sigma)); EXPECT_FLOAT_EQ(-11.928077 - 6.5378327, - stan::math::multi_normal_prec_log(vec_y_t, vec_mu_t, Sigma)); + stan::math::multi_normal_prec_lpdf(vec_y_t, vec_mu_t, Sigma)); // y vectorized EXPECT_FLOAT_EQ(-10.44027 - 6.537833, - stan::math::multi_normal_prec_log(vec_y, mu, Sigma)); + stan::math::multi_normal_prec_lpdf(vec_y, mu, Sigma)); EXPECT_FLOAT_EQ(-10.44027 - 6.537833, - stan::math::multi_normal_prec_log(vec_y_t, mu, Sigma)); + stan::math::multi_normal_prec_lpdf(vec_y_t, mu, Sigma)); EXPECT_FLOAT_EQ(-10.44027 - 6.537833, - stan::math::multi_normal_prec_log(vec_y, mu_t, Sigma)); + stan::math::multi_normal_prec_lpdf(vec_y, mu_t, Sigma)); EXPECT_FLOAT_EQ(-10.44027 - 6.537833, - stan::math::multi_normal_prec_log(vec_y_t, mu_t, Sigma)); + stan::math::multi_normal_prec_lpdf(vec_y_t, mu_t, Sigma)); // mu vectorized EXPECT_FLOAT_EQ(-6.26954 - 6.537833, - stan::math::multi_normal_prec_log(y, vec_mu, Sigma)); + stan::math::multi_normal_prec_lpdf(y, vec_mu, Sigma)); EXPECT_FLOAT_EQ(-6.26954 - 6.537833, - stan::math::multi_normal_prec_log(y_t, vec_mu, Sigma)); + stan::math::multi_normal_prec_lpdf(y_t, vec_mu, Sigma)); EXPECT_FLOAT_EQ(-6.26954 - 6.537833, - stan::math::multi_normal_prec_log(y, vec_mu_t, Sigma)); + stan::math::multi_normal_prec_lpdf(y, vec_mu_t, Sigma)); EXPECT_FLOAT_EQ(-6.26954 - 6.537833, - stan::math::multi_normal_prec_log(y_t, vec_mu_t, Sigma)); + stan::math::multi_normal_prec_lpdf(y_t, vec_mu_t, Sigma)); } /* TEST(ProbDistributionsMultiNormalPrec, MultiNormalOneRow) { @@ -89,7 +89,7 @@ TEST(ProbDistributionsMultiNormalPrec, MultiNormalOneRow) { -3.0, 4.0, 0.0, 0.0, 0.0, 5.0; Matrix L = Sigma.inverse(); - EXPECT_FLOAT_EQ(-11.73908, stan::math::multi_normal_prec_log(y, mu, L)); + EXPECT_FLOAT_EQ(-11.73908, stan::math::multi_normal_prec_lpdf(y, mu, L)); } TEST(ProbDistributionsMultiNormalPrec, MultiNormalMultiRow) { @@ -103,7 +103,7 @@ TEST(ProbDistributionsMultiNormalPrec, MultiNormalMultiRow) { -3.0, 4.0, 0.0, 0.0, 0.0, 5.0; Matrix L = Sigma.inverse(); - EXPECT_FLOAT_EQ(-54.2152, stan::math::multi_normal_prec_log(y, mu, L)); + EXPECT_FLOAT_EQ(-54.2152, stan::math::multi_normal_prec_lpdf(y, mu, L)); } */ diff --git a/test/unit/math/prim/prob/multi_normal_test.cpp b/test/unit/math/prim/prob/multi_normal_test.cpp index 4cf0f4bcf3d..c8a56e62aa0 100644 --- a/test/unit/math/prim/prob/multi_normal_test.cpp +++ b/test/unit/math/prim/prob/multi_normal_test.cpp @@ -17,7 +17,7 @@ TEST(ProbDistributionsMultiNormal, NotVectorized) { mu << 1.0, -1.0, 3.0; Matrix Sigma(3, 3); Sigma << 9.0, -3.0, 0.0, -3.0, 4.0, 0.0, 0.0, 0.0, 5.0; - EXPECT_FLOAT_EQ(-11.73908, stan::math::multi_normal_log(y, mu, Sigma)); + EXPECT_FLOAT_EQ(-11.73908, stan::math::multi_normal_lpdf(y, mu, Sigma)); EXPECT_NO_THROW(stan::math::multi_normal_rng(mu, Sigma, rng)); } @@ -55,33 +55,33 @@ TEST(ProbDistributionsMultiNormal, Vectorized) { // y and mu vectorized EXPECT_FLOAT_EQ(-11.928077 - 6.5378327, - stan::math::multi_normal_log(vec_y, vec_mu, Sigma)); + stan::math::multi_normal_lpdf(vec_y, vec_mu, Sigma)); EXPECT_FLOAT_EQ(-11.928077 - 6.5378327, - stan::math::multi_normal_log(vec_y_t, vec_mu, Sigma)); + stan::math::multi_normal_lpdf(vec_y_t, vec_mu, Sigma)); EXPECT_FLOAT_EQ(-11.928077 - 6.5378327, - stan::math::multi_normal_log(vec_y, vec_mu_t, Sigma)); + stan::math::multi_normal_lpdf(vec_y, vec_mu_t, Sigma)); EXPECT_FLOAT_EQ(-11.928077 - 6.5378327, - stan::math::multi_normal_log(vec_y_t, vec_mu_t, Sigma)); + stan::math::multi_normal_lpdf(vec_y_t, vec_mu_t, Sigma)); // y vectorized EXPECT_FLOAT_EQ(-10.44027 - 6.537833, - stan::math::multi_normal_log(vec_y, mu, Sigma)); + stan::math::multi_normal_lpdf(vec_y, mu, Sigma)); EXPECT_FLOAT_EQ(-10.44027 - 6.537833, - stan::math::multi_normal_log(vec_y_t, mu, Sigma)); + stan::math::multi_normal_lpdf(vec_y_t, mu, Sigma)); EXPECT_FLOAT_EQ(-10.44027 - 6.537833, - stan::math::multi_normal_log(vec_y, mu_t, Sigma)); + stan::math::multi_normal_lpdf(vec_y, mu_t, Sigma)); EXPECT_FLOAT_EQ(-10.44027 - 6.537833, - stan::math::multi_normal_log(vec_y_t, mu_t, Sigma)); + stan::math::multi_normal_lpdf(vec_y_t, mu_t, Sigma)); // mu vectorized EXPECT_FLOAT_EQ(-6.26954 - 6.537833, - stan::math::multi_normal_log(y, vec_mu, Sigma)); + stan::math::multi_normal_lpdf(y, vec_mu, Sigma)); EXPECT_FLOAT_EQ(-6.26954 - 6.537833, - stan::math::multi_normal_log(y_t, vec_mu, Sigma)); + stan::math::multi_normal_lpdf(y_t, vec_mu, Sigma)); EXPECT_FLOAT_EQ(-6.26954 - 6.537833, - stan::math::multi_normal_log(y, vec_mu_t, Sigma)); + stan::math::multi_normal_lpdf(y, vec_mu_t, Sigma)); EXPECT_FLOAT_EQ(-6.26954 - 6.537833, - stan::math::multi_normal_log(y_t, vec_mu_t, Sigma)); + stan::math::multi_normal_lpdf(y_t, vec_mu_t, Sigma)); EXPECT_NO_THROW(stan::math::multi_normal_rng(vec_mu, Sigma, rng)); EXPECT_NO_THROW(stan::math::multi_normal_rng(vec_mu_t, Sigma, rng)); } @@ -96,12 +96,12 @@ TEST(ProbDistributionsMultiNormal, Sigma) { mu << 1.0, -1.0; Matrix Sigma(2, 2); Sigma << 9.0, -3.0, -3.0, 4.0; - EXPECT_NO_THROW(stan::math::multi_normal_log(y, mu, Sigma)); + EXPECT_NO_THROW(stan::math::multi_normal_lpdf(y, mu, Sigma)); EXPECT_NO_THROW(stan::math::multi_normal_rng(mu, Sigma, rng)); // non-symmetric Sigma(0, 1) = -2.5; - EXPECT_THROW(stan::math::multi_normal_log(y, mu, Sigma), std::domain_error); + EXPECT_THROW(stan::math::multi_normal_lpdf(y, mu, Sigma), std::domain_error); EXPECT_THROW(stan::math::multi_normal_rng(mu, Sigma, rng), std::domain_error); } TEST(ProbDistributionsMultiNormal, Mu) { @@ -115,17 +115,17 @@ TEST(ProbDistributionsMultiNormal, Mu) { mu << 1.0, -1.0, 3.0; Matrix Sigma(3, 3); Sigma << 9.0, -3.0, 0.0, -3.0, 4.0, 0.0, 0.0, 0.0, 5.0; - EXPECT_NO_THROW(stan::math::multi_normal_log(y, mu, Sigma)); + EXPECT_NO_THROW(stan::math::multi_normal_lpdf(y, mu, Sigma)); EXPECT_NO_THROW(stan::math::multi_normal_rng(mu, Sigma, rng)); mu(0) = std::numeric_limits::infinity(); - EXPECT_THROW(stan::math::multi_normal_log(y, mu, Sigma), std::domain_error); + EXPECT_THROW(stan::math::multi_normal_lpdf(y, mu, Sigma), std::domain_error); EXPECT_THROW(stan::math::multi_normal_rng(mu, Sigma, rng), std::domain_error); mu(0) = -std::numeric_limits::infinity(); - EXPECT_THROW(stan::math::multi_normal_log(y, mu, Sigma), std::domain_error); + EXPECT_THROW(stan::math::multi_normal_lpdf(y, mu, Sigma), std::domain_error); EXPECT_THROW(stan::math::multi_normal_rng(mu, Sigma, rng), std::domain_error); mu(0) = std::numeric_limits::quiet_NaN(); - EXPECT_THROW(stan::math::multi_normal_log(y, mu, Sigma), std::domain_error); + EXPECT_THROW(stan::math::multi_normal_lpdf(y, mu, Sigma), std::domain_error); EXPECT_THROW(stan::math::multi_normal_rng(mu, Sigma, rng), std::domain_error); } TEST(ProbDistributionsMultiNormal, MultiNormalOneRow) { @@ -139,7 +139,7 @@ TEST(ProbDistributionsMultiNormal, MultiNormalOneRow) { mu << 1.0, -1.0, 3.0; Matrix Sigma(3, 3); Sigma << 9.0, -3.0, 0.0, -3.0, 4.0, 0.0, 0.0, 0.0, 5.0; - EXPECT_FLOAT_EQ(-11.73908, stan::math::multi_normal_log(y, mu, Sigma)); + EXPECT_FLOAT_EQ(-11.73908, stan::math::multi_normal_lpdf(y, mu, Sigma)); EXPECT_NO_THROW(stan::math::multi_normal_rng(mu, Sigma, rng)); } @@ -154,18 +154,18 @@ TEST(ProbDistributionsMultiNormal, SigmaMultiRow) { mu << 1.0, -1.0; Matrix Sigma(2, 2); Sigma << 9.0, -3.0, -3.0, 4.0; - EXPECT_NO_THROW(stan::math::multi_normal_log(y, mu, Sigma)); + EXPECT_NO_THROW(stan::math::multi_normal_lpdf(y, mu, Sigma)); EXPECT_NO_THROW(stan::math::multi_normal_rng(mu, Sigma, rng)); // wrong dimensions Matrix z(3, 1); z << 2.0, -2.0, 1.0; - EXPECT_THROW(stan::math::multi_normal_log(z, mu, Sigma), + EXPECT_THROW(stan::math::multi_normal_lpdf(z, mu, Sigma), std::invalid_argument); // non-symmetric Sigma(0, 1) = -2.5; - EXPECT_THROW(stan::math::multi_normal_log(y, mu, Sigma), std::domain_error); + EXPECT_THROW(stan::math::multi_normal_lpdf(y, mu, Sigma), std::domain_error); EXPECT_THROW(stan::math::multi_normal_rng(mu, Sigma, rng), std::domain_error); } TEST(ProbDistributionsMultiNormal, MuMultiRow) { @@ -179,17 +179,17 @@ TEST(ProbDistributionsMultiNormal, MuMultiRow) { mu << 1.0, -1.0, 3.0; Matrix Sigma(3, 3); Sigma << 9.0, -3.0, 0.0, -3.0, 4.0, 0.0, 0.0, 0.0, 5.0; - EXPECT_NO_THROW(stan::math::multi_normal_log(y, mu, Sigma)); + EXPECT_NO_THROW(stan::math::multi_normal_lpdf(y, mu, Sigma)); EXPECT_NO_THROW(stan::math::multi_normal_rng(mu, Sigma, rng)); mu(0) = std::numeric_limits::infinity(); - EXPECT_THROW(stan::math::multi_normal_log(y, mu, Sigma), std::domain_error); + EXPECT_THROW(stan::math::multi_normal_lpdf(y, mu, Sigma), std::domain_error); EXPECT_THROW(stan::math::multi_normal_rng(mu, Sigma, rng), std::domain_error); mu(0) = -std::numeric_limits::infinity(); - EXPECT_THROW(stan::math::multi_normal_log(y, mu, Sigma), std::domain_error); + EXPECT_THROW(stan::math::multi_normal_lpdf(y, mu, Sigma), std::domain_error); EXPECT_THROW(stan::math::multi_normal_rng(mu, Sigma, rng), std::domain_error); mu(0) = std::numeric_limits::quiet_NaN(); - EXPECT_THROW(stan::math::multi_normal_log(y, mu, Sigma), std::domain_error); + EXPECT_THROW(stan::math::multi_normal_lpdf(y, mu, Sigma), std::domain_error); EXPECT_THROW(stan::math::multi_normal_rng(mu, Sigma, rng), std::domain_error); } TEST(ProbDistributionsMultiNormal, SizeMismatch) { @@ -203,7 +203,7 @@ TEST(ProbDistributionsMultiNormal, SizeMismatch) { mu << 1.0, -1.0; Matrix Sigma(2, 3); Sigma << 9.0, -3.0, 0.0, -3.0, 4.0, 0.0; - EXPECT_THROW(stan::math::multi_normal_log(y, mu, Sigma), + EXPECT_THROW(stan::math::multi_normal_lpdf(y, mu, Sigma), std::invalid_argument); EXPECT_THROW(stan::math::multi_normal_rng(mu, Sigma, rng), std::invalid_argument); diff --git a/test/unit/math/prim/prob/multi_student_t_test.cpp b/test/unit/math/prim/prob/multi_student_t_test.cpp index 5d0795e9e5e..5f656450225 100644 --- a/test/unit/math/prim/prob/multi_student_t_test.cpp +++ b/test/unit/math/prim/prob/multi_student_t_test.cpp @@ -8,7 +8,7 @@ TEST(ProbDistributionsMultiStudentT, NotVectorized) { using Eigen::Dynamic; using Eigen::Matrix; - using stan::math::multi_student_t_log; + using stan::math::multi_student_t_lpdf; using stan::math::multi_student_t_rng; using std::vector; boost::random::mt19937 rng; @@ -19,7 +19,7 @@ TEST(ProbDistributionsMultiStudentT, NotVectorized) { Matrix Sigma(3, 3); Sigma << 9.0, -3.0, 0.0, -3.0, 4.0, 0.0, 0.0, 0.0, 5.0; double nu = 4.0; - double lp = multi_student_t_log(y, nu, mu, Sigma); + double lp = multi_student_t_lpdf(y, nu, mu, Sigma); EXPECT_NO_THROW(multi_student_t_rng(nu, mu, Sigma, rng)); // calc using R's mnormt package's dmt function EXPECT_NEAR(-10.1245958182, lp, 1e-9); @@ -27,7 +27,7 @@ TEST(ProbDistributionsMultiStudentT, NotVectorized) { TEST(ProbDistributionsMultiStudentT, Vectorized) { using Eigen::Dynamic; using Eigen::Matrix; - using stan::math::multi_student_t_log; + using stan::math::multi_student_t_lpdf; using stan::math::multi_student_t_rng; using std::vector; boost::random::mt19937 rng; @@ -62,34 +62,34 @@ TEST(ProbDistributionsMultiStudentT, Vectorized) { // y and mu vectorized EXPECT_FLOAT_EQ(-8.9286697030 - 6.8183896234, - stan::math::multi_student_t_log(vec_y, nu, vec_mu, Sigma)); + stan::math::multi_student_t_lpdf(vec_y, nu, vec_mu, Sigma)); EXPECT_FLOAT_EQ(-8.9286697030 - 6.8183896234, - stan::math::multi_student_t_log(vec_y_t, nu, vec_mu, Sigma)); + stan::math::multi_student_t_lpdf(vec_y_t, nu, vec_mu, Sigma)); EXPECT_FLOAT_EQ(-8.9286697030 - 6.8183896234, - stan::math::multi_student_t_log(vec_y, nu, vec_mu_t, Sigma)); + stan::math::multi_student_t_lpdf(vec_y, nu, vec_mu_t, Sigma)); EXPECT_FLOAT_EQ( -8.9286697030 - 6.8183896234, - stan::math::multi_student_t_log(vec_y_t, nu, vec_mu_t, Sigma)); + stan::math::multi_student_t_lpdf(vec_y_t, nu, vec_mu_t, Sigma)); // y vectorized EXPECT_FLOAT_EQ(-9.1670535409 - 6.8183896234, - stan::math::multi_student_t_log(vec_y, nu, mu, Sigma)); + stan::math::multi_student_t_lpdf(vec_y, nu, mu, Sigma)); EXPECT_FLOAT_EQ(-9.1670535409 - 6.8183896234, - stan::math::multi_student_t_log(vec_y_t, nu, mu, Sigma)); + stan::math::multi_student_t_lpdf(vec_y_t, nu, mu, Sigma)); EXPECT_FLOAT_EQ(-9.1670535409 - 6.8183896234, - stan::math::multi_student_t_log(vec_y, nu, mu_t, Sigma)); + stan::math::multi_student_t_lpdf(vec_y, nu, mu_t, Sigma)); EXPECT_FLOAT_EQ(-9.1670535409 - 6.8183896234, - stan::math::multi_student_t_log(vec_y_t, nu, mu_t, Sigma)); + stan::math::multi_student_t_lpdf(vec_y_t, nu, mu_t, Sigma)); // mu vectorized EXPECT_FLOAT_EQ(-5.5280118939 - 6.8183896234, - stan::math::multi_student_t_log(y, nu, vec_mu, Sigma)); + stan::math::multi_student_t_lpdf(y, nu, vec_mu, Sigma)); EXPECT_FLOAT_EQ(-5.5280118939 - 6.8183896234, - stan::math::multi_student_t_log(y_t, nu, vec_mu, Sigma)); + stan::math::multi_student_t_lpdf(y_t, nu, vec_mu, Sigma)); EXPECT_FLOAT_EQ(-5.5280118939 - 6.8183896234, - stan::math::multi_student_t_log(y, nu, vec_mu_t, Sigma)); + stan::math::multi_student_t_lpdf(y, nu, vec_mu_t, Sigma)); EXPECT_FLOAT_EQ(-5.5280118939 - 6.8183896234, - stan::math::multi_student_t_log(y_t, nu, vec_mu_t, Sigma)); + stan::math::multi_student_t_lpdf(y_t, nu, vec_mu_t, Sigma)); EXPECT_NO_THROW(stan::math::multi_student_t_rng(nu, vec_mu, Sigma, rng)); EXPECT_NO_THROW(stan::math::multi_student_t_rng(nu, vec_mu_t, Sigma, rng)); } @@ -97,7 +97,7 @@ TEST(ProbDistributionsMultiStudentT, Vectorized) { TEST(ProbDistributionsMultiStudentT, Sigma) { using Eigen::Dynamic; using Eigen::Matrix; - using stan::math::multi_student_t_log; + using stan::math::multi_student_t_lpdf; using stan::math::multi_student_t_rng; using std::vector; boost::random::mt19937 rng; @@ -108,19 +108,19 @@ TEST(ProbDistributionsMultiStudentT, Sigma) { Matrix Sigma(3, 3); Sigma << 9.0, -3.0, 0.0, -3.0, 4.0, 0.0, 0.0, 0.0, 5.0; double nu = 4.0; - EXPECT_NO_THROW(multi_student_t_log(y, nu, mu, Sigma)); + EXPECT_NO_THROW(multi_student_t_lpdf(y, nu, mu, Sigma)); EXPECT_NO_THROW(multi_student_t_rng(nu, mu, Sigma, rng)); // non-symmetric Sigma(0, 1) = 10; - EXPECT_THROW(multi_student_t_log(y, nu, mu, Sigma), std::domain_error); + EXPECT_THROW(multi_student_t_lpdf(y, nu, mu, Sigma), std::domain_error); EXPECT_THROW(multi_student_t_rng(nu, mu, Sigma, rng), std::domain_error); } TEST(ProbDistributionsMultiStudentT, Mu) { using Eigen::Dynamic; using Eigen::Matrix; - using stan::math::multi_student_t_log; + using stan::math::multi_student_t_lpdf; using stan::math::multi_student_t_rng; using std::vector; boost::random::mt19937 rng; @@ -131,26 +131,26 @@ TEST(ProbDistributionsMultiStudentT, Mu) { Matrix Sigma(3, 3); Sigma << 9.0, -3.0, 0.0, -3.0, 4.0, 0.0, 0.0, 0.0, 5.0; double nu = 4.0; - EXPECT_NO_THROW(multi_student_t_log(y, nu, mu, Sigma)); + EXPECT_NO_THROW(multi_student_t_lpdf(y, nu, mu, Sigma)); EXPECT_NO_THROW(multi_student_t_rng(nu, mu, Sigma, rng)); mu(0) = std::numeric_limits::quiet_NaN(); - EXPECT_THROW(multi_student_t_log(y, nu, mu, Sigma), std::domain_error); + EXPECT_THROW(multi_student_t_lpdf(y, nu, mu, Sigma), std::domain_error); EXPECT_THROW(multi_student_t_rng(nu, mu, Sigma, rng), std::domain_error); mu(0) = std::numeric_limits::infinity(); - EXPECT_THROW(multi_student_t_log(y, nu, mu, Sigma), std::domain_error); + EXPECT_THROW(multi_student_t_lpdf(y, nu, mu, Sigma), std::domain_error); EXPECT_THROW(multi_student_t_rng(nu, mu, Sigma, rng), std::domain_error); mu(0) = -std::numeric_limits::infinity(); - EXPECT_THROW(multi_student_t_log(y, nu, mu, Sigma), std::domain_error); + EXPECT_THROW(multi_student_t_lpdf(y, nu, mu, Sigma), std::domain_error); EXPECT_THROW(multi_student_t_rng(nu, mu, Sigma, rng), std::domain_error); } TEST(ProbDistributionsMultiStudentT, Y) { using Eigen::Dynamic; using Eigen::Matrix; - using stan::math::multi_student_t_log; + using stan::math::multi_student_t_lpdf; using stan::math::multi_student_t_rng; using std::vector; Matrix y(3, 1); @@ -160,22 +160,22 @@ TEST(ProbDistributionsMultiStudentT, Y) { Matrix Sigma(3, 3); Sigma << 9.0, -3.0, 0.0, -3.0, 4.0, 0.0, 0.0, 0.0, 5.0; double nu = 4.0; - EXPECT_NO_THROW(multi_student_t_log(y, nu, mu, Sigma)); + EXPECT_NO_THROW(multi_student_t_lpdf(y, nu, mu, Sigma)); y(0) = std::numeric_limits::quiet_NaN(); - EXPECT_THROW(multi_student_t_log(y, nu, mu, Sigma), std::domain_error); + EXPECT_THROW(multi_student_t_lpdf(y, nu, mu, Sigma), std::domain_error); y(0) = std::numeric_limits::infinity(); - EXPECT_NO_THROW(multi_student_t_log(y, nu, mu, Sigma)); + EXPECT_NO_THROW(multi_student_t_lpdf(y, nu, mu, Sigma)); y(0) = -std::numeric_limits::infinity(); - EXPECT_NO_THROW(multi_student_t_log(y, nu, mu, Sigma)); + EXPECT_NO_THROW(multi_student_t_lpdf(y, nu, mu, Sigma)); } TEST(ProbDistributionsMultiStudentT, Nu) { using Eigen::Dynamic; using Eigen::Matrix; - using stan::math::multi_student_t_log; + using stan::math::multi_student_t_lpdf; using stan::math::multi_student_t_rng; using std::vector; boost::random::mt19937 rng; @@ -186,35 +186,35 @@ TEST(ProbDistributionsMultiStudentT, Nu) { Matrix Sigma(3, 3); Sigma << 9.0, -3.0, 0.0, -3.0, 4.0, 0.0, 0.0, 0.0, 5.0; double nu = 4.0; - EXPECT_NO_THROW(multi_student_t_log(y, nu, mu, Sigma)); + EXPECT_NO_THROW(multi_student_t_lpdf(y, nu, mu, Sigma)); EXPECT_NO_THROW(multi_student_t_rng(nu, mu, Sigma, rng)); nu = std::numeric_limits::quiet_NaN(); - EXPECT_THROW(multi_student_t_log(y, nu, mu, Sigma), std::domain_error); + EXPECT_THROW(multi_student_t_lpdf(y, nu, mu, Sigma), std::domain_error); EXPECT_THROW(multi_student_t_rng(nu, mu, Sigma, rng), std::domain_error); nu = 0.0; - EXPECT_THROW(multi_student_t_log(y, nu, mu, Sigma), std::domain_error); + EXPECT_THROW(multi_student_t_lpdf(y, nu, mu, Sigma), std::domain_error); EXPECT_THROW(multi_student_t_rng(nu, mu, Sigma, rng), std::domain_error); nu = -1.0; - EXPECT_THROW(multi_student_t_log(y, nu, mu, Sigma), std::domain_error); + EXPECT_THROW(multi_student_t_lpdf(y, nu, mu, Sigma), std::domain_error); EXPECT_THROW(multi_student_t_rng(nu, mu, Sigma, rng), std::domain_error); nu = -std::numeric_limits::infinity(); - EXPECT_THROW(multi_student_t_log(y, nu, mu, Sigma), std::domain_error); + EXPECT_THROW(multi_student_t_lpdf(y, nu, mu, Sigma), std::domain_error); EXPECT_THROW(multi_student_t_rng(nu, mu, Sigma, rng), std::domain_error); // nu = infinity NOT OK nu = std::numeric_limits::infinity(); - EXPECT_THROW(multi_student_t_log(y, nu, mu, Sigma), std::domain_error); + EXPECT_THROW(multi_student_t_lpdf(y, nu, mu, Sigma), std::domain_error); EXPECT_THROW(multi_student_t_rng(nu, mu, Sigma, rng), std::domain_error); } TEST(ProbDistributionsMultiStudentT, ErrorSize1) { using Eigen::Dynamic; using Eigen::Matrix; - using stan::math::multi_student_t_log; + using stan::math::multi_student_t_lpdf; using stan::math::multi_student_t_rng; using std::vector; Matrix y(2, 1); @@ -225,13 +225,13 @@ TEST(ProbDistributionsMultiStudentT, ErrorSize1) { Sigma << 9.0, -3.0, 0.0, -3.0, 4.0, 0.0, 0.0, 0.0, 5.0; double nu = 4.0; - EXPECT_THROW(multi_student_t_log(y, nu, mu, Sigma), std::invalid_argument); + EXPECT_THROW(multi_student_t_lpdf(y, nu, mu, Sigma), std::invalid_argument); } TEST(ProbDistributionsMultiStudentT, ErrorSize2) { using Eigen::Dynamic; using Eigen::Matrix; - using stan::math::multi_student_t_log; + using stan::math::multi_student_t_lpdf; using stan::math::multi_student_t_rng; using std::vector; boost::random::mt19937 rng; @@ -243,14 +243,14 @@ TEST(ProbDistributionsMultiStudentT, ErrorSize2) { Sigma << 9.0, -3.0, 0.0, -3.0, 4.0, 0.0; double nu = 4.0; - EXPECT_THROW(multi_student_t_log(y, nu, mu, Sigma), std::invalid_argument); + EXPECT_THROW(multi_student_t_lpdf(y, nu, mu, Sigma), std::invalid_argument); EXPECT_THROW(multi_student_t_rng(nu, mu, Sigma, rng), std::invalid_argument); } TEST(ProbDistributionsMultiStudentT, ErrorSize3) { using Eigen::Dynamic; using Eigen::Matrix; - using stan::math::multi_student_t_log; + using stan::math::multi_student_t_lpdf; using stan::math::multi_student_t_rng; using std::vector; boost::random::mt19937 rng; @@ -262,7 +262,7 @@ TEST(ProbDistributionsMultiStudentT, ErrorSize3) { Sigma << 9.0, -3.0, 0.0, -3.0, 4.0, 0.0; double nu = 4.0; - EXPECT_THROW(multi_student_t_log(y, nu, mu, Sigma), std::invalid_argument); + EXPECT_THROW(multi_student_t_lpdf(y, nu, mu, Sigma), std::invalid_argument); EXPECT_THROW(multi_student_t_rng(nu, mu, Sigma, rng), std::invalid_argument); } @@ -288,7 +288,7 @@ TEST(ProbDistributionsMultiStudentT, ErrorSizeSigma) { TEST(ProbDistributionsMultiStudentT, ProptoAllDoublesZero) { using Eigen::Dynamic; using Eigen::Matrix; - using stan::math::multi_student_t_log; + using stan::math::multi_student_t_lpdf; using stan::math::multi_student_t_rng; using std::vector; Matrix y(3, 1); @@ -299,13 +299,13 @@ TEST(ProbDistributionsMultiStudentT, ProptoAllDoublesZero) { Sigma << 9.0, -3.0, 0.0, -3.0, 4.0, 0.0, 0.0, 0.0, 5.0; double nu = 4.0; - EXPECT_FLOAT_EQ(0.0, multi_student_t_log(y, nu, mu, Sigma)); + EXPECT_FLOAT_EQ(0.0, multi_student_t_lpdf(y, nu, mu, Sigma)); } TEST(ProbDistributionsMultiStudentT, marginalOneChiSquareGoodnessFitTest) { using Eigen::Dynamic; using Eigen::Matrix; - using stan::math::multi_student_t_log; + using stan::math::multi_student_t_lpdf; using stan::math::multi_student_t_rng; using std::vector; boost::random::mt19937 rng; @@ -348,7 +348,7 @@ TEST(ProbDistributionsMultiStudentT, marginalOneChiSquareGoodnessFitTest) { TEST(ProbDistributionsMultiStudentT, marginalTwoChiSquareGoodnessFitTest) { using Eigen::Dynamic; using Eigen::Matrix; - using stan::math::multi_student_t_log; + using stan::math::multi_student_t_lpdf; using stan::math::multi_student_t_rng; using std::vector; boost::random::mt19937 rng; @@ -391,7 +391,7 @@ TEST(ProbDistributionsMultiStudentT, marginalTwoChiSquareGoodnessFitTest) { TEST(ProbDistributionsMultiStudentT, WrongSize) { using Eigen::Dynamic; using Eigen::Matrix; - using stan::math::multi_student_t_log; + using stan::math::multi_student_t_lpdf; using stan::math::multi_student_t_rng; using std::vector; vector > y_3_3(3); diff --git a/test/unit/math/prim/prob/multinomial_logit_test.cpp b/test/unit/math/prim/prob/multinomial_logit_test.cpp index 19988208587..2cfd3a3db93 100644 --- a/test/unit/math/prim/prob/multinomial_logit_test.cpp +++ b/test/unit/math/prim/prob/multinomial_logit_test.cpp @@ -23,7 +23,7 @@ TEST(ProbDistributionsMultinomialLogit, MultinomialLogit) { ns.push_back(3); Matrix beta(3, 1); beta << log(0.2), log(0.3), log(0.5); - EXPECT_FLOAT_EQ(-2.002481, stan::math::multinomial_logit_log(ns, beta)); + EXPECT_FLOAT_EQ(-2.002481, stan::math::multinomial_logit_lpmf(ns, beta)); } TEST(ProbDistributionsMultinomialLogit, Propto) { std::vector ns; @@ -32,10 +32,10 @@ TEST(ProbDistributionsMultinomialLogit, Propto) { ns.push_back(3); Matrix beta(3, 1); beta << log(0.2), log(0.3), log(0.5); - EXPECT_FLOAT_EQ(0.0, stan::math::multinomial_logit_log(ns, beta)); + EXPECT_FLOAT_EQ(0.0, stan::math::multinomial_logit_lpmf(ns, beta)); } -using stan::math::multinomial_logit_log; +using stan::math::multinomial_logit_lpmf; TEST(ProbDistributionsMultinomialLogit, error) { double nan = std::numeric_limits::quiet_NaN(); @@ -48,27 +48,27 @@ TEST(ProbDistributionsMultinomialLogit, error) { Matrix beta(3, 1); beta << log(0.2), log(0.3), log(0.5); - EXPECT_NO_THROW(multinomial_logit_log(ns, beta)); + EXPECT_NO_THROW(multinomial_logit_lpmf(ns, beta)); ns[1] = 0; - EXPECT_NO_THROW(multinomial_logit_log(ns, beta)); + EXPECT_NO_THROW(multinomial_logit_lpmf(ns, beta)); ns[1] = -1; - EXPECT_THROW(multinomial_logit_log(ns, beta), std::domain_error); + EXPECT_THROW(multinomial_logit_lpmf(ns, beta), std::domain_error); ns[1] = 1; beta(0) = nan; - EXPECT_THROW(multinomial_logit_log(ns, beta), std::domain_error); + EXPECT_THROW(multinomial_logit_lpmf(ns, beta), std::domain_error); beta(0) = inf; - EXPECT_THROW(multinomial_logit_log(ns, beta), std::domain_error); + EXPECT_THROW(multinomial_logit_lpmf(ns, beta), std::domain_error); beta(0) = -inf; - EXPECT_THROW(multinomial_logit_log(ns, beta), std::domain_error); + EXPECT_THROW(multinomial_logit_lpmf(ns, beta), std::domain_error); beta(0) = 0.2; beta(1) = 0.3; beta(2) = 0.5; ns.resize(2); - EXPECT_THROW(multinomial_logit_log(ns, beta), std::invalid_argument); + EXPECT_THROW(multinomial_logit_lpmf(ns, beta), std::invalid_argument); } TEST(ProbDistributionsMultinomialLogit, zeros) { @@ -80,7 +80,7 @@ TEST(ProbDistributionsMultinomialLogit, zeros) { Matrix beta(3, 1); beta << log(0.2), log(0.3), log(0.5); - result = multinomial_logit_log(ns, beta); + result = multinomial_logit_lpmf(ns, beta); EXPECT_FALSE(std::isnan(result)); std::vector ns2; @@ -88,7 +88,7 @@ TEST(ProbDistributionsMultinomialLogit, zeros) { ns2.push_back(0); ns2.push_back(0); - double result2 = multinomial_logit_log(ns2, beta); + double result2 = multinomial_logit_lpmf(ns2, beta); EXPECT_FLOAT_EQ(0.0, result2); } diff --git a/test/unit/math/prim/prob/multinomial_test.cpp b/test/unit/math/prim/prob/multinomial_test.cpp index 7821264f05e..f4b5a693ee8 100644 --- a/test/unit/math/prim/prob/multinomial_test.cpp +++ b/test/unit/math/prim/prob/multinomial_test.cpp @@ -26,7 +26,7 @@ TEST(ProbDistributionsMultinomial, Multinomial) { ns.push_back(3); Matrix theta(3, 1); theta << 0.2, 0.3, 0.5; - EXPECT_FLOAT_EQ(-2.002481, stan::math::multinomial_log(ns, theta)); + EXPECT_FLOAT_EQ(-2.002481, stan::math::multinomial_lpmf(ns, theta)); } TEST(ProbDistributionsMultinomial, Propto) { using Eigen::Dynamic; @@ -37,10 +37,10 @@ TEST(ProbDistributionsMultinomial, Propto) { ns.push_back(3); Matrix theta(3, 1); theta << 0.2, 0.3, 0.5; - EXPECT_FLOAT_EQ(0.0, stan::math::multinomial_log(ns, theta)); + EXPECT_FLOAT_EQ(0.0, stan::math::multinomial_lpmf(ns, theta)); } -using stan::math::multinomial_log; +using stan::math::multinomial_lpmf; TEST(ProbDistributionsMultinomial, error) { using Eigen::Dynamic; @@ -55,32 +55,32 @@ TEST(ProbDistributionsMultinomial, error) { Matrix theta(3, 1); theta << 0.2, 0.3, 0.5; - EXPECT_NO_THROW(multinomial_log(ns, theta)); + EXPECT_NO_THROW(multinomial_lpmf(ns, theta)); ns[1] = 0; - EXPECT_NO_THROW(multinomial_log(ns, theta)); + EXPECT_NO_THROW(multinomial_lpmf(ns, theta)); ns[1] = -1; - EXPECT_THROW(multinomial_log(ns, theta), std::domain_error); + EXPECT_THROW(multinomial_lpmf(ns, theta), std::domain_error); ns[1] = 1; theta(0) = 0.0; - EXPECT_THROW(multinomial_log(ns, theta), std::domain_error); + EXPECT_THROW(multinomial_lpmf(ns, theta), std::domain_error); theta(0) = nan; - EXPECT_THROW(multinomial_log(ns, theta), std::domain_error); + EXPECT_THROW(multinomial_lpmf(ns, theta), std::domain_error); theta(0) = inf; - EXPECT_THROW(multinomial_log(ns, theta), std::domain_error); + EXPECT_THROW(multinomial_lpmf(ns, theta), std::domain_error); theta(0) = -inf; - EXPECT_THROW(multinomial_log(ns, theta), std::domain_error); + EXPECT_THROW(multinomial_lpmf(ns, theta), std::domain_error); theta(0) = -1; theta(1) = 1.5; theta(2) = 0.5; - EXPECT_THROW(multinomial_log(ns, theta), std::domain_error); + EXPECT_THROW(multinomial_lpmf(ns, theta), std::domain_error); theta(0) = 0.2; theta(1) = 0.3; theta(2) = 0.5; ns.resize(2); - EXPECT_THROW(multinomial_log(ns, theta), std::invalid_argument); + EXPECT_THROW(multinomial_lpmf(ns, theta), std::invalid_argument); } TEST(ProbDistributionsMultinomial, zeros) { @@ -94,7 +94,7 @@ TEST(ProbDistributionsMultinomial, zeros) { Matrix theta(3, 1); theta << 0.2, 0.3, 0.5; - result = multinomial_log(ns, theta); + result = multinomial_lpmf(ns, theta); EXPECT_FALSE(std::isnan(result)); std::vector ns2; @@ -102,7 +102,7 @@ TEST(ProbDistributionsMultinomial, zeros) { ns2.push_back(0); ns2.push_back(0); - double result2 = multinomial_log(ns2, theta); + double result2 = multinomial_lpmf(ns2, theta); EXPECT_FLOAT_EQ(0.0, result2); } diff --git a/test/unit/math/prim/prob/neg_binomial_2_log_test.cpp b/test/unit/math/prim/prob/neg_binomial_2_log_test.cpp index 335ee820f8e..b1ae1b2d5d1 100644 --- a/test/unit/math/prim/prob/neg_binomial_2_log_test.cpp +++ b/test/unit/math/prim/prob/neg_binomial_2_log_test.cpp @@ -184,32 +184,6 @@ TEST(ProbDistributionsNegBinomial2Log, chiSquareGoodnessFitTest3) { EXPECT_TRUE(chi < quantile(complement(mydist, 1e-6))); } -TEST(ProbNegBinomial2, log_matches_lpmf) { - double y = 0.8; - double mu = 1.1; - double phi = 2.3; - - EXPECT_FLOAT_EQ((stan::math::neg_binomial_2_lpmf(y, mu, phi)), - (stan::math::neg_binomial_2_log(y, mu, phi))); - EXPECT_FLOAT_EQ((stan::math::neg_binomial_2_lpmf(y, mu, phi)), - (stan::math::neg_binomial_2_log(y, mu, phi))); - EXPECT_FLOAT_EQ((stan::math::neg_binomial_2_lpmf(y, mu, phi)), - (stan::math::neg_binomial_2_log(y, mu, phi))); - EXPECT_FLOAT_EQ( - (stan::math::neg_binomial_2_lpmf(y, mu, - phi)), - (stan::math::neg_binomial_2_log(y, mu, - phi))); - EXPECT_FLOAT_EQ( - (stan::math::neg_binomial_2_lpmf(y, mu, - phi)), - (stan::math::neg_binomial_2_log(y, mu, - phi))); - EXPECT_FLOAT_EQ( - (stan::math::neg_binomial_2_lpmf(y, mu, phi)), - (stan::math::neg_binomial_2_log(y, mu, phi))); -} - TEST(ProbDistributionsNegBinomial2Log, neg_binomial_2_log_grid_test) { std::vector mu_log_to_test = {-101, -27, -3, -1, -0.132, 0, 4, 10, 87}; diff --git a/test/unit/math/prim/prob/neg_binomial_2_test.cpp b/test/unit/math/prim/prob/neg_binomial_2_test.cpp index 0c7d2f0c35a..232e8b45289 100644 --- a/test/unit/math/prim/prob/neg_binomial_2_test.cpp +++ b/test/unit/math/prim/prob/neg_binomial_2_test.cpp @@ -245,7 +245,7 @@ TEST(ProbDistributionsNegBinomial2, extreme_values) { for (int n : n_to_test) { // Test across a range of phi for (double phi = 1e12; phi < 1e22; phi *= 10) { - double logp = stan::math::neg_binomial_2_log(n, mu, phi); + double logp = stan::math::neg_binomial_2_lpmf(n, mu, phi); EXPECT_LT(logp, 0) << "n = " << n << ", mu = " << mu << ", phi = " << phi; } diff --git a/test/unit/math/prim/prob/neg_binomial_test.cpp b/test/unit/math/prim/prob/neg_binomial_test.cpp index ac5b0f611cb..ce35180a761 100644 --- a/test/unit/math/prim/prob/neg_binomial_test.cpp +++ b/test/unit/math/prim/prob/neg_binomial_test.cpp @@ -75,8 +75,8 @@ void expected_bin_sizes(double* expect, const int K, const int N, const double alpha, const double beta) { long double p = 0; for (int i = 0; i < K; i++) { - expect[i] = N * std::exp(stan::math::neg_binomial_log(i, alpha, beta)); - p += std::exp(stan::math::neg_binomial_log(i, alpha, beta)); + expect[i] = N * std::exp(stan::math::neg_binomial_lpmf(i, alpha, beta)); + p += std::exp(stan::math::neg_binomial_lpmf(i, alpha, beta)); } expect[K - 1] = N * static_cast(1.0 - p); } diff --git a/test/unit/math/prim/prob/ordered_logistic_test.cpp b/test/unit/math/prim/prob/ordered_logistic_test.cpp index c036906c702..9f71fb8b253 100644 --- a/test/unit/math/prim/prob/ordered_logistic_test.cpp +++ b/test/unit/math/prim/prob/ordered_logistic_test.cpp @@ -23,7 +23,7 @@ TEST(ProbDistributions, ordered_logistic_vals) { using Eigen::Matrix; using stan::math::inv_logit; - using stan::math::ordered_logistic_log; + using stan::math::ordered_logistic_lpmf; std::vector y{1, 2, 3, 4, 5}; std::vector zero{1, 2, 0, 4, 5}; @@ -46,15 +46,15 @@ TEST(ProbDistributions, ordered_logistic_vals) { EXPECT_FLOAT_EQ(1.0, sum); for (int k = 0; k < K; ++k) - EXPECT_FLOAT_EQ(log(theta(k)), ordered_logistic_log(k + 1, lambda[k], c)); + EXPECT_FLOAT_EQ(log(theta(k)), ordered_logistic_lpmf(k + 1, lambda[k], c)); - EXPECT_FLOAT_EQ(log_sum, ordered_logistic_log(y, lambda, c)); + EXPECT_FLOAT_EQ(log_sum, ordered_logistic_lpmf(y, lambda, c)); - EXPECT_THROW(ordered_logistic_log(0, lambda[0], c), std::domain_error); - EXPECT_THROW(ordered_logistic_log(6, lambda[0], c), std::domain_error); + EXPECT_THROW(ordered_logistic_lpmf(0, lambda[0], c), std::domain_error); + EXPECT_THROW(ordered_logistic_lpmf(6, lambda[0], c), std::domain_error); - EXPECT_THROW(ordered_logistic_log(zero, lambda, c), std::domain_error); - EXPECT_THROW(ordered_logistic_log(six, lambda, c), std::domain_error); + EXPECT_THROW(ordered_logistic_lpmf(zero, lambda, c), std::domain_error); + EXPECT_THROW(ordered_logistic_lpmf(six, lambda, c), std::domain_error); } TEST(ProbDistributions, ordered_logistic_vals_2) { @@ -62,7 +62,7 @@ TEST(ProbDistributions, ordered_logistic_vals_2) { using Eigen::Matrix; using stan::math::inv_logit; - using stan::math::ordered_logistic_log; + using stan::math::ordered_logistic_lpmf; std::vector y{1, 2, 3}; std::vector zero{1, 0, 3}; @@ -85,19 +85,19 @@ TEST(ProbDistributions, ordered_logistic_vals_2) { EXPECT_FLOAT_EQ(1.0, sum); for (int k = 0; k < K; ++k) - EXPECT_FLOAT_EQ(log(theta(k)), ordered_logistic_log(k + 1, lambda[0], c)); + EXPECT_FLOAT_EQ(log(theta(k)), ordered_logistic_lpmf(k + 1, lambda[0], c)); - EXPECT_FLOAT_EQ(log_sum, ordered_logistic_log(y, lambda, c)); + EXPECT_FLOAT_EQ(log_sum, ordered_logistic_lpmf(y, lambda, c)); - EXPECT_THROW(ordered_logistic_log(0, lambda[0], c), std::domain_error); - EXPECT_THROW(ordered_logistic_log(4, lambda[0], c), std::domain_error); + EXPECT_THROW(ordered_logistic_lpmf(0, lambda[0], c), std::domain_error); + EXPECT_THROW(ordered_logistic_lpmf(4, lambda[0], c), std::domain_error); - EXPECT_THROW(ordered_logistic_log(zero, lambda, c), std::domain_error); - EXPECT_THROW(ordered_logistic_log(six, lambda, c), std::domain_error); + EXPECT_THROW(ordered_logistic_lpmf(zero, lambda, c), std::domain_error); + EXPECT_THROW(ordered_logistic_lpmf(six, lambda, c), std::domain_error); } TEST(ProbDistributions, ordered_logistic) { - using stan::math::ordered_logistic_log; + using stan::math::ordered_logistic_lpmf; std::vector y{1, 1, 1, 1}; int K = 4; Eigen::Matrix c(K - 1); @@ -107,12 +107,12 @@ TEST(ProbDistributions, ordered_logistic) { Eigen::Matrix c_neg(1); c_neg << -13.7; - EXPECT_NO_THROW(ordered_logistic_log(1, lambda[0], c_neg)); + EXPECT_NO_THROW(ordered_logistic_lpmf(1, lambda[0], c_neg)); Eigen::Matrix c_unord(3); c_unord << 1.0, 0.4, 2.0; - EXPECT_THROW(ordered_logistic_log(1, lambda[0], c_unord), std::domain_error); - EXPECT_THROW(ordered_logistic_log(y, lambda, c_unord), std::domain_error); + EXPECT_THROW(ordered_logistic_lpmf(1, lambda[0], c_unord), std::domain_error); + EXPECT_THROW(ordered_logistic_lpmf(y, lambda, c_unord), std::domain_error); double nan = std::numeric_limits::quiet_NaN(); double inf = std::numeric_limits::infinity(); @@ -123,38 +123,39 @@ TEST(ProbDistributions, ordered_logistic) { Eigen::Matrix inf_vec(4); inf_vec << inf, inf, inf, inf; - EXPECT_THROW(ordered_logistic_log(1, nan, c), std::domain_error); - EXPECT_THROW(ordered_logistic_log(1, inf, c), std::domain_error); - EXPECT_THROW(ordered_logistic_log(y, nan_vec, c), std::domain_error); - EXPECT_THROW(ordered_logistic_log(y, inf_vec, c), std::domain_error); + EXPECT_THROW(ordered_logistic_lpmf(1, nan, c), std::domain_error); + EXPECT_THROW(ordered_logistic_lpmf(1, inf, c), std::domain_error); + EXPECT_THROW(ordered_logistic_lpmf(y, nan_vec, c), std::domain_error); + EXPECT_THROW(ordered_logistic_lpmf(y, inf_vec, c), std::domain_error); Eigen::Matrix cbad(2); cbad << 0.2, inf; - EXPECT_THROW(ordered_logistic_log(1, 1.0, cbad), std::domain_error); - EXPECT_THROW(ordered_logistic_log(y, lambda, cbad), std::domain_error); + EXPECT_THROW(ordered_logistic_lpmf(1, 1.0, cbad), std::domain_error); + EXPECT_THROW(ordered_logistic_lpmf(y, lambda, cbad), std::domain_error); cbad[1] = nan; - EXPECT_THROW(ordered_logistic_log(1, 1.0, cbad), std::domain_error); - EXPECT_THROW(ordered_logistic_log(y, lambda, cbad), std::domain_error); + EXPECT_THROW(ordered_logistic_lpmf(1, 1.0, cbad), std::domain_error); + EXPECT_THROW(ordered_logistic_lpmf(y, lambda, cbad), std::domain_error); Eigen::Matrix cbad1(1); cbad1 << inf; - EXPECT_THROW(ordered_logistic_log(1, 1.0, cbad1), std::domain_error); - EXPECT_THROW(ordered_logistic_log(y, lambda, cbad1), std::domain_error); + EXPECT_THROW(ordered_logistic_lpmf(1, 1.0, cbad1), std::domain_error); + EXPECT_THROW(ordered_logistic_lpmf(y, lambda, cbad1), std::domain_error); cbad1[0] = nan; - EXPECT_THROW(ordered_logistic_log(1, 1.0, cbad1), std::domain_error); - EXPECT_THROW(ordered_logistic_log(y, lambda, cbad1), std::domain_error); + EXPECT_THROW(ordered_logistic_lpmf(1, 1.0, cbad1), std::domain_error); + EXPECT_THROW(ordered_logistic_lpmf(y, lambda, cbad1), std::domain_error); Eigen::Matrix cbad3(3); cbad3 << 0.5, inf, 1.0; - EXPECT_THROW(ordered_logistic_log(1, 1.0, cbad3), std::domain_error); - EXPECT_THROW(ordered_logistic_log(y, lambda, cbad3), std::domain_error); + EXPECT_THROW(ordered_logistic_lpmf(1, 1.0, cbad3), std::domain_error); + EXPECT_THROW(ordered_logistic_lpmf(y, lambda, cbad3), std::domain_error); cbad3[1] = nan; - EXPECT_THROW(ordered_logistic_log(1, 1.0, cbad3), std::domain_error); - EXPECT_THROW(ordered_logistic_log(y, lambda, cbad3), std::domain_error); + EXPECT_THROW(ordered_logistic_lpmf(1, 1.0, cbad3), std::domain_error); + EXPECT_THROW(ordered_logistic_lpmf(y, lambda, cbad3), std::domain_error); Eigen::Matrix lambda_small(3); lambda_small << 1, 1, 1; - EXPECT_THROW(ordered_logistic_log(y, lambda_small, c), std::invalid_argument); + EXPECT_THROW(ordered_logistic_lpmf(y, lambda_small, c), + std::invalid_argument); Eigen::Matrix c_small(K - 2); c_small << -0.3, 0.1; @@ -163,7 +164,7 @@ TEST(ProbDistributions, ordered_logistic) { c_small_vec[1] = c; c_small_vec[2] = c_small; c_small_vec[3] = c; - EXPECT_THROW(ordered_logistic_log(y, lambda, c_small_vec), + EXPECT_THROW(ordered_logistic_lpmf(y, lambda, c_small_vec), std::invalid_argument); } diff --git a/test/unit/math/prim/prob/ordered_probit_test.cpp b/test/unit/math/prim/prob/ordered_probit_test.cpp index 0e5d82d5af6..44ca2754e89 100644 --- a/test/unit/math/prim/prob/ordered_probit_test.cpp +++ b/test/unit/math/prim/prob/ordered_probit_test.cpp @@ -19,25 +19,25 @@ stan::math::vector_d get_simplex_Phi(double lambda, TEST(ProbDistributions, ordered_probit_stability) { using stan::math::is_inf; - using stan::math::ordered_probit_log; + using stan::math::ordered_probit_lpmf; Eigen::VectorXd c(3); c << -0.3, 0.1, 1.2; - EXPECT_FALSE(is_inf(ordered_probit_log(1, 10, c))); - EXPECT_FALSE(is_inf(ordered_probit_log(2, 10, c))); - EXPECT_NE(ordered_probit_log(4, 10, c), 0); + EXPECT_FALSE(is_inf(ordered_probit_lpmf(1, 10, c))); + EXPECT_FALSE(is_inf(ordered_probit_lpmf(2, 10, c))); + EXPECT_NE(ordered_probit_lpmf(4, 10, c), 0); - EXPECT_NE(ordered_probit_log(1, -38, c), 0); - EXPECT_FALSE(is_inf(ordered_probit_log(2, -38, c))); - EXPECT_FALSE(is_inf(ordered_probit_log(4, -38, c))); + EXPECT_NE(ordered_probit_lpmf(1, -38, c), 0); + EXPECT_FALSE(is_inf(ordered_probit_lpmf(2, -38, c))); + EXPECT_FALSE(is_inf(ordered_probit_lpmf(4, -38, c))); } TEST(ProbDistributions, ordered_probit_vals) { using Eigen::Dynamic; using Eigen::Matrix; - using stan::math::ordered_probit_log; + using stan::math::ordered_probit_lpmf; using stan::math::Phi; int K = 5; @@ -53,17 +53,17 @@ TEST(ProbDistributions, ordered_probit_vals) { EXPECT_FLOAT_EQ(1.0, sum); for (int k = 0; k < K; ++k) - EXPECT_FLOAT_EQ(log(theta(k)), ordered_probit_log(k + 1, lambda, c)); + EXPECT_FLOAT_EQ(log(theta(k)), ordered_probit_lpmf(k + 1, lambda, c)); - EXPECT_THROW(ordered_probit_log(0, lambda, c), std::domain_error); - EXPECT_THROW(ordered_probit_log(6, lambda, c), std::domain_error); + EXPECT_THROW(ordered_probit_lpmf(0, lambda, c), std::domain_error); + EXPECT_THROW(ordered_probit_lpmf(6, lambda, c), std::domain_error); } TEST(ProbDistributions, ordered_probit_vals_2) { using Eigen::Dynamic; using Eigen::Matrix; - using stan::math::ordered_probit_log; + using stan::math::ordered_probit_lpmf; using stan::math::Phi; int K = 3; @@ -79,64 +79,64 @@ TEST(ProbDistributions, ordered_probit_vals_2) { EXPECT_FLOAT_EQ(1.0, sum); for (int k = 0; k < K; ++k) - EXPECT_FLOAT_EQ(log(theta(k)), ordered_probit_log(k + 1, lambda, c)); + EXPECT_FLOAT_EQ(log(theta(k)), ordered_probit_lpmf(k + 1, lambda, c)); - EXPECT_THROW(ordered_probit_log(0, lambda, c), std::domain_error); - EXPECT_THROW(ordered_probit_log(4, lambda, c), std::domain_error); + EXPECT_THROW(ordered_probit_lpmf(0, lambda, c), std::domain_error); + EXPECT_THROW(ordered_probit_lpmf(4, lambda, c), std::domain_error); } TEST(ProbDistributions, ordered_probit) { - using stan::math::ordered_probit_log; + using stan::math::ordered_probit_lpmf; int K = 4; Eigen::Matrix c(K - 1); c << -0.3, 0.1, 1.2; double lambda = 0.5; - EXPECT_THROW(ordered_probit_log(-1, lambda, c), std::domain_error); - EXPECT_THROW(ordered_probit_log(0, lambda, c), std::domain_error); - EXPECT_THROW(ordered_probit_log(5, lambda, c), std::domain_error); + EXPECT_THROW(ordered_probit_lpmf(-1, lambda, c), std::domain_error); + EXPECT_THROW(ordered_probit_lpmf(0, lambda, c), std::domain_error); + EXPECT_THROW(ordered_probit_lpmf(5, lambda, c), std::domain_error); for (int k = 1; k <= K; ++k) - EXPECT_NO_THROW(ordered_probit_log(k, lambda, c)); + EXPECT_NO_THROW(ordered_probit_lpmf(k, lambda, c)); // init size zero Eigen::Matrix c_zero; EXPECT_EQ(0, c_zero.size()); - EXPECT_THROW(ordered_probit_log(1, lambda, c_zero), std::invalid_argument); + EXPECT_THROW(ordered_probit_lpmf(1, lambda, c_zero), std::invalid_argument); Eigen::Matrix c_neg(1); c_neg << -13.7; - EXPECT_NO_THROW(ordered_probit_log(1, lambda, c_neg)); + EXPECT_NO_THROW(ordered_probit_lpmf(1, lambda, c_neg)); Eigen::Matrix c_unord(3); c_unord << 1.0, 0.4, 2.0; - EXPECT_THROW(ordered_probit_log(1, lambda, c_unord), std::domain_error); + EXPECT_THROW(ordered_probit_lpmf(1, lambda, c_unord), std::domain_error); Eigen::Matrix c_unord_2(3); c_unord_2 << 1.0, 2.0, 0.4; - EXPECT_THROW(ordered_probit_log(1, lambda, c_unord_2), std::domain_error); + EXPECT_THROW(ordered_probit_lpmf(1, lambda, c_unord_2), std::domain_error); double nan = std::numeric_limits::quiet_NaN(); double inf = std::numeric_limits::infinity(); - EXPECT_THROW(ordered_probit_log(1, nan, c), std::domain_error); - EXPECT_THROW(ordered_probit_log(1, inf, c), std::domain_error); + EXPECT_THROW(ordered_probit_lpmf(1, nan, c), std::domain_error); + EXPECT_THROW(ordered_probit_lpmf(1, inf, c), std::domain_error); Eigen::Matrix cbad(2); cbad << 0.2, inf; - EXPECT_THROW(ordered_probit_log(1, 1.0, cbad), std::domain_error); + EXPECT_THROW(ordered_probit_lpmf(1, 1.0, cbad), std::domain_error); cbad[1] = nan; - EXPECT_THROW(ordered_probit_log(1, 1.0, cbad), std::domain_error); + EXPECT_THROW(ordered_probit_lpmf(1, 1.0, cbad), std::domain_error); Eigen::Matrix cbad1(1); cbad1 << inf; - EXPECT_THROW(ordered_probit_log(1, 1.0, cbad1), std::domain_error); + EXPECT_THROW(ordered_probit_lpmf(1, 1.0, cbad1), std::domain_error); cbad1[0] = nan; - EXPECT_THROW(ordered_probit_log(1, 1.0, cbad1), std::domain_error); + EXPECT_THROW(ordered_probit_lpmf(1, 1.0, cbad1), std::domain_error); Eigen::Matrix cbad3(3); cbad3 << 0.5, inf, 1.0; - EXPECT_THROW(ordered_probit_log(1, 1.0, cbad3), std::domain_error); + EXPECT_THROW(ordered_probit_lpmf(1, 1.0, cbad3), std::domain_error); cbad3[1] = nan; - EXPECT_THROW(ordered_probit_log(1, 1.0, cbad3), std::domain_error); + EXPECT_THROW(ordered_probit_lpmf(1, 1.0, cbad3), std::domain_error); } TEST(ProbDistributionOrderedProbit, error_check) { diff --git a/test/unit/math/prim/prob/poisson_test.cpp b/test/unit/math/prim/prob/poisson_test.cpp index 1966cbe14e1..709395c481a 100644 --- a/test/unit/math/prim/prob/poisson_test.cpp +++ b/test/unit/math/prim/prob/poisson_test.cpp @@ -130,21 +130,3 @@ TEST(ProbDistributionsPoisson, chiSquareGoodnessFitTest2) { EXPECT_TRUE(chi < quantile(complement(mydist, 1e-6))); } - -TEST(ProbPoisson, log_matches_lpmf) { - int y = 3; - double lambda = 2.3; - - EXPECT_FLOAT_EQ((stan::math::poisson_lpmf(y, lambda)), - (stan::math::poisson_log(y, lambda))); - EXPECT_FLOAT_EQ((stan::math::poisson_lpmf(y, lambda)), - (stan::math::poisson_log(y, lambda))); - EXPECT_FLOAT_EQ((stan::math::poisson_lpmf(y, lambda)), - (stan::math::poisson_log(y, lambda))); - EXPECT_FLOAT_EQ((stan::math::poisson_lpmf(y, lambda)), - (stan::math::poisson_log(y, lambda))); - EXPECT_FLOAT_EQ((stan::math::poisson_lpmf(y, lambda)), - (stan::math::poisson_log(y, lambda))); - EXPECT_FLOAT_EQ((stan::math::poisson_lpmf(y, lambda)), - (stan::math::poisson_log(y, lambda))); -} diff --git a/test/unit/math/prim/prob/wiener_test.cpp b/test/unit/math/prim/prob/wiener_test.cpp index 15906138915..a86f21bb974 100644 --- a/test/unit/math/prim/prob/wiener_test.cpp +++ b/test/unit/math/prim/prob/wiener_test.cpp @@ -3,14 +3,14 @@ #include TEST(mathPrimScalProbWienerMat, illegal_tau_gt_y) { - using stan::math::wiener_log; + using stan::math::wiener_lpdf; std::vector ys; ys.push_back(2.5); ys.push_back(0.4); - EXPECT_THROW(wiener_log(ys, 4.1, 1.9, 0.05, 0.1), std::domain_error); + EXPECT_THROW(wiener_lpdf(ys, 4.1, 1.9, 0.05, 0.1), std::domain_error); } TEST(mathPrimScalProbWienerScal, illegal_tau_gt_y) { - using stan::math::wiener_log; - EXPECT_THROW(wiener_log(0.4, 4.1, 1.9, 0.05, 0.1), std::domain_error); + using stan::math::wiener_lpdf; + EXPECT_THROW(wiener_lpdf(0.4, 4.1, 1.9, 0.05, 0.1), std::domain_error); } diff --git a/test/unit/math/prim/prob/wishart_test.cpp b/test/unit/math/prim/prob/wishart_test.cpp index 9e1b12d762d..85df75934a4 100644 --- a/test/unit/math/prim/prob/wishart_test.cpp +++ b/test/unit/math/prim/prob/wishart_test.cpp @@ -9,7 +9,7 @@ TEST(ProbDistributionsWishart, wishart_symmetry) { using Eigen::Matrix; using Eigen::MatrixXd; - using stan::math::wishart_log; + using stan::math::wishart_lpdf; MatrixXd Sigma(4, 4); MatrixXd Sigma_non_sym(4, 4); @@ -34,9 +34,9 @@ TEST(ProbDistributionsWishart, wishart_symmetry) { unsigned int dof = 5; - EXPECT_NO_THROW(wishart_log(Y, dof, Sigma)); - EXPECT_THROW(wishart_log(Y_non_sym, dof, Sigma), std::domain_error); - EXPECT_THROW(wishart_log(Y, dof, Sigma_non_sym), std::domain_error); + EXPECT_NO_THROW(wishart_lpdf(Y, dof, Sigma)); + EXPECT_THROW(wishart_lpdf(Y_non_sym, dof, Sigma), std::domain_error); + EXPECT_THROW(wishart_lpdf(Y, dof, Sigma_non_sym), std::domain_error); } TEST(ProbDistributionsWishart, wishart_pos_def) { @@ -44,7 +44,7 @@ TEST(ProbDistributionsWishart, wishart_pos_def) { using Eigen::Matrix; using Eigen::MatrixXd; - using stan::math::wishart_log; + using stan::math::wishart_lpdf; MatrixXd Sigma(2, 2); MatrixXd Sigma_non_pos_def(2, 2); @@ -58,9 +58,9 @@ TEST(ProbDistributionsWishart, wishart_pos_def) { unsigned int dof = 5; - EXPECT_NO_THROW(wishart_log(Y, dof, Sigma)); - EXPECT_THROW(wishart_log(Y_non_pos_def, dof, Sigma), std::domain_error); - EXPECT_THROW(wishart_log(Y, dof, Sigma_non_pos_def), std::domain_error); + EXPECT_NO_THROW(wishart_lpdf(Y, dof, Sigma)); + EXPECT_THROW(wishart_lpdf(Y_non_pos_def, dof, Sigma), std::domain_error); + EXPECT_THROW(wishart_lpdf(Y, dof, Sigma_non_pos_def), std::domain_error); } TEST(ProbDistributionsWishart, 2x2) { @@ -77,7 +77,7 @@ TEST(ProbDistributionsWishart, 2x2) { // computed with MCMCpack in R double lp = log(8.658e-07); - EXPECT_NEAR(lp, stan::math::wishart_log(Y, dof, Sigma), 0.01); + EXPECT_NEAR(lp, stan::math::wishart_lpdf(Y, dof, Sigma), 0.01); } TEST(ProbDistributionsWishart, 4x4) { using Eigen::Dynamic; @@ -94,11 +94,11 @@ TEST(ProbDistributionsWishart, 4x4) { double dof = 4; double log_p = log(8.034197e-10); - EXPECT_NEAR(log_p, stan::math::wishart_log(Y, dof, Sigma), 0.01); + EXPECT_NEAR(log_p, stan::math::wishart_lpdf(Y, dof, Sigma), 0.01); dof = 5; log_p = log(1.517951e-10); - EXPECT_NEAR(log_p, stan::math::wishart_log(Y, dof, Sigma), 0.01); + EXPECT_NEAR(log_p, stan::math::wishart_lpdf(Y, dof, Sigma), 0.01); } TEST(ProbDistributionsWishart, 2x2Propto) { @@ -112,7 +112,7 @@ TEST(ProbDistributionsWishart, 2x2Propto) { unsigned int dof = 3; - EXPECT_FLOAT_EQ(0.0, stan::math::wishart_log(Y, dof, Sigma)); + EXPECT_FLOAT_EQ(0.0, stan::math::wishart_lpdf(Y, dof, Sigma)); } TEST(ProbDistributionsWishart, 4x4Propto) { @@ -129,16 +129,16 @@ TEST(ProbDistributionsWishart, 4x4Propto) { 0.1055911, -3.1129955, -3.5866852, 1.4482736; double dof = 4; - EXPECT_FLOAT_EQ(0.0, stan::math::wishart_log(Y, dof, Sigma)); + EXPECT_FLOAT_EQ(0.0, stan::math::wishart_lpdf(Y, dof, Sigma)); dof = 5; - EXPECT_FLOAT_EQ(0.0, stan::math::wishart_log(Y, dof, Sigma)); + EXPECT_FLOAT_EQ(0.0, stan::math::wishart_lpdf(Y, dof, Sigma)); } TEST(ProbDistributionsWishart, error) { using Eigen::Dynamic; using Eigen::Matrix; - using stan::math::wishart_log; + using stan::math::wishart_lpdf; Matrix Sigma; Matrix Y; double nu; @@ -148,28 +148,28 @@ TEST(ProbDistributionsWishart, error) { Sigma.setIdentity(); Y.setIdentity(); nu = 1; - EXPECT_NO_THROW(wishart_log(Y, nu, Sigma)); + EXPECT_NO_THROW(wishart_lpdf(Y, nu, Sigma)); nu = 5; Sigma.resize(2, 1); - EXPECT_THROW(wishart_log(Y, nu, Sigma), std::invalid_argument); + EXPECT_THROW(wishart_lpdf(Y, nu, Sigma), std::invalid_argument); nu = 5; Sigma.resize(2, 2); Y.resize(2, 1); - EXPECT_THROW(wishart_log(Y, nu, Sigma), std::invalid_argument); + EXPECT_THROW(wishart_lpdf(Y, nu, Sigma), std::invalid_argument); nu = 5; Sigma.resize(2, 2); Y.resize(3, 3); - EXPECT_THROW(wishart_log(Y, nu, Sigma), std::invalid_argument); + EXPECT_THROW(wishart_lpdf(Y, nu, Sigma), std::invalid_argument); Sigma.resize(3, 3); Sigma.setIdentity(); Y.resize(3, 3); Y.setIdentity(); nu = 3; - EXPECT_NO_THROW(wishart_log(Y, nu, Sigma)); + EXPECT_NO_THROW(wishart_lpdf(Y, nu, Sigma)); nu = 2; - EXPECT_THROW(wishart_log(Y, nu, Sigma), std::domain_error); + EXPECT_THROW(wishart_lpdf(Y, nu, Sigma), std::domain_error); } diff --git a/test/unit/math/rev/fun/cholesky_decompose_test.cpp b/test/unit/math/rev/fun/cholesky_decompose_test.cpp index 60e7f54aa35..d04fab845a2 100644 --- a/test/unit/math/rev/fun/cholesky_decompose_test.cpp +++ b/test/unit/math/rev/fun/cholesky_decompose_test.cpp @@ -77,7 +77,7 @@ struct chol_functor_2 { T operator()(Eigen::Matrix x) const { using stan::math::cholesky_decompose; using stan::math::cov_matrix_constrain; - using stan::math::multi_normal_cholesky_log; + using stan::math::multi_normal_cholesky_lpdf; T lp(0.0); Eigen::Matrix x_c = cov_matrix_constrain(x, K, lp); Eigen::Matrix L = cholesky_decompose(x_c); @@ -85,7 +85,7 @@ struct chol_functor_2 { Eigen::Matrix mu(K); vec.setZero(); mu.setOnes(); - lp += multi_normal_cholesky_log(vec, mu, L); + lp += multi_normal_cholesky_lpdf(vec, mu, L); return lp; } }; diff --git a/test/unit/math/rev/prob/categorical2_test.cpp b/test/unit/math/rev/prob/categorical2_test.cpp index 3de7118d72e..97b3344a84e 100644 --- a/test/unit/math/rev/prob/categorical2_test.cpp +++ b/test/unit/math/rev/prob/categorical2_test.cpp @@ -4,13 +4,13 @@ #include template -void expect_propto_categorical_log(unsigned int n1, T_prob theta1, - unsigned int n2, T_prob theta2, - std::string message) { - expect_eq_diffs(stan::math::categorical_log(n1, theta1), - stan::math::categorical_log(n2, theta2), - stan::math::categorical_log(n1, theta1), - stan::math::categorical_log(n2, theta2), message); +void expect_propto_categorical_lpmf(unsigned int n1, T_prob theta1, + unsigned int n2, T_prob theta2, + std::string message) { + expect_eq_diffs(stan::math::categorical_lpmf(n1, theta1), + stan::math::categorical_lpmf(n2, theta2), + stan::math::categorical_lpmf(n1, theta1), + stan::math::categorical_lpmf(n2, theta2), message); } TEST(AgradDistributionsCategorical, Propto) { @@ -24,11 +24,11 @@ TEST(AgradDistributionsCategorical, Propto) { theta2 << 0.1, 0.2, 0.7; n = 1; - expect_propto_categorical_log(n, theta1, n, theta2, "var: theta"); + expect_propto_categorical_lpmf(n, theta1, n, theta2, "var: theta"); n = 2; - expect_propto_categorical_log(n, theta1, n, theta2, "var: theta"); + expect_propto_categorical_lpmf(n, theta1, n, theta2, "var: theta"); n = 3; - expect_propto_categorical_log(n, theta1, n, theta2, "var: theta"); + expect_propto_categorical_lpmf(n, theta1, n, theta2, "var: theta"); } diff --git a/test/unit/math/rev/prob/dirichlet2_test.cpp b/test/unit/math/rev/prob/dirichlet2_test.cpp index b9b9d39c399..57f23995c63 100644 --- a/test/unit/math/rev/prob/dirichlet2_test.cpp +++ b/test/unit/math/rev/prob/dirichlet2_test.cpp @@ -4,13 +4,13 @@ #include template -void expect_propto_dirichlet_log(T_prob theta, T_prior_sample_size alpha, - T_prob theta2, T_prior_sample_size alpha2, - std::string message) { - expect_eq_diffs(stan::math::dirichlet_log(theta, alpha), - stan::math::dirichlet_log(theta2, alpha2), - stan::math::dirichlet_log(theta, alpha), - stan::math::dirichlet_log(theta2, alpha2), message); +void expect_propto_dirichlet_lpdf(T_prob theta, T_prior_sample_size alpha, + T_prob theta2, T_prior_sample_size alpha2, + std::string message) { + expect_eq_diffs(stan::math::dirichlet_lpdf(theta, alpha), + stan::math::dirichlet_lpdf(theta2, alpha2), + stan::math::dirichlet_lpdf(theta, alpha), + stan::math::dirichlet_lpdf(theta2, alpha2), message); } class AgradDistributionsDirichlet : public ::testing::Test { @@ -36,29 +36,29 @@ TEST_F(AgradDistributionsDirichlet, Propto) { using Eigen::Matrix; using stan::math::to_var; using stan::math::var; - expect_propto_dirichlet_log(to_var(theta), to_var(alpha), to_var(theta2), - to_var(alpha2), "var: theta and alpha"); + expect_propto_dirichlet_lpdf(to_var(theta), to_var(alpha), to_var(theta2), + to_var(alpha2), "var: theta and alpha"); } TEST_F(AgradDistributionsDirichlet, ProptoTheta) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::to_var; using stan::math::var; - expect_propto_dirichlet_log(to_var(theta), alpha, to_var(theta2), alpha, - "var: theta"); + expect_propto_dirichlet_lpdf(to_var(theta), alpha, to_var(theta2), alpha, + "var: theta"); } TEST_F(AgradDistributionsDirichlet, ProptoAlpha) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::to_var; using stan::math::var; - expect_propto_dirichlet_log(theta, to_var(alpha), theta, to_var(alpha2), - "var: alpha"); + expect_propto_dirichlet_lpdf(theta, to_var(alpha), theta, to_var(alpha2), + "var: alpha"); } TEST_F(AgradDistributionsDirichlet, Bounds) { using Eigen::Dynamic; using Eigen::Matrix; - using stan::math::dirichlet_log; + using stan::math::dirichlet_lpdf; using stan::math::to_var; using stan::math::var; Matrix good_alpha(2, 1), bad_alpha(2, 1); @@ -66,73 +66,73 @@ TEST_F(AgradDistributionsDirichlet, Bounds) { good_theta << 0.25, 0.75; good_alpha << 2, 3; - EXPECT_NO_THROW(dirichlet_log(to_var(good_theta), to_var(good_alpha))); - EXPECT_NO_THROW(dirichlet_log(to_var(good_theta), good_alpha)); - EXPECT_NO_THROW(dirichlet_log(good_theta, to_var(good_alpha))); + EXPECT_NO_THROW(dirichlet_lpdf(to_var(good_theta), to_var(good_alpha))); + EXPECT_NO_THROW(dirichlet_lpdf(to_var(good_theta), good_alpha)); + EXPECT_NO_THROW(dirichlet_lpdf(good_theta, to_var(good_alpha))); good_theta << 1.0, 0.0; good_alpha << 2, 3; - EXPECT_NO_THROW(dirichlet_log(to_var(good_theta), to_var(good_alpha))) + EXPECT_NO_THROW(dirichlet_lpdf(to_var(good_theta), to_var(good_alpha))) << "elements of theta can be 0"; - EXPECT_NO_THROW(dirichlet_log(to_var(good_theta), good_alpha)) + EXPECT_NO_THROW(dirichlet_lpdf(to_var(good_theta), good_alpha)) << "elements of theta can be 0"; - EXPECT_NO_THROW(dirichlet_log(good_theta, to_var(good_alpha))) + EXPECT_NO_THROW(dirichlet_lpdf(good_theta, to_var(good_alpha))) << "elements of theta can be 0"; bad_theta << 0.25, 0.25; - EXPECT_THROW(dirichlet_log(to_var(bad_theta), to_var(good_alpha)), + EXPECT_THROW(dirichlet_lpdf(to_var(bad_theta), to_var(good_alpha)), std::domain_error) << "sum of theta is not 1"; - EXPECT_THROW(dirichlet_log(to_var(bad_theta), good_alpha), std::domain_error) + EXPECT_THROW(dirichlet_lpdf(to_var(bad_theta), good_alpha), std::domain_error) << "sum of theta is not 1"; - EXPECT_THROW(dirichlet_log(bad_theta, to_var(good_alpha)), std::domain_error) + EXPECT_THROW(dirichlet_lpdf(bad_theta, to_var(good_alpha)), std::domain_error) << "sum of theta is not 1"; bad_theta << -0.25, 1.25; - EXPECT_THROW(dirichlet_log(to_var(bad_theta), to_var(good_alpha)), + EXPECT_THROW(dirichlet_lpdf(to_var(bad_theta), to_var(good_alpha)), std::domain_error) << "theta has element less than 0"; - EXPECT_THROW(dirichlet_log(to_var(bad_theta), good_alpha), std::domain_error) + EXPECT_THROW(dirichlet_lpdf(to_var(bad_theta), good_alpha), std::domain_error) << "theta has element less than 0"; - EXPECT_THROW(dirichlet_log(bad_theta, to_var(good_alpha)), std::domain_error) + EXPECT_THROW(dirichlet_lpdf(bad_theta, to_var(good_alpha)), std::domain_error) << "theta has element less than 0"; bad_theta << -0.25, 1.25; - EXPECT_THROW(dirichlet_log(to_var(bad_theta), to_var(good_alpha)), + EXPECT_THROW(dirichlet_lpdf(to_var(bad_theta), to_var(good_alpha)), std::domain_error) << "theta has element less than 0"; - EXPECT_THROW(dirichlet_log(to_var(bad_theta), good_alpha), std::domain_error) + EXPECT_THROW(dirichlet_lpdf(to_var(bad_theta), good_alpha), std::domain_error) << "theta has element less than 0"; - EXPECT_THROW(dirichlet_log(bad_theta, to_var(good_alpha)), std::domain_error) + EXPECT_THROW(dirichlet_lpdf(bad_theta, to_var(good_alpha)), std::domain_error) << "theta has element less than 0"; bad_alpha << 0.0, 1.0; - EXPECT_THROW(dirichlet_log(to_var(good_theta), to_var(bad_alpha)), + EXPECT_THROW(dirichlet_lpdf(to_var(good_theta), to_var(bad_alpha)), std::domain_error) << "alpha has element equal to 0"; - EXPECT_THROW(dirichlet_log(to_var(good_theta), bad_alpha), std::domain_error) + EXPECT_THROW(dirichlet_lpdf(to_var(good_theta), bad_alpha), std::domain_error) << "alpha has element equal to 0"; - EXPECT_THROW(dirichlet_log(good_theta, to_var(bad_alpha)), std::domain_error) + EXPECT_THROW(dirichlet_lpdf(good_theta, to_var(bad_alpha)), std::domain_error) << "alpha has element equal to 0"; bad_alpha << -0.5, 1.0; - EXPECT_THROW(dirichlet_log(to_var(good_theta), to_var(bad_alpha)), + EXPECT_THROW(dirichlet_lpdf(to_var(good_theta), to_var(bad_alpha)), std::domain_error) << "alpha has element less than 0"; - EXPECT_THROW(dirichlet_log(to_var(good_theta), bad_alpha), std::domain_error) + EXPECT_THROW(dirichlet_lpdf(to_var(good_theta), bad_alpha), std::domain_error) << "alpha has element less than 0"; - EXPECT_THROW(dirichlet_log(good_theta, to_var(bad_alpha)), std::domain_error) + EXPECT_THROW(dirichlet_lpdf(good_theta, to_var(bad_alpha)), std::domain_error) << "alpha has element less than 0"; bad_alpha = Matrix(4, 1); bad_alpha << 1, 2, 3, 4; - EXPECT_THROW(dirichlet_log(to_var(good_theta), to_var(bad_alpha)), + EXPECT_THROW(dirichlet_lpdf(to_var(good_theta), to_var(bad_alpha)), std::invalid_argument) << "size mismatch: theta is a 2-vector, alpha is a 4-vector"; - EXPECT_THROW(dirichlet_log(to_var(good_theta), bad_alpha), + EXPECT_THROW(dirichlet_lpdf(to_var(good_theta), bad_alpha), std::invalid_argument) << "size mismatch: theta is a 2-vector, alpha is a 4-vector"; - EXPECT_THROW(dirichlet_log(good_theta, to_var(bad_alpha)), + EXPECT_THROW(dirichlet_lpdf(good_theta, to_var(bad_alpha)), std::invalid_argument) << "size mismatch: theta is a 2-vector, alpha is a 4-vector"; } diff --git a/test/unit/math/rev/prob/inv_wishart2_test.cpp b/test/unit/math/rev/prob/inv_wishart2_test.cpp index ed9919ac7b1..cc70da88423 100644 --- a/test/unit/math/rev/prob/inv_wishart2_test.cpp +++ b/test/unit/math/rev/prob/inv_wishart2_test.cpp @@ -5,12 +5,13 @@ #include template -void expect_propto_inv_wishart_log(T_y W1, T_dof nu1, T_scale S1, T_y W2, - T_dof nu2, T_scale S2, std::string message) { - expect_eq_diffs(stan::math::inv_wishart_log(W1, nu1, S1), - stan::math::inv_wishart_log(W2, nu2, S2), - stan::math::inv_wishart_log(W1, nu1, S1), - stan::math::inv_wishart_log(W2, nu2, S2), message); +void expect_propto_inv_wishart_lpdf(T_y W1, T_dof nu1, T_scale S1, T_y W2, + T_dof nu2, T_scale S2, + std::string message) { + expect_eq_diffs(stan::math::inv_wishart_lpdf(W1, nu1, S1), + stan::math::inv_wishart_lpdf(W2, nu2, S2), + stan::math::inv_wishart_lpdf(W1, nu1, S1), + stan::math::inv_wishart_lpdf(W2, nu2, S2), message); } class AgradDistributionsInvWishart : public ::testing::Test { @@ -42,39 +43,39 @@ class AgradDistributionsInvWishart : public ::testing::Test { TEST_F(AgradDistributionsInvWishart, Propto) { using stan::math::to_var; - expect_propto_inv_wishart_log(to_var(Y1), to_var(nu1), to_var(S1), to_var(Y2), - to_var(nu2), to_var(S2), - "var: y, nu, and sigma"); + expect_propto_inv_wishart_lpdf(to_var(Y1), to_var(nu1), to_var(S1), + to_var(Y2), to_var(nu2), to_var(S2), + "var: y, nu, and sigma"); } TEST_F(AgradDistributionsInvWishart, ProptoY) { using stan::math::to_var; - expect_propto_inv_wishart_log(to_var(Y1), nu1, S1, to_var(Y2), nu1, S1, - "var: y"); + expect_propto_inv_wishart_lpdf(to_var(Y1), nu1, S1, to_var(Y2), nu1, S1, + "var: y"); } TEST_F(AgradDistributionsInvWishart, ProptoYNu) { using stan::math::to_var; - expect_propto_inv_wishart_log(to_var(Y1), to_var(nu1), S1, to_var(Y2), - to_var(nu2), S1, "var: y, and nu"); + expect_propto_inv_wishart_lpdf(to_var(Y1), to_var(nu1), S1, to_var(Y2), + to_var(nu2), S1, "var: y, and nu"); } TEST_F(AgradDistributionsInvWishart, ProptoYSigma) { using stan::math::to_var; - expect_propto_inv_wishart_log(to_var(Y1), nu1, to_var(S1), to_var(Y2), nu1, - to_var(S2), "var: y and sigma"); + expect_propto_inv_wishart_lpdf(to_var(Y1), nu1, to_var(S1), to_var(Y2), nu1, + to_var(S2), "var: y and sigma"); } TEST_F(AgradDistributionsInvWishart, ProptoNu) { using stan::math::to_var; - expect_propto_inv_wishart_log(Y1, to_var(nu1), S1, Y1, to_var(nu2), S1, - "var: nu"); + expect_propto_inv_wishart_lpdf(Y1, to_var(nu1), S1, Y1, to_var(nu2), S1, + "var: nu"); } TEST_F(AgradDistributionsInvWishart, ProptoNuSigma) { using stan::math::to_var; - expect_propto_inv_wishart_log(Y1, to_var(nu1), to_var(S1), Y1, to_var(nu2), - to_var(S2), "var: nu and sigma"); + expect_propto_inv_wishart_lpdf(Y1, to_var(nu1), to_var(S1), Y1, to_var(nu2), + to_var(S2), "var: nu and sigma"); } TEST_F(AgradDistributionsInvWishart, ProptoSigma) { using stan::math::to_var; - expect_propto_inv_wishart_log(Y1, nu1, to_var(S1), Y1, nu1, to_var(S2), - "var: sigma"); + expect_propto_inv_wishart_lpdf(Y1, nu1, to_var(S1), Y1, nu1, to_var(S2), + "var: sigma"); } TEST(InvWishart, check_varis_on_stack) { @@ -88,34 +89,34 @@ TEST(InvWishart, check_varis_on_stack) { S << 1.848220, 1.899623, 1.899623, 12.751941; test::check_varis_on_stack( - stan::math::inv_wishart_log(to_var(W), to_var(nu), to_var(S))); + stan::math::inv_wishart_lpdf(to_var(W), to_var(nu), to_var(S))); test::check_varis_on_stack( - stan::math::inv_wishart_log(to_var(W), to_var(nu), S)); + stan::math::inv_wishart_lpdf(to_var(W), to_var(nu), S)); test::check_varis_on_stack( - stan::math::inv_wishart_log(to_var(W), nu, to_var(S))); + stan::math::inv_wishart_lpdf(to_var(W), nu, to_var(S))); test::check_varis_on_stack( - stan::math::inv_wishart_log(to_var(W), nu, S)); + stan::math::inv_wishart_lpdf(to_var(W), nu, S)); test::check_varis_on_stack( - stan::math::inv_wishart_log(W, to_var(nu), to_var(S))); + stan::math::inv_wishart_lpdf(W, to_var(nu), to_var(S))); test::check_varis_on_stack( - stan::math::inv_wishart_log(W, to_var(nu), S)); + stan::math::inv_wishart_lpdf(W, to_var(nu), S)); test::check_varis_on_stack( - stan::math::inv_wishart_log(W, nu, to_var(S))); + stan::math::inv_wishart_lpdf(W, nu, to_var(S))); test::check_varis_on_stack( - stan::math::inv_wishart_log(to_var(W), to_var(nu), to_var(S))); + stan::math::inv_wishart_lpdf(to_var(W), to_var(nu), to_var(S))); test::check_varis_on_stack( - stan::math::inv_wishart_log(to_var(W), to_var(nu), S)); + stan::math::inv_wishart_lpdf(to_var(W), to_var(nu), S)); test::check_varis_on_stack( - stan::math::inv_wishart_log(to_var(W), nu, to_var(S))); + stan::math::inv_wishart_lpdf(to_var(W), nu, to_var(S))); test::check_varis_on_stack( - stan::math::inv_wishart_log(to_var(W), nu, S)); + stan::math::inv_wishart_lpdf(to_var(W), nu, S)); test::check_varis_on_stack( - stan::math::inv_wishart_log(W, to_var(nu), to_var(S))); + stan::math::inv_wishart_lpdf(W, to_var(nu), to_var(S))); test::check_varis_on_stack( - stan::math::inv_wishart_log(W, to_var(nu), S)); + stan::math::inv_wishart_lpdf(W, to_var(nu), S)); test::check_varis_on_stack( - stan::math::inv_wishart_log(W, nu, to_var(S))); + stan::math::inv_wishart_lpdf(W, nu, to_var(S))); stan::math::recover_memory(); } diff --git a/test/unit/math/rev/prob/lkj_corr_cholesky_test_functors.hpp b/test/unit/math/rev/prob/lkj_corr_cholesky_test_functors.hpp index 266bd61b77c..e3871ef7c43 100644 --- a/test/unit/math/rev/prob/lkj_corr_cholesky_test_functors.hpp +++ b/test/unit/math/rev/prob/lkj_corr_cholesky_test_functors.hpp @@ -11,14 +11,14 @@ template return_type_t lkj_corr_cholesky_uc( Eigen::Matrix L, T_eta eta, int K) { using math::cholesky_corr_constrain; - using math::lkj_corr_cholesky_log; + using math::lkj_corr_cholesky_lpdf; using math::positive_constrain; return_type_t lp(0.0); Eigen::Matrix L_c = cholesky_corr_constrain(L, K, lp); T_eta eta_c = positive_constrain(eta, lp); - lp += lkj_corr_cholesky_log(L_c, eta_c); + lp += lkj_corr_cholesky_lpdf(L_c, eta_c); return lp; } @@ -35,11 +35,11 @@ struct lkj_corr_cholesky_cd { } template T operator()(Eigen::Matrix vec) const { - using math::lkj_corr_cholesky_log; + using math::lkj_corr_cholesky_lpdf; using math::positive_constrain; T lp(0.0); T eta_c = positive_constrain(vec(0), lp); - lp += lkj_corr_cholesky_log(L_def, eta_c); + lp += lkj_corr_cholesky_lpdf(L_def, eta_c); return lp; } }; @@ -54,10 +54,10 @@ struct lkj_corr_cholesky_dc { template T operator()(Eigen::Matrix vec) const { using math::cholesky_corr_constrain; - using math::lkj_corr_cholesky_log; + using math::lkj_corr_cholesky_lpdf; T lp(0.0); Eigen::Matrix L_c = cholesky_corr_constrain(vec, K, lp); - lp += lkj_corr_cholesky_log(L_c, eta_c); + lp += lkj_corr_cholesky_lpdf(L_c, eta_c); return lp; } }; diff --git a/test/unit/math/rev/prob/lkj_corr_test.cpp b/test/unit/math/rev/prob/lkj_corr_test.cpp index 9faa3024e8f..94a61c66927 100644 --- a/test/unit/math/rev/prob/lkj_corr_test.cpp +++ b/test/unit/math/rev/prob/lkj_corr_test.cpp @@ -18,13 +18,13 @@ TEST(ProbDistributionsLkjCorr, var) { Sigma_d.diagonal().setOnes(); var eta = stan::math::uniform_rng(0, 2, rng); var f = stan::math::do_lkj_constant(eta, K); - EXPECT_FLOAT_EQ(f.val(), stan::math::lkj_corr_log(Sigma, eta).val()); - EXPECT_FLOAT_EQ(f.val(), stan::math::lkj_corr_log(Sigma_d, eta).val()); + EXPECT_FLOAT_EQ(f.val(), stan::math::lkj_corr_lpdf(Sigma, eta).val()); + EXPECT_FLOAT_EQ(f.val(), stan::math::lkj_corr_lpdf(Sigma_d, eta).val()); eta = 1.0; double eta_d = 1.0; f = stan::math::do_lkj_constant(eta, K); - EXPECT_FLOAT_EQ(f.val(), stan::math::lkj_corr_log(Sigma, eta).val()); - EXPECT_FLOAT_EQ(f.val(), stan::math::lkj_corr_log(Sigma, eta_d).val()); + EXPECT_FLOAT_EQ(f.val(), stan::math::lkj_corr_lpdf(Sigma, eta).val()); + EXPECT_FLOAT_EQ(f.val(), stan::math::lkj_corr_lpdf(Sigma, eta_d).val()); } TEST(ProbDistributionsLkjCorrCholesky, var) { @@ -39,15 +39,17 @@ TEST(ProbDistributionsLkjCorrCholesky, var) { Sigma_d.diagonal().setOnes(); var eta = stan::math::uniform_rng(0, 2, rng); var f = stan::math::do_lkj_constant(eta, K); - EXPECT_FLOAT_EQ(f.val(), stan::math::lkj_corr_cholesky_log(Sigma, eta).val()); EXPECT_FLOAT_EQ(f.val(), - stan::math::lkj_corr_cholesky_log(Sigma_d, eta).val()); + stan::math::lkj_corr_cholesky_lpdf(Sigma, eta).val()); + EXPECT_FLOAT_EQ(f.val(), + stan::math::lkj_corr_cholesky_lpdf(Sigma_d, eta).val()); eta = 1.0; double eta_d = 1.0; f = stan::math::do_lkj_constant(eta, K); - EXPECT_FLOAT_EQ(f.val(), stan::math::lkj_corr_cholesky_log(Sigma, eta).val()); EXPECT_FLOAT_EQ(f.val(), - stan::math::lkj_corr_cholesky_log(Sigma, eta_d).val()); + stan::math::lkj_corr_cholesky_lpdf(Sigma, eta).val()); + EXPECT_FLOAT_EQ(f.val(), + stan::math::lkj_corr_cholesky_lpdf(Sigma, eta_d).val()); } TEST(ProbDistributionsLkjCorrCholesky, gradients) { diff --git a/test/unit/math/rev/prob/multi_gp2_test.cpp b/test/unit/math/rev/prob/multi_gp2_test.cpp index 8a384d89c9f..5e5267c1b5b 100644 --- a/test/unit/math/rev/prob/multi_gp2_test.cpp +++ b/test/unit/math/rev/prob/multi_gp2_test.cpp @@ -10,10 +10,10 @@ template void expect_propto(T_y y1, T_scale sigma1, T_w w1, T_y y2, T_scale sigma2, T_w w2, std::string message = "") { - expect_eq_diffs(stan::math::multi_gp_log(y1, sigma1, w1), - stan::math::multi_gp_log(y2, sigma2, w2), - stan::math::multi_gp_log(y1, sigma1, w1), - stan::math::multi_gp_log(y2, sigma2, w2), message); + expect_eq_diffs(stan::math::multi_gp_lpdf(y1, sigma1, w1), + stan::math::multi_gp_lpdf(y2, sigma2, w2), + stan::math::multi_gp_lpdf(y1, sigma1, w1), + stan::math::multi_gp_lpdf(y2, sigma2, w2), message); } TEST_F(agrad_distributions_multi_gp, Propto) { @@ -73,7 +73,7 @@ TEST(ProbDistributionsMultiGP, MultiGPVar) { w << 1.0, 0.5, 3.0; Matrix Sigma(3, 3); Sigma << 9.0, -3.0, 0.0, -3.0, 4.0, 0.0, 0.0, 0.0, 5.0; - EXPECT_FLOAT_EQ(-46.087162, stan::math::multi_gp_log(y, Sigma, w).val()); + EXPECT_FLOAT_EQ(-46.087162, stan::math::multi_gp_lpdf(y, Sigma, w).val()); stan::math::recover_memory(); } @@ -82,7 +82,7 @@ TEST(ProbDistributionsMultiGP, MultiGPGradientUnivariate) { using Eigen::Dynamic; using Eigen::Matrix; using Eigen::VectorXd; - using stan::math::multi_gp_log; + using stan::math::multi_gp_lpdf; using stan::math::var; using std::vector; @@ -100,7 +100,7 @@ TEST(ProbDistributionsMultiGP, MultiGPGradientUnivariate) { x.push_back(w_var(0)); x.push_back(Sigma_var(0, 0)); - var lp = stan::math::multi_gp_log(y_var, Sigma_var, w_var); + var lp = stan::math::multi_gp_lpdf(y_var, Sigma_var, w_var); vector grad; lp.grad(x, grad); @@ -121,15 +121,16 @@ TEST(ProbDistributionsMultiGP, MultiGPGradientUnivariate) { Matrix y_p(1, 1); y_p(0) = y(0) + epsilon; y_m(0) = y(0) - epsilon; - double grad_diff = (multi_gp_log(y_p, Sigma, w) - multi_gp_log(y_m, Sigma, w)) - / (2 * epsilon); + double grad_diff + = (multi_gp_lpdf(y_p, Sigma, w) - multi_gp_lpdf(y_m, Sigma, w)) + / (2 * epsilon); EXPECT_FLOAT_EQ(grad_diff, grad[0]); Matrix w_m(1, 1); Matrix w_p(1, 1); w_p[0] = w[0] + epsilon; w_m[0] = w[0] - epsilon; - grad_diff = (multi_gp_log(y, Sigma, w_p) - multi_gp_log(y, Sigma, w_m)) + grad_diff = (multi_gp_lpdf(y, Sigma, w_p) - multi_gp_lpdf(y, Sigma, w_m)) / (2 * epsilon); EXPECT_FLOAT_EQ(grad_diff, grad[1]); @@ -137,7 +138,7 @@ TEST(ProbDistributionsMultiGP, MultiGPGradientUnivariate) { Matrix Sigma_p(1, 1); Sigma_p(0) = Sigma(0) + epsilon; Sigma_m(0) = Sigma(0) - epsilon; - grad_diff = (multi_gp_log(y, Sigma_p, w) - multi_gp_log(y, Sigma_m, w)) + grad_diff = (multi_gp_lpdf(y, Sigma_p, w) - multi_gp_lpdf(y, Sigma_m, w)) / (2 * epsilon); EXPECT_FLOAT_EQ(grad_diff, grad[2]); @@ -170,7 +171,7 @@ struct multi_gp_fun { } for (int i = 0; i < K_; ++i) w(i) = x[pos++]; - return stan::math::multi_gp_log(y, Sigma, w); + return stan::math::multi_gp_lpdf(y, Sigma, w); } }; @@ -219,34 +220,34 @@ TEST(MultiGP, check_varis_on_stack) { Sigma << 9.0, -3.0, 0.0, -3.0, 4.0, 0.0, 0.0, 0.0, 5.0; test::check_varis_on_stack( - stan::math::multi_gp_log(to_var(y), to_var(Sigma), to_var(w))); + stan::math::multi_gp_lpdf(to_var(y), to_var(Sigma), to_var(w))); test::check_varis_on_stack( - stan::math::multi_gp_log(to_var(y), to_var(Sigma), w)); + stan::math::multi_gp_lpdf(to_var(y), to_var(Sigma), w)); test::check_varis_on_stack( - stan::math::multi_gp_log(to_var(y), Sigma, to_var(w))); + stan::math::multi_gp_lpdf(to_var(y), Sigma, to_var(w))); test::check_varis_on_stack( - stan::math::multi_gp_log(to_var(y), Sigma, w)); + stan::math::multi_gp_lpdf(to_var(y), Sigma, w)); test::check_varis_on_stack( - stan::math::multi_gp_log(y, to_var(Sigma), to_var(w))); + stan::math::multi_gp_lpdf(y, to_var(Sigma), to_var(w))); test::check_varis_on_stack( - stan::math::multi_gp_log(y, to_var(Sigma), w)); + stan::math::multi_gp_lpdf(y, to_var(Sigma), w)); test::check_varis_on_stack( - stan::math::multi_gp_log(y, Sigma, to_var(w))); + stan::math::multi_gp_lpdf(y, Sigma, to_var(w))); test::check_varis_on_stack( - stan::math::multi_gp_log(to_var(y), to_var(Sigma), to_var(w))); + stan::math::multi_gp_lpdf(to_var(y), to_var(Sigma), to_var(w))); test::check_varis_on_stack( - stan::math::multi_gp_log(to_var(y), to_var(Sigma), w)); + stan::math::multi_gp_lpdf(to_var(y), to_var(Sigma), w)); test::check_varis_on_stack( - stan::math::multi_gp_log(to_var(y), Sigma, to_var(w))); + stan::math::multi_gp_lpdf(to_var(y), Sigma, to_var(w))); test::check_varis_on_stack( - stan::math::multi_gp_log(to_var(y), Sigma, w)); + stan::math::multi_gp_lpdf(to_var(y), Sigma, w)); test::check_varis_on_stack( - stan::math::multi_gp_log(y, to_var(Sigma), to_var(w))); + stan::math::multi_gp_lpdf(y, to_var(Sigma), to_var(w))); test::check_varis_on_stack( - stan::math::multi_gp_log(y, to_var(Sigma), w)); + stan::math::multi_gp_lpdf(y, to_var(Sigma), w)); test::check_varis_on_stack( - stan::math::multi_gp_log(y, Sigma, to_var(w))); + stan::math::multi_gp_lpdf(y, Sigma, to_var(w))); stan::math::recover_memory(); } diff --git a/test/unit/math/rev/prob/multi_gp_cholesky2_test.cpp b/test/unit/math/rev/prob/multi_gp_cholesky2_test.cpp index d7e4eb1f5d3..100e9fe9ea9 100644 --- a/test/unit/math/rev/prob/multi_gp_cholesky2_test.cpp +++ b/test/unit/math/rev/prob/multi_gp_cholesky2_test.cpp @@ -8,50 +8,51 @@ #include template -void expect_propto_multi_gp_cholesky_log(T_y y1, T_scale L1, T_w w1, T_y y2, - T_scale L2, T_w w2, - std::string message = "") { - expect_eq_diffs(stan::math::multi_gp_cholesky_log(y1, L1, w1), - stan::math::multi_gp_cholesky_log(y2, L2, w2), - stan::math::multi_gp_cholesky_log(y1, L1, w1), - stan::math::multi_gp_cholesky_log(y2, L2, w2), message); +void expect_propto_multi_gp_cholesky_lpdf(T_y y1, T_scale L1, T_w w1, T_y y2, + T_scale L2, T_w w2, + std::string message = "") { + expect_eq_diffs(stan::math::multi_gp_cholesky_lpdf(y1, L1, w1), + stan::math::multi_gp_cholesky_lpdf(y2, L2, w2), + stan::math::multi_gp_cholesky_lpdf(y1, L1, w1), + stan::math::multi_gp_cholesky_lpdf(y2, L2, w2), + message); } TEST_F(agrad_distributions_multi_gp_cholesky, Propto) { using stan::math::to_var; - expect_propto_multi_gp_cholesky_log(to_var(y), to_var(L), to_var(w), - to_var(y2), to_var(L2), to_var(w2), - "All vars: y, w, sigma"); + expect_propto_multi_gp_cholesky_lpdf(to_var(y), to_var(L), to_var(w), + to_var(y2), to_var(L2), to_var(w2), + "All vars: y, w, sigma"); } TEST_F(agrad_distributions_multi_gp_cholesky, ProptoY) { using stan::math::to_var; - expect_propto_multi_gp_cholesky_log(to_var(y), L, w, to_var(y2), L, w, - "var: y"); + expect_propto_multi_gp_cholesky_lpdf(to_var(y), L, w, to_var(y2), L, w, + "var: y"); } TEST_F(agrad_distributions_multi_gp_cholesky, ProptoYMu) { using stan::math::to_var; - expect_propto_multi_gp_cholesky_log(to_var(y), L, to_var(w), to_var(y2), L, - to_var(w2), "var: y and w"); + expect_propto_multi_gp_cholesky_lpdf(to_var(y), L, to_var(w), to_var(y2), L, + to_var(w2), "var: y and w"); } TEST_F(agrad_distributions_multi_gp_cholesky, ProptoYSigma) { using stan::math::to_var; - expect_propto_multi_gp_cholesky_log(to_var(y), to_var(L), w, to_var(y2), - to_var(L2), w, "var: y and sigma"); + expect_propto_multi_gp_cholesky_lpdf(to_var(y), to_var(L), w, to_var(y2), + to_var(L2), w, "var: y and sigma"); } TEST_F(agrad_distributions_multi_gp_cholesky, ProptoMu) { using stan::math::to_var; - expect_propto_multi_gp_cholesky_log(y, L, to_var(w), y, L, to_var(w2), - "var: w"); + expect_propto_multi_gp_cholesky_lpdf(y, L, to_var(w), y, L, to_var(w2), + "var: w"); } TEST_F(agrad_distributions_multi_gp_cholesky, ProptoMuSigma) { using stan::math::to_var; - expect_propto_multi_gp_cholesky_log(y, to_var(L), to_var(w), y, to_var(L2), - to_var(w2), "var: w and sigma"); + expect_propto_multi_gp_cholesky_lpdf(y, to_var(L), to_var(w), y, to_var(L2), + to_var(w2), "var: w and sigma"); } TEST_F(agrad_distributions_multi_gp_cholesky, ProptoSigma) { using stan::math::to_var; - expect_propto_multi_gp_cholesky_log(y, to_var(L), w, y, to_var(L2), w, - "var: sigma"); + expect_propto_multi_gp_cholesky_lpdf(y, to_var(L), w, y, to_var(L2), w, + "var: sigma"); } TEST(ProbDistributionsMultiGPCholesky, MultiGPCholeskyVar) { @@ -65,14 +66,15 @@ TEST(ProbDistributionsMultiGPCholesky, MultiGPCholeskyVar) { Matrix Sigma(3, 3); Sigma << 9.0, -3.0, 0.0, -3.0, 4.0, 0.0, 0.0, 0.0, 5.0; Matrix L = Sigma.llt().matrixL(); - EXPECT_FLOAT_EQ(-46.087162, stan::math::multi_gp_cholesky_log(y, L, w).val()); + EXPECT_FLOAT_EQ(-46.087162, + stan::math::multi_gp_cholesky_lpdf(y, L, w).val()); } TEST(ProbDistributionsMultiGPCholesky, MultiGPCholeskyGradientUnivariate) { using Eigen::Dynamic; using Eigen::Matrix; using Eigen::VectorXd; - using stan::math::multi_gp_cholesky_log; + using stan::math::multi_gp_cholesky_lpdf; using stan::math::var; using std::vector; @@ -90,7 +92,7 @@ TEST(ProbDistributionsMultiGPCholesky, MultiGPCholeskyGradientUnivariate) { x.push_back(w_var(0)); x.push_back(L_var(0, 0)); - var lp = stan::math::multi_gp_cholesky_log(y_var, L_var, w_var); + var lp = stan::math::multi_gp_cholesky_lpdf(y_var, L_var, w_var); vector grad; lp.grad(x, grad); @@ -112,7 +114,7 @@ TEST(ProbDistributionsMultiGPCholesky, MultiGPCholeskyGradientUnivariate) { y_p(0) = y(0) + epsilon; y_m(0) = y(0) - epsilon; double grad_diff - = (multi_gp_cholesky_log(y_p, L, w) - multi_gp_cholesky_log(y_m, L, w)) + = (multi_gp_cholesky_lpdf(y_p, L, w) - multi_gp_cholesky_lpdf(y_m, L, w)) / (2 * epsilon); EXPECT_FLOAT_EQ(grad_diff, grad[0]); @@ -121,7 +123,7 @@ TEST(ProbDistributionsMultiGPCholesky, MultiGPCholeskyGradientUnivariate) { w_p[0] = w[0] + epsilon; w_m[0] = w[0] - epsilon; grad_diff - = (multi_gp_cholesky_log(y, L, w_p) - multi_gp_cholesky_log(y, L, w_m)) + = (multi_gp_cholesky_lpdf(y, L, w_p) - multi_gp_cholesky_lpdf(y, L, w_m)) / (2 * epsilon); EXPECT_FLOAT_EQ(grad_diff, grad[1]); @@ -130,7 +132,7 @@ TEST(ProbDistributionsMultiGPCholesky, MultiGPCholeskyGradientUnivariate) { L_p(0) = L(0) + epsilon; L_m(0) = L(0) - epsilon; grad_diff - = (multi_gp_cholesky_log(y, L_p, w) - multi_gp_cholesky_log(y, L_m, w)) + = (multi_gp_cholesky_lpdf(y, L_p, w) - multi_gp_cholesky_lpdf(y, L_m, w)) / (2 * epsilon); EXPECT_FLOAT_EQ(grad_diff, grad[2]); } @@ -162,7 +164,7 @@ struct multi_gp_cholesky_fun { Matrix L = Sigma.llt().matrixL(); for (int i = 0; i < K_; ++i) w(i) = x[pos++]; - return stan::math::multi_gp_cholesky_log(y, L, w); + return stan::math::multi_gp_cholesky_lpdf(y, L, w); } }; @@ -209,33 +211,33 @@ TEST(ProbDistributionsMultiGPCholesky, check_varis_on_stack) { Sigma << 9.0, -3.0, 0.0, -3.0, 4.0, 0.0, 0.0, 0.0, 5.0; Matrix L = Sigma.llt().matrixL(); + test::check_varis_on_stack(stan::math::multi_gp_cholesky_lpdf( + to_var(y), to_var(L), to_var(w))); test::check_varis_on_stack( - stan::math::multi_gp_cholesky_log(to_var(y), to_var(L), to_var(w))); - test::check_varis_on_stack( - stan::math::multi_gp_cholesky_log(to_var(y), to_var(L), w)); + stan::math::multi_gp_cholesky_lpdf(to_var(y), to_var(L), w)); test::check_varis_on_stack( - stan::math::multi_gp_cholesky_log(to_var(y), L, to_var(w))); + stan::math::multi_gp_cholesky_lpdf(to_var(y), L, to_var(w))); test::check_varis_on_stack( - stan::math::multi_gp_cholesky_log(to_var(y), L, w)); + stan::math::multi_gp_cholesky_lpdf(to_var(y), L, w)); test::check_varis_on_stack( - stan::math::multi_gp_cholesky_log(y, to_var(L), to_var(w))); + stan::math::multi_gp_cholesky_lpdf(y, to_var(L), to_var(w))); test::check_varis_on_stack( - stan::math::multi_gp_cholesky_log(y, to_var(L), w)); + stan::math::multi_gp_cholesky_lpdf(y, to_var(L), w)); test::check_varis_on_stack( - stan::math::multi_gp_cholesky_log(y, L, to_var(w))); + stan::math::multi_gp_cholesky_lpdf(y, L, to_var(w))); - test::check_varis_on_stack(stan::math::multi_gp_cholesky_log( + test::check_varis_on_stack(stan::math::multi_gp_cholesky_lpdf( to_var(y), to_var(L), to_var(w))); test::check_varis_on_stack( - stan::math::multi_gp_cholesky_log(to_var(y), to_var(L), w)); + stan::math::multi_gp_cholesky_lpdf(to_var(y), to_var(L), w)); test::check_varis_on_stack( - stan::math::multi_gp_cholesky_log(to_var(y), L, to_var(w))); + stan::math::multi_gp_cholesky_lpdf(to_var(y), L, to_var(w))); test::check_varis_on_stack( - stan::math::multi_gp_cholesky_log(to_var(y), L, w)); + stan::math::multi_gp_cholesky_lpdf(to_var(y), L, w)); test::check_varis_on_stack( - stan::math::multi_gp_cholesky_log(y, to_var(L), to_var(w))); + stan::math::multi_gp_cholesky_lpdf(y, to_var(L), to_var(w))); test::check_varis_on_stack( - stan::math::multi_gp_cholesky_log(y, to_var(L), w)); + stan::math::multi_gp_cholesky_lpdf(y, to_var(L), w)); test::check_varis_on_stack( - stan::math::multi_gp_cholesky_log(y, L, to_var(w))); + stan::math::multi_gp_cholesky_lpdf(y, L, to_var(w))); } diff --git a/test/unit/math/rev/prob/multi_normal2_test.cpp b/test/unit/math/rev/prob/multi_normal2_test.cpp index 45f6355762a..ad125c4d1ee 100644 --- a/test/unit/math/rev/prob/multi_normal2_test.cpp +++ b/test/unit/math/rev/prob/multi_normal2_test.cpp @@ -9,113 +9,114 @@ #include template -void expect_propto_multi_normal_log(T_y y1, T_loc mu1, T_scale sigma1, T_y y2, - T_loc mu2, T_scale sigma2, - std::string message = "") { - expect_eq_diffs(stan::math::multi_normal_log(y1, mu1, sigma1), - stan::math::multi_normal_log(y2, mu2, sigma2), - stan::math::multi_normal_log(y1, mu1, sigma1), - stan::math::multi_normal_log(y2, mu2, sigma2), message); +void expect_propto_multi_normal_lpdf(T_y y1, T_loc mu1, T_scale sigma1, T_y y2, + T_loc mu2, T_scale sigma2, + std::string message = "") { + expect_eq_diffs(stan::math::multi_normal_lpdf(y1, mu1, sigma1), + stan::math::multi_normal_lpdf(y2, mu2, sigma2), + stan::math::multi_normal_lpdf(y1, mu1, sigma1), + stan::math::multi_normal_lpdf(y2, mu2, sigma2), + message); } TEST_F(agrad_distributions_multi_normal, Propto) { using stan::math::to_var; - expect_propto_multi_normal_log(to_var(y), to_var(mu), to_var(Sigma), - to_var(y2), to_var(mu2), to_var(Sigma2), - "All vars: y, mu, sigma"); + expect_propto_multi_normal_lpdf(to_var(y), to_var(mu), to_var(Sigma), + to_var(y2), to_var(mu2), to_var(Sigma2), + "All vars: y, mu, sigma"); stan::math::recover_memory(); } TEST_F(agrad_distributions_multi_normal, ProptoY) { using stan::math::to_var; - expect_propto_multi_normal_log(to_var(y), mu, Sigma, to_var(y2), mu, Sigma, - "var: y"); + expect_propto_multi_normal_lpdf(to_var(y), mu, Sigma, to_var(y2), mu, Sigma, + "var: y"); stan::math::recover_memory(); } TEST_F(agrad_distributions_multi_normal, ProptoYMu) { using stan::math::to_var; - expect_propto_multi_normal_log(to_var(y), to_var(mu), Sigma, to_var(y2), - to_var(mu2), Sigma, "var: y and mu"); + expect_propto_multi_normal_lpdf(to_var(y), to_var(mu), Sigma, to_var(y2), + to_var(mu2), Sigma, "var: y and mu"); stan::math::recover_memory(); } TEST_F(agrad_distributions_multi_normal, ProptoYSigma) { using stan::math::to_var; - expect_propto_multi_normal_log(to_var(y), mu, to_var(Sigma), to_var(y2), mu, - to_var(Sigma2), "var: y and sigma"); + expect_propto_multi_normal_lpdf(to_var(y), mu, to_var(Sigma), to_var(y2), mu, + to_var(Sigma2), "var: y and sigma"); stan::math::recover_memory(); } TEST_F(agrad_distributions_multi_normal, ProptoMu) { using stan::math::to_var; - expect_propto_multi_normal_log(y, to_var(mu), Sigma, y, to_var(mu2), Sigma, - "var: mu"); + expect_propto_multi_normal_lpdf(y, to_var(mu), Sigma, y, to_var(mu2), Sigma, + "var: mu"); stan::math::recover_memory(); } TEST_F(agrad_distributions_multi_normal, ProptoMuSigma) { using stan::math::to_var; - expect_propto_multi_normal_log(y, to_var(mu), to_var(Sigma), y, to_var(mu2), - to_var(Sigma2), "var: mu and sigma"); + expect_propto_multi_normal_lpdf(y, to_var(mu), to_var(Sigma), y, to_var(mu2), + to_var(Sigma2), "var: mu and sigma"); stan::math::recover_memory(); } TEST_F(agrad_distributions_multi_normal, ProptoSigma) { using stan::math::to_var; - expect_propto_multi_normal_log(y, mu, to_var(Sigma), y, mu, to_var(Sigma2), - "var: sigma"); + expect_propto_multi_normal_lpdf(y, mu, to_var(Sigma), y, mu, to_var(Sigma2), + "var: sigma"); stan::math::recover_memory(); } TEST_F(agrad_distributions_multi_normal_multi_row, Propto) { using stan::math::to_var; - expect_propto_multi_normal_log(to_var(y), to_var(mu), to_var(Sigma), - to_var(y2), to_var(mu2), to_var(Sigma2), - "All vars: y, mu, sigma"); + expect_propto_multi_normal_lpdf(to_var(y), to_var(mu), to_var(Sigma), + to_var(y2), to_var(mu2), to_var(Sigma2), + "All vars: y, mu, sigma"); stan::math::recover_memory(); } TEST_F(agrad_distributions_multi_normal_multi_row, ProptoY) { using stan::math::to_var; - expect_propto_multi_normal_log(to_var(y), mu, Sigma, to_var(y2), mu, Sigma, - "var: y"); + expect_propto_multi_normal_lpdf(to_var(y), mu, Sigma, to_var(y2), mu, Sigma, + "var: y"); stan::math::recover_memory(); } TEST_F(agrad_distributions_multi_normal_multi_row, ProptoYMu) { using stan::math::to_var; - expect_propto_multi_normal_log(to_var(y), to_var(mu), Sigma, to_var(y2), - to_var(mu2), Sigma, "var: y and mu"); + expect_propto_multi_normal_lpdf(to_var(y), to_var(mu), Sigma, to_var(y2), + to_var(mu2), Sigma, "var: y and mu"); stan::math::recover_memory(); } TEST_F(agrad_distributions_multi_normal_multi_row, ProptoYSigma) { using stan::math::to_var; - expect_propto_multi_normal_log(to_var(y), mu, to_var(Sigma), to_var(y2), mu, - to_var(Sigma2), "var: y and sigma"); + expect_propto_multi_normal_lpdf(to_var(y), mu, to_var(Sigma), to_var(y2), mu, + to_var(Sigma2), "var: y and sigma"); stan::math::recover_memory(); } TEST_F(agrad_distributions_multi_normal_multi_row, ProptoMu) { using stan::math::to_var; - expect_propto_multi_normal_log(y, to_var(mu), Sigma, y, to_var(mu2), Sigma, - "var: mu"); + expect_propto_multi_normal_lpdf(y, to_var(mu), Sigma, y, to_var(mu2), Sigma, + "var: mu"); stan::math::recover_memory(); } TEST_F(agrad_distributions_multi_normal_multi_row, ProptoMuSigma) { using stan::math::to_var; - expect_propto_multi_normal_log(y, to_var(mu), to_var(Sigma), y, to_var(mu2), - to_var(Sigma2), "var: mu and sigma"); + expect_propto_multi_normal_lpdf(y, to_var(mu), to_var(Sigma), y, to_var(mu2), + to_var(Sigma2), "var: mu and sigma"); stan::math::recover_memory(); } TEST_F(agrad_distributions_multi_normal_multi_row, ProptoSigma) { using stan::math::to_var; - expect_propto_multi_normal_log(y, mu, to_var(Sigma), y, mu, to_var(Sigma2), - "var: sigma"); + expect_propto_multi_normal_lpdf(y, mu, to_var(Sigma), y, mu, to_var(Sigma2), + "var: sigma"); stan::math::recover_memory(); } @@ -130,7 +131,7 @@ TEST(ProbDistributionsMultiNormal, MultiNormalVar) { mu << 1.0, -1.0, 3.0; Matrix Sigma(3, 3); Sigma << 9.0, -3.0, 0.0, -3.0, 4.0, 0.0, 0.0, 0.0, 5.0; - EXPECT_FLOAT_EQ(-11.73908, stan::math::multi_normal_log(y, mu, Sigma).val()); + EXPECT_FLOAT_EQ(-11.73908, stan::math::multi_normal_lpdf(y, mu, Sigma).val()); stan::math::recover_memory(); } @@ -138,7 +139,7 @@ TEST(ProbDistributionsMultiNormal, MultiNormalGradientUnivariate) { using Eigen::Dynamic; using Eigen::Matrix; using Eigen::VectorXd; - using stan::math::multi_normal_log; + using stan::math::multi_normal_lpdf; using stan::math::var; using std::vector; @@ -156,7 +157,7 @@ TEST(ProbDistributionsMultiNormal, MultiNormalGradientUnivariate) { x.push_back(mu_var(0)); x.push_back(Sigma_var(0, 0)); - var lp = stan::math::multi_normal_log(y_var, mu_var, Sigma_var); + var lp = stan::math::multi_normal_lpdf(y_var, mu_var, Sigma_var); vector grad; lp.grad(x, grad); @@ -178,7 +179,7 @@ TEST(ProbDistributionsMultiNormal, MultiNormalGradientUnivariate) { y_p[0] = y[0] + epsilon; y_m[0] = y[0] - epsilon; double grad_diff - = (multi_normal_log(y_p, mu, Sigma) - multi_normal_log(y_m, mu, Sigma)) + = (multi_normal_lpdf(y_p, mu, Sigma) - multi_normal_lpdf(y_m, mu, Sigma)) / (2 * epsilon); EXPECT_FLOAT_EQ(grad_diff, grad[0]); @@ -187,7 +188,7 @@ TEST(ProbDistributionsMultiNormal, MultiNormalGradientUnivariate) { mu_p[0] = mu[0] + epsilon; mu_m[0] = mu[0] - epsilon; grad_diff - = (multi_normal_log(y, mu_p, Sigma) - multi_normal_log(y, mu_m, Sigma)) + = (multi_normal_lpdf(y, mu_p, Sigma) - multi_normal_lpdf(y, mu_m, Sigma)) / (2 * epsilon); EXPECT_FLOAT_EQ(grad_diff, grad[1]); @@ -196,7 +197,7 @@ TEST(ProbDistributionsMultiNormal, MultiNormalGradientUnivariate) { Sigma_p(0) = Sigma(0) + epsilon; Sigma_m(0) = Sigma(0) - epsilon; grad_diff - = (multi_normal_log(y, mu, Sigma_p) - multi_normal_log(y, mu, Sigma_m)) + = (multi_normal_lpdf(y, mu, Sigma_p) - multi_normal_lpdf(y, mu, Sigma_m)) / (2 * epsilon); EXPECT_FLOAT_EQ(grad_diff, grad[2]); @@ -227,7 +228,7 @@ struct multi_normal_fun { Sigma(j, i) = Sigma(i, j); } } - return stan::math::multi_normal_log(y, mu, Sigma); + return stan::math::multi_normal_lpdf(y, mu, Sigma); } }; @@ -314,14 +315,14 @@ struct vectorized_multi_normal_fun { if (dont_vectorize_y) { if (dont_vectorize_mu) - return stan::math::multi_normal_log(y[0], mu[0], Sigma); + return stan::math::multi_normal_lpdf(y[0], mu[0], Sigma); else - return stan::math::multi_normal_log(y[0], mu, Sigma); + return stan::math::multi_normal_lpdf(y[0], mu, Sigma); } else { if (dont_vectorize_mu) - return stan::math::multi_normal_log(y, mu[0], Sigma); + return stan::math::multi_normal_lpdf(y, mu[0], Sigma); else - return stan::math::multi_normal_log(y, mu, Sigma); + return stan::math::multi_normal_lpdf(y, mu, Sigma); } } }; diff --git a/test/unit/math/rev/prob/multi_normal_cholesky2_test.cpp b/test/unit/math/rev/prob/multi_normal_cholesky2_test.cpp index efe513fbe72..82c46bf55cc 100644 --- a/test/unit/math/rev/prob/multi_normal_cholesky2_test.cpp +++ b/test/unit/math/rev/prob/multi_normal_cholesky2_test.cpp @@ -30,7 +30,7 @@ struct multi_normal_cholesky_fun { for (int j = i + 1; j < K_; ++j) L(i, j) = 0; } - return stan::math::multi_normal_cholesky_log(y, mu, L); + return stan::math::multi_normal_cholesky_lpdf(y, mu, L); // can't test propto=true because finite diffs are // all 0 by design for double inputs } @@ -116,14 +116,14 @@ struct vectorized_multi_normal_cholesky_fun { if (dont_vectorize_y) { if (dont_vectorize_mu) - return stan::math::multi_normal_cholesky_log(y[0], mu[0], L); + return stan::math::multi_normal_cholesky_lpdf(y[0], mu[0], L); else - return stan::math::multi_normal_cholesky_log(y[0], mu, L); + return stan::math::multi_normal_cholesky_lpdf(y[0], mu, L); } else { if (dont_vectorize_mu) - return stan::math::multi_normal_cholesky_log(y, mu[0], L); + return stan::math::multi_normal_cholesky_lpdf(y, mu[0], L); else - return stan::math::multi_normal_cholesky_log(y, mu, L); + return stan::math::multi_normal_cholesky_lpdf(y, mu, L); } } }; diff --git a/test/unit/math/rev/prob/multi_normal_cholesky_test.cpp b/test/unit/math/rev/prob/multi_normal_cholesky_test.cpp index bd286a7a55c..0e5b87eadb6 100644 --- a/test/unit/math/rev/prob/multi_normal_cholesky_test.cpp +++ b/test/unit/math/rev/prob/multi_normal_cholesky_test.cpp @@ -15,7 +15,7 @@ TEST(ProbDistributionsMultiNormalCholesky, MultiNormalVar) { Sigma << 9.0, -3.0, 0.0, -3.0, 4.0, 0.0, 0.0, 0.0, 5.0; Matrix L = Sigma.llt().matrixL(); EXPECT_FLOAT_EQ(-11.73908, - stan::math::multi_normal_cholesky_log(y, mu, L).val()); + stan::math::multi_normal_cholesky_lpdf(y, mu, L).val()); } TEST(ProbDistributionsMultiNormalCholesky, check_varis_on_stack) { @@ -30,33 +30,33 @@ TEST(ProbDistributionsMultiNormalCholesky, check_varis_on_stack) { Matrix Sigma(3, 3); Sigma << 9.0, -3.0, 0.0, -3.0, 4.0, 0.0, 0.0, 0.0, 5.0; Matrix L = Sigma.llt().matrixL(); - test::check_varis_on_stack(stan::math::multi_normal_cholesky_log( + test::check_varis_on_stack(stan::math::multi_normal_cholesky_lpdf( to_var(y), to_var(mu), to_var(L))); test::check_varis_on_stack( - stan::math::multi_normal_cholesky_log(to_var(y), to_var(mu), L)); + stan::math::multi_normal_cholesky_lpdf(to_var(y), to_var(mu), L)); test::check_varis_on_stack( - stan::math::multi_normal_cholesky_log(to_var(y), mu, to_var(L))); + stan::math::multi_normal_cholesky_lpdf(to_var(y), mu, to_var(L))); test::check_varis_on_stack( - stan::math::multi_normal_cholesky_log(to_var(y), mu, L)); + stan::math::multi_normal_cholesky_lpdf(to_var(y), mu, L)); test::check_varis_on_stack( - stan::math::multi_normal_cholesky_log(y, to_var(mu), to_var(L))); + stan::math::multi_normal_cholesky_lpdf(y, to_var(mu), to_var(L))); test::check_varis_on_stack( - stan::math::multi_normal_cholesky_log(y, to_var(mu), L)); + stan::math::multi_normal_cholesky_lpdf(y, to_var(mu), L)); test::check_varis_on_stack( - stan::math::multi_normal_cholesky_log(y, mu, to_var(L))); + stan::math::multi_normal_cholesky_lpdf(y, mu, to_var(L))); - test::check_varis_on_stack(stan::math::multi_normal_cholesky_log( + test::check_varis_on_stack(stan::math::multi_normal_cholesky_lpdf( to_var(y), to_var(mu), to_var(L))); test::check_varis_on_stack( - stan::math::multi_normal_cholesky_log(to_var(y), to_var(mu), L)); + stan::math::multi_normal_cholesky_lpdf(to_var(y), to_var(mu), L)); test::check_varis_on_stack( - stan::math::multi_normal_cholesky_log(to_var(y), mu, to_var(L))); + stan::math::multi_normal_cholesky_lpdf(to_var(y), mu, to_var(L))); test::check_varis_on_stack( - stan::math::multi_normal_cholesky_log(to_var(y), mu, L)); + stan::math::multi_normal_cholesky_lpdf(to_var(y), mu, L)); test::check_varis_on_stack( - stan::math::multi_normal_cholesky_log(y, to_var(mu), to_var(L))); + stan::math::multi_normal_cholesky_lpdf(y, to_var(mu), to_var(L))); test::check_varis_on_stack( - stan::math::multi_normal_cholesky_log(y, to_var(mu), L)); + stan::math::multi_normal_cholesky_lpdf(y, to_var(mu), L)); test::check_varis_on_stack( - stan::math::multi_normal_cholesky_log(y, mu, to_var(L))); + stan::math::multi_normal_cholesky_lpdf(y, mu, to_var(L))); } diff --git a/test/unit/math/rev/prob/multi_normal_prec2_test.cpp b/test/unit/math/rev/prob/multi_normal_prec2_test.cpp index 2e79e1e3789..7047c189c4c 100644 --- a/test/unit/math/rev/prob/multi_normal_prec2_test.cpp +++ b/test/unit/math/rev/prob/multi_normal_prec2_test.cpp @@ -9,116 +9,116 @@ #include template -void expect_propto_multi_normal_prec_log(T_y y1, T_loc mu1, T_scale sigma1, - T_y y2, T_loc mu2, T_scale sigma2, - std::string message = "") { - expect_eq_diffs(stan::math::multi_normal_prec_log(y1, mu1, sigma1), - stan::math::multi_normal_prec_log(y2, mu2, sigma2), - stan::math::multi_normal_prec_log(y1, mu1, sigma1), - stan::math::multi_normal_prec_log(y2, mu2, sigma2), +void expect_propto_multi_normal_prec_lpdf(T_y y1, T_loc mu1, T_scale sigma1, + T_y y2, T_loc mu2, T_scale sigma2, + std::string message = "") { + expect_eq_diffs(stan::math::multi_normal_prec_lpdf(y1, mu1, sigma1), + stan::math::multi_normal_prec_lpdf(y2, mu2, sigma2), + stan::math::multi_normal_prec_lpdf(y1, mu1, sigma1), + stan::math::multi_normal_prec_lpdf(y2, mu2, sigma2), message); } TEST_F(agrad_distributions_multi_normal, Propto_prec2) { using stan::math::to_var; - expect_propto_multi_normal_prec_log(to_var(y), to_var(mu), to_var(Sigma), - to_var(y2), to_var(mu2), to_var(Sigma2), - "All vars: y, mu, sigma"); + expect_propto_multi_normal_prec_lpdf(to_var(y), to_var(mu), to_var(Sigma), + to_var(y2), to_var(mu2), to_var(Sigma2), + "All vars: y, mu, sigma"); stan::math::recover_memory(); } TEST_F(agrad_distributions_multi_normal, ProptoY_prec2) { using stan::math::to_var; - expect_propto_multi_normal_prec_log(to_var(y), mu, Sigma, to_var(y2), mu, - Sigma, "var: y"); + expect_propto_multi_normal_prec_lpdf(to_var(y), mu, Sigma, to_var(y2), mu, + Sigma, "var: y"); stan::math::recover_memory(); } TEST_F(agrad_distributions_multi_normal, ProptoYMu_prec2) { using stan::math::to_var; - expect_propto_multi_normal_prec_log(to_var(y), to_var(mu), Sigma, to_var(y2), - to_var(mu2), Sigma, "var: y and mu"); + expect_propto_multi_normal_prec_lpdf(to_var(y), to_var(mu), Sigma, to_var(y2), + to_var(mu2), Sigma, "var: y and mu"); stan::math::recover_memory(); } TEST_F(agrad_distributions_multi_normal, ProptoYSigma_prec2) { using stan::math::to_var; - expect_propto_multi_normal_prec_log(to_var(y), mu, to_var(Sigma), to_var(y2), - mu, to_var(Sigma2), "var: y and sigma"); + expect_propto_multi_normal_prec_lpdf(to_var(y), mu, to_var(Sigma), to_var(y2), + mu, to_var(Sigma2), "var: y and sigma"); stan::math::recover_memory(); } TEST_F(agrad_distributions_multi_normal, ProptoMu_prec2) { using stan::math::to_var; - expect_propto_multi_normal_prec_log(y, to_var(mu), Sigma, y, to_var(mu2), - Sigma, "var: mu"); + expect_propto_multi_normal_prec_lpdf(y, to_var(mu), Sigma, y, to_var(mu2), + Sigma, "var: mu"); stan::math::recover_memory(); } TEST_F(agrad_distributions_multi_normal, ProptoMuSigma_prec2) { using stan::math::to_var; - expect_propto_multi_normal_prec_log(y, to_var(mu), to_var(Sigma), y, - to_var(mu2), to_var(Sigma2), - "var: mu and sigma"); + expect_propto_multi_normal_prec_lpdf(y, to_var(mu), to_var(Sigma), y, + to_var(mu2), to_var(Sigma2), + "var: mu and sigma"); stan::math::recover_memory(); } TEST_F(agrad_distributions_multi_normal, ProptoSigma_prec2) { using stan::math::to_var; - expect_propto_multi_normal_prec_log(y, mu, to_var(Sigma), y, mu, - to_var(Sigma2), "var: sigma"); + expect_propto_multi_normal_prec_lpdf(y, mu, to_var(Sigma), y, mu, + to_var(Sigma2), "var: sigma"); stan::math::recover_memory(); } TEST_F(agrad_distributions_multi_normal_multi_row, Propto_prec2) { using stan::math::to_var; - expect_propto_multi_normal_prec_log(to_var(y), to_var(mu), to_var(Sigma), - to_var(y2), to_var(mu2), to_var(Sigma2), - "All vars: y, mu, sigma"); + expect_propto_multi_normal_prec_lpdf(to_var(y), to_var(mu), to_var(Sigma), + to_var(y2), to_var(mu2), to_var(Sigma2), + "All vars: y, mu, sigma"); stan::math::recover_memory(); } TEST_F(agrad_distributions_multi_normal_multi_row, ProptoY_prec2) { using stan::math::to_var; - expect_propto_multi_normal_prec_log(to_var(y), mu, Sigma, to_var(y2), mu, - Sigma, "var: y"); + expect_propto_multi_normal_prec_lpdf(to_var(y), mu, Sigma, to_var(y2), mu, + Sigma, "var: y"); stan::math::recover_memory(); } TEST_F(agrad_distributions_multi_normal_multi_row, ProptoYMu_prec2) { using stan::math::to_var; - expect_propto_multi_normal_prec_log(to_var(y), to_var(mu), Sigma, to_var(y2), - to_var(mu2), Sigma, "var: y and mu"); + expect_propto_multi_normal_prec_lpdf(to_var(y), to_var(mu), Sigma, to_var(y2), + to_var(mu2), Sigma, "var: y and mu"); stan::math::recover_memory(); } TEST_F(agrad_distributions_multi_normal_multi_row, ProptoYSigma_prec2) { using stan::math::to_var; - expect_propto_multi_normal_prec_log(to_var(y), mu, to_var(Sigma), to_var(y2), - mu, to_var(Sigma2), "var: y and sigma"); + expect_propto_multi_normal_prec_lpdf(to_var(y), mu, to_var(Sigma), to_var(y2), + mu, to_var(Sigma2), "var: y and sigma"); stan::math::recover_memory(); } TEST_F(agrad_distributions_multi_normal_multi_row, ProptoMu_prec2) { using stan::math::to_var; - expect_propto_multi_normal_prec_log(y, to_var(mu), Sigma, y, to_var(mu2), - Sigma, "var: mu"); + expect_propto_multi_normal_prec_lpdf(y, to_var(mu), Sigma, y, to_var(mu2), + Sigma, "var: mu"); stan::math::recover_memory(); } TEST_F(agrad_distributions_multi_normal_multi_row, ProptoMuSigma_prec2) { using stan::math::to_var; - expect_propto_multi_normal_prec_log(y, to_var(mu), to_var(Sigma), y, - to_var(mu2), to_var(Sigma2), - "var: mu and sigma"); + expect_propto_multi_normal_prec_lpdf(y, to_var(mu), to_var(Sigma), y, + to_var(mu2), to_var(Sigma2), + "var: mu and sigma"); stan::math::recover_memory(); } TEST_F(agrad_distributions_multi_normal_multi_row, ProptoSigma_prec2) { using stan::math::to_var; - expect_propto_multi_normal_prec_log(y, mu, to_var(Sigma), y, mu, - to_var(Sigma2), "var: sigma"); + expect_propto_multi_normal_prec_lpdf(y, mu, to_var(Sigma), y, mu, + to_var(Sigma2), "var: sigma"); stan::math::recover_memory(); } @@ -147,7 +147,7 @@ struct multi_normal_prec_fun { Sigma(j, i) = Sigma(i, j); } } - return stan::math::multi_normal_prec_log(y, mu, Sigma); + return stan::math::multi_normal_prec_lpdf(y, mu, Sigma); } }; @@ -234,14 +234,14 @@ struct vectorized_multi_normal_prec_fun { if (dont_vectorize_y) { if (dont_vectorize_mu) - return stan::math::multi_normal_prec_log(y[0], mu[0], Sigma); + return stan::math::multi_normal_prec_lpdf(y[0], mu[0], Sigma); else - return stan::math::multi_normal_prec_log(y[0], mu, Sigma); + return stan::math::multi_normal_prec_lpdf(y[0], mu, Sigma); } else { if (dont_vectorize_mu) - return stan::math::multi_normal_prec_log(y, mu[0], Sigma); + return stan::math::multi_normal_prec_lpdf(y, mu[0], Sigma); else - return stan::math::multi_normal_prec_log(y, mu, Sigma); + return stan::math::multi_normal_prec_lpdf(y, mu, Sigma); } } }; diff --git a/test/unit/math/rev/prob/multi_normal_prec_test.cpp b/test/unit/math/rev/prob/multi_normal_prec_test.cpp index 3cff7b850c0..ce15cefc508 100644 --- a/test/unit/math/rev/prob/multi_normal_prec_test.cpp +++ b/test/unit/math/rev/prob/multi_normal_prec_test.cpp @@ -14,7 +14,8 @@ TEST(ProbDistributionsMultiNormalPrec, MultiNormalVar) { Matrix Sigma(3, 3); Sigma << 9.0, -3.0, 0.0, -3.0, 4.0, 0.0, 0.0, 0.0, 5.0; Matrix L = Sigma.inverse(); - EXPECT_FLOAT_EQ(-11.73908, stan::math::multi_normal_prec_log(y, mu, L).val()); + EXPECT_FLOAT_EQ(-11.73908, + stan::math::multi_normal_prec_lpdf(y, mu, L).val()); stan::math::recover_memory(); } @@ -32,35 +33,35 @@ TEST(ProbDistributionsMultiNormalPrec, check_varis_on_stack) { Sigma << 9.0, -3.0, 0.0, -3.0, 4.0, 0.0, 0.0, 0.0, 5.0; Matrix L = Sigma.inverse(); - test::check_varis_on_stack(stan::math::multi_normal_prec_log( + test::check_varis_on_stack(stan::math::multi_normal_prec_lpdf( to_var(y), to_var(mu), to_var(L))); test::check_varis_on_stack( - stan::math::multi_normal_prec_log(to_var(y), to_var(mu), L)); + stan::math::multi_normal_prec_lpdf(to_var(y), to_var(mu), L)); test::check_varis_on_stack( - stan::math::multi_normal_prec_log(to_var(y), mu, to_var(L))); + stan::math::multi_normal_prec_lpdf(to_var(y), mu, to_var(L))); test::check_varis_on_stack( - stan::math::multi_normal_prec_log(to_var(y), mu, L)); + stan::math::multi_normal_prec_lpdf(to_var(y), mu, L)); test::check_varis_on_stack( - stan::math::multi_normal_prec_log(y, to_var(mu), to_var(L))); + stan::math::multi_normal_prec_lpdf(y, to_var(mu), to_var(L))); test::check_varis_on_stack( - stan::math::multi_normal_prec_log(y, to_var(mu), L)); + stan::math::multi_normal_prec_lpdf(y, to_var(mu), L)); test::check_varis_on_stack( - stan::math::multi_normal_prec_log(y, mu, to_var(L))); + stan::math::multi_normal_prec_lpdf(y, mu, to_var(L))); - test::check_varis_on_stack(stan::math::multi_normal_prec_log( + test::check_varis_on_stack(stan::math::multi_normal_prec_lpdf( to_var(y), to_var(mu), to_var(L))); test::check_varis_on_stack( - stan::math::multi_normal_prec_log(to_var(y), to_var(mu), L)); + stan::math::multi_normal_prec_lpdf(to_var(y), to_var(mu), L)); test::check_varis_on_stack( - stan::math::multi_normal_prec_log(to_var(y), mu, to_var(L))); + stan::math::multi_normal_prec_lpdf(to_var(y), mu, to_var(L))); test::check_varis_on_stack( - stan::math::multi_normal_prec_log(to_var(y), mu, L)); + stan::math::multi_normal_prec_lpdf(to_var(y), mu, L)); test::check_varis_on_stack( - stan::math::multi_normal_prec_log(y, to_var(mu), to_var(L))); + stan::math::multi_normal_prec_lpdf(y, to_var(mu), to_var(L))); test::check_varis_on_stack( - stan::math::multi_normal_prec_log(y, to_var(mu), L)); + stan::math::multi_normal_prec_lpdf(y, to_var(mu), L)); test::check_varis_on_stack( - stan::math::multi_normal_prec_log(y, mu, to_var(L))); + stan::math::multi_normal_prec_lpdf(y, mu, to_var(L))); stan::math::recover_memory(); } diff --git a/test/unit/math/rev/prob/multi_student_t2_test.cpp b/test/unit/math/rev/prob/multi_student_t2_test.cpp index e0dbdf5969d..3756f653fa7 100644 --- a/test/unit/math/rev/prob/multi_student_t2_test.cpp +++ b/test/unit/math/rev/prob/multi_student_t2_test.cpp @@ -10,20 +10,20 @@ #include template -void expect_propto_multi_student_t_log(T_y y1, T_dof nu1, T_loc mu1, - T_scale sigma1, T_y y2, T_dof nu2, - T_loc mu2, T_scale sigma2, - std::string message = "") { - expect_eq_diffs(stan::math::multi_student_t_log(y1, nu1, mu1, sigma1), - stan::math::multi_student_t_log(y2, nu2, mu2, sigma2), - stan::math::multi_student_t_log(y1, nu1, mu1, sigma1), - stan::math::multi_student_t_log(y2, nu2, mu2, sigma2), +void expect_propto_multi_student_t_lpdf(T_y y1, T_dof nu1, T_loc mu1, + T_scale sigma1, T_y y2, T_dof nu2, + T_loc mu2, T_scale sigma2, + std::string message = "") { + expect_eq_diffs(stan::math::multi_student_t_lpdf(y1, nu1, mu1, sigma1), + stan::math::multi_student_t_lpdf(y2, nu2, mu2, sigma2), + stan::math::multi_student_t_lpdf(y1, nu1, mu1, sigma1), + stan::math::multi_student_t_lpdf(y2, nu2, mu2, sigma2), message); } TEST_F(agrad_distributions_multi_student_t, Propto) { using stan::math::to_var; - expect_propto_multi_student_t_log( + expect_propto_multi_student_t_lpdf( to_var(y), to_var(nu), to_var(mu), to_var(Sigma), to_var(y2), to_var(nu), to_var(mu2), to_var(Sigma2), "All vars: y, nu, mu, sigma"); @@ -31,46 +31,46 @@ TEST_F(agrad_distributions_multi_student_t, Propto) { } TEST_F(agrad_distributions_multi_student_t, ProptoY) { using stan::math::to_var; - expect_propto_multi_student_t_log(to_var(y), nu, mu, Sigma, to_var(y2), nu, - mu, Sigma, "var: y"); + expect_propto_multi_student_t_lpdf(to_var(y), nu, mu, Sigma, to_var(y2), nu, + mu, Sigma, "var: y"); stan::math::recover_memory(); } TEST_F(agrad_distributions_multi_student_t, ProptoYMu) { using stan::math::to_var; - expect_propto_multi_student_t_log(to_var(y), nu, to_var(mu), Sigma, - to_var(y2), nu, to_var(mu2), Sigma, - "var: y and mu"); + expect_propto_multi_student_t_lpdf(to_var(y), nu, to_var(mu), Sigma, + to_var(y2), nu, to_var(mu2), Sigma, + "var: y and mu"); stan::math::recover_memory(); } TEST_F(agrad_distributions_multi_student_t, ProptoYSigma) { using stan::math::to_var; - expect_propto_multi_student_t_log(to_var(y), nu, mu, to_var(Sigma), - to_var(y2), nu, mu, to_var(Sigma2), - "var: y and sigma"); + expect_propto_multi_student_t_lpdf(to_var(y), nu, mu, to_var(Sigma), + to_var(y2), nu, mu, to_var(Sigma2), + "var: y and sigma"); stan::math::recover_memory(); } TEST_F(agrad_distributions_multi_student_t, ProptoMu) { using stan::math::to_var; - expect_propto_multi_student_t_log(y, nu, to_var(mu), Sigma, y, nu, - to_var(mu2), Sigma, "var: mu"); + expect_propto_multi_student_t_lpdf(y, nu, to_var(mu), Sigma, y, nu, + to_var(mu2), Sigma, "var: mu"); stan::math::recover_memory(); } TEST_F(agrad_distributions_multi_student_t, ProptoMuSigma) { using stan::math::to_var; - expect_propto_multi_student_t_log(y, nu, to_var(mu), to_var(Sigma), y, nu, - to_var(mu2), to_var(Sigma2), - "var: mu and sigma"); + expect_propto_multi_student_t_lpdf(y, nu, to_var(mu), to_var(Sigma), y, nu, + to_var(mu2), to_var(Sigma2), + "var: mu and sigma"); stan::math::recover_memory(); } TEST_F(agrad_distributions_multi_student_t, ProptoSigma) { using stan::math::to_var; - expect_propto_multi_student_t_log(y, nu, mu, to_var(Sigma), y, nu, mu, - to_var(Sigma2), "var: sigma"); + expect_propto_multi_student_t_lpdf(y, nu, mu, to_var(Sigma), y, nu, mu, + to_var(Sigma2), "var: sigma"); stan::math::recover_memory(); } @@ -88,7 +88,7 @@ TEST(ProbDistributionsMultiStudentT, MultiStudentTVar) { Matrix Sigma(3, 3); Sigma << 9.0, -3.0, 0.0, -3.0, 4.0, 0.0, 0.0, 0.0, 5.0; EXPECT_FLOAT_EQ(-10.2136949646, - stan::math::multi_student_t_log(y, nu, mu, Sigma).val()); + stan::math::multi_student_t_lpdf(y, nu, mu, Sigma).val()); stan::math::recover_memory(); } @@ -96,7 +96,7 @@ TEST(ProbDistributionsMultiStudentT, MultiStudentTGradientUnivariate) { using Eigen::Dynamic; using Eigen::Matrix; using Eigen::VectorXd; - using stan::math::multi_student_t_log; + using stan::math::multi_student_t_lpdf; using stan::math::var; using std::vector; @@ -117,7 +117,7 @@ TEST(ProbDistributionsMultiStudentT, MultiStudentTGradientUnivariate) { x.push_back(Sigma_var(0, 0)); x.push_back(nu_var); - var lp = stan::math::multi_student_t_log(y_var, nu_var, mu_var, Sigma_var); + var lp = stan::math::multi_student_t_lpdf(y_var, nu_var, mu_var, Sigma_var); vector grad; lp.grad(x, grad); @@ -140,8 +140,8 @@ TEST(ProbDistributionsMultiStudentT, MultiStudentTGradientUnivariate) { Matrix y_p(1, 1); y_p[0] = y[0] + epsilon; y_m[0] = y[0] - epsilon; - double grad_diff = (multi_student_t_log(y_p, nu, mu, Sigma) - - multi_student_t_log(y_m, nu, mu, Sigma)) + double grad_diff = (multi_student_t_lpdf(y_p, nu, mu, Sigma) + - multi_student_t_lpdf(y_m, nu, mu, Sigma)) / (2 * epsilon); EXPECT_FLOAT_EQ(grad_diff, grad[0]); @@ -149,8 +149,8 @@ TEST(ProbDistributionsMultiStudentT, MultiStudentTGradientUnivariate) { Matrix mu_p(1, 1); mu_p[0] = mu[0] + epsilon; mu_m[0] = mu[0] - epsilon; - grad_diff = (multi_student_t_log(y, nu, mu_p, Sigma) - - multi_student_t_log(y, nu, mu_m, Sigma)) + grad_diff = (multi_student_t_lpdf(y, nu, mu_p, Sigma) + - multi_student_t_lpdf(y, nu, mu_m, Sigma)) / (2 * epsilon); EXPECT_FLOAT_EQ(grad_diff, grad[1]); @@ -158,15 +158,15 @@ TEST(ProbDistributionsMultiStudentT, MultiStudentTGradientUnivariate) { Matrix Sigma_p(1, 1); Sigma_p(0) = Sigma(0) + epsilon; Sigma_m(0) = Sigma(0) - epsilon; - grad_diff = (multi_student_t_log(y, nu, mu, Sigma_p) - - multi_student_t_log(y, nu, mu, Sigma_m)) + grad_diff = (multi_student_t_lpdf(y, nu, mu, Sigma_p) + - multi_student_t_lpdf(y, nu, mu, Sigma_m)) / (2 * epsilon); EXPECT_FLOAT_EQ(grad_diff, grad[2]); double nu_p(nu + epsilon); double nu_m(nu - epsilon); - grad_diff = (multi_student_t_log(y, nu_p, mu, Sigma) - - multi_student_t_log(y, nu_m, mu, Sigma)) + grad_diff = (multi_student_t_lpdf(y, nu_p, mu, Sigma) + - multi_student_t_lpdf(y, nu_m, mu, Sigma)) / (2 * epsilon); EXPECT_FLOAT_EQ(grad_diff, grad[3]); @@ -199,7 +199,7 @@ struct multi_student_t_fun { } } nu = x[pos++]; - return stan::math::multi_student_t_log(y, nu, mu, Sigma); + return stan::math::multi_student_t_lpdf(y, nu, mu, Sigma); } }; @@ -289,14 +289,14 @@ struct vectorized_multi_student_t_fun { if (dont_vectorize_y) { if (dont_vectorize_mu) - return stan::math::multi_student_t_log(y[0], nu, mu[0], Sigma); + return stan::math::multi_student_t_lpdf(y[0], nu, mu[0], Sigma); else - return stan::math::multi_student_t_log(y[0], nu, mu, Sigma); + return stan::math::multi_student_t_lpdf(y[0], nu, mu, Sigma); } else { if (dont_vectorize_mu) - return stan::math::multi_student_t_log(y, nu, mu[0], Sigma); + return stan::math::multi_student_t_lpdf(y, nu, mu[0], Sigma); else - return stan::math::multi_student_t_log(y, nu, mu, Sigma); + return stan::math::multi_student_t_lpdf(y, nu, mu, Sigma); } } }; @@ -553,68 +553,68 @@ TEST(ProbDistributionsMultiStudentT, check_varis_on_stack) { Matrix Sigma(3, 3); Sigma << 9.0, -3.0, 0.0, -3.0, 4.0, 0.0, 0.0, 0.0, 5.0; - using stan::math::multi_student_t_log; + using stan::math::multi_student_t_lpdf; using stan::math::to_var; - test::check_varis_on_stack(multi_student_t_log( + test::check_varis_on_stack(multi_student_t_lpdf( to_var(y), to_var(nu), to_var(mu), to_var(Sigma))); test::check_varis_on_stack( - multi_student_t_log(to_var(y), to_var(nu), to_var(mu), Sigma)); + multi_student_t_lpdf(to_var(y), to_var(nu), to_var(mu), Sigma)); test::check_varis_on_stack( - multi_student_t_log(to_var(y), to_var(nu), mu, to_var(Sigma))); + multi_student_t_lpdf(to_var(y), to_var(nu), mu, to_var(Sigma))); test::check_varis_on_stack( - multi_student_t_log(to_var(y), to_var(nu), mu, Sigma)); + multi_student_t_lpdf(to_var(y), to_var(nu), mu, Sigma)); test::check_varis_on_stack( - multi_student_t_log(to_var(y), nu, to_var(mu), to_var(Sigma))); + multi_student_t_lpdf(to_var(y), nu, to_var(mu), to_var(Sigma))); test::check_varis_on_stack( - multi_student_t_log(to_var(y), nu, to_var(mu), Sigma)); + multi_student_t_lpdf(to_var(y), nu, to_var(mu), Sigma)); test::check_varis_on_stack( - multi_student_t_log(to_var(y), nu, mu, to_var(Sigma))); + multi_student_t_lpdf(to_var(y), nu, mu, to_var(Sigma))); test::check_varis_on_stack( - multi_student_t_log(to_var(y), nu, mu, Sigma)); + multi_student_t_lpdf(to_var(y), nu, mu, Sigma)); test::check_varis_on_stack( - multi_student_t_log(y, to_var(nu), to_var(mu), to_var(Sigma))); + multi_student_t_lpdf(y, to_var(nu), to_var(mu), to_var(Sigma))); test::check_varis_on_stack( - multi_student_t_log(y, to_var(nu), to_var(mu), Sigma)); + multi_student_t_lpdf(y, to_var(nu), to_var(mu), Sigma)); test::check_varis_on_stack( - multi_student_t_log(y, to_var(nu), mu, to_var(Sigma))); + multi_student_t_lpdf(y, to_var(nu), mu, to_var(Sigma))); test::check_varis_on_stack( - multi_student_t_log(y, to_var(nu), mu, Sigma)); + multi_student_t_lpdf(y, to_var(nu), mu, Sigma)); test::check_varis_on_stack( - multi_student_t_log(y, nu, to_var(mu), to_var(Sigma))); + multi_student_t_lpdf(y, nu, to_var(mu), to_var(Sigma))); test::check_varis_on_stack( - multi_student_t_log(y, nu, to_var(mu), Sigma)); + multi_student_t_lpdf(y, nu, to_var(mu), Sigma)); test::check_varis_on_stack( - multi_student_t_log(y, nu, mu, to_var(Sigma))); - test::check_varis_on_stack(multi_student_t_log( + multi_student_t_lpdf(y, nu, mu, to_var(Sigma))); + test::check_varis_on_stack(multi_student_t_lpdf( to_var(y), to_var(nu), to_var(mu), to_var(Sigma))); test::check_varis_on_stack( - multi_student_t_log(to_var(y), to_var(nu), to_var(mu), Sigma)); + multi_student_t_lpdf(to_var(y), to_var(nu), to_var(mu), Sigma)); test::check_varis_on_stack( - multi_student_t_log(to_var(y), to_var(nu), mu, to_var(Sigma))); + multi_student_t_lpdf(to_var(y), to_var(nu), mu, to_var(Sigma))); test::check_varis_on_stack( - multi_student_t_log(to_var(y), to_var(nu), mu, Sigma)); + multi_student_t_lpdf(to_var(y), to_var(nu), mu, Sigma)); test::check_varis_on_stack( - multi_student_t_log(to_var(y), nu, to_var(mu), to_var(Sigma))); + multi_student_t_lpdf(to_var(y), nu, to_var(mu), to_var(Sigma))); test::check_varis_on_stack( - multi_student_t_log(to_var(y), nu, to_var(mu), Sigma)); + multi_student_t_lpdf(to_var(y), nu, to_var(mu), Sigma)); test::check_varis_on_stack( - multi_student_t_log(to_var(y), nu, mu, to_var(Sigma))); + multi_student_t_lpdf(to_var(y), nu, mu, to_var(Sigma))); test::check_varis_on_stack( - multi_student_t_log(to_var(y), nu, mu, Sigma)); + multi_student_t_lpdf(to_var(y), nu, mu, Sigma)); test::check_varis_on_stack( - multi_student_t_log(y, to_var(nu), to_var(mu), to_var(Sigma))); + multi_student_t_lpdf(y, to_var(nu), to_var(mu), to_var(Sigma))); test::check_varis_on_stack( - multi_student_t_log(y, to_var(nu), to_var(mu), Sigma)); + multi_student_t_lpdf(y, to_var(nu), to_var(mu), Sigma)); test::check_varis_on_stack( - multi_student_t_log(y, to_var(nu), mu, to_var(Sigma))); + multi_student_t_lpdf(y, to_var(nu), mu, to_var(Sigma))); test::check_varis_on_stack( - multi_student_t_log(y, to_var(nu), mu, Sigma)); + multi_student_t_lpdf(y, to_var(nu), mu, Sigma)); test::check_varis_on_stack( - multi_student_t_log(y, nu, to_var(mu), to_var(Sigma))); + multi_student_t_lpdf(y, nu, to_var(mu), to_var(Sigma))); test::check_varis_on_stack( - multi_student_t_log(y, nu, to_var(mu), Sigma)); + multi_student_t_lpdf(y, nu, to_var(mu), Sigma)); test::check_varis_on_stack( - multi_student_t_log(y, nu, mu, to_var(Sigma))); + multi_student_t_lpdf(y, nu, mu, to_var(Sigma))); stan::math::recover_memory(); } diff --git a/test/unit/math/rev/prob/multinomial_test.cpp b/test/unit/math/rev/prob/multinomial_test.cpp index 2b1c61aafa9..2c358f9bb24 100644 --- a/test/unit/math/rev/prob/multinomial_test.cpp +++ b/test/unit/math/rev/prob/multinomial_test.cpp @@ -9,10 +9,10 @@ template void expect_propto_multinomial(std::vector& ns1, T_prob theta1, std::vector& ns2, T_prob theta2, std::string message) { - expect_eq_diffs(stan::math::multinomial_log(ns1, theta1), - stan::math::multinomial_log(ns2, theta2), - stan::math::multinomial_log(ns1, theta1), - stan::math::multinomial_log(ns2, theta2), message); + expect_eq_diffs(stan::math::multinomial_lpmf(ns1, theta1), + stan::math::multinomial_lpmf(ns2, theta2), + stan::math::multinomial_lpmf(ns1, theta1), + stan::math::multinomial_lpmf(ns2, theta2), message); } TEST(AgradDistributionsMultinomial, Propto) { @@ -42,6 +42,6 @@ TEST(AgradDistributionsMultinomial, check_varis_on_stack) { Matrix theta(3, 1); theta << 0.3, 0.5, 0.2; - test::check_varis_on_stack(stan::math::multinomial_log(ns, theta)); - test::check_varis_on_stack(stan::math::multinomial_log(ns, theta)); + test::check_varis_on_stack(stan::math::multinomial_lpmf(ns, theta)); + test::check_varis_on_stack(stan::math::multinomial_lpmf(ns, theta)); } diff --git a/test/unit/math/rev/prob/neg_binomial_2_test.cpp b/test/unit/math/rev/prob/neg_binomial_2_test.cpp index 52542071c83..0a873fb5b1b 100644 --- a/test/unit/math/rev/prob/neg_binomial_2_test.cpp +++ b/test/unit/math/rev/prob/neg_binomial_2_test.cpp @@ -435,7 +435,7 @@ TEST(ProbDistributionsNegativeBinomial2, derivativesPrecomputed) { using neg_binomial_2_test_internal::TestValue; using neg_binomial_2_test_internal::testValues; using stan::math::is_nan; - using stan::math::neg_binomial_2_log; + using stan::math::neg_binomial_2_lpmf; using stan::math::value_of; using stan::math::var; @@ -443,7 +443,7 @@ TEST(ProbDistributionsNegativeBinomial2, derivativesPrecomputed) { int n = t.n; var mu(t.mu); var phi(t.phi); - var val = neg_binomial_2_log(n, mu, phi); + var val = neg_binomial_2_lpmf(n, mu, phi); std::vector x; x.push_back(mu); @@ -470,15 +470,15 @@ TEST(ProbDistributionsNegativeBinomial2, derivativesPrecomputed) { TEST(ProbDistributionsNegBinomial2, derivativesComplexStep) { using boost::math::differentiation::complex_step_derivative; using stan::math::is_nan; - using stan::math::neg_binomial_2_log; + using stan::math::neg_binomial_2_lpmf; using stan::math::var; using stan::test::internal::expect_near_rel_finite; std::vector n_to_test = {0, 7, 100, 835, 14238, 385000, 1000000}; std::vector mu_to_test = {0.8, 8, 24, 271, 2586, 33294}; - auto nb2_log_for_test = [](int n, const std::complex& mu, - const std::complex& phi) { + auto nb2_lpmf_for_test = [](int n, const std::complex& mu, + const std::complex& phi) { // Using first-order Taylor expansion of lgamma(a + b*i) around b = 0 // Which happens to work nice in this case, as b is always 0 or the very // small complex step @@ -514,17 +514,17 @@ TEST(ProbDistributionsNegBinomial2, derivativesComplexStep) { EXPECT_FALSE(is_nan(gradients[i])); } - auto nb2_log_mu - = [n, phi_dbl, nb2_log_for_test](const std::complex& mu) { - return nb2_log_for_test(n, mu, phi_dbl); + auto nb2_lpmf_mu + = [n, phi_dbl, nb2_lpmf_for_test](const std::complex& mu) { + return nb2_lpmf_for_test(n, mu, phi_dbl); }; - auto nb2_log_phi - = [n, mu_dbl, nb2_log_for_test](const std::complex& phi) { - return nb2_log_for_test(n, mu_dbl, phi); + auto nb2_lpmf_phi + = [n, mu_dbl, nb2_lpmf_for_test](const std::complex& phi) { + return nb2_lpmf_for_test(n, mu_dbl, phi); }; - double complex_step_dmu = complex_step_derivative(nb2_log_mu, mu_dbl); + double complex_step_dmu = complex_step_derivative(nb2_lpmf_mu, mu_dbl); double complex_step_dphi - = complex_step_derivative(nb2_log_phi, phi_dbl); + = complex_step_derivative(nb2_lpmf_phi, phi_dbl); std::stringstream message; message << ", n = " << n << ", mu = " << mu_dbl diff --git a/test/unit/math/rev/prob/normal_log_test.cpp b/test/unit/math/rev/prob/normal_log_test.cpp index da5d17a6f3b..8c4612efc6b 100644 --- a/test/unit/math/rev/prob/normal_log_test.cpp +++ b/test/unit/math/rev/prob/normal_log_test.cpp @@ -6,14 +6,14 @@ TEST(ProbDistributionsNormal, intVsDouble) { for (double thetaval = -5.0; thetaval < 6.0; thetaval += 0.5) { var theta(thetaval); var lp1(0.0); - lp1 += stan::math::normal_log(0, theta, 1); + lp1 += stan::math::normal_lpdf(0, theta, 1); double lp1val = lp1.val(); stan::math::grad(lp1.vi_); double lp1adj = lp1.adj(); var theta2(thetaval); var lp2(0.0); - lp2 += stan::math::normal_log(theta2, 0, 1); + lp2 += stan::math::normal_lpdf(theta2, 0, 1); double lp2val = lp2.val(); stan::math::grad(lp2.vi_); double lp2adj = lp2.adj(); diff --git a/test/unit/math/rev/prob/wishart_test.cpp b/test/unit/math/rev/prob/wishart_test.cpp index f3e36ec67c9..b9622911e64 100644 --- a/test/unit/math/rev/prob/wishart_test.cpp +++ b/test/unit/math/rev/prob/wishart_test.cpp @@ -5,12 +5,12 @@ #include template -void expect_propto_wishart_log(T_y W1, T_dof nu1, T_scale S1, T_y W2, T_dof nu2, - T_scale S2, std::string message) { - expect_eq_diffs(stan::math::wishart_log(W1, nu1, S1), - stan::math::wishart_log(W2, nu2, S2), - stan::math::wishart_log(W1, nu1, S1), - stan::math::wishart_log(W2, nu2, S2), message); +void expect_propto_wishart_lpdf(T_y W1, T_dof nu1, T_scale S1, T_y W2, + T_dof nu2, T_scale S2, std::string message) { + expect_eq_diffs(stan::math::wishart_lpdf(W1, nu1, S1), + stan::math::wishart_lpdf(W2, nu2, S2), + stan::math::wishart_lpdf(W1, nu1, S1), + stan::math::wishart_lpdf(W2, nu2, S2), message); } using Eigen::Dynamic; @@ -42,49 +42,50 @@ class AgradDistributionsWishart : public ::testing::Test { TEST_F(AgradDistributionsWishart, Propto) { using stan::math::to_var; - expect_propto_wishart_log(to_var(Y1), to_var(nu1), to_var(S1), to_var(Y2), - to_var(nu2), to_var(S2), "var: y, nu, and sigma"); + expect_propto_wishart_lpdf(to_var(Y1), to_var(nu1), to_var(S1), to_var(Y2), + to_var(nu2), to_var(S2), "var: y, nu, and sigma"); stan::math::recover_memory(); } TEST_F(AgradDistributionsWishart, ProptoY) { using stan::math::to_var; - expect_propto_wishart_log(to_var(Y1), nu1, S1, to_var(Y2), nu1, S1, "var: y"); + expect_propto_wishart_lpdf(to_var(Y1), nu1, S1, to_var(Y2), nu1, S1, + "var: y"); stan::math::recover_memory(); } TEST_F(AgradDistributionsWishart, ProptoYNu) { using stan::math::to_var; - expect_propto_wishart_log(to_var(Y1), to_var(nu1), S1, to_var(Y2), - to_var(nu2), S1, "var: y, and nu"); + expect_propto_wishart_lpdf(to_var(Y1), to_var(nu1), S1, to_var(Y2), + to_var(nu2), S1, "var: y, and nu"); stan::math::recover_memory(); } TEST_F(AgradDistributionsWishart, ProptoYSigma) { using stan::math::to_var; - expect_propto_wishart_log(to_var(Y1), nu1, to_var(S1), to_var(Y2), nu1, - to_var(S2), "var: y and sigma"); + expect_propto_wishart_lpdf(to_var(Y1), nu1, to_var(S1), to_var(Y2), nu1, + to_var(S2), "var: y and sigma"); stan::math::recover_memory(); } TEST_F(AgradDistributionsWishart, ProptoNu) { using stan::math::to_var; - expect_propto_wishart_log(Y1, to_var(nu1), S1, Y1, to_var(nu2), S1, - "var: nu"); + expect_propto_wishart_lpdf(Y1, to_var(nu1), S1, Y1, to_var(nu2), S1, + "var: nu"); stan::math::recover_memory(); } TEST_F(AgradDistributionsWishart, ProptoNuSigma) { using stan::math::to_var; - expect_propto_wishart_log(Y1, to_var(nu1), to_var(S1), Y1, to_var(nu2), - to_var(S2), "var: nu and sigma"); + expect_propto_wishart_lpdf(Y1, to_var(nu1), to_var(S1), Y1, to_var(nu2), + to_var(S2), "var: nu and sigma"); stan::math::recover_memory(); } TEST_F(AgradDistributionsWishart, ProptoSigma) { using stan::math::to_var; - expect_propto_wishart_log(Y1, nu1, to_var(S1), Y1, nu1, to_var(S2), - "var: sigma"); + expect_propto_wishart_lpdf(Y1, nu1, to_var(S1), Y1, nu1, to_var(S2), + "var: sigma"); stan::math::recover_memory(); } @@ -100,28 +101,28 @@ TEST(Wishart, check_varis_on_stack) { S << 1.848220, 1.899623, 1.899623, 12.751941; test::check_varis_on_stack( - stan::math::wishart_log(to_var(W), to_var(nu), to_var(S))); + stan::math::wishart_lpdf(to_var(W), to_var(nu), to_var(S))); test::check_varis_on_stack( - stan::math::wishart_log(to_var(W), to_var(nu), S)); + stan::math::wishart_lpdf(to_var(W), to_var(nu), S)); test::check_varis_on_stack( - stan::math::wishart_log(to_var(W), nu, to_var(S))); - test::check_varis_on_stack(stan::math::wishart_log(to_var(W), nu, S)); + stan::math::wishart_lpdf(to_var(W), nu, to_var(S))); + test::check_varis_on_stack(stan::math::wishart_lpdf(to_var(W), nu, S)); test::check_varis_on_stack( - stan::math::wishart_log(W, to_var(nu), to_var(S))); - test::check_varis_on_stack(stan::math::wishart_log(W, to_var(nu), S)); - test::check_varis_on_stack(stan::math::wishart_log(W, nu, to_var(S))); + stan::math::wishart_lpdf(W, to_var(nu), to_var(S))); + test::check_varis_on_stack(stan::math::wishart_lpdf(W, to_var(nu), S)); + test::check_varis_on_stack(stan::math::wishart_lpdf(W, nu, to_var(S))); test::check_varis_on_stack( - stan::math::wishart_log(to_var(W), to_var(nu), to_var(S))); + stan::math::wishart_lpdf(to_var(W), to_var(nu), to_var(S))); test::check_varis_on_stack( - stan::math::wishart_log(to_var(W), to_var(nu), S)); + stan::math::wishart_lpdf(to_var(W), to_var(nu), S)); test::check_varis_on_stack( - stan::math::wishart_log(to_var(W), nu, to_var(S))); - test::check_varis_on_stack(stan::math::wishart_log(to_var(W), nu, S)); + stan::math::wishart_lpdf(to_var(W), nu, to_var(S))); + test::check_varis_on_stack(stan::math::wishart_lpdf(to_var(W), nu, S)); test::check_varis_on_stack( - stan::math::wishart_log(W, to_var(nu), to_var(S))); - test::check_varis_on_stack(stan::math::wishart_log(W, to_var(nu), S)); - test::check_varis_on_stack(stan::math::wishart_log(W, nu, to_var(S))); + stan::math::wishart_lpdf(W, to_var(nu), to_var(S))); + test::check_varis_on_stack(stan::math::wishart_lpdf(W, to_var(nu), S)); + test::check_varis_on_stack(stan::math::wishart_lpdf(W, nu, to_var(S))); stan::math::recover_memory(); } diff --git a/test/unit/math_include_test.cpp b/test/unit/math_include_test.cpp index ecebf955cd2..d325a216f58 100644 --- a/test/unit/math_include_test.cpp +++ b/test/unit/math_include_test.cpp @@ -68,7 +68,7 @@ TEST_F(Math, paper_example_3) { double y = 1.3; stan::math::var mu = 0.5, sigma = 1.2; - stan::math::var lp = normal_log(y, mu, sigma); + stan::math::var lp = normal_lpdf(y, mu, sigma); EXPECT_FLOAT_EQ(-1.323482, lp.val()); } From 92bad51e6806e8fc7ee535887e9e1380accbbd7d Mon Sep 17 00:00:00 2001 From: Daniel Lee Date: Wed, 3 Jan 2024 01:27:41 -0500 Subject: [PATCH 24/52] removing old log_matches_lpmf tests --- .../math/prim/prob/bernoulli_log_test.cpp | 20 ------- .../prim/prob/bernoulli_logit_log_test.cpp | 49 ---------------- .../math/prim/prob/beta_binomial_log_test.cpp | 31 ---------- test/unit/math/prim/prob/beta_log_test.cpp | 24 -------- .../prim/prob/beta_proportion_log_test.cpp | 28 --------- .../unit/math/prim/prob/binomial_log_test.cpp | 21 ------- .../prim/prob/binomial_logit_log_test.cpp | 21 ------- .../math/prim/prob/categorical_log_test.cpp | 28 --------- .../prim/prob/categorical_logit_log_test.cpp | 29 ---------- test/unit/math/prim/prob/cauchy_log_test.cpp | 24 -------- .../math/prim/prob/chi_square_log_test.cpp | 20 ------- .../math/prim/prob/dirichlet_log_test.cpp | 25 -------- .../prim/prob/discrete_range_log_test.cpp | 24 -------- .../prim/prob/double_exponential_log_test.cpp | 29 ---------- .../prim/prob/exp_mod_normal_log_test.cpp | 32 ---------- .../math/prim/prob/exponential_log_test.cpp | 21 ------- test/unit/math/prim/prob/frechet_log_test.cpp | 23 -------- test/unit/math/prim/prob/gamma_log_test.cpp | 24 -------- .../prim/prob/gaussian_dlm_obs_log_test.cpp | 39 ------------- test/unit/math/prim/prob/gumbel_log_test.cpp | 24 -------- .../prim/prob/hypergeometric_log_test.cpp | 38 ------------ .../prim/prob/inv_chi_square_log_test.cpp | 22 ------- .../math/prim/prob/inv_gamma_log_test.cpp | 26 --------- .../math/prim/prob/inv_wishart_log_test.cpp | 25 -------- .../prim/prob/lkj_corr_cholesky_log_test.cpp | 20 ------- .../unit/math/prim/prob/lkj_corr_log_test.cpp | 21 ------- test/unit/math/prim/prob/lkj_cov_log_test.cpp | 25 -------- .../unit/math/prim/prob/logistic_log_test.cpp | 24 -------- .../math/prim/prob/lognormal_log_test.cpp | 27 --------- .../prim/prob/matrix_normal_prec_log_test.cpp | 26 --------- .../prim/prob/multi_gp_cholesky_log_test.cpp | 33 ----------- .../unit/math/prim/prob/multi_gp_log_test.cpp | 31 ---------- .../prob/multi_normal_cholesky_log_test.cpp | 39 ------------- .../math/prim/prob/multi_normal_log_test.cpp | 32 ---------- .../prim/prob/multi_normal_prec_log_test.cpp | 36 ------------ .../prim/prob/multi_student_t_log_test.cpp | 38 ------------ .../math/prim/prob/multinomial_log_test.cpp | 24 -------- .../prim/prob/multinomial_logit_log_test.cpp | 21 ------- .../prim/prob/neg_binomial_2_log_log_test.cpp | 29 ---------- .../math/prim/prob/neg_binomial_log_test.cpp | 37 ------------ test/unit/math/prim/prob/normal_log_test.cpp | 24 -------- .../prim/prob/ordered_logistic_log_test.cpp | 58 ------------------- .../prim/prob/ordered_probit_log_test.cpp | 25 -------- test/unit/math/prim/prob/pareto_log_test.cpp | 24 -------- .../math/prim/prob/pareto_type_2_log_test.cpp | 31 ---------- .../prim/prob/poisson_binomial_log_test.cpp | 37 ------------ .../math/prim/prob/poisson_log_log_test.cpp | 20 ------- .../unit/math/prim/prob/rayleigh_log_test.cpp | 20 ------- .../prob/scaled_inv_chi_square_log_test.cpp | 30 ---------- .../prob/skew_double_exponential_log_test.cpp | 33 ----------- .../math/prim/prob/skew_normal_log_test.cpp | 30 ---------- .../math/prim/prob/std_normal_log_test.cpp | 19 ------ .../math/prim/prob/student_t_log_test.cpp | 30 ---------- test/unit/math/prim/prob/uniform_log_test.cpp | 24 -------- .../math/prim/prob/von_mises_log_test.cpp | 33 ----------- test/unit/math/prim/prob/weibull_log_test.cpp | 25 -------- test/unit/math/prim/prob/wiener_log_test.cpp | 32 ---------- test/unit/math/prim/prob/wishart_log_test.cpp | 19 ------ 58 files changed, 1624 deletions(-) delete mode 100644 test/unit/math/prim/prob/bernoulli_log_test.cpp delete mode 100644 test/unit/math/prim/prob/bernoulli_logit_log_test.cpp delete mode 100644 test/unit/math/prim/prob/beta_binomial_log_test.cpp delete mode 100644 test/unit/math/prim/prob/beta_log_test.cpp delete mode 100644 test/unit/math/prim/prob/beta_proportion_log_test.cpp delete mode 100644 test/unit/math/prim/prob/binomial_log_test.cpp delete mode 100644 test/unit/math/prim/prob/binomial_logit_log_test.cpp delete mode 100644 test/unit/math/prim/prob/categorical_log_test.cpp delete mode 100644 test/unit/math/prim/prob/categorical_logit_log_test.cpp delete mode 100644 test/unit/math/prim/prob/cauchy_log_test.cpp delete mode 100644 test/unit/math/prim/prob/chi_square_log_test.cpp delete mode 100644 test/unit/math/prim/prob/dirichlet_log_test.cpp delete mode 100644 test/unit/math/prim/prob/discrete_range_log_test.cpp delete mode 100644 test/unit/math/prim/prob/double_exponential_log_test.cpp delete mode 100644 test/unit/math/prim/prob/exp_mod_normal_log_test.cpp delete mode 100644 test/unit/math/prim/prob/exponential_log_test.cpp delete mode 100644 test/unit/math/prim/prob/frechet_log_test.cpp delete mode 100644 test/unit/math/prim/prob/gamma_log_test.cpp delete mode 100644 test/unit/math/prim/prob/gaussian_dlm_obs_log_test.cpp delete mode 100644 test/unit/math/prim/prob/gumbel_log_test.cpp delete mode 100644 test/unit/math/prim/prob/hypergeometric_log_test.cpp delete mode 100644 test/unit/math/prim/prob/inv_chi_square_log_test.cpp delete mode 100644 test/unit/math/prim/prob/inv_gamma_log_test.cpp delete mode 100644 test/unit/math/prim/prob/inv_wishart_log_test.cpp delete mode 100644 test/unit/math/prim/prob/lkj_corr_cholesky_log_test.cpp delete mode 100644 test/unit/math/prim/prob/lkj_corr_log_test.cpp delete mode 100644 test/unit/math/prim/prob/lkj_cov_log_test.cpp delete mode 100644 test/unit/math/prim/prob/logistic_log_test.cpp delete mode 100644 test/unit/math/prim/prob/lognormal_log_test.cpp delete mode 100644 test/unit/math/prim/prob/matrix_normal_prec_log_test.cpp delete mode 100644 test/unit/math/prim/prob/multi_gp_cholesky_log_test.cpp delete mode 100644 test/unit/math/prim/prob/multi_gp_log_test.cpp delete mode 100644 test/unit/math/prim/prob/multi_normal_cholesky_log_test.cpp delete mode 100644 test/unit/math/prim/prob/multi_normal_log_test.cpp delete mode 100644 test/unit/math/prim/prob/multi_normal_prec_log_test.cpp delete mode 100644 test/unit/math/prim/prob/multi_student_t_log_test.cpp delete mode 100644 test/unit/math/prim/prob/multinomial_log_test.cpp delete mode 100644 test/unit/math/prim/prob/multinomial_logit_log_test.cpp delete mode 100644 test/unit/math/prim/prob/neg_binomial_2_log_log_test.cpp delete mode 100644 test/unit/math/prim/prob/neg_binomial_log_test.cpp delete mode 100644 test/unit/math/prim/prob/normal_log_test.cpp delete mode 100644 test/unit/math/prim/prob/ordered_logistic_log_test.cpp delete mode 100644 test/unit/math/prim/prob/ordered_probit_log_test.cpp delete mode 100644 test/unit/math/prim/prob/pareto_log_test.cpp delete mode 100644 test/unit/math/prim/prob/pareto_type_2_log_test.cpp delete mode 100644 test/unit/math/prim/prob/poisson_binomial_log_test.cpp delete mode 100644 test/unit/math/prim/prob/poisson_log_log_test.cpp delete mode 100644 test/unit/math/prim/prob/rayleigh_log_test.cpp delete mode 100644 test/unit/math/prim/prob/scaled_inv_chi_square_log_test.cpp delete mode 100644 test/unit/math/prim/prob/skew_double_exponential_log_test.cpp delete mode 100644 test/unit/math/prim/prob/skew_normal_log_test.cpp delete mode 100644 test/unit/math/prim/prob/std_normal_log_test.cpp delete mode 100644 test/unit/math/prim/prob/student_t_log_test.cpp delete mode 100644 test/unit/math/prim/prob/uniform_log_test.cpp delete mode 100644 test/unit/math/prim/prob/von_mises_log_test.cpp delete mode 100644 test/unit/math/prim/prob/weibull_log_test.cpp delete mode 100644 test/unit/math/prim/prob/wiener_log_test.cpp delete mode 100644 test/unit/math/prim/prob/wishart_log_test.cpp diff --git a/test/unit/math/prim/prob/bernoulli_log_test.cpp b/test/unit/math/prim/prob/bernoulli_log_test.cpp deleted file mode 100644 index e9eccba1772..00000000000 --- a/test/unit/math/prim/prob/bernoulli_log_test.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include -#include - -TEST(ProbBernoulli, log_matches_lpmf) { - int n = 1; - double theta = 0.3; - - EXPECT_FLOAT_EQ((stan::math::bernoulli_lpmf(n, theta)), - (stan::math::bernoulli_log(n, theta))); - EXPECT_FLOAT_EQ((stan::math::bernoulli_lpmf(n, theta)), - (stan::math::bernoulli_log(n, theta))); - EXPECT_FLOAT_EQ((stan::math::bernoulli_lpmf(n, theta)), - (stan::math::bernoulli_log(n, theta))); - EXPECT_FLOAT_EQ((stan::math::bernoulli_lpmf(n, theta)), - (stan::math::bernoulli_log(n, theta))); - EXPECT_FLOAT_EQ((stan::math::bernoulli_lpmf(n, theta)), - (stan::math::bernoulli_log(n, theta))); - EXPECT_FLOAT_EQ((stan::math::bernoulli_lpmf(n, theta)), - (stan::math::bernoulli_log(n, theta))); -} diff --git a/test/unit/math/prim/prob/bernoulli_logit_log_test.cpp b/test/unit/math/prim/prob/bernoulli_logit_log_test.cpp deleted file mode 100644 index bb549fea048..00000000000 --- a/test/unit/math/prim/prob/bernoulli_logit_log_test.cpp +++ /dev/null @@ -1,49 +0,0 @@ -#include -#include - -TEST(ProbBernoulliLogitMat, log_matches_lpmf) { - using Eigen::Dynamic; - using Eigen::Matrix; - Matrix n(3, 1); - n << 0, 1, 0; - Matrix theta(3, 1); - theta << 1.2, 2, 0.9; - - EXPECT_FLOAT_EQ((stan::math::bernoulli_logit_lpmf(n, theta)), - (stan::math::bernoulli_logit_log(n, theta))); - EXPECT_FLOAT_EQ((stan::math::bernoulli_logit_lpmf(n, theta)), - (stan::math::bernoulli_logit_log(n, theta))); - EXPECT_FLOAT_EQ((stan::math::bernoulli_logit_lpmf(n, theta)), - (stan::math::bernoulli_logit_log(n, theta))); - EXPECT_FLOAT_EQ( - (stan::math::bernoulli_logit_lpmf>(n, - theta)), - (stan::math::bernoulli_logit_log>(n, - theta))); - EXPECT_FLOAT_EQ( - (stan::math::bernoulli_logit_lpmf>(n, - theta)), - (stan::math::bernoulli_logit_log>(n, - theta))); - EXPECT_FLOAT_EQ( - (stan::math::bernoulli_logit_lpmf>(n, theta)), - (stan::math::bernoulli_logit_log>(n, theta))); -} - -TEST(ProbBernoulliLogitScal, log_matches_lpmf) { - int n = 1; - double theta = 1.2; - - EXPECT_FLOAT_EQ((stan::math::bernoulli_logit_lpmf(n, theta)), - (stan::math::bernoulli_logit_log(n, theta))); - EXPECT_FLOAT_EQ((stan::math::bernoulli_logit_lpmf(n, theta)), - (stan::math::bernoulli_logit_log(n, theta))); - EXPECT_FLOAT_EQ((stan::math::bernoulli_logit_lpmf(n, theta)), - (stan::math::bernoulli_logit_log(n, theta))); - EXPECT_FLOAT_EQ((stan::math::bernoulli_logit_lpmf(n, theta)), - (stan::math::bernoulli_logit_log(n, theta))); - EXPECT_FLOAT_EQ((stan::math::bernoulli_logit_lpmf(n, theta)), - (stan::math::bernoulli_logit_log(n, theta))); - EXPECT_FLOAT_EQ((stan::math::bernoulli_logit_lpmf(n, theta)), - (stan::math::bernoulli_logit_log(n, theta))); -} diff --git a/test/unit/math/prim/prob/beta_binomial_log_test.cpp b/test/unit/math/prim/prob/beta_binomial_log_test.cpp deleted file mode 100644 index a5b82723675..00000000000 --- a/test/unit/math/prim/prob/beta_binomial_log_test.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include -#include - -TEST(ProbBetaBinomial, log_matches_lpmf) { - int n = 2; - int N = 6; - double alpha = 1.1; - double beta = 0.3; - - EXPECT_FLOAT_EQ((stan::math::beta_binomial_lpmf(n, N, alpha, beta)), - (stan::math::beta_binomial_log(n, N, alpha, beta))); - EXPECT_FLOAT_EQ((stan::math::beta_binomial_lpmf(n, N, alpha, beta)), - (stan::math::beta_binomial_log(n, N, alpha, beta))); - EXPECT_FLOAT_EQ((stan::math::beta_binomial_lpmf(n, N, alpha, beta)), - (stan::math::beta_binomial_log(n, N, alpha, beta))); - EXPECT_FLOAT_EQ( - (stan::math::beta_binomial_lpmf( - n, N, alpha, beta)), - (stan::math::beta_binomial_log( - n, N, alpha, beta))); - EXPECT_FLOAT_EQ( - (stan::math::beta_binomial_lpmf( - n, N, alpha, beta)), - (stan::math::beta_binomial_log( - n, N, alpha, beta))); - EXPECT_FLOAT_EQ( - (stan::math::beta_binomial_lpmf( - n, N, alpha, beta)), - (stan::math::beta_binomial_log( - n, N, alpha, beta))); -} diff --git a/test/unit/math/prim/prob/beta_log_test.cpp b/test/unit/math/prim/prob/beta_log_test.cpp deleted file mode 100644 index e0d376af68f..00000000000 --- a/test/unit/math/prim/prob/beta_log_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include -#include - -TEST(ProbBeta, log_matches_lpdf) { - double y = 0.8; - double alpha = 1.1; - double beta = 2.3; - - EXPECT_FLOAT_EQ((stan::math::beta_lpdf(y, alpha, beta)), - (stan::math::beta_log(y, alpha, beta))); - EXPECT_FLOAT_EQ((stan::math::beta_lpdf(y, alpha, beta)), - (stan::math::beta_log(y, alpha, beta))); - EXPECT_FLOAT_EQ((stan::math::beta_lpdf(y, alpha, beta)), - (stan::math::beta_log(y, alpha, beta))); - EXPECT_FLOAT_EQ( - (stan::math::beta_lpdf(y, alpha, beta)), - (stan::math::beta_log(y, alpha, beta))); - EXPECT_FLOAT_EQ( - (stan::math::beta_lpdf(y, alpha, beta)), - (stan::math::beta_log(y, alpha, beta))); - EXPECT_FLOAT_EQ( - (stan::math::beta_lpdf(y, alpha, beta)), - (stan::math::beta_log(y, alpha, beta))); -} diff --git a/test/unit/math/prim/prob/beta_proportion_log_test.cpp b/test/unit/math/prim/prob/beta_proportion_log_test.cpp deleted file mode 100644 index ab31a05995a..00000000000 --- a/test/unit/math/prim/prob/beta_proportion_log_test.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include -#include - -TEST(ProbBetaProportion, log_matches_lpdf) { - double y = 0.8; - double mu = .51; - double kappa = 2.3; - - EXPECT_FLOAT_EQ((stan::math::beta_proportion_lpdf(y, mu, kappa)), - (stan::math::beta_proportion_log(y, mu, kappa))); - EXPECT_FLOAT_EQ((stan::math::beta_proportion_lpdf(y, mu, kappa)), - (stan::math::beta_proportion_log(y, mu, kappa))); - EXPECT_FLOAT_EQ((stan::math::beta_proportion_lpdf(y, mu, kappa)), - (stan::math::beta_proportion_log(y, mu, kappa))); - EXPECT_FLOAT_EQ( - (stan::math::beta_proportion_lpdf(y, mu, - kappa)), - (stan::math::beta_proportion_log(y, mu, - kappa))); - EXPECT_FLOAT_EQ( - (stan::math::beta_proportion_lpdf(y, mu, - kappa)), - (stan::math::beta_proportion_log(y, mu, - kappa))); - EXPECT_FLOAT_EQ( - (stan::math::beta_proportion_lpdf(y, mu, kappa)), - (stan::math::beta_proportion_log(y, mu, kappa))); -} diff --git a/test/unit/math/prim/prob/binomial_log_test.cpp b/test/unit/math/prim/prob/binomial_log_test.cpp deleted file mode 100644 index ed92e01ad31..00000000000 --- a/test/unit/math/prim/prob/binomial_log_test.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include - -TEST(ProbBinomial, log_matches_lpmf) { - int n = 3; - int N = 6; - double theta = 0.4; - - EXPECT_FLOAT_EQ((stan::math::binomial_lpmf(n, N, theta)), - (stan::math::binomial_log(n, N, theta))); - EXPECT_FLOAT_EQ((stan::math::binomial_lpmf(n, N, theta)), - (stan::math::binomial_log(n, N, theta))); - EXPECT_FLOAT_EQ((stan::math::binomial_lpmf(n, N, theta)), - (stan::math::binomial_log(n, N, theta))); - EXPECT_FLOAT_EQ((stan::math::binomial_lpmf(n, N, theta)), - (stan::math::binomial_log(n, N, theta))); - EXPECT_FLOAT_EQ((stan::math::binomial_lpmf(n, N, theta)), - (stan::math::binomial_log(n, N, theta))); - EXPECT_FLOAT_EQ((stan::math::binomial_lpmf(n, N, theta)), - (stan::math::binomial_log(n, N, theta))); -} diff --git a/test/unit/math/prim/prob/binomial_logit_log_test.cpp b/test/unit/math/prim/prob/binomial_logit_log_test.cpp deleted file mode 100644 index 047fcd25979..00000000000 --- a/test/unit/math/prim/prob/binomial_logit_log_test.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include - -TEST(ProbBinomialLogit, log_matches_lpmf) { - int n = 3; - int N = 6; - double theta = 1.2; - - EXPECT_FLOAT_EQ((stan::math::binomial_logit_lpmf(n, N, theta)), - (stan::math::binomial_logit_log(n, N, theta))); - EXPECT_FLOAT_EQ((stan::math::binomial_logit_lpmf(n, N, theta)), - (stan::math::binomial_logit_log(n, N, theta))); - EXPECT_FLOAT_EQ((stan::math::binomial_logit_lpmf(n, N, theta)), - (stan::math::binomial_logit_log(n, N, theta))); - EXPECT_FLOAT_EQ((stan::math::binomial_logit_lpmf(n, N, theta)), - (stan::math::binomial_logit_log(n, N, theta))); - EXPECT_FLOAT_EQ((stan::math::binomial_logit_lpmf(n, N, theta)), - (stan::math::binomial_logit_log(n, N, theta))); - EXPECT_FLOAT_EQ((stan::math::binomial_logit_lpmf(n, N, theta)), - (stan::math::binomial_logit_log(n, N, theta))); -} diff --git a/test/unit/math/prim/prob/categorical_log_test.cpp b/test/unit/math/prim/prob/categorical_log_test.cpp deleted file mode 100644 index 77c36ab88b1..00000000000 --- a/test/unit/math/prim/prob/categorical_log_test.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include -#include -#include - -TEST(ProbDistributionsCategorical, log_matches_lpmf) { - Eigen::Matrix theta(3, 1); - theta << 0.3, 0.5, 0.2; - - EXPECT_FLOAT_EQ((stan::math::categorical_lpmf(1, theta)), - (stan::math::categorical_log(1, theta))); - EXPECT_FLOAT_EQ((stan::math::categorical_lpmf(1, theta)), - (stan::math::categorical_log(1, theta))); - EXPECT_FLOAT_EQ((stan::math::categorical_lpmf(1, theta)), - (stan::math::categorical_log(1, theta))); - - std::vector ns(5); - ns[0] = 1; - ns[1] = 2; - ns[2] = 2; - ns[3] = 1; - ns[4] = 3; - EXPECT_FLOAT_EQ((stan::math::categorical_lpmf(ns, theta)), - (stan::math::categorical_log(ns, theta))); - EXPECT_FLOAT_EQ((stan::math::categorical_lpmf(ns, theta)), - (stan::math::categorical_log(ns, theta))); - EXPECT_FLOAT_EQ((stan::math::categorical_lpmf(ns, theta)), - (stan::math::categorical_log(ns, theta))); -} diff --git a/test/unit/math/prim/prob/categorical_logit_log_test.cpp b/test/unit/math/prim/prob/categorical_logit_log_test.cpp deleted file mode 100644 index 70c652e7b3b..00000000000 --- a/test/unit/math/prim/prob/categorical_logit_log_test.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include -#include - -TEST(ProbCategoricalLogit, log_matches_lpmf) { - Eigen::Matrix theta(3, 1); - theta << -1, 2, -10; - - EXPECT_FLOAT_EQ((stan::math::categorical_logit_lpmf(1, theta)), - (stan::math::categorical_logit_log(1, theta))); - EXPECT_FLOAT_EQ((stan::math::categorical_logit_lpmf(1, theta)), - (stan::math::categorical_logit_log(1, theta))); - EXPECT_FLOAT_EQ((stan::math::categorical_logit_lpmf(1, theta)), - (stan::math::categorical_logit_log(1, theta))); - - std::vector ns(5); - ns[0] = 1; - ns[1] = 1; - ns[2] = 3; - ns[3] = 2; - ns[4] = 3; - - EXPECT_FLOAT_EQ((stan::math::categorical_logit_lpmf(ns, theta)), - (stan::math::categorical_logit_log(ns, theta))); - EXPECT_FLOAT_EQ((stan::math::categorical_logit_lpmf(ns, theta)), - (stan::math::categorical_logit_log(ns, theta))); - EXPECT_FLOAT_EQ((stan::math::categorical_logit_lpmf(ns, theta)), - (stan::math::categorical_logit_log(ns, theta))); -} diff --git a/test/unit/math/prim/prob/cauchy_log_test.cpp b/test/unit/math/prim/prob/cauchy_log_test.cpp deleted file mode 100644 index d59470c8252..00000000000 --- a/test/unit/math/prim/prob/cauchy_log_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include -#include - -TEST(ProbCauchy, log_matches_lpdf) { - double y = 2; - double mu = 1.5; - double sigma = 0.5; - - EXPECT_FLOAT_EQ((stan::math::cauchy_lpdf(y, mu, sigma)), - (stan::math::cauchy_log(y, mu, sigma))); - EXPECT_FLOAT_EQ((stan::math::cauchy_lpdf(y, mu, sigma)), - (stan::math::cauchy_log(y, mu, sigma))); - EXPECT_FLOAT_EQ((stan::math::cauchy_lpdf(y, mu, sigma)), - (stan::math::cauchy_log(y, mu, sigma))); - EXPECT_FLOAT_EQ( - (stan::math::cauchy_lpdf(y, mu, sigma)), - (stan::math::cauchy_log(y, mu, sigma))); - EXPECT_FLOAT_EQ( - (stan::math::cauchy_lpdf(y, mu, sigma)), - (stan::math::cauchy_log(y, mu, sigma))); - EXPECT_FLOAT_EQ( - (stan::math::cauchy_lpdf(y, mu, sigma)), - (stan::math::cauchy_log(y, mu, sigma))); -} diff --git a/test/unit/math/prim/prob/chi_square_log_test.cpp b/test/unit/math/prim/prob/chi_square_log_test.cpp deleted file mode 100644 index b202be2fbea..00000000000 --- a/test/unit/math/prim/prob/chi_square_log_test.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include -#include - -TEST(ProbChiSquare, log_matches_lpdf) { - double y = 0.3; - double nu = 15; - - EXPECT_FLOAT_EQ((stan::math::chi_square_lpdf(y, nu)), - (stan::math::chi_square_log(y, nu))); - EXPECT_FLOAT_EQ((stan::math::chi_square_lpdf(y, nu)), - (stan::math::chi_square_log(y, nu))); - EXPECT_FLOAT_EQ((stan::math::chi_square_lpdf(y, nu)), - (stan::math::chi_square_log(y, nu))); - EXPECT_FLOAT_EQ((stan::math::chi_square_lpdf(y, nu)), - (stan::math::chi_square_log(y, nu))); - EXPECT_FLOAT_EQ((stan::math::chi_square_lpdf(y, nu)), - (stan::math::chi_square_log(y, nu))); - EXPECT_FLOAT_EQ((stan::math::chi_square_lpdf(y, nu)), - (stan::math::chi_square_log(y, nu))); -} diff --git a/test/unit/math/prim/prob/dirichlet_log_test.cpp b/test/unit/math/prim/prob/dirichlet_log_test.cpp deleted file mode 100644 index bfa4656c9b4..00000000000 --- a/test/unit/math/prim/prob/dirichlet_log_test.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include -#include - -TEST(ProbDirichlet, log_matches_lpdf) { - using stan::math::vector_d; - Eigen::Matrix theta(3, 1); - theta << 0.2, 0.3, 0.5; - Eigen::Matrix alpha(3, 1); - alpha << 1.0, 1.0, 1.0; - EXPECT_FLOAT_EQ( - (stan::math::dirichlet_lpdf(theta, alpha)), - (stan::math::dirichlet_log(theta, alpha))); - EXPECT_FLOAT_EQ( - (stan::math::dirichlet_lpdf(theta, alpha)), - (stan::math::dirichlet_log(theta, alpha))); - EXPECT_FLOAT_EQ( - (stan::math::dirichlet_lpdf(theta, alpha)), - (stan::math::dirichlet_log(theta, alpha))); - EXPECT_FLOAT_EQ((stan::math::dirichlet_lpdf(theta, alpha)), - (stan::math::dirichlet_log(theta, alpha))); - EXPECT_FLOAT_EQ((stan::math::dirichlet_lpdf(theta, alpha)), - (stan::math::dirichlet_log(theta, alpha))); - EXPECT_FLOAT_EQ((stan::math::dirichlet_lpdf(theta, alpha)), - (stan::math::dirichlet_log(theta, alpha))); -} diff --git a/test/unit/math/prim/prob/discrete_range_log_test.cpp b/test/unit/math/prim/prob/discrete_range_log_test.cpp deleted file mode 100644 index 94472b46432..00000000000 --- a/test/unit/math/prim/prob/discrete_range_log_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include -#include - -TEST(ProbDiscreteRange, log_matches_lpmf) { - int y = 3; - int lower = -2; - int upper = 5; - - EXPECT_FLOAT_EQ((stan::math::discrete_range_lpmf(y, lower, upper)), - (stan::math::discrete_range_log(y, lower, upper))); - EXPECT_FLOAT_EQ((stan::math::discrete_range_lpmf(y, lower, upper)), - (stan::math::discrete_range_log(y, lower, upper))); - EXPECT_FLOAT_EQ((stan::math::discrete_range_lpmf(y, lower, upper)), - (stan::math::discrete_range_log(y, lower, upper))); - EXPECT_FLOAT_EQ( - (stan::math::discrete_range_lpmf(y, lower, upper)), - (stan::math::discrete_range_log(y, lower, upper))); - EXPECT_FLOAT_EQ( - (stan::math::discrete_range_lpmf(y, lower, upper)), - (stan::math::discrete_range_log(y, lower, upper))); - EXPECT_FLOAT_EQ( - (stan::math::discrete_range_lpmf(y, lower, upper)), - (stan::math::discrete_range_log(y, lower, upper))); -} diff --git a/test/unit/math/prim/prob/double_exponential_log_test.cpp b/test/unit/math/prim/prob/double_exponential_log_test.cpp deleted file mode 100644 index d90de742bc0..00000000000 --- a/test/unit/math/prim/prob/double_exponential_log_test.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include - -TEST(ProbDoubleExponential, log_matches_lpdf) { - double y = 0.8; - double mu = 1.1; - double sigma = 2.3; - - EXPECT_FLOAT_EQ((stan::math::double_exponential_lpdf(y, mu, sigma)), - (stan::math::double_exponential_log(y, mu, sigma))); - EXPECT_FLOAT_EQ((stan::math::double_exponential_lpdf(y, mu, sigma)), - (stan::math::double_exponential_log(y, mu, sigma))); - EXPECT_FLOAT_EQ((stan::math::double_exponential_lpdf(y, mu, sigma)), - (stan::math::double_exponential_log(y, mu, sigma))); - EXPECT_FLOAT_EQ( - (stan::math::double_exponential_lpdf( - y, mu, sigma)), - (stan::math::double_exponential_log( - y, mu, sigma))); - EXPECT_FLOAT_EQ( - (stan::math::double_exponential_lpdf( - y, mu, sigma)), - (stan::math::double_exponential_log( - y, mu, sigma))); - EXPECT_FLOAT_EQ((stan::math::double_exponential_lpdf( - y, mu, sigma)), - (stan::math::double_exponential_log( - y, mu, sigma))); -} diff --git a/test/unit/math/prim/prob/exp_mod_normal_log_test.cpp b/test/unit/math/prim/prob/exp_mod_normal_log_test.cpp deleted file mode 100644 index 087c5c60e95..00000000000 --- a/test/unit/math/prim/prob/exp_mod_normal_log_test.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include -#include - -TEST(ProbExpModNormal, log_matches_lpmf) { - double y = 0.8; - double mu = 1.1; - double sigma = 2.3; - double lambda = 0.5; - - EXPECT_FLOAT_EQ((stan::math::exp_mod_normal_lpdf(y, mu, lambda, sigma)), - (stan::math::exp_mod_normal_log(y, mu, lambda, sigma))); - EXPECT_FLOAT_EQ((stan::math::exp_mod_normal_lpdf(y, mu, lambda, sigma)), - (stan::math::exp_mod_normal_log(y, mu, lambda, sigma))); - EXPECT_FLOAT_EQ( - (stan::math::exp_mod_normal_lpdf(y, mu, lambda, sigma)), - (stan::math::exp_mod_normal_log(y, mu, lambda, sigma))); - EXPECT_FLOAT_EQ( - (stan::math::exp_mod_normal_lpdf( - y, mu, lambda, sigma)), - (stan::math::exp_mod_normal_log( - y, mu, lambda, sigma))); - EXPECT_FLOAT_EQ( - (stan::math::exp_mod_normal_lpdf( - y, mu, lambda, sigma)), - (stan::math::exp_mod_normal_log( - y, mu, lambda, sigma))); - EXPECT_FLOAT_EQ( - (stan::math::exp_mod_normal_lpdf( - y, mu, lambda, sigma)), - (stan::math::exp_mod_normal_log( - y, mu, lambda, sigma))); -} diff --git a/test/unit/math/prim/prob/exponential_log_test.cpp b/test/unit/math/prim/prob/exponential_log_test.cpp deleted file mode 100644 index 085ce20a1f7..00000000000 --- a/test/unit/math/prim/prob/exponential_log_test.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include - -TEST(ProbExponential, log_matches_lpdf) { - double y = 0.8; - double beta = 1.2; - - EXPECT_FLOAT_EQ((stan::math::exponential_lpdf(y, beta)), - (stan::math::exponential_log(y, beta))); - EXPECT_FLOAT_EQ((stan::math::exponential_lpdf(y, beta)), - (stan::math::exponential_log(y, beta))); - EXPECT_FLOAT_EQ((stan::math::exponential_lpdf(y, beta)), - (stan::math::exponential_log(y, beta))); - EXPECT_FLOAT_EQ((stan::math::exponential_lpdf(y, beta)), - (stan::math::exponential_log(y, beta))); - EXPECT_FLOAT_EQ( - (stan::math::exponential_lpdf(y, beta)), - (stan::math::exponential_log(y, beta))); - EXPECT_FLOAT_EQ((stan::math::exponential_lpdf(y, beta)), - (stan::math::exponential_log(y, beta))); -} diff --git a/test/unit/math/prim/prob/frechet_log_test.cpp b/test/unit/math/prim/prob/frechet_log_test.cpp deleted file mode 100644 index d682343a66d..00000000000 --- a/test/unit/math/prim/prob/frechet_log_test.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include - -TEST(ProbFrechet, log_matches_lpdf) { - double y = 0.3; - double alpha = 2; - double sigma = 1.5; - - EXPECT_FLOAT_EQ((stan::math::frechet_lpdf(y, alpha, sigma)), - (stan::math::frechet_log(y, alpha, sigma))); - EXPECT_FLOAT_EQ((stan::math::frechet_lpdf(y, alpha, sigma)), - (stan::math::frechet_log(y, alpha, sigma))); - EXPECT_FLOAT_EQ((stan::math::frechet_lpdf(y, alpha, sigma)), - (stan::math::frechet_log(y, alpha, sigma))); - EXPECT_FLOAT_EQ( - (stan::math::frechet_lpdf(y, alpha, sigma)), - (stan::math::frechet_log(y, alpha, sigma))); - EXPECT_FLOAT_EQ( - (stan::math::frechet_lpdf(y, alpha, sigma)), - (stan::math::frechet_log(y, alpha, sigma))); - EXPECT_FLOAT_EQ((stan::math::frechet_lpdf(y, alpha, sigma)), - (stan::math::frechet_log(y, alpha, sigma))); -} diff --git a/test/unit/math/prim/prob/gamma_log_test.cpp b/test/unit/math/prim/prob/gamma_log_test.cpp deleted file mode 100644 index 65c654847f5..00000000000 --- a/test/unit/math/prim/prob/gamma_log_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include -#include - -TEST(ProbGamma, log_matches_lpdf) { - double y = 0.8; - double alpha = 1.1; - double beta = 2.3; - - EXPECT_FLOAT_EQ((stan::math::gamma_lpdf(y, alpha, beta)), - (stan::math::gamma_log(y, alpha, beta))); - EXPECT_FLOAT_EQ((stan::math::gamma_lpdf(y, alpha, beta)), - (stan::math::gamma_log(y, alpha, beta))); - EXPECT_FLOAT_EQ((stan::math::gamma_lpdf(y, alpha, beta)), - (stan::math::gamma_log(y, alpha, beta))); - EXPECT_FLOAT_EQ( - (stan::math::gamma_lpdf(y, alpha, beta)), - (stan::math::gamma_log(y, alpha, beta))); - EXPECT_FLOAT_EQ( - (stan::math::gamma_lpdf(y, alpha, beta)), - (stan::math::gamma_log(y, alpha, beta))); - EXPECT_FLOAT_EQ( - (stan::math::gamma_lpdf(y, alpha, beta)), - (stan::math::gamma_log(y, alpha, beta))); -} diff --git a/test/unit/math/prim/prob/gaussian_dlm_obs_log_test.cpp b/test/unit/math/prim/prob/gaussian_dlm_obs_log_test.cpp deleted file mode 100644 index 6f2e2534072..00000000000 --- a/test/unit/math/prim/prob/gaussian_dlm_obs_log_test.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include -#include - -TEST(ProbGaussianDlmObs, log_matches_lpmf) { - Eigen::Matrix y(1, 10); - y << -0.286804393606091, 1.30654039013044, 0.184631538931975, - 1.76116251447979, 1.64691178557684, 0.0599998209370169, - -0.498099220647035, 1.77794756092381, -0.435458550812876, - 1.17332931763075; - Eigen::Matrix F(1, 1); - F << 0.585528817843856; - Eigen::Matrix G(1, 1); - G << -0.109303314681054; - Eigen::Matrix V(1, 1); - V << 2.25500747900521; - Eigen::Matrix W(1, 1); - W << 0.461487989960454; - Eigen::Matrix m0(1); - m0 << 11.5829455171551; - Eigen::Matrix C0(1, 1); - C0 << 65.2373490156606; - - EXPECT_FLOAT_EQ( - (stan::math::gaussian_dlm_obs_lpdf(y, F, G, V, W, m0, C0)), - (stan::math::gaussian_dlm_obs_log(y, F, G, V, W, m0, C0))); - EXPECT_FLOAT_EQ( - (stan::math::gaussian_dlm_obs_lpdf(y, F, G, V, W, m0, C0)), - (stan::math::gaussian_dlm_obs_log(y, F, G, V, W, m0, C0))); - EXPECT_FLOAT_EQ((stan::math::gaussian_dlm_obs_lpdf<>(y, F, G, V, W, m0, C0)), - (stan::math::gaussian_dlm_obs_log<>(y, F, G, V, W, m0, C0))); - EXPECT_FLOAT_EQ((stan::math::gaussian_dlm_obs_lpdf(y, F, G, V, W, m0, C0)), - (stan::math::gaussian_dlm_obs_log(y, F, G, V, W, m0, C0))); - EXPECT_FLOAT_EQ( - (stan::math::gaussian_dlm_obs_lpdf(y, F, G, V, W, m0, C0)), - (stan::math::gaussian_dlm_obs_log(y, F, G, V, W, m0, C0))); - EXPECT_FLOAT_EQ( - (stan::math::gaussian_dlm_obs_lpdf(y, F, G, V, W, m0, C0)), - (stan::math::gaussian_dlm_obs_log(y, F, G, V, W, m0, C0))); -} diff --git a/test/unit/math/prim/prob/gumbel_log_test.cpp b/test/unit/math/prim/prob/gumbel_log_test.cpp deleted file mode 100644 index 728649f1ae4..00000000000 --- a/test/unit/math/prim/prob/gumbel_log_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include -#include - -TEST(ProbGumbel, log_matches_lpdf) { - double y = 0.8; - double mu = 1.1; - double sigma = 2.3; - - EXPECT_FLOAT_EQ((stan::math::gumbel_lpdf(y, mu, sigma)), - (stan::math::gumbel_log(y, mu, sigma))); - EXPECT_FLOAT_EQ((stan::math::gumbel_lpdf(y, mu, sigma)), - (stan::math::gumbel_log(y, mu, sigma))); - EXPECT_FLOAT_EQ((stan::math::gumbel_lpdf(y, mu, sigma)), - (stan::math::gumbel_log(y, mu, sigma))); - EXPECT_FLOAT_EQ( - (stan::math::gumbel_lpdf(y, mu, sigma)), - (stan::math::gumbel_log(y, mu, sigma))); - EXPECT_FLOAT_EQ( - (stan::math::gumbel_lpdf(y, mu, sigma)), - (stan::math::gumbel_log(y, mu, sigma))); - EXPECT_FLOAT_EQ( - (stan::math::gumbel_lpdf(y, mu, sigma)), - (stan::math::gumbel_log(y, mu, sigma))); -} diff --git a/test/unit/math/prim/prob/hypergeometric_log_test.cpp b/test/unit/math/prim/prob/hypergeometric_log_test.cpp deleted file mode 100644 index 0b456f1892c..00000000000 --- a/test/unit/math/prim/prob/hypergeometric_log_test.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include -#include - -TEST(ProbHypergeometric, log_matches_lpmf) { - int n = 1; - int N = 4; - double a = 1.1; - double b = 3.5; - - EXPECT_FLOAT_EQ((stan::math::hypergeometric_lpmf(n, N, a, b)), - (stan::math::hypergeometric_log(n, N, a, b))); - EXPECT_FLOAT_EQ((stan::math::hypergeometric_lpmf(n, N, a, b)), - (stan::math::hypergeometric_log(n, N, a, b))); - EXPECT_FLOAT_EQ((stan::math::hypergeometric_lpmf(n, N, a, b)), - (stan::math::hypergeometric_log(n, N, a, b))); - EXPECT_FLOAT_EQ( - (stan::math::hypergeometric_lpmf(n, N, a, - b)), - (stan::math::hypergeometric_log(n, N, a, - b))); - EXPECT_FLOAT_EQ( - (stan::math::hypergeometric_lpmf(n, N, a, - b)), - (stan::math::hypergeometric_log(n, N, a, - b))); - EXPECT_FLOAT_EQ( - (stan::math::hypergeometric_lpmf(n, N, a, b)), - (stan::math::hypergeometric_log(n, N, a, b))); -} - -TEST(ProbHypergeometric, n_equal_N) { - int n = 2; - int N = 2; - int a = 2; - int b = 4; - - EXPECT_NO_THROW(stan::math::hypergeometric_lpmf(n, N, a, b)); -} diff --git a/test/unit/math/prim/prob/inv_chi_square_log_test.cpp b/test/unit/math/prim/prob/inv_chi_square_log_test.cpp deleted file mode 100644 index 405baee3bb6..00000000000 --- a/test/unit/math/prim/prob/inv_chi_square_log_test.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include - -TEST(ProbInvChiSquare, log_matches_lpdf) { - double y = 0.8; - double nu = 2.3; - - EXPECT_FLOAT_EQ((stan::math::inv_chi_square_lpdf(y, nu)), - (stan::math::inv_chi_square_log(y, nu))); - EXPECT_FLOAT_EQ((stan::math::inv_chi_square_lpdf(y, nu)), - (stan::math::inv_chi_square_log(y, nu))); - EXPECT_FLOAT_EQ((stan::math::inv_chi_square_lpdf(y, nu)), - (stan::math::inv_chi_square_log(y, nu))); - EXPECT_FLOAT_EQ( - (stan::math::inv_chi_square_lpdf(y, nu)), - (stan::math::inv_chi_square_log(y, nu))); - EXPECT_FLOAT_EQ( - (stan::math::inv_chi_square_lpdf(y, nu)), - (stan::math::inv_chi_square_log(y, nu))); - EXPECT_FLOAT_EQ((stan::math::inv_chi_square_lpdf(y, nu)), - (stan::math::inv_chi_square_log(y, nu))); -} diff --git a/test/unit/math/prim/prob/inv_gamma_log_test.cpp b/test/unit/math/prim/prob/inv_gamma_log_test.cpp deleted file mode 100644 index 1384fce535e..00000000000 --- a/test/unit/math/prim/prob/inv_gamma_log_test.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include -#include - -TEST(ProbInvGamma, log_matches_lpdf) { - double y = 0.8; - double alpha = 1.1; - double beta = 2.3; - - EXPECT_FLOAT_EQ((stan::math::inv_gamma_lpdf(y, alpha, beta)), - (stan::math::inv_gamma_log(y, alpha, beta))); - EXPECT_FLOAT_EQ((stan::math::inv_gamma_lpdf(y, alpha, beta)), - (stan::math::inv_gamma_log(y, alpha, beta))); - EXPECT_FLOAT_EQ((stan::math::inv_gamma_lpdf(y, alpha, beta)), - (stan::math::inv_gamma_log(y, alpha, beta))); - EXPECT_FLOAT_EQ((stan::math::inv_gamma_lpdf( - y, alpha, beta)), - (stan::math::inv_gamma_log( - y, alpha, beta))); - EXPECT_FLOAT_EQ((stan::math::inv_gamma_lpdf( - y, alpha, beta)), - (stan::math::inv_gamma_log( - y, alpha, beta))); - EXPECT_FLOAT_EQ( - (stan::math::inv_gamma_lpdf(y, alpha, beta)), - (stan::math::inv_gamma_log(y, alpha, beta))); -} diff --git a/test/unit/math/prim/prob/inv_wishart_log_test.cpp b/test/unit/math/prim/prob/inv_wishart_log_test.cpp deleted file mode 100644 index 78555bb636b..00000000000 --- a/test/unit/math/prim/prob/inv_wishart_log_test.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include -#include - -TEST(ProbInvWishart, log_matches_lpmf) { - Eigen::MatrixXd Y(4, 4); - Eigen::MatrixXd Sigma(4, 4); - Y << 7.988168, -9.555605, -14.47483, 4.395895, -9.555605, 44.750570, 49.21577, - -18.454186, -14.474830, 49.21577, 60.08987, -21.48108, 4.395895, - -18.454186, -21.48108, 7.885833; - Sigma << 2.9983662, 0.2898776, -2.650523, 0.1055911, 0.2898776, 11.4803610, - 7.1579931, -3.1129955, -2.650523, 7.1579931, 11.676181, -3.5866852, - 0.1055911, -3.1129955, -3.5866852, 1.4482736; - unsigned int dof = 5; - - EXPECT_FLOAT_EQ((stan::math::inv_wishart_lpdf(Y, dof, Sigma)), - (stan::math::inv_wishart_log(Y, dof, Sigma))); - EXPECT_FLOAT_EQ((stan::math::inv_wishart_lpdf(Y, dof, Sigma)), - (stan::math::inv_wishart_log(Y, dof, Sigma))); - EXPECT_FLOAT_EQ((stan::math::inv_wishart_lpdf(Y, dof, Sigma)), - (stan::math::inv_wishart_log(Y, dof, Sigma))); - EXPECT_FLOAT_EQ((stan::math::inv_wishart_lpdf(Y, dof, Sigma)), - (stan::math::inv_wishart_log(Y, dof, Sigma))); - EXPECT_FLOAT_EQ((stan::math::inv_wishart_lpdf(Y, dof, Sigma)), - (stan::math::inv_wishart_log(Y, dof, Sigma))); -} diff --git a/test/unit/math/prim/prob/lkj_corr_cholesky_log_test.cpp b/test/unit/math/prim/prob/lkj_corr_cholesky_log_test.cpp deleted file mode 100644 index 61de506a5b0..00000000000 --- a/test/unit/math/prim/prob/lkj_corr_cholesky_log_test.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include -#include - -TEST(ProbLkjCorrCholesky, log_matches_lpmf) { - unsigned int K = 4; - Eigen::MatrixXd Sigma(K, K); - double eta = 1.2; - Sigma.setZero(); - Sigma.diagonal().setOnes(); - EXPECT_FLOAT_EQ((stan::math::lkj_corr_cholesky_lpdf(Sigma, eta)), - (stan::math::lkj_corr_cholesky_log(Sigma, eta))); - EXPECT_FLOAT_EQ((stan::math::lkj_corr_cholesky_lpdf(Sigma, eta)), - (stan::math::lkj_corr_cholesky_log(Sigma, eta))); - EXPECT_FLOAT_EQ((stan::math::lkj_corr_cholesky_lpdf(Sigma, eta)), - (stan::math::lkj_corr_cholesky_log(Sigma, eta))); - EXPECT_FLOAT_EQ((stan::math::lkj_corr_cholesky_lpdf(Sigma, eta)), - (stan::math::lkj_corr_cholesky_log(Sigma, eta))); - EXPECT_FLOAT_EQ((stan::math::lkj_corr_cholesky_lpdf(Sigma, eta)), - (stan::math::lkj_corr_cholesky_log(Sigma, eta))); -} diff --git a/test/unit/math/prim/prob/lkj_corr_log_test.cpp b/test/unit/math/prim/prob/lkj_corr_log_test.cpp deleted file mode 100644 index 596520577de..00000000000 --- a/test/unit/math/prim/prob/lkj_corr_log_test.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include - -TEST(ProbLkjCorr, log_matches_lpmf) { - unsigned int K = 4; - Eigen::MatrixXd Sigma(K, K); - Sigma.setZero(); - Sigma.diagonal().setOnes(); - double eta = 1.2; - - EXPECT_FLOAT_EQ((stan::math::lkj_corr_lpdf(Sigma, eta)), - (stan::math::lkj_corr_log(Sigma, eta))); - EXPECT_FLOAT_EQ((stan::math::lkj_corr_lpdf(Sigma, eta)), - (stan::math::lkj_corr_log(Sigma, eta))); - EXPECT_FLOAT_EQ((stan::math::lkj_corr_lpdf(Sigma, eta)), - (stan::math::lkj_corr_log(Sigma, eta))); - EXPECT_FLOAT_EQ((stan::math::lkj_corr_lpdf(Sigma, eta)), - (stan::math::lkj_corr_log(Sigma, eta))); - EXPECT_FLOAT_EQ((stan::math::lkj_corr_lpdf(Sigma, eta)), - (stan::math::lkj_corr_log(Sigma, eta))); -} diff --git a/test/unit/math/prim/prob/lkj_cov_log_test.cpp b/test/unit/math/prim/prob/lkj_cov_log_test.cpp deleted file mode 100644 index 5ad46954cbe..00000000000 --- a/test/unit/math/prim/prob/lkj_cov_log_test.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include -#include - -TEST(ProbLkjCov, log_matches_lpmf) { - unsigned int K = 4; - Eigen::MatrixXd y(K, K); - Eigen::VectorXd mu(K); - Eigen::VectorXd sigma(K); - y.setZero(); - y.diagonal().setOnes(); - mu << 0.1, 0.2, -1.2, 0.3; - sigma << 1, 0.2, 4, 0.5; - double eta = 1.2; - - EXPECT_FLOAT_EQ((stan::math::lkj_cov_lpdf(y, mu, sigma, eta)), - (stan::math::lkj_cov_log(y, mu, sigma, eta))); - EXPECT_FLOAT_EQ((stan::math::lkj_cov_lpdf(y, mu, sigma, eta)), - (stan::math::lkj_cov_log(y, mu, sigma, eta))); - EXPECT_FLOAT_EQ((stan::math::lkj_cov_lpdf(y, mu, sigma, eta)), - (stan::math::lkj_cov_log(y, mu, sigma, eta))); - EXPECT_FLOAT_EQ((stan::math::lkj_cov_lpdf(y, mu, sigma, eta)), - (stan::math::lkj_cov_log(y, mu, sigma, eta))); - EXPECT_FLOAT_EQ((stan::math::lkj_cov_lpdf(y, mu, sigma, eta)), - (stan::math::lkj_cov_log(y, mu, sigma, eta))); -} diff --git a/test/unit/math/prim/prob/logistic_log_test.cpp b/test/unit/math/prim/prob/logistic_log_test.cpp deleted file mode 100644 index 60e7575e20b..00000000000 --- a/test/unit/math/prim/prob/logistic_log_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include -#include - -TEST(ProbLogistic, log_matches_lpdf) { - double y = 0.8; - double mu = -1.2; - double sigma = 2.3; - - EXPECT_FLOAT_EQ((stan::math::logistic_lpdf(y, mu, sigma)), - (stan::math::logistic_log(y, mu, sigma))); - EXPECT_FLOAT_EQ((stan::math::logistic_lpdf(y, mu, sigma)), - (stan::math::logistic_log(y, mu, sigma))); - EXPECT_FLOAT_EQ((stan::math::logistic_lpdf(y, mu, sigma)), - (stan::math::logistic_log(y, mu, sigma))); - EXPECT_FLOAT_EQ( - (stan::math::logistic_lpdf(y, mu, sigma)), - (stan::math::logistic_log(y, mu, sigma))); - EXPECT_FLOAT_EQ( - (stan::math::logistic_lpdf(y, mu, sigma)), - (stan::math::logistic_log(y, mu, sigma))); - EXPECT_FLOAT_EQ( - (stan::math::logistic_lpdf(y, mu, sigma)), - (stan::math::logistic_log(y, mu, sigma))); -} diff --git a/test/unit/math/prim/prob/lognormal_log_test.cpp b/test/unit/math/prim/prob/lognormal_log_test.cpp deleted file mode 100644 index 5b9324a1c81..00000000000 --- a/test/unit/math/prim/prob/lognormal_log_test.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include -#include - -TEST(ProbLognormal, log_matches_lpdf) { - double y = 0.8; - double mu = 1.1; - double sigma = 2.3; - - EXPECT_FLOAT_EQ((stan::math::lognormal_lpdf(y, mu, sigma)), - (stan::math::lognormal_log(y, mu, sigma))); - EXPECT_FLOAT_EQ((stan::math::lognormal_lpdf(y, mu, sigma)), - (stan::math::lognormal_log(y, mu, sigma))); - EXPECT_FLOAT_EQ((stan::math::lognormal_lpdf(y, mu, sigma)), - (stan::math::lognormal_log(y, mu, sigma))); - EXPECT_FLOAT_EQ( - (stan::math::lognormal_lpdf(y, mu, sigma)), - (stan::math::lognormal_log(y, mu, sigma))); - EXPECT_FLOAT_EQ( - (stan::math::lognormal_lpdf(y, mu, sigma)), - (stan::math::lognormal_log(y, mu, sigma))); - EXPECT_FLOAT_EQ( - (stan::math::lognormal_lpdf(y, mu, sigma)), - (stan::math::lognormal_log(y, mu, sigma))); - - EXPECT_FLOAT_EQ((stan::math::lognormal_lpdf(0.8, 2.0, 2.0)), - (stan::math::lognormal_log(0.8, 2, 2))); -} diff --git a/test/unit/math/prim/prob/matrix_normal_prec_log_test.cpp b/test/unit/math/prim/prob/matrix_normal_prec_log_test.cpp deleted file mode 100644 index 35d1e46ce77..00000000000 --- a/test/unit/math/prim/prob/matrix_normal_prec_log_test.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include -#include - -TEST(ProbMatrixNormalPrec, log_matches_lpmf) { - using Eigen::MatrixXd; - - MatrixXd y(3, 5); - y << 2.0, -2.0, 11.0, 4.0, -2.0, 11.0, 2.0, -5.0, 11.0, 0.0, -2.0, 11.0, 2.0, - -2.0, -11.0; - - MatrixXd mu = MatrixXd::Zero(3, 5); - - MatrixXd Sigma(3, 3); - Sigma << 1.0, 0.5, 0.1, 0.5, 1.0, 0.2, 0.1, 0.2, 1.0; - - MatrixXd D(5, 5); - D << 9.0, -3.0, 0.0, 0.0, 0.0, -3.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 5.0, 1.0, - 0.0, 0.0, 0.0, 1.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.0; - - EXPECT_FLOAT_EQ((stan::math::matrix_normal_prec_lpdf(y, mu, Sigma, D)), - (stan::math::matrix_normal_prec_log(y, mu, Sigma, D))); - EXPECT_FLOAT_EQ((stan::math::matrix_normal_prec_lpdf(y, mu, Sigma, D)), - (stan::math::matrix_normal_prec_log(y, mu, Sigma, D))); - EXPECT_FLOAT_EQ((stan::math::matrix_normal_prec_lpdf(y, mu, Sigma, D)), - (stan::math::matrix_normal_prec_log(y, mu, Sigma, D))); -} diff --git a/test/unit/math/prim/prob/multi_gp_cholesky_log_test.cpp b/test/unit/math/prim/prob/multi_gp_cholesky_log_test.cpp deleted file mode 100644 index c2db6b7645a..00000000000 --- a/test/unit/math/prim/prob/multi_gp_cholesky_log_test.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include -#include - -TEST(ProbMultiGpCholesky, log_matches_lpmf) { - Eigen::Matrix mu(5, 1); - mu.setZero(); - - Eigen::Matrix y(3, 5); - y << 2.0, -2.0, 11.0, 4.0, -2.0, 11.0, 2.0, -5.0, 11.0, 0.0, -2.0, 11.0, 2.0, - -2.0, -11.0; - - Eigen::Matrix Sigma(5, 5); - Sigma << 9.0, -3.0, 0.0, 0.0, 0.0, -3.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 5.0, - 1.0, 0.0, 0.0, 0.0, 1.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.0; - Eigen::Matrix L - = Sigma.llt().matrixL(); - - Eigen::Matrix w(3, 1); - w << 1.0, 0.5, 1.5; - - EXPECT_FLOAT_EQ((stan::math::multi_gp_cholesky_lpdf(y, L, w)), - (stan::math::multi_gp_cholesky_log(y, L, w))); - EXPECT_FLOAT_EQ((stan::math::multi_gp_cholesky_lpdf(y, L, w)), - (stan::math::multi_gp_cholesky_log(y, L, w))); - EXPECT_FLOAT_EQ((stan::math::multi_gp_cholesky_lpdf(y, L, w)), - (stan::math::multi_gp_cholesky_log(y, L, w))); - EXPECT_FLOAT_EQ((stan::math::multi_gp_cholesky_lpdf(y, L, w)), - (stan::math::multi_gp_cholesky_log(y, L, w))); - EXPECT_FLOAT_EQ((stan::math::multi_gp_cholesky_lpdf(y, L, w)), - (stan::math::multi_gp_cholesky_log(y, L, w))); - EXPECT_FLOAT_EQ((stan::math::multi_gp_cholesky_lpdf<>(y, L, w)), - (stan::math::multi_gp_cholesky_log<>(y, L, w))); -} diff --git a/test/unit/math/prim/prob/multi_gp_log_test.cpp b/test/unit/math/prim/prob/multi_gp_log_test.cpp deleted file mode 100644 index ce1746d56c6..00000000000 --- a/test/unit/math/prim/prob/multi_gp_log_test.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include -#include - -TEST(ProbMultiGp, log_matches_lpmf) { - Eigen::Matrix mu(5, 1); - mu.setZero(); - - Eigen::Matrix y(3, 5); - y << 2.0, -2.0, 11.0, 4.0, -2.0, 11.0, 2.0, -5.0, 11.0, 0.0, -2.0, 11.0, 2.0, - -2.0, -11.0; - - Eigen::Matrix Sigma(5, 5); - Sigma << 9.0, -3.0, 0.0, 0.0, 0.0, -3.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 5.0, - 1.0, 0.0, 0.0, 0.0, 1.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.0; - - Eigen::Matrix w(3, 1); - w << 1.0, 0.5, 1.5; - - EXPECT_FLOAT_EQ((stan::math::multi_gp_lpdf(y, Sigma, w)), - (stan::math::multi_gp_log(y, Sigma, w))); - EXPECT_FLOAT_EQ((stan::math::multi_gp_lpdf(y, Sigma, w)), - (stan::math::multi_gp_log(y, Sigma, w))); - EXPECT_FLOAT_EQ((stan::math::multi_gp_lpdf(y, Sigma, w)), - (stan::math::multi_gp_log(y, Sigma, w))); - EXPECT_FLOAT_EQ((stan::math::multi_gp_lpdf(y, Sigma, w)), - (stan::math::multi_gp_log(y, Sigma, w))); - EXPECT_FLOAT_EQ((stan::math::multi_gp_lpdf(y, Sigma, w)), - (stan::math::multi_gp_log(y, Sigma, w))); - EXPECT_FLOAT_EQ((stan::math::multi_gp_lpdf<>(y, Sigma, w)), - (stan::math::multi_gp_log<>(y, Sigma, w))); -} diff --git a/test/unit/math/prim/prob/multi_normal_cholesky_log_test.cpp b/test/unit/math/prim/prob/multi_normal_cholesky_log_test.cpp deleted file mode 100644 index c0368506901..00000000000 --- a/test/unit/math/prim/prob/multi_normal_cholesky_log_test.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include -#include - -TEST(ProbMultiNormalCholesky, log_matches_lpmf) { - Eigen::Matrix y(3, 1); - y << 2.0, -2.0, 11.0; - Eigen::Matrix mu(3, 1); - mu << 1.0, -1.0, 3.0; - Eigen::Matrix Sigma(3, 3); - Sigma << 9.0, -3.0, 0.0, -3.0, 4.0, 0.0, 0.0, 0.0, 5.0; - Eigen::Matrix L - = Sigma.llt().matrixL(); - - EXPECT_FLOAT_EQ((stan::math::multi_normal_cholesky_lpdf(y, mu, L)), - (stan::math::multi_normal_cholesky_log(y, mu, L))); - EXPECT_FLOAT_EQ((stan::math::multi_normal_cholesky_lpdf(y, mu, L)), - (stan::math::multi_normal_cholesky_log(y, mu, L))); - EXPECT_FLOAT_EQ((stan::math::multi_normal_cholesky_lpdf(y, mu, L)), - (stan::math::multi_normal_cholesky_log(y, mu, L))); - EXPECT_FLOAT_EQ( - (stan::math::multi_normal_cholesky_lpdf( - y, mu, L)), - (stan::math::multi_normal_cholesky_log( - y, mu, L))); - EXPECT_FLOAT_EQ( - (stan::math::multi_normal_cholesky_lpdf( - y, mu, L)), - (stan::math::multi_normal_cholesky_log( - y, mu, L))); - EXPECT_FLOAT_EQ( - (stan::math::multi_normal_cholesky_lpdf(y, mu, L)), - (stan::math::multi_normal_cholesky_log(y, mu, L))); -} diff --git a/test/unit/math/prim/prob/multi_normal_log_test.cpp b/test/unit/math/prim/prob/multi_normal_log_test.cpp deleted file mode 100644 index bafd7fed5e9..00000000000 --- a/test/unit/math/prim/prob/multi_normal_log_test.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include -#include - -TEST(ProbMultiNormal, log_matches_lpmf) { - Eigen::Matrix y(3, 1); - y << 2.0, -2.0, 11.0; - Eigen::Matrix mu(3, 1); - mu << 1.0, -1.0, 3.0; - Eigen::Matrix Sigma(3, 3); - Sigma << 9.0, -3.0, 0.0, -3.0, 4.0, 0.0, 0.0, 0.0, 5.0; - EXPECT_FLOAT_EQ((stan::math::multi_normal_lpdf(y, mu, Sigma)), - (stan::math::multi_normal_log(y, mu, Sigma))); - EXPECT_FLOAT_EQ((stan::math::multi_normal_lpdf(y, mu, Sigma)), - (stan::math::multi_normal_log(y, mu, Sigma))); - EXPECT_FLOAT_EQ((stan::math::multi_normal_lpdf(y, mu, Sigma)), - (stan::math::multi_normal_log(y, mu, Sigma))); - EXPECT_FLOAT_EQ( - (stan::math::multi_normal_lpdf(y, mu, Sigma)), - (stan::math::multi_normal_log(y, mu, Sigma))); - EXPECT_FLOAT_EQ( - (stan::math::multi_normal_lpdf(y, mu, Sigma)), - (stan::math::multi_normal_log(y, mu, Sigma))); - EXPECT_FLOAT_EQ( - (stan::math::multi_normal_lpdf(y, mu, Sigma)), - (stan::math::multi_normal_log(y, mu, Sigma))); -} diff --git a/test/unit/math/prim/prob/multi_normal_prec_log_test.cpp b/test/unit/math/prim/prob/multi_normal_prec_log_test.cpp deleted file mode 100644 index 95e7909c27c..00000000000 --- a/test/unit/math/prim/prob/multi_normal_prec_log_test.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include -#include - -TEST(ProbMultiNormalPrec, log_matches_lpmf) { - Eigen::Matrix y(3, 1); - y << 2.0, -2.0, 11.0; - Eigen::Matrix mu(3, 1); - mu << 1.0, -1.0, 3.0; - Eigen::Matrix Sigma(3, 3); - Sigma << 9.0, -3.0, 0.0, -3.0, 4.0, 0.0, 0.0, 0.0, 5.0; - Eigen::Matrix L = Sigma.inverse(); - EXPECT_FLOAT_EQ((stan::math::multi_normal_prec_lpdf(y, mu, L)), - (stan::math::multi_normal_prec_log(y, mu, L))); - EXPECT_FLOAT_EQ((stan::math::multi_normal_prec_lpdf(y, mu, L)), - (stan::math::multi_normal_prec_log(y, mu, L))); - EXPECT_FLOAT_EQ((stan::math::multi_normal_prec_lpdf(y, mu, L)), - (stan::math::multi_normal_prec_log(y, mu, L))); - EXPECT_FLOAT_EQ( - (stan::math::multi_normal_prec_lpdf( - y, mu, L)), - (stan::math::multi_normal_prec_log(y, mu, L))); - EXPECT_FLOAT_EQ( - (stan::math::multi_normal_prec_lpdf( - y, mu, L)), - (stan::math::multi_normal_prec_log( - y, mu, L))); - EXPECT_FLOAT_EQ( - (stan::math::multi_normal_prec_lpdf(y, mu, L)), - (stan::math::multi_normal_prec_log(y, mu, L))); -} diff --git a/test/unit/math/prim/prob/multi_student_t_log_test.cpp b/test/unit/math/prim/prob/multi_student_t_log_test.cpp deleted file mode 100644 index b63f77bc766..00000000000 --- a/test/unit/math/prim/prob/multi_student_t_log_test.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include -#include - -TEST(ProbMultiStudentT, log_matches_lpmf) { - Eigen::Matrix y(3, 1); - y << 2.0, -2.0, 11.0; - Eigen::Matrix mu(3, 1); - mu << 1.0, -1.0, 3.0; - Eigen::Matrix Sigma(3, 3); - Sigma << 9.0, -3.0, 0.0, -3.0, 4.0, 0.0, 0.0, 0.0, 5.0; - double nu = 4.0; - EXPECT_FLOAT_EQ((stan::math::multi_student_t_lpdf(y, nu, mu, Sigma)), - (stan::math::multi_student_t_log(y, nu, mu, Sigma))); - EXPECT_FLOAT_EQ((stan::math::multi_student_t_lpdf(y, nu, mu, Sigma)), - (stan::math::multi_student_t_log(y, nu, mu, Sigma))); - EXPECT_FLOAT_EQ((stan::math::multi_student_t_lpdf(y, nu, mu, Sigma)), - (stan::math::multi_student_t_log(y, nu, mu, Sigma))); - EXPECT_FLOAT_EQ( - (stan::math::multi_student_t_lpdf( - y, nu, mu, Sigma)), - (stan::math::multi_student_t_log( - y, nu, mu, Sigma))); - EXPECT_FLOAT_EQ( - (stan::math::multi_student_t_lpdf( - y, nu, mu, Sigma)), - (stan::math::multi_student_t_log( - y, nu, mu, Sigma))); - EXPECT_FLOAT_EQ( - (stan::math::multi_student_t_lpdf( - y, nu, mu, Sigma)), - (stan::math::multi_student_t_log(y, nu, mu, Sigma))); -} diff --git a/test/unit/math/prim/prob/multinomial_log_test.cpp b/test/unit/math/prim/prob/multinomial_log_test.cpp deleted file mode 100644 index dddfe35e053..00000000000 --- a/test/unit/math/prim/prob/multinomial_log_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include -#include -#include - -TEST(ProbMultinomial, log_matches_lpmf) { - std::vector ns; - ns.push_back(1); - ns.push_back(2); - ns.push_back(3); - Eigen::Matrix theta(3, 1); - theta << 0.2, 0.3, 0.5; - EXPECT_FLOAT_EQ((stan::math::multinomial_lpmf(ns, theta)), - (stan::math::multinomial_log(ns, theta))); - EXPECT_FLOAT_EQ((stan::math::multinomial_lpmf(ns, theta)), - (stan::math::multinomial_log(ns, theta))); - EXPECT_FLOAT_EQ((stan::math::multinomial_lpmf(ns, theta)), - (stan::math::multinomial_log(ns, theta))); - EXPECT_FLOAT_EQ((stan::math::multinomial_lpmf(ns, theta)), - (stan::math::multinomial_log(ns, theta))); - EXPECT_FLOAT_EQ((stan::math::multinomial_lpmf(ns, theta)), - (stan::math::multinomial_log(ns, theta))); - EXPECT_FLOAT_EQ((stan::math::multinomial_lpmf<>(ns, theta)), - (stan::math::multinomial_log<>(ns, theta))); -} diff --git a/test/unit/math/prim/prob/multinomial_logit_log_test.cpp b/test/unit/math/prim/prob/multinomial_logit_log_test.cpp deleted file mode 100644 index 51ff744bee5..00000000000 --- a/test/unit/math/prim/prob/multinomial_logit_log_test.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include -#include - -TEST(ProbMultinomialLogit, log_matches_lpmf) { - using stan::math::multinomial_logit_log; - using stan::math::multinomial_logit_lpmf; - - std::vector ns; - ns.push_back(1); - ns.push_back(2); - ns.push_back(3); - Eigen::Matrix theta(3, 1); - theta << log(0.2), log(0.3), log(0.5); - EXPECT_FLOAT_EQ((multinomial_logit_lpmf(ns, theta)), - (multinomial_logit_log(ns, theta))); - EXPECT_FLOAT_EQ((multinomial_logit_lpmf(ns, theta)), - (multinomial_logit_log(ns, theta))); - EXPECT_FLOAT_EQ((multinomial_logit_lpmf(ns, theta)), - (multinomial_logit_log(ns, theta))); -} diff --git a/test/unit/math/prim/prob/neg_binomial_2_log_log_test.cpp b/test/unit/math/prim/prob/neg_binomial_2_log_log_test.cpp deleted file mode 100644 index c8203097b94..00000000000 --- a/test/unit/math/prim/prob/neg_binomial_2_log_log_test.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include - -TEST(ProbNegBinomial2Log, log_matches_lpmf) { - double y = 0.8; - double eta = 1.1; - double phi = 2.3; - - EXPECT_FLOAT_EQ((stan::math::neg_binomial_2_log_lpmf(y, eta, phi)), - (stan::math::neg_binomial_2_log_log(y, eta, phi))); - EXPECT_FLOAT_EQ((stan::math::neg_binomial_2_log_lpmf(y, eta, phi)), - (stan::math::neg_binomial_2_log_log(y, eta, phi))); - EXPECT_FLOAT_EQ((stan::math::neg_binomial_2_log_lpmf(y, eta, phi)), - (stan::math::neg_binomial_2_log_log(y, eta, phi))); - EXPECT_FLOAT_EQ( - (stan::math::neg_binomial_2_log_lpmf(y, eta, - phi)), - (stan::math::neg_binomial_2_log_log(y, eta, - phi))); - EXPECT_FLOAT_EQ( - (stan::math::neg_binomial_2_log_lpmf( - y, eta, phi)), - (stan::math::neg_binomial_2_log_log(y, eta, - phi))); - EXPECT_FLOAT_EQ((stan::math::neg_binomial_2_log_lpmf( - y, eta, phi)), - (stan::math::neg_binomial_2_log_log( - y, eta, phi))); -} diff --git a/test/unit/math/prim/prob/neg_binomial_log_test.cpp b/test/unit/math/prim/prob/neg_binomial_log_test.cpp deleted file mode 100644 index 5b5ae00c634..00000000000 --- a/test/unit/math/prim/prob/neg_binomial_log_test.cpp +++ /dev/null @@ -1,37 +0,0 @@ -#include -#include - -TEST(ProbNegBinomial, log_matches_lpmf) { - int y = 3; - double alpha = 1.1; - double beta = 2.3; - - long double alpha2 = 1e11; - long double beta2 = 1e10; - - EXPECT_FLOAT_EQ(stan::math::neg_binomial_lpmf(0, 1e11, 1e10), - -alpha2 * std::log1p(1.0 / beta2)); - EXPECT_FLOAT_EQ(stan::math::neg_binomial_lpmf(1, 1e11, 1e10), - std::log(alpha2 - 1.0) - alpha2 * std::log1p(1.0 / beta2) - - std::log1p(beta2)); - EXPECT_FLOAT_EQ((stan::math::neg_binomial_lpmf(13, 1e11, 1e10)), - -2.6185576442208003); - - EXPECT_FLOAT_EQ((stan::math::neg_binomial_lpmf(y, alpha, beta)), - (stan::math::neg_binomial_log(y, alpha, beta))); - EXPECT_FLOAT_EQ((stan::math::neg_binomial_lpmf(y, alpha, beta)), - (stan::math::neg_binomial_log(y, alpha, beta))); - EXPECT_FLOAT_EQ((stan::math::neg_binomial_lpmf(y, alpha, beta)), - (stan::math::neg_binomial_log(y, alpha, beta))); - EXPECT_FLOAT_EQ((stan::math::neg_binomial_lpmf( - y, alpha, beta)), - (stan::math::neg_binomial_log( - y, alpha, beta))); - EXPECT_FLOAT_EQ((stan::math::neg_binomial_lpmf( - y, alpha, beta)), - (stan::math::neg_binomial_log( - y, alpha, beta))); - EXPECT_FLOAT_EQ( - (stan::math::neg_binomial_lpmf(y, alpha, beta)), - (stan::math::neg_binomial_log(y, alpha, beta))); -} diff --git a/test/unit/math/prim/prob/normal_log_test.cpp b/test/unit/math/prim/prob/normal_log_test.cpp deleted file mode 100644 index fc4906fdc7b..00000000000 --- a/test/unit/math/prim/prob/normal_log_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include -#include - -TEST(ProbNormal, log_matches_lpdf) { - double y = 0.8; - double mu = 1.1; - double sigma = 2.3; - - EXPECT_FLOAT_EQ((stan::math::normal_lpdf(y, mu, sigma)), - (stan::math::normal_log(y, mu, sigma))); - EXPECT_FLOAT_EQ((stan::math::normal_lpdf(y, mu, sigma)), - (stan::math::normal_log(y, mu, sigma))); - EXPECT_FLOAT_EQ((stan::math::normal_lpdf(y, mu, sigma)), - (stan::math::normal_log(y, mu, sigma))); - EXPECT_FLOAT_EQ( - (stan::math::normal_lpdf(y, mu, sigma)), - (stan::math::normal_log(y, mu, sigma))); - EXPECT_FLOAT_EQ( - (stan::math::normal_lpdf(y, mu, sigma)), - (stan::math::normal_log(y, mu, sigma))); - EXPECT_FLOAT_EQ( - (stan::math::normal_lpdf(y, mu, sigma)), - (stan::math::normal_log(y, mu, sigma))); -} diff --git a/test/unit/math/prim/prob/ordered_logistic_log_test.cpp b/test/unit/math/prim/prob/ordered_logistic_log_test.cpp deleted file mode 100644 index 3edc167fe71..00000000000 --- a/test/unit/math/prim/prob/ordered_logistic_log_test.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#include -#include -#include - -TEST(ProbOrderedLogistic, log_matches_lpmf) { - /** - * Variables for int ~ ordered_logistic(double, vector) - */ - int K = 5; - Eigen::Matrix c(K - 1); - c << -1.7, -0.3, 1.2, 2.6; - double lambda = 1.1; - - /** - * Variables for int[] ~ ordered_logistic(vector, vector) - */ - Eigen::Matrix lamvec(K); - lamvec << 1.1, 1.3, 2.2, 3.1, 2.1; - - std::vector kvec{1, 2, 3, 1, 3}; - - /** - * Variables for int[] ~ ordered_logistic(vector, vector[]) - */ - - Eigen::Matrix c_1(K - 1); - c_1 << -2.3, -0.3, 1.5, 2.6; - - Eigen::Matrix c_2(K - 1); - c_2 << -1.7, -0.3, 1.2, 2.6; - - Eigen::Matrix c_3(K - 1); - c_3 << -1.7, 0.2, 1.4, 2.6; - - Eigen::Matrix c_4(K - 1); - c_4 << -1.5, -0.3, 0.2, 2.6; - - Eigen::Matrix c_5(K - 1); - c_5 << -1.7, -0.3, 1.7, 2.3; - - std::vector> cutvec{c_1, c_2, c_3, - c_4, c_5}; - - EXPECT_FLOAT_EQ((stan::math::ordered_logistic_lpmf(3, lambda, c)), - (stan::math::ordered_logistic_log(3, lambda, c))); - - EXPECT_FLOAT_EQ((stan::math::ordered_logistic_lpmf(kvec, lamvec, c)), - (stan::math::ordered_logistic_log(kvec, lamvec, c))); - - EXPECT_FLOAT_EQ((stan::math::ordered_logistic_lpmf(kvec, lamvec, cutvec)), - (stan::math::ordered_logistic_log(kvec, lamvec, cutvec))); - - EXPECT_FLOAT_EQ((stan::math::ordered_logistic_lpmf(3, lambda, c)), - (stan::math::ordered_logistic_log(3, lambda, c))); - EXPECT_FLOAT_EQ( - (stan::math::ordered_logistic_lpmf(3, lambda, c)), - (stan::math::ordered_logistic_log(3, lambda, c))); -} diff --git a/test/unit/math/prim/prob/ordered_probit_log_test.cpp b/test/unit/math/prim/prob/ordered_probit_log_test.cpp deleted file mode 100644 index 6c36ec4440a..00000000000 --- a/test/unit/math/prim/prob/ordered_probit_log_test.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include -#include - -TEST(ProbOrderedProbit, log_matches_lpmf) { - int K = 5; - Eigen::Matrix c(K - 1); - c << -1.7, -0.3, 1.2, 2.6; - double lambda = 1.1; - - EXPECT_FLOAT_EQ((stan::math::ordered_probit_lpmf(3, lambda, c)), - (stan::math::ordered_probit_log(3, lambda, c))); - EXPECT_FLOAT_EQ((stan::math::ordered_probit_lpmf(3, lambda, c)), - (stan::math::ordered_probit_log(3, lambda, c))); - EXPECT_FLOAT_EQ((stan::math::ordered_probit_lpmf(3, lambda, c)), - (stan::math::ordered_probit_log(3, lambda, c))); - EXPECT_FLOAT_EQ( - (stan::math::ordered_probit_lpmf(3, lambda, c)), - (stan::math::ordered_probit_log(3, lambda, c))); - EXPECT_FLOAT_EQ( - (stan::math::ordered_probit_lpmf(3, lambda, c)), - (stan::math::ordered_probit_log(3, lambda, c))); - EXPECT_FLOAT_EQ( - (stan::math::ordered_probit_lpmf(3, lambda, c)), - (stan::math::ordered_probit_log(3, lambda, c))); -} diff --git a/test/unit/math/prim/prob/pareto_log_test.cpp b/test/unit/math/prim/prob/pareto_log_test.cpp deleted file mode 100644 index bd63874cf5b..00000000000 --- a/test/unit/math/prim/prob/pareto_log_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include -#include - -TEST(ProbPareto, log_matches_lpdf) { - double y = 2.0; - double y_min = 1.1; - double alpha = 2.3; - - EXPECT_FLOAT_EQ((stan::math::pareto_lpdf(y, y_min, alpha)), - (stan::math::pareto_log(y, y_min, alpha))); - EXPECT_FLOAT_EQ((stan::math::pareto_lpdf(y, y_min, alpha)), - (stan::math::pareto_log(y, y_min, alpha))); - EXPECT_FLOAT_EQ((stan::math::pareto_lpdf(y, y_min, alpha)), - (stan::math::pareto_log(y, y_min, alpha))); - EXPECT_FLOAT_EQ( - (stan::math::pareto_lpdf(y, y_min, alpha)), - (stan::math::pareto_log(y, y_min, alpha))); - EXPECT_FLOAT_EQ( - (stan::math::pareto_lpdf(y, y_min, alpha)), - (stan::math::pareto_log(y, y_min, alpha))); - EXPECT_FLOAT_EQ( - (stan::math::pareto_lpdf(y, y_min, alpha)), - (stan::math::pareto_log(y, y_min, alpha))); -} diff --git a/test/unit/math/prim/prob/pareto_type_2_log_test.cpp b/test/unit/math/prim/prob/pareto_type_2_log_test.cpp deleted file mode 100644 index 8a245696310..00000000000 --- a/test/unit/math/prim/prob/pareto_type_2_log_test.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include -#include - -TEST(ProbParetoType2, log_matches_lpdf) { - double y = 0.8; - double mu = -2; - double lambda = 2; - double alpha = 2.3; - - EXPECT_FLOAT_EQ((stan::math::pareto_type_2_lpdf(y, mu, lambda, alpha)), - (stan::math::pareto_type_2_log(y, mu, lambda, alpha))); - EXPECT_FLOAT_EQ((stan::math::pareto_type_2_lpdf(y, mu, lambda, alpha)), - (stan::math::pareto_type_2_log(y, mu, lambda, alpha))); - EXPECT_FLOAT_EQ((stan::math::pareto_type_2_lpdf(y, mu, lambda, alpha)), - (stan::math::pareto_type_2_log(y, mu, lambda, alpha))); - EXPECT_FLOAT_EQ( - (stan::math::pareto_type_2_lpdf( - y, mu, lambda, alpha)), - (stan::math::pareto_type_2_log( - y, mu, lambda, alpha))); - EXPECT_FLOAT_EQ( - (stan::math::pareto_type_2_lpdf( - y, mu, lambda, alpha)), - (stan::math::pareto_type_2_log( - y, mu, lambda, alpha))); - EXPECT_FLOAT_EQ( - (stan::math::pareto_type_2_lpdf( - y, mu, lambda, alpha)), - (stan::math::pareto_type_2_log( - y, mu, lambda, alpha))); -} diff --git a/test/unit/math/prim/prob/poisson_binomial_log_test.cpp b/test/unit/math/prim/prob/poisson_binomial_log_test.cpp deleted file mode 100644 index 4f3e11b2de3..00000000000 --- a/test/unit/math/prim/prob/poisson_binomial_log_test.cpp +++ /dev/null @@ -1,37 +0,0 @@ -#include -#include - -TEST(ProbDistributionsPoissonBinomial, log_matches_lpmf) { - using vec = Eigen::Matrix; - - int y = 2; - vec theta(3, 1); - theta << 0.5, 0.2, 0.7; - - EXPECT_FLOAT_EQ((stan::math::poisson_binomial_lpmf(y, theta)), - (stan::math::poisson_binomial_log(y, theta))); - - EXPECT_FLOAT_EQ((stan::math::poisson_binomial_lpmf(y, theta)), - (stan::math::poisson_binomial_log(y, theta))); - - EXPECT_FLOAT_EQ((stan::math::poisson_binomial_lpmf(y, theta)), - (stan::math::poisson_binomial_log(y, theta))); -} - -TEST(ProbDistributionsPoissonBinomial, log_matches_lpmf_vectorial) { - using vec = Eigen::Matrix; - - int y = 2; - vec theta(3, 1); - theta << 0.5, 0.2, 0.7; - std::vector thetas{theta, theta}; - - EXPECT_FLOAT_EQ((stan::math::poisson_binomial_lpmf(y, thetas)), - (stan::math::poisson_binomial_log(y, thetas))); - - EXPECT_FLOAT_EQ((stan::math::poisson_binomial_lpmf(y, thetas)), - (stan::math::poisson_binomial_log(y, thetas))); - - EXPECT_FLOAT_EQ((stan::math::poisson_binomial_lpmf(y, thetas)), - (stan::math::poisson_binomial_log(y, thetas))); -} diff --git a/test/unit/math/prim/prob/poisson_log_log_test.cpp b/test/unit/math/prim/prob/poisson_log_log_test.cpp deleted file mode 100644 index fc100d5a7b5..00000000000 --- a/test/unit/math/prim/prob/poisson_log_log_test.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include -#include - -TEST(ProbPoissonLog, log_matches_lpmf) { - int y = 3; - double alpha = -0.3; - - EXPECT_FLOAT_EQ((stan::math::poisson_log_lpmf(y, alpha)), - (stan::math::poisson_log_log(y, alpha))); - EXPECT_FLOAT_EQ((stan::math::poisson_log_lpmf(y, alpha)), - (stan::math::poisson_log_log(y, alpha))); - EXPECT_FLOAT_EQ((stan::math::poisson_log_lpmf(y, alpha)), - (stan::math::poisson_log_log(y, alpha))); - EXPECT_FLOAT_EQ((stan::math::poisson_log_lpmf(y, alpha)), - (stan::math::poisson_log_log(y, alpha))); - EXPECT_FLOAT_EQ((stan::math::poisson_log_lpmf(y, alpha)), - (stan::math::poisson_log_log(y, alpha))); - EXPECT_FLOAT_EQ((stan::math::poisson_log_lpmf(y, alpha)), - (stan::math::poisson_log_log(y, alpha))); -} diff --git a/test/unit/math/prim/prob/rayleigh_log_test.cpp b/test/unit/math/prim/prob/rayleigh_log_test.cpp deleted file mode 100644 index d406cd734b4..00000000000 --- a/test/unit/math/prim/prob/rayleigh_log_test.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include -#include - -TEST(ProbRayleigh, log_matches_lpdf) { - double y = 0.8; - double sigma = 2.3; - - EXPECT_FLOAT_EQ((stan::math::rayleigh_lpdf(y, sigma)), - (stan::math::rayleigh_log(y, sigma))); - EXPECT_FLOAT_EQ((stan::math::rayleigh_lpdf(y, sigma)), - (stan::math::rayleigh_log(y, sigma))); - EXPECT_FLOAT_EQ((stan::math::rayleigh_lpdf(y, sigma)), - (stan::math::rayleigh_log(y, sigma))); - EXPECT_FLOAT_EQ((stan::math::rayleigh_lpdf(y, sigma)), - (stan::math::rayleigh_log(y, sigma))); - EXPECT_FLOAT_EQ((stan::math::rayleigh_lpdf(y, sigma)), - (stan::math::rayleigh_log(y, sigma))); - EXPECT_FLOAT_EQ((stan::math::rayleigh_lpdf(y, sigma)), - (stan::math::rayleigh_log(y, sigma))); -} diff --git a/test/unit/math/prim/prob/scaled_inv_chi_square_log_test.cpp b/test/unit/math/prim/prob/scaled_inv_chi_square_log_test.cpp deleted file mode 100644 index 6e8fc0c668e..00000000000 --- a/test/unit/math/prim/prob/scaled_inv_chi_square_log_test.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include - -TEST(ProbScaledInvChiSquare, log_matches_lpdf) { - double y = 0.8; - double nu = 1.1; - double sigma = 2.3; - - EXPECT_FLOAT_EQ((stan::math::scaled_inv_chi_square_lpdf(y, nu, sigma)), - (stan::math::scaled_inv_chi_square_log(y, nu, sigma))); - EXPECT_FLOAT_EQ((stan::math::scaled_inv_chi_square_lpdf(y, nu, sigma)), - (stan::math::scaled_inv_chi_square_log(y, nu, sigma))); - EXPECT_FLOAT_EQ((stan::math::scaled_inv_chi_square_lpdf(y, nu, sigma)), - (stan::math::scaled_inv_chi_square_log(y, nu, sigma))); - EXPECT_FLOAT_EQ( - (stan::math::scaled_inv_chi_square_lpdf( - y, nu, sigma)), - (stan::math::scaled_inv_chi_square_log( - y, nu, sigma))); - EXPECT_FLOAT_EQ( - (stan::math::scaled_inv_chi_square_lpdf( - y, nu, sigma)), - (stan::math::scaled_inv_chi_square_log( - y, nu, sigma))); - EXPECT_FLOAT_EQ( - (stan::math::scaled_inv_chi_square_lpdf(y, nu, - sigma)), - (stan::math::scaled_inv_chi_square_log(y, nu, - sigma))); -} diff --git a/test/unit/math/prim/prob/skew_double_exponential_log_test.cpp b/test/unit/math/prim/prob/skew_double_exponential_log_test.cpp deleted file mode 100644 index af2e51a962b..00000000000 --- a/test/unit/math/prim/prob/skew_double_exponential_log_test.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include -#include - -TEST(ProbDistributionsSkewedDoubleExponential, log_matches_lpdf) { - double y = 0.8; - double mu = 2; - double sigma = 2.3; - double tau = .25; - - EXPECT_FLOAT_EQ((stan::math::skew_double_exponential_lpdf(y, mu, sigma, tau)), - (stan::math::skew_double_exponential_log(y, mu, sigma, tau))); - EXPECT_FLOAT_EQ( - (stan::math::skew_double_exponential_lpdf(y, mu, sigma, tau)), - (stan::math::skew_double_exponential_log(y, mu, sigma, tau))); - EXPECT_FLOAT_EQ( - (stan::math::skew_double_exponential_lpdf(y, mu, sigma, tau)), - (stan::math::skew_double_exponential_log(y, mu, sigma, tau))); - EXPECT_FLOAT_EQ( - (stan::math::skew_double_exponential_lpdf(y, mu, sigma, tau)), - (stan::math::skew_double_exponential_log(y, mu, sigma, tau))); - EXPECT_FLOAT_EQ( - (stan::math::skew_double_exponential_lpdf(y, mu, sigma, tau)), - (stan::math::skew_double_exponential_log(y, mu, sigma, tau))); - EXPECT_FLOAT_EQ( - (stan::math::skew_double_exponential_lpdf( - y, mu, sigma, tau)), - (stan::math::skew_double_exponential_log( - y, mu, sigma, tau))); -} diff --git a/test/unit/math/prim/prob/skew_normal_log_test.cpp b/test/unit/math/prim/prob/skew_normal_log_test.cpp deleted file mode 100644 index 40407018dfd..00000000000 --- a/test/unit/math/prim/prob/skew_normal_log_test.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include - -TEST(ProbSkewNormal, log_matches_lpdf) { - double y = 0.8; - double mu = 2; - double sigma = 2.3; - double alpha = -3; - - EXPECT_FLOAT_EQ((stan::math::skew_normal_lpdf(y, mu, sigma, alpha)), - (stan::math::skew_normal_log(y, mu, sigma, alpha))); - EXPECT_FLOAT_EQ((stan::math::skew_normal_lpdf(y, mu, sigma, alpha)), - (stan::math::skew_normal_log(y, mu, sigma, alpha))); - EXPECT_FLOAT_EQ((stan::math::skew_normal_lpdf(y, mu, sigma, alpha)), - (stan::math::skew_normal_log(y, mu, sigma, alpha))); - EXPECT_FLOAT_EQ( - (stan::math::skew_normal_lpdf( - y, mu, sigma, alpha)), - (stan::math::skew_normal_log( - y, mu, sigma, alpha))); - EXPECT_FLOAT_EQ( - (stan::math::skew_normal_lpdf( - y, mu, sigma, alpha)), - (stan::math::skew_normal_log( - y, mu, sigma, alpha))); - EXPECT_FLOAT_EQ((stan::math::skew_normal_lpdf( - y, mu, sigma, alpha)), - (stan::math::skew_normal_log( - y, mu, sigma, alpha))); -} diff --git a/test/unit/math/prim/prob/std_normal_log_test.cpp b/test/unit/math/prim/prob/std_normal_log_test.cpp deleted file mode 100644 index 7d010946b9c..00000000000 --- a/test/unit/math/prim/prob/std_normal_log_test.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include -#include - -TEST(ProbStdNormal, log_matches_lpdf) { - double y = 0.8; - - EXPECT_FLOAT_EQ((stan::math::std_normal_lpdf(y)), - (stan::math::std_normal_log(y))); - EXPECT_FLOAT_EQ((stan::math::std_normal_lpdf(y)), - (stan::math::std_normal_log(y))); - EXPECT_FLOAT_EQ((stan::math::std_normal_lpdf(y)), - (stan::math::std_normal_log(y))); - EXPECT_FLOAT_EQ((stan::math::std_normal_lpdf(y)), - (stan::math::std_normal_log(y))); - EXPECT_FLOAT_EQ((stan::math::std_normal_lpdf(y)), - (stan::math::std_normal_log(y))); - EXPECT_FLOAT_EQ((stan::math::std_normal_lpdf(y)), - (stan::math::std_normal_log(y))); -} diff --git a/test/unit/math/prim/prob/student_t_log_test.cpp b/test/unit/math/prim/prob/student_t_log_test.cpp deleted file mode 100644 index 566b99485ae..00000000000 --- a/test/unit/math/prim/prob/student_t_log_test.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include - -TEST(ProbStudentT, log_matches_lpdf) { - double y = 0.8; - double nu = 4.8; - double mu = 2; - double sigma = 2.3; - - EXPECT_FLOAT_EQ((stan::math::student_t_lpdf(y, nu, mu, sigma)), - (stan::math::student_t_log(y, nu, mu, sigma))); - EXPECT_FLOAT_EQ((stan::math::student_t_lpdf(y, nu, mu, sigma)), - (stan::math::student_t_log(y, nu, mu, sigma))); - EXPECT_FLOAT_EQ((stan::math::student_t_lpdf(y, nu, mu, sigma)), - (stan::math::student_t_log(y, nu, mu, sigma))); - EXPECT_FLOAT_EQ( - (stan::math::student_t_lpdf( - y, nu, mu, sigma)), - (stan::math::student_t_log( - y, nu, mu, sigma))); - EXPECT_FLOAT_EQ( - (stan::math::student_t_lpdf( - y, nu, mu, sigma)), - (stan::math::student_t_log( - y, nu, mu, sigma))); - EXPECT_FLOAT_EQ((stan::math::student_t_lpdf( - y, nu, mu, sigma)), - (stan::math::student_t_log( - y, nu, mu, sigma))); -} diff --git a/test/unit/math/prim/prob/uniform_log_test.cpp b/test/unit/math/prim/prob/uniform_log_test.cpp deleted file mode 100644 index a607bc724f9..00000000000 --- a/test/unit/math/prim/prob/uniform_log_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include -#include - -TEST(ProbUniform, log_matches_lpdf) { - double y = 0.8; - double alpha = 0.4; - double beta = 2.3; - - EXPECT_FLOAT_EQ((stan::math::uniform_lpdf(y, alpha, beta)), - (stan::math::uniform_log(y, alpha, beta))); - EXPECT_FLOAT_EQ((stan::math::uniform_lpdf(y, alpha, beta)), - (stan::math::uniform_log(y, alpha, beta))); - EXPECT_FLOAT_EQ((stan::math::uniform_lpdf(y, alpha, beta)), - (stan::math::uniform_log(y, alpha, beta))); - EXPECT_FLOAT_EQ( - (stan::math::uniform_lpdf(y, alpha, beta)), - (stan::math::uniform_log(y, alpha, beta))); - EXPECT_FLOAT_EQ( - (stan::math::uniform_lpdf(y, alpha, beta)), - (stan::math::uniform_log(y, alpha, beta))); - EXPECT_FLOAT_EQ( - (stan::math::uniform_lpdf(y, alpha, beta)), - (stan::math::uniform_log(y, alpha, beta))); -} diff --git a/test/unit/math/prim/prob/von_mises_log_test.cpp b/test/unit/math/prim/prob/von_mises_log_test.cpp deleted file mode 100644 index 912b0067d1a..00000000000 --- a/test/unit/math/prim/prob/von_mises_log_test.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include -#include - -TEST(ProbVonMises, log_matches_lpdf) { - double y = -0.8; - double mu = 0.4; - double kappa = 2.3; - - EXPECT_FLOAT_EQ((stan::math::von_mises_lpdf(y, mu, kappa)), - (stan::math::von_mises_log(y, mu, kappa))); - EXPECT_FLOAT_EQ((stan::math::von_mises_lpdf(y, mu, kappa)), - (stan::math::von_mises_log(y, mu, kappa))); - EXPECT_FLOAT_EQ((stan::math::von_mises_lpdf(y, mu, kappa)), - (stan::math::von_mises_log(y, mu, kappa))); - EXPECT_FLOAT_EQ( - (stan::math::von_mises_lpdf(y, mu, kappa)), - (stan::math::von_mises_log(y, mu, kappa))); - EXPECT_FLOAT_EQ( - (stan::math::von_mises_lpdf(y, mu, kappa)), - (stan::math::von_mises_log(y, mu, kappa))); - EXPECT_FLOAT_EQ( - (stan::math::von_mises_lpdf(y, mu, kappa)), - (stan::math::von_mises_log(y, mu, kappa))); -} - -TEST(ProbVonMises, kappa_zero) { - double y = -0.8; - double mu = 0.4; - double kappa = 0; - - EXPECT_FLOAT_EQ(-1.8378770664093453390819, - stan::math::von_mises_lpdf(y, mu, kappa)); -} diff --git a/test/unit/math/prim/prob/weibull_log_test.cpp b/test/unit/math/prim/prob/weibull_log_test.cpp deleted file mode 100644 index ba2d9275574..00000000000 --- a/test/unit/math/prim/prob/weibull_log_test.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include -#include - -TEST(ProbWeibull, log_matches_lpdf) { - double y = 0.8; - double alpha = 1.1; - double sigma = 2.3; - - EXPECT_FLOAT_EQ((stan::math::weibull_lpdf(y, alpha, sigma)), - (stan::math::weibull_log(y, alpha, sigma))); - EXPECT_FLOAT_EQ((stan::math::weibull_lpdf(y, alpha, sigma)), - (stan::math::weibull_log(y, alpha, sigma))); - EXPECT_FLOAT_EQ((stan::math::weibull_lpdf(y, alpha, sigma)), - (stan::math::weibull_log(y, alpha, sigma))); - EXPECT_FLOAT_EQ( - (stan::math::weibull_lpdf(y, alpha, sigma)), - (stan::math::weibull_log(y, alpha, sigma))); - EXPECT_FLOAT_EQ((stan::math::weibull_lpdf( - y, alpha, sigma)), - (stan::math::weibull_log( - y, alpha, sigma))); - EXPECT_FLOAT_EQ( - (stan::math::weibull_lpdf(y, alpha, sigma)), - (stan::math::weibull_log(y, alpha, sigma))); -} diff --git a/test/unit/math/prim/prob/wiener_log_test.cpp b/test/unit/math/prim/prob/wiener_log_test.cpp deleted file mode 100644 index 0d04869ef3a..00000000000 --- a/test/unit/math/prim/prob/wiener_log_test.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include -#include - -TEST(ProbWiener, log_matches_lpdf) { - double y = 2.4; - double alpha = 2; - double tau = 1.2; - double beta = 0.3; - double delta = -5; - - EXPECT_FLOAT_EQ((stan::math::wiener_lpdf(y, alpha, tau, beta, delta)), - (stan::math::wiener_log(y, alpha, tau, beta, delta))); - EXPECT_FLOAT_EQ((stan::math::wiener_lpdf(y, alpha, tau, beta, delta)), - (stan::math::wiener_log(y, alpha, tau, beta, delta))); - EXPECT_FLOAT_EQ((stan::math::wiener_lpdf(y, alpha, tau, beta, delta)), - (stan::math::wiener_log(y, alpha, tau, beta, delta))); - EXPECT_FLOAT_EQ( - (stan::math::wiener_lpdf( - y, alpha, tau, beta, delta)), - (stan::math::wiener_log( - y, alpha, tau, beta, delta))); - EXPECT_FLOAT_EQ( - (stan::math::wiener_lpdf( - y, alpha, tau, beta, delta)), - (stan::math::wiener_log( - y, alpha, tau, beta, delta))); - EXPECT_FLOAT_EQ( - (stan::math::wiener_lpdf( - y, alpha, tau, beta, delta)), - (stan::math::wiener_log( - y, alpha, tau, beta, delta))); -} diff --git a/test/unit/math/prim/prob/wishart_log_test.cpp b/test/unit/math/prim/prob/wishart_log_test.cpp deleted file mode 100644 index 25638f16602..00000000000 --- a/test/unit/math/prim/prob/wishart_log_test.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include -#include - -TEST(ProbWishart, log_matches_lpmf) { - Eigen::Matrix Sigma(2, 2); - Sigma << 1.848220, 1.899623, 1.899623, 12.751941; - - Eigen::Matrix Y(2, 2); - Y << 2.011108, -11.206611, -11.206611, 112.94139; - - unsigned int dof = 3; - - EXPECT_FLOAT_EQ((stan::math::wishart_lpdf(Y, dof, Sigma)), - (stan::math::wishart_log(Y, dof, Sigma))); - EXPECT_FLOAT_EQ((stan::math::wishart_lpdf(Y, dof, Sigma)), - (stan::math::wishart_log(Y, dof, Sigma))); - EXPECT_FLOAT_EQ((stan::math::wishart_lpdf(Y, dof, Sigma)), - (stan::math::wishart_log(Y, dof, Sigma))); -} From c3bd077447fa0749f1c67d8e4bdfcf606f26756e Mon Sep 17 00:00:00 2001 From: Daniel Lee Date: Thu, 4 Jan 2024 19:40:20 -0500 Subject: [PATCH 25/52] updating doc --- doxygen/contributor_help_pages/distribution_tests.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doxygen/contributor_help_pages/distribution_tests.md b/doxygen/contributor_help_pages/distribution_tests.md index 2df00dc1b17..61a9134dcae 100644 --- a/doxygen/contributor_help_pages/distribution_tests.md +++ b/doxygen/contributor_help_pages/distribution_tests.md @@ -28,7 +28,7 @@ Here, I'm just going to describe the steps that are taken to run the tests. Deta 1. `make generate-tests` is called. 1. This first builds the `test/prob/generate_tests` executable from `test/prob/generate_tests.cpp`. - 2. For each test file inside `test/prob/*/*`, it will call the executable with the test file as the first argument and the number of template instantiations per file within the second argument. For example, for testing the `bernoulli_log()` function, make will call: `test/prob/generate_tests test/prob/bernoulli/bernoulli_test.hpp 100` + 2. For each test file inside `test/prob/*/*`, it will call the executable with the test file as the first argument and the number of template instantiations per file within the second argument. For example, for testing the `bernoulli_lpmf()` function, make will call: `test/prob/generate_tests test/prob/bernoulli/bernoulli_test.hpp 100` The call to the executable will generate 5 different test files, all within the `test/prob/bernoulli/` folder: - bernoulli\_00000\_generated\_fd\_test.cpp - bernoulli\_00000\_generated\_ffd\_test.cpp From 421fb4a3e163b6fd896eef9384c9d43ce0f121a5 Mon Sep 17 00:00:00 2001 From: Daniel Lee Date: Fri, 5 Jan 2024 21:35:17 -0500 Subject: [PATCH 26/52] updating include --- stan/math/prim/prob/lkj_corr_cholesky_lpdf.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/stan/math/prim/prob/lkj_corr_cholesky_lpdf.hpp b/stan/math/prim/prob/lkj_corr_cholesky_lpdf.hpp index 97233e2c6ee..161768ba75e 100644 --- a/stan/math/prim/prob/lkj_corr_cholesky_lpdf.hpp +++ b/stan/math/prim/prob/lkj_corr_cholesky_lpdf.hpp @@ -7,6 +7,7 @@ #include #include #include +#include namespace stan { namespace math { From b37d163394186ac18e342467b7bd6823f0601b83 Mon Sep 17 00:00:00 2001 From: Steve Bronder Date: Thu, 29 Feb 2024 13:23:42 -0500 Subject: [PATCH 27/52] remove double include for hypergeo2f1 --- stan/math/prim/fun/hypergeometric_2F1.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/stan/math/prim/fun/hypergeometric_2F1.hpp b/stan/math/prim/fun/hypergeometric_2F1.hpp index 15329ccd884..2dbae6bc418 100644 --- a/stan/math/prim/fun/hypergeometric_2F1.hpp +++ b/stan/math/prim/fun/hypergeometric_2F1.hpp @@ -16,7 +16,6 @@ #include #include #include -#include #include #include From eb6276cad07ac6dc455590d3275d656bd6649121 Mon Sep 17 00:00:00 2001 From: Steve Bronder Date: Fri, 22 Mar 2024 15:03:00 -0400 Subject: [PATCH 28/52] update constructors and assignment operators for arena_matrix --- .../contributor_help_pages/common_pitfalls.md | 2 +- stan/math/rev/core/arena_matrix.hpp | 136 +++++++++--------- 2 files changed, 65 insertions(+), 73 deletions(-) diff --git a/doxygen/contributor_help_pages/common_pitfalls.md b/doxygen/contributor_help_pages/common_pitfalls.md index fd01bf9e42e..1d199b054db 100644 --- a/doxygen/contributor_help_pages/common_pitfalls.md +++ b/doxygen/contributor_help_pages/common_pitfalls.md @@ -207,7 +207,7 @@ Eigen::Matrix mu_good = multiply(X, y); mu_good(4) = 1.0; ``` -The reason we do this is for cases where functions returns are passe to other functions. An `arena_matrix` will always make a shallow copy when being constructed from another `arena_matrix`, which let's the functions avoid unnecessary copies. +The reason we do this is for cases where function returns are passed to other functions. An `arena_matrix` will always make a shallow copy when being constructed from another `arena_matrix`, which lets the functions avoid unnecessary copies. ```c++ Eigen::Matrix y1; diff --git a/stan/math/rev/core/arena_matrix.hpp b/stan/math/rev/core/arena_matrix.hpp index 5385bd3041f..d1a13fefa0a 100644 --- a/stan/math/rev/core/arena_matrix.hpp +++ b/stan/math/rev/core/arena_matrix.hpp @@ -53,6 +53,23 @@ class arena_matrix : public Eigen::Map { ChainableStack::instance_->memalloc_.alloc_array(size), size) {} + private: + template + constexpr auto get_rows(T&& x) { + return (RowsAtCompileTime == 1 && T::ColsAtCompileTime == 1) + || (ColsAtCompileTime == 1 && T::RowsAtCompileTime == 1) + ? other.cols() + : other.rows(); + } + template + constexpr auto get_cols(T&& x) { + return (RowsAtCompileTime == 1 && T::ColsAtCompileTime == 1) + || (ColsAtCompileTime == 1 && T::RowsAtCompileTime == 1) + ? other.rows() + : other.cols() + } + public: + /** * Constructs `arena_matrix` from an expression * @param other expression @@ -62,60 +79,67 @@ class arena_matrix : public Eigen::Map { : Base::Map( ChainableStack::instance_->memalloc_.alloc_array( other.size()), - (RowsAtCompileTime == 1 && T::ColsAtCompileTime == 1) - || (ColsAtCompileTime == 1 && T::RowsAtCompileTime == 1) - ? other.cols() - : other.rows(), - (RowsAtCompileTime == 1 && T::ColsAtCompileTime == 1) - || (ColsAtCompileTime == 1 && T::RowsAtCompileTime == 1) - ? other.rows() - : other.cols()) { + get_rows(other), + get_cols(other)) { *this = other; } + /** + * Overwrite the current arena_matrix with new memory and assign a matrix to it + * @tparam T An eigen type inheriting from `Eigen::EigenBase` + * @param other A matrix that will be copied over to the arena allocator + */ + template * = nullptr> + arena_matrix& operator=(const T& other) { + new (this) Base( + ChainableStack::instance_->memalloc_.alloc_array( + other.size()), + get_rows(other), + get_cols(other)); + Base::operator=(other); + return *this; + } + /** - * Constructs `arena_matrix` from an expression, then send it to either the - * object stack or memory arena. + * Constructs `arena_matrix` from an rvalue expression that is a `plain_type`, + * then movies it to the object stack. * @tparam T A type that inherits from Eigen::DenseBase that is not an * `arena_matrix`. * @param other expression * @note When T is both an rvalue and a plain type, the expression is moved to - * the object stack. However when T is an lvalue, or an rvalue that is not a - * plain type, the expression is copied to the memory arena. + * the object stack. */ template * = nullptr, - require_not_arena_matrix_t* = nullptr> + require_not_arena_matrix_t* = nullptr, + require_t>* = nullptr, + require_plain_type_t* = nullptr> arena_matrix(T&& other) // NOLINT : Base::Map([](auto&& x) { using base_map_t = typename stan::math::arena_matrix::Base; - using T_t = std::decay_t; - if (std::is_rvalue_reference::value - && is_plain_type::value) { - // Note: plain_type_t here does nothing since T_t is plain type - auto other - = make_chainable_ptr(plain_type_t(std::move(x))); - // other has it's rows and cols swapped already if it needed that - return base_map_t(&(other->coeffRef(0)), other->rows(), - other->cols()); - } else { - base_map_t map( - ChainableStack::instance_->memalloc_.alloc_array( - x.size()), - (RowsAtCompileTime == 1 && T_t::ColsAtCompileTime == 1) - || (ColsAtCompileTime == 1 - && T_t::RowsAtCompileTime == 1) - ? x.cols() - : x.rows(), - (RowsAtCompileTime == 1 && T_t::ColsAtCompileTime == 1) - || (ColsAtCompileTime == 1 - && T_t::RowsAtCompileTime == 1) - ? x.rows() - : x.cols()); - map = x; - return map; - } - }(std::forward(other))) {} + auto other_ptr = make_chainable_ptr(std::move(x)); + // other has it's rows and cols swapped already if it needed that + return base_map_t(&(other_ptr->coeffRef(0)), other_ptr->rows(), + other_ptr->cols()); + }(std::move(other))) {} + + /** + * Assignment operator for assigning an expression. + * This is for rvalue plain type objects that can be moved over to the object + * stack instead of allocating new memory. + * @param other expression to evaluate into this + * @return `*this` + */ + template * = nullptr, + require_not_arena_matrix_t* = nullptr, + require_t>* = nullptr, + require_plain_type_t* = nullptr> + arena_matrix& operator=(T&& other) { + auto other_ptr = make_chainable_ptr(std::move(other)); + new (this) Base(&(other_ptr->coeffRef(0)), other_ptr->rows(), other_ptr->cols()); + return *this; + } + /** * Constructs `arena_matrix` from an expression. This makes an assumption that @@ -149,38 +173,6 @@ class arena_matrix : public Eigen::Map { return *this; } - /** - * Assignment operator for assigning an expression. - * @param a expression to evaluate into this - * @return `*this` - */ - template * = nullptr> - arena_matrix& operator=(T&& a) { - using T_t = std::decay_t; - if (std::is_rvalue_reference::value && is_plain_type::value) { - // Note: plain_type_t here does nothing since T_t is plain type - auto other = make_chainable_ptr(plain_type_t(std::move(a))); - new (this) Base(&(other->coeffRef(0)), other->rows(), other->cols()); - return *this; - } else { - // do we need to transpose? - if ((RowsAtCompileTime == 1 && T_t::ColsAtCompileTime == 1) - || (ColsAtCompileTime == 1 && T_t::RowsAtCompileTime == 1)) { - // placement new changes what data map points to - there is no - // allocation - new (this) Base( - ChainableStack::instance_->memalloc_.alloc_array(a.size()), - a.cols(), a.rows()); - - } else { - new (this) Base( - ChainableStack::instance_->memalloc_.alloc_array(a.size()), - a.rows(), a.cols()); - } - Base::operator=(a); - return *this; - } - } /** * Forces hard copying matrices into an arena matrix * @tparam T Any type assignable to `Base` From 8acdb6d03be34ad7cd974ee671c45bc6b3c548e5 Mon Sep 17 00:00:00 2001 From: Stan Jenkins Date: Fri, 22 Mar 2024 15:04:00 -0400 Subject: [PATCH 29/52] [Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1 --- stan/math/rev/core/arena_matrix.hpp | 70 ++++++++++++++--------------- 1 file changed, 33 insertions(+), 37 deletions(-) diff --git a/stan/math/rev/core/arena_matrix.hpp b/stan/math/rev/core/arena_matrix.hpp index d1a13fefa0a..2448d54847a 100644 --- a/stan/math/rev/core/arena_matrix.hpp +++ b/stan/math/rev/core/arena_matrix.hpp @@ -53,53 +53,49 @@ class arena_matrix : public Eigen::Map { ChainableStack::instance_->memalloc_.alloc_array(size), size) {} - private: - template - constexpr auto get_rows(T&& x) { - return (RowsAtCompileTime == 1 && T::ColsAtCompileTime == 1) - || (ColsAtCompileTime == 1 && T::RowsAtCompileTime == 1) - ? other.cols() - : other.rows(); - } - template - constexpr auto get_cols(T&& x) { - return (RowsAtCompileTime == 1 && T::ColsAtCompileTime == 1) - || (ColsAtCompileTime == 1 && T::RowsAtCompileTime == 1) - ? other.rows() - : other.cols() - } - public: + private: + template + constexpr auto get_rows(T&& x) { + return (RowsAtCompileTime == 1 && T::ColsAtCompileTime == 1) + || (ColsAtCompileTime == 1 && T::RowsAtCompileTime == 1) + ? other.cols() + : other.rows(); + } + template + constexpr auto get_cols(T&& x) { + return (RowsAtCompileTime == 1 && T::ColsAtCompileTime == 1) + || (ColsAtCompileTime == 1 && T::RowsAtCompileTime == 1) + ? other.rows() + : other.cols() + } + public: /** * Constructs `arena_matrix` from an expression * @param other expression */ template * = nullptr> arena_matrix(const T& other) // NOLINT - : Base::Map( - ChainableStack::instance_->memalloc_.alloc_array( - other.size()), - get_rows(other), - get_cols(other)) { + : Base::Map(ChainableStack::instance_->memalloc_.alloc_array( + other.size()), + get_rows(other), get_cols(other)) { *this = other; } /** - * Overwrite the current arena_matrix with new memory and assign a matrix to it - * @tparam T An eigen type inheriting from `Eigen::EigenBase` + * Overwrite the current arena_matrix with new memory and assign a matrix to + * it + * @tparam T An eigen type inheriting from `Eigen::EigenBase` * @param other A matrix that will be copied over to the arena allocator */ template * = nullptr> - arena_matrix& operator=(const T& other) { + arena_matrix& operator=(const T& other) { new (this) Base( - ChainableStack::instance_->memalloc_.alloc_array( - other.size()), - get_rows(other), - get_cols(other)); + ChainableStack::instance_->memalloc_.alloc_array(other.size()), + get_rows(other), get_cols(other)); Base::operator=(other); return *this; } - /** * Constructs `arena_matrix` from an rvalue expression that is a `plain_type`, * then movies it to the object stack. @@ -122,25 +118,25 @@ class arena_matrix : public Eigen::Map { return base_map_t(&(other_ptr->coeffRef(0)), other_ptr->rows(), other_ptr->cols()); }(std::move(other))) {} - + /** * Assignment operator for assigning an expression. - * This is for rvalue plain type objects that can be moved over to the object + * This is for rvalue plain type objects that can be moved over to the object * stack instead of allocating new memory. * @param other expression to evaluate into this * @return `*this` */ - template * = nullptr, - require_not_arena_matrix_t* = nullptr, - require_t>* = nullptr, - require_plain_type_t* = nullptr> + template * = nullptr, + require_not_arena_matrix_t* = nullptr, + require_t>* = nullptr, + require_plain_type_t* = nullptr> arena_matrix& operator=(T&& other) { auto other_ptr = make_chainable_ptr(std::move(other)); - new (this) Base(&(other_ptr->coeffRef(0)), other_ptr->rows(), other_ptr->cols()); + new (this) + Base(&(other_ptr->coeffRef(0)), other_ptr->rows(), other_ptr->cols()); return *this; } - /** * Constructs `arena_matrix` from an expression. This makes an assumption that * any other `Eigen::Map` also contains memory allocated in the arena. From 11da0dd6870dc10b6cd86e176e5a7d8f442e2ddf Mon Sep 17 00:00:00 2001 From: Steve Bronder Date: Fri, 22 Mar 2024 15:09:37 -0400 Subject: [PATCH 30/52] update get_rows and get_cols for arena_matrix --- stan/math/rev/core/arena_matrix.hpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/stan/math/rev/core/arena_matrix.hpp b/stan/math/rev/core/arena_matrix.hpp index 2448d54847a..e8b2f9fef08 100644 --- a/stan/math/rev/core/arena_matrix.hpp +++ b/stan/math/rev/core/arena_matrix.hpp @@ -55,18 +55,18 @@ class arena_matrix : public Eigen::Map { private: template - constexpr auto get_rows(T&& x) { + constexpr auto get_rows(const T& x) { return (RowsAtCompileTime == 1 && T::ColsAtCompileTime == 1) || (ColsAtCompileTime == 1 && T::RowsAtCompileTime == 1) - ? other.cols() - : other.rows(); + ? x.cols() + : x.rows(); } template - constexpr auto get_cols(T&& x) { + constexpr auto get_cols(const T& x) { return (RowsAtCompileTime == 1 && T::ColsAtCompileTime == 1) || (ColsAtCompileTime == 1 && T::RowsAtCompileTime == 1) - ? other.rows() - : other.cols() + ? x.rows() + : x.cols(); } public: From 8a1f9f0bbeba44b65658ba16a7a0120353a90b8a Mon Sep 17 00:00:00 2001 From: Steve Bronder Date: Fri, 22 Mar 2024 17:02:36 -0400 Subject: [PATCH 31/52] update docs --- .../contributor_help_pages/common_pitfalls.md | 126 +++++++++++++++--- 1 file changed, 107 insertions(+), 19 deletions(-) diff --git a/doxygen/contributor_help_pages/common_pitfalls.md b/doxygen/contributor_help_pages/common_pitfalls.md index 1d199b054db..371faa07017 100644 --- a/doxygen/contributor_help_pages/common_pitfalls.md +++ b/doxygen/contributor_help_pages/common_pitfalls.md @@ -154,8 +154,6 @@ The implementation of @ref stan::math::make_holder is [here](https://github.com/ ### Move Semantics -In general, Stan Math does not use move semantics very often. -This is because of our arena allocator. Move semantics generally work as ```cpp @@ -179,6 +177,93 @@ We can see in the above that the standard style of a move (the constructor takin But in Stan, particularly for reverse mode, we need to keep memory around even if it's only temporary for when we call the gradient calculations in the reverse pass. And since memory for reverse mode is stored in our arena allocator no copying happens in the first place. +Functions for Stan math's reverse mode autodiff should use [_perfect forwarding_](https://drewcampbell92.medium.com/understanding-move-semantics-and-perfect-forwarding-part-3-65575d523ff8) arguments. This arguments are a template parameter with `&&` next to them. + +```c++ + template + auto my_function(T&& x) { + return my_other_function(std::forward(x)); + } +``` + +A perfect forwarding argument of a function accepts any reference type as it's input argument. +The above signature is equivalent to writing out several functions with different reference types + +```c++ + // Accepts a plain lvalue reference + auto my_function(Eigen::MatrixXd& x) { + return my_other_function(x); + } + // Accepts a const lvalue reference + auto my_function(const Eigen::MatrixXd& x) { + return my_other_function(x); + } + // Accepts an rvalue reference + auto my_function(Eigen::MatrixXd&& x) { + return my_other_function(std::move(x)); + } +``` + +The `std::forward` in the in the code above tells the compiler that if `T` is deduced to be an rvalue reference (such as `Eigen::MatrixXd&&`), then it should be moved to `my_other_function`, where there it can possibly use another objects move constructor to reuse memory. + +In Stan, perfect forwarding is used in reverse mode functions which can accept an Eigen matrix type. + +```c++ +template * = nullptr> +inline auto sin(T&& x) { + // Store `x` on the arena + arena_t x_arena(std::forward(x)); + arena_t ret(x_arena.val().array().sin().matrix()); + reverse_pass_callback([x_arena, ret] mutable { + x_arena.adj() += ret.adj().cwiseProduct(x_arena.val().array().cos().matrix()); + }); + return ret; +} +``` + +Let's go through the above line by line. + +```c++ +template * = nullptr> +inline auto sin(T&& x) { +``` + +The signature for this function has a template `T` that is required to be an Eigen type with a `value_type` that is a `var` type. +The template parameter `T` is then used in the signature as an perfect forwarding argument. + +```c++ + // Store `x` on the arena + arena_t x_arena(std::forward(x)); +``` + +The input is stored in the arena, which is where the perfect forwarding magic actually occurs. +If `T` is an lvalue type such as `Eigen::MatrixXd&` then `arena_matrix` will use it's copy constructor, creating new memory in Stan's arena allocator and then copying the values of `x` into that memory. +But if `T` was a temporary rvalue type such as `Eigen::MatrixXd&&`, then the `arena_matrix` class will use it's move constructor to place the temporary matrix in Stan's `var_alloc_stack_`. +The `var_alloc_stick_` is used to hold objects that were created outside of the arena allocator but need to be deleted when the arena allocator is cleared. +This allows the `arena_matrix` to reuse the memory from the temporary matrix. Then the matrix will be deleted once arena allocator requests memory to be cleared. + +```c++ + arena_t ret(x_arena.val().array().sin().matrix()); +``` + +This construction of an `arena_matrix` will *not* use the move constructor for `arena_matrix`. +Here, `x_arena` is an `arena_matrix`, which is then wrapped in an expression to compute the elementwise `sin`. +That expression will be evaluated into new memory allocated in the arena allocator and then a pointer to it will be stored in the `arena_matrix.` + +```c++ + reverse_pass_callback([x_arena, ret] mutable { + x_arena.adj() += ret.adj().cwiseProduct(x_arena.val().array().cos().matrix()); + }); + return ret; +``` + +The rest of this code follows the standard format for the rest of Stan math's reverse mode that accepts Eigen types as input. +The `reverse_pass_callback` function accepts a lambda as input and places the lambda in Stan's callback stack to be called later when `grad()` is called by the user. +Since `arena_matrix` types only store a pointer to memory allocated elsewhere they are copied into the lambda. +The body of the lambda holds the gradient calculation needed for the reverse mode pass. + +Then finally `ret`, the `arena_matrix` type is returned by the function. + When working with arithmetic types, keep in mind that moving Scalars is often less optimal than simply taking their copy. For instance, Stan's `var` type uses the pointer to implementation (PIMPL) pattern, so it simply holds a pointer of size 8 bytes. A `double` is also 8 bytes which just so happens to fit exactly in a [word](https://en.wikipedia.org/wiki/Word_(computer_architecture)) of most modern CPUs with at least 64-byte cache lines. @@ -192,9 +277,16 @@ The general rules to follow for passing values to a function are: ### Using auto is Dangerous With Eigen Matrix Functions in Reverse Mode -The use of auto with the Stan Math library should be used with care, like in [Eigen](https://eigen.tuxfamily.org/dox/TopicPitfalls.html). Along with the cautions mentioned in the Eigen docs, there are also memory considerations when using reverse mode automatic differentiation. When returning from a function in the Stan math library with an Eigen matrix output with a scalar `var` type, the actual returned type will often be an `arena_matrix>`. The `arena_matrix` class is an Eigen matrix where the underlying array of memory is located in Stan's memory arena. The `arena_matrix` that is returned by Stan functions is normally the same one resting in the callback used to calculate gradients in the reverse pass. Directly changing the elements of this matrix would also change the memory the reverse pass callback sees which would result in incorrect calculations. +The use of auto with the Stan Math library should be used with care, like in [Eigen](https://eigen.tuxfamily.org/dox/TopicPitfalls.html). +Along with the cautions mentioned in the Eigen docs, there are also memory considerations when using reverse mode automatic differentiation. +When returning from a function in the Stan math library with an Eigen matrix output with a scalar `var` type, the actual returned type will often be an `arena_matrix>`. +The `arena_matrix` class is an Eigen matrix where the underlying array of memory is located in Stan's memory arena. +The `arena_matrix` that is returned by Stan functions is normally the same one resting in the callback used to calculate gradients in the reverse pass. +Directly changing the elements of this matrix would also change the memory the reverse pass callback sees which would result in incorrect calculations. -The simple solution to this is that when you use a math library function that returns a matrix and then want to assign to any of the individual elements of the matrix, assign to an actual Eigen matrix type instead of using auto. In the below example, we see the first case which uses auto and will change the memory of the `arena_matrix` returned in the callback for multiply's reverse mode. Directly below it is the safe version, which just directly assigns to an Eigen matrix type and is safe to do element insertion into. +The simple solution to this is that when you use a math library function that returns a matrix and then want to assign to any of the individual elements of the matrix, assign to an actual Eigen matrix type instead of using auto. +In the below example, we see the first case which uses auto and will change the memory of the `arena_matrix` returned in the callback for multiply's reverse mode. +Directly below it is the safe version, which just directly assigns to an Eigen matrix type and is safe to do element insertion into. ```c++ Eigen::Matrix y; @@ -207,7 +299,8 @@ Eigen::Matrix mu_good = multiply(X, y); mu_good(4) = 1.0; ``` -The reason we do this is for cases where function returns are passed to other functions. An `arena_matrix` will always make a shallow copy when being constructed from another `arena_matrix`, which lets the functions avoid unnecessary copies. +The reason we do this is for cases where function returns are passed to other functions. +An `arena_matrix` will always make a shallow copy when being constructed from another `arena_matrix`, which lets the functions avoid unnecessary copies. ```c++ Eigen::Matrix y1; @@ -273,22 +366,17 @@ grad(); ``` Now `res` is `innocent_return` and we've changed one of the elements of `innocent_return`, but that is also going to change the element of `res` which is being used in our reverse pass callback! -The answer for this is simple but sadly requires a copy. -```cpp -template * = nullptr> -inline var cool_fun(const EigVec& v) { - arena_t arena_v(v); - arena_t res = arena_v.val().array() * arena_v.val().array(); - reverse_pass_callback([res, arena_v]() mutable { - arena_v.adj().array() += (2.0 * res.adj().array()) * arena_v.val().array(); - }); - return plain_type_t(res); -} -``` +Care must be taken by end users of Stan math by using `auto` with caution. +When a user wishes to manipulate the coefficients of a matrix that is a return from a function in Stan math, they should assign the matrix to a plain Eigen type. -we make a deep copy of the return whose inner `vari` will not be the same, but the `var` will produce a new copy of the pointer to the `vari`. -Now the user code above will be protected, and it is safe for them to assign to individual elements of the `auto` returned matrix. +```c++ +Eigen::Matrix x = Eigen::Matrix::Random(5); +Eigen::MatrixXd actually_innocent_return = cool_fun(x); +actually_innocent_return.coeffRef(3) = var(3.0); +auto still_unsafe_return = cool_fun2(actually_innocent_return); +grad(); +``` ### Const correctness, reverse mode autodiff, and arena types From e649349ec31912cda3c0558ec278ae52f8bb8be7 Mon Sep 17 00:00:00 2001 From: Sean Pinkney Date: Sun, 24 Mar 2024 18:01:31 -0400 Subject: [PATCH 32/52] move stuff --- stan/math/fwd.hpp | 2 + stan/math/fwd/constraint.hpp | 9 ++ .../unit_vector_constrain.hpp | 6 +- stan/math/fwd/fun.hpp | 2 +- stan/math/mix.hpp | 2 + .../prim/{ => constraint}/lb_constrain.hpp | 4 +- .../prim/{ => constraint}/lub_constrain.hpp | 4 +- .../offset_multiplier_constrain.hpp | 4 +- .../prim/{ => constraint}/ub_constrain.hpp | 4 +- .../unit_vector_constrain.hpp | 4 +- stan/math/opencl/prim_constraint.cpp | 111 ++++++++++++++++++ .../rev/{ => constraint}/lb_constrain.hpp | 4 +- .../rev/{ => constraint}/lub_constrain.hpp | 4 +- .../offset_multiplier_constrain.hpp | 4 +- .../rev/{ => constraint}/ub_constrain.hpp | 4 +- .../unit_vector_constrain.hpp | 4 +- stan/math/opencl/rev_constraint.cpp | 111 ++++++++++++++++++ stan/math/prim.hpp | 2 + stan/math/prim/constraint.hpp | 42 +++++++ .../cholesky_corr_constrain.hpp | 6 +- .../cholesky_corr_free.hpp | 6 +- .../cholesky_factor_constrain.hpp | 4 +- .../cholesky_factor_free.hpp | 4 +- .../{fun => constraint}/corr_constrain.hpp | 4 +- .../prim/{fun => constraint}/corr_free.hpp | 4 +- .../corr_matrix_constrain.hpp | 6 +- .../{fun => constraint}/corr_matrix_free.hpp | 4 +- .../cov_matrix_constrain.hpp | 4 +- .../cov_matrix_constrain_lkj.hpp | 8 +- .../{fun => constraint}/cov_matrix_free.hpp | 4 +- .../cov_matrix_free_lkj.hpp | 4 +- .../identity_constrain.hpp | 4 +- .../{fun => constraint}/identity_free.hpp | 4 +- .../prim/{fun => constraint}/lb_constrain.hpp | 8 +- .../math/prim/{fun => constraint}/lb_free.hpp | 6 +- .../{fun => constraint}/lub_constrain.hpp | 10 +- .../prim/{fun => constraint}/lub_free.hpp | 8 +- .../offset_multiplier_constrain.hpp | 6 +- .../offset_multiplier_free.hpp | 6 +- .../{fun => constraint}/ordered_constrain.hpp | 4 +- .../prim/{fun => constraint}/ordered_free.hpp | 4 +- .../positive_constrain.hpp | 4 +- .../{fun => constraint}/positive_free.hpp | 4 +- .../positive_ordered_constrain.hpp | 4 +- .../positive_ordered_free.hpp | 4 +- .../{fun => constraint}/prob_constrain.hpp | 4 +- .../prim/{fun => constraint}/prob_free.hpp | 4 +- .../{fun => constraint}/simplex_constrain.hpp | 4 +- .../prim/{fun => constraint}/simplex_free.hpp | 4 +- .../stochastic_column_constrain.hpp | 6 +- .../stochastic_column_free.hpp | 6 +- .../stochastic_row_constrain.hpp | 6 +- .../stochastic_row_free.hpp | 6 +- .../prim/{fun => constraint}/ub_constrain.hpp | 8 +- .../math/prim/{fun => constraint}/ub_free.hpp | 6 +- .../unit_vector_constrain.hpp | 4 +- .../{fun => constraint}/unit_vector_free.hpp | 4 +- stan/math/prim/fun.hpp | 38 ------ stan/math/rev.hpp | 2 + stan/math/rev/constraint.hpp | 26 ++++ .../cholesky_corr_constrain.hpp | 6 +- .../cholesky_factor_constrain.hpp | 4 +- .../corr_matrix_constrain.hpp | 6 +- .../cov_matrix_constrain.hpp | 4 +- .../cov_matrix_constrain_lkj.hpp | 8 +- .../identity_constrain.hpp | 6 +- .../rev/{fun => constraint}/identity_free.hpp | 6 +- .../rev/{fun => constraint}/lb_constrain.hpp | 10 +- .../rev/{fun => constraint}/lub_constrain.hpp | 10 +- .../{fun => constraint}/ordered_constrain.hpp | 4 +- .../positive_ordered_constrain.hpp | 4 +- .../{fun => constraint}/simplex_constrain.hpp | 4 +- .../stochastic_column_constrain.hpp | 4 +- .../stochastic_row_constrain.hpp | 4 +- .../rev/{fun => constraint}/ub_constrain.hpp | 6 +- .../unit_vector_constrain.hpp | 4 +- stan/math/rev/fun.hpp | 17 +-- .../cholesky_corr_constrain_test.cpp | 0 .../cholesky_factor_constrain_test.cpp | 0 .../corr_constrain_test.cpp | 0 .../corr_matrix_constrain_test.cpp | 0 .../cov_matrix_constrain_lkj_test.cpp | 0 .../cov_matrix_constrain_test.cpp | 0 .../identity_constrain_test.cpp | 0 .../lb_constrain_matvar_test.cpp | 0 .../{fun => constraint}/lb_constrain_test.cpp | 0 .../lub_constrain_1_test.cpp | 2 +- .../lub_constrain_2_test.cpp | 2 +- .../lub_constrain_3_test.cpp | 2 +- .../lub_constrain_4_test.cpp | 2 +- .../lub_constrain_5_test.cpp | 2 +- .../lub_constrain_6_test.cpp | 2 +- .../lub_constrain_7_test.cpp | 2 +- .../lub_constrain_8_test.cpp | 2 +- .../lub_constrain_helpers.hpp | 0 .../lub_constrain_matvar_test.cpp | 0 ...set_multiplier_constrain_1_matvar_test.cpp | 2 +- .../offset_multiplier_constrain_1_test.cpp | 2 +- ...set_multiplier_constrain_2_matvar_test.cpp | 2 +- .../offset_multiplier_constrain_2_test.cpp | 2 +- ...set_multiplier_constrain_3_matvar_test.cpp | 2 +- .../offset_multiplier_constrain_3_test.cpp | 2 +- ...set_multiplier_constrain_4_matvar_test.cpp | 2 +- .../offset_multiplier_constrain_4_test.cpp | 2 +- ...set_multiplier_constrain_5_matvar_test.cpp | 2 +- .../offset_multiplier_constrain_5_test.cpp | 2 +- ...set_multiplier_constrain_6_matvar_test.cpp | 2 +- .../offset_multiplier_constrain_6_test.cpp | 2 +- .../offset_multiplier_constrain_7_test.cpp | 0 .../offset_multiplier_constrain_helpers.hpp | 0 ...et_multiplier_constrain_matvar_helpers.hpp | 0 .../ordered_constrain_test.cpp | 0 .../positive_ordered_constrain_test.cpp | 0 .../simplex_constrain_test.cpp | 0 .../stochastic_column_constrain_test.cpp | 0 .../stochastic_row_constrain_test.cpp | 0 .../unit_vector_constrain_test.cpp | 0 .../{ => constraint}/lb_constrain_test.cpp | 0 .../{ => constraint}/lub_constrain_test.cpp | 0 .../offset_multiplier_constrain_test.cpp | 0 .../{ => constraint}/ub_constrain_test.cpp | 0 .../unit_vector_constrain_test.cpp | 0 .../cholesky_corr_transform_test.cpp | 0 .../cholesky_factor_transform_test.cpp | 0 .../corr_transform_test.cpp | 0 .../cov_matrix_transform_test.cpp | 0 .../identity_transform_test.cpp | 0 .../{fun => constraint}/lb_transform_test.cpp | 0 .../lub_transform_test.cpp | 0 ...ffset_multiplier_matrix_transform_test.cpp | 0 .../offset_multiplier_transform_test.cpp | 0 .../ordered_transform_test.cpp | 0 .../prob_transform_test.cpp | 0 .../simplex_transform_test.cpp | 0 .../stochastic_column_constrain_test.cpp | 0 .../stochastic_row_constrain_test.cpp | 0 .../{fun => constraint}/ub_transform_test.cpp | 0 .../unit_vector_transform_test.cpp | 0 138 files changed, 495 insertions(+), 241 deletions(-) create mode 100644 stan/math/fwd/constraint.hpp rename stan/math/fwd/{fun => constraint}/unit_vector_constrain.hpp (90%) rename stan/math/opencl/prim/{ => constraint}/lb_constrain.hpp (94%) rename stan/math/opencl/prim/{ => constraint}/lub_constrain.hpp (96%) rename stan/math/opencl/prim/{ => constraint}/offset_multiplier_constrain.hpp (96%) rename stan/math/opencl/prim/{ => constraint}/ub_constrain.hpp (94%) rename stan/math/opencl/prim/{ => constraint}/unit_vector_constrain.hpp (92%) create mode 100644 stan/math/opencl/prim_constraint.cpp rename stan/math/opencl/rev/{ => constraint}/lb_constrain.hpp (96%) rename stan/math/opencl/rev/{ => constraint}/lub_constrain.hpp (97%) rename stan/math/opencl/rev/{ => constraint}/offset_multiplier_constrain.hpp (96%) rename stan/math/opencl/rev/{ => constraint}/ub_constrain.hpp (96%) rename stan/math/opencl/rev/{ => constraint}/unit_vector_constrain.hpp (93%) create mode 100644 stan/math/opencl/rev_constraint.cpp create mode 100644 stan/math/prim/constraint.hpp rename stan/math/prim/{fun => constraint}/cholesky_corr_constrain.hpp (96%) rename stan/math/prim/{fun => constraint}/cholesky_corr_free.hpp (89%) rename stan/math/prim/{fun => constraint}/cholesky_factor_constrain.hpp (97%) rename stan/math/prim/{fun => constraint}/cholesky_factor_free.hpp (94%) rename stan/math/prim/{fun => constraint}/corr_constrain.hpp (95%) rename stan/math/prim/{fun => constraint}/corr_free.hpp (89%) rename stan/math/prim/{fun => constraint}/corr_matrix_constrain.hpp (97%) rename stan/math/prim/{fun => constraint}/corr_matrix_free.hpp (95%) rename stan/math/prim/{fun => constraint}/cov_matrix_constrain.hpp (98%) rename stan/math/prim/{fun => constraint}/cov_matrix_constrain_lkj.hpp (95%) rename stan/math/prim/{fun => constraint}/cov_matrix_free.hpp (95%) rename stan/math/prim/{fun => constraint}/cov_matrix_free_lkj.hpp (95%) rename stan/math/prim/{fun => constraint}/identity_constrain.hpp (87%) rename stan/math/prim/{fun => constraint}/identity_free.hpp (86%) rename stan/math/prim/{fun => constraint}/lb_constrain.hpp (97%) rename stan/math/prim/{fun => constraint}/lb_free.hpp (96%) rename stan/math/prim/{fun => constraint}/lub_constrain.hpp (98%) rename stan/math/prim/{fun => constraint}/lub_free.hpp (96%) rename stan/math/prim/{fun => constraint}/offset_multiplier_constrain.hpp (98%) rename stan/math/prim/{fun => constraint}/offset_multiplier_free.hpp (96%) rename stan/math/prim/{fun => constraint}/ordered_constrain.hpp (97%) rename stan/math/prim/{fun => constraint}/ordered_free.hpp (94%) rename stan/math/prim/{fun => constraint}/positive_constrain.hpp (96%) rename stan/math/prim/{fun => constraint}/positive_free.hpp (89%) rename stan/math/prim/{fun => constraint}/positive_ordered_constrain.hpp (96%) rename stan/math/prim/{fun => constraint}/positive_ordered_free.hpp (93%) rename stan/math/prim/{fun => constraint}/prob_constrain.hpp (95%) rename stan/math/prim/{fun => constraint}/prob_free.hpp (89%) rename stan/math/prim/{fun => constraint}/simplex_constrain.hpp (97%) rename stan/math/prim/{fun => constraint}/simplex_free.hpp (95%) rename stan/math/prim/{fun => constraint}/stochastic_column_constrain.hpp (95%) rename stan/math/prim/{fun => constraint}/stochastic_column_free.hpp (88%) rename stan/math/prim/{fun => constraint}/stochastic_row_constrain.hpp (96%) rename stan/math/prim/{fun => constraint}/stochastic_row_free.hpp (89%) rename stan/math/prim/{fun => constraint}/ub_constrain.hpp (97%) rename stan/math/prim/{fun => constraint}/ub_free.hpp (96%) rename stan/math/prim/{fun => constraint}/unit_vector_constrain.hpp (97%) rename stan/math/prim/{fun => constraint}/unit_vector_free.hpp (92%) create mode 100644 stan/math/rev/constraint.hpp rename stan/math/rev/{fun => constraint}/cholesky_corr_constrain.hpp (96%) rename stan/math/rev/{fun => constraint}/cholesky_factor_constrain.hpp (96%) rename stan/math/rev/{fun => constraint}/corr_matrix_constrain.hpp (94%) rename stan/math/rev/{fun => constraint}/cov_matrix_constrain.hpp (97%) rename stan/math/rev/{fun => constraint}/cov_matrix_constrain_lkj.hpp (92%) rename stan/math/rev/{fun => constraint}/identity_constrain.hpp (87%) rename stan/math/rev/{fun => constraint}/identity_free.hpp (80%) rename stan/math/rev/{fun => constraint}/lb_constrain.hpp (98%) rename stan/math/rev/{fun => constraint}/lub_constrain.hpp (99%) rename stan/math/rev/{fun => constraint}/ordered_constrain.hpp (95%) rename stan/math/rev/{fun => constraint}/positive_ordered_constrain.hpp (92%) rename stan/math/rev/{fun => constraint}/simplex_constrain.hpp (97%) rename stan/math/rev/{fun => constraint}/stochastic_column_constrain.hpp (97%) rename stan/math/rev/{fun => constraint}/stochastic_row_constrain.hpp (97%) rename stan/math/rev/{fun => constraint}/ub_constrain.hpp (98%) rename stan/math/rev/{fun => constraint}/unit_vector_constrain.hpp (95%) rename test/unit/math/mix/{fun => constraint}/cholesky_corr_constrain_test.cpp (100%) rename test/unit/math/mix/{fun => constraint}/cholesky_factor_constrain_test.cpp (100%) rename test/unit/math/mix/{fun => constraint}/corr_constrain_test.cpp (100%) rename test/unit/math/mix/{fun => constraint}/corr_matrix_constrain_test.cpp (100%) rename test/unit/math/mix/{fun => constraint}/cov_matrix_constrain_lkj_test.cpp (100%) rename test/unit/math/mix/{fun => constraint}/cov_matrix_constrain_test.cpp (100%) rename test/unit/math/mix/{fun => constraint}/identity_constrain_test.cpp (100%) rename test/unit/math/mix/{fun => constraint}/lb_constrain_matvar_test.cpp (100%) rename test/unit/math/mix/{fun => constraint}/lb_constrain_test.cpp (100%) rename test/unit/math/mix/{fun => constraint}/lub_constrain_1_test.cpp (91%) rename test/unit/math/mix/{fun => constraint}/lub_constrain_2_test.cpp (95%) rename test/unit/math/mix/{fun => constraint}/lub_constrain_3_test.cpp (96%) rename test/unit/math/mix/{fun => constraint}/lub_constrain_4_test.cpp (94%) rename test/unit/math/mix/{fun => constraint}/lub_constrain_5_test.cpp (96%) rename test/unit/math/mix/{fun => constraint}/lub_constrain_6_test.cpp (96%) rename test/unit/math/mix/{fun => constraint}/lub_constrain_7_test.cpp (96%) rename test/unit/math/mix/{fun => constraint}/lub_constrain_8_test.cpp (96%) rename test/unit/math/mix/{fun => constraint}/lub_constrain_helpers.hpp (100%) rename test/unit/math/mix/{fun => constraint}/lub_constrain_matvar_test.cpp (100%) rename test/unit/math/mix/{fun => constraint}/offset_multiplier_constrain_1_matvar_test.cpp (92%) rename test/unit/math/mix/{fun => constraint}/offset_multiplier_constrain_1_test.cpp (92%) rename test/unit/math/mix/{fun => constraint}/offset_multiplier_constrain_2_matvar_test.cpp (91%) rename test/unit/math/mix/{fun => constraint}/offset_multiplier_constrain_2_test.cpp (91%) rename test/unit/math/mix/{fun => constraint}/offset_multiplier_constrain_3_matvar_test.cpp (94%) rename test/unit/math/mix/{fun => constraint}/offset_multiplier_constrain_3_test.cpp (94%) rename test/unit/math/mix/{fun => constraint}/offset_multiplier_constrain_4_matvar_test.cpp (88%) rename test/unit/math/mix/{fun => constraint}/offset_multiplier_constrain_4_test.cpp (88%) rename test/unit/math/mix/{fun => constraint}/offset_multiplier_constrain_5_matvar_test.cpp (90%) rename test/unit/math/mix/{fun => constraint}/offset_multiplier_constrain_5_test.cpp (90%) rename test/unit/math/mix/{fun => constraint}/offset_multiplier_constrain_6_matvar_test.cpp (91%) rename test/unit/math/mix/{fun => constraint}/offset_multiplier_constrain_6_test.cpp (91%) rename test/unit/math/mix/{fun => constraint}/offset_multiplier_constrain_7_test.cpp (100%) rename test/unit/math/mix/{fun => constraint}/offset_multiplier_constrain_helpers.hpp (100%) rename test/unit/math/mix/{fun => constraint}/offset_multiplier_constrain_matvar_helpers.hpp (100%) rename test/unit/math/mix/{fun => constraint}/ordered_constrain_test.cpp (100%) rename test/unit/math/mix/{fun => constraint}/positive_ordered_constrain_test.cpp (100%) rename test/unit/math/mix/{fun => constraint}/simplex_constrain_test.cpp (100%) rename test/unit/math/mix/{fun => constraint}/stochastic_column_constrain_test.cpp (100%) rename test/unit/math/mix/{fun => constraint}/stochastic_row_constrain_test.cpp (100%) rename test/unit/math/mix/{fun => constraint}/unit_vector_constrain_test.cpp (100%) rename test/unit/math/opencl/rev/{ => constraint}/lb_constrain_test.cpp (100%) rename test/unit/math/opencl/rev/{ => constraint}/lub_constrain_test.cpp (100%) rename test/unit/math/opencl/rev/{ => constraint}/offset_multiplier_constrain_test.cpp (100%) rename test/unit/math/opencl/rev/{ => constraint}/ub_constrain_test.cpp (100%) rename test/unit/math/opencl/rev/{ => constraint}/unit_vector_constrain_test.cpp (100%) rename test/unit/math/prim/{fun => constraint}/cholesky_corr_transform_test.cpp (100%) rename test/unit/math/prim/{fun => constraint}/cholesky_factor_transform_test.cpp (100%) rename test/unit/math/prim/{fun => constraint}/corr_transform_test.cpp (100%) rename test/unit/math/prim/{fun => constraint}/cov_matrix_transform_test.cpp (100%) rename test/unit/math/prim/{fun => constraint}/identity_transform_test.cpp (100%) rename test/unit/math/prim/{fun => constraint}/lb_transform_test.cpp (100%) rename test/unit/math/prim/{fun => constraint}/lub_transform_test.cpp (100%) rename test/unit/math/prim/{fun => constraint}/offset_multiplier_matrix_transform_test.cpp (100%) rename test/unit/math/prim/{fun => constraint}/offset_multiplier_transform_test.cpp (100%) rename test/unit/math/prim/{fun => constraint}/ordered_transform_test.cpp (100%) rename test/unit/math/prim/{fun => constraint}/prob_transform_test.cpp (100%) rename test/unit/math/prim/{fun => constraint}/simplex_transform_test.cpp (100%) rename test/unit/math/prim/{fun => constraint}/stochastic_column_constrain_test.cpp (100%) rename test/unit/math/prim/{fun => constraint}/stochastic_row_constrain_test.cpp (100%) rename test/unit/math/prim/{fun => constraint}/ub_transform_test.cpp (100%) rename test/unit/math/prim/{fun => constraint}/unit_vector_transform_test.cpp (100%) diff --git a/stan/math/fwd.hpp b/stan/math/fwd.hpp index 3bab5be267f..2ff806f5d34 100644 --- a/stan/math/fwd.hpp +++ b/stan/math/fwd.hpp @@ -5,8 +5,10 @@ #ifdef STAN_OPENCL #include +#include #endif +#include #include #include #include diff --git a/stan/math/fwd/constraint.hpp b/stan/math/fwd/constraint.hpp new file mode 100644 index 00000000000..87a396055b4 --- /dev/null +++ b/stan/math/fwd/constraint.hpp @@ -0,0 +1,9 @@ +#ifndef STAN_MATH_FWD_CONSTRAINT_HPP +#define STAN_MATH_FWD_CONSTRAINT_HPP + +#include +#include + +#include + +#endif \ No newline at end of file diff --git a/stan/math/fwd/fun/unit_vector_constrain.hpp b/stan/math/fwd/constraint/unit_vector_constrain.hpp similarity index 90% rename from stan/math/fwd/fun/unit_vector_constrain.hpp rename to stan/math/fwd/constraint/unit_vector_constrain.hpp index 1cd708174cb..1b1b258e5a8 100644 --- a/stan/math/fwd/fun/unit_vector_constrain.hpp +++ b/stan/math/fwd/constraint/unit_vector_constrain.hpp @@ -1,5 +1,5 @@ -#ifndef STAN_MATH_FWD_FUN_UNIT_VECTOR_CONSTRAIN_HPP -#define STAN_MATH_FWD_FUN_UNIT_VECTOR_CONSTRAIN_HPP +#ifndef STAN_MATH_FWD_CONSTRAINT_UNIT_VECTOR_CONSTRAIN_HPP +#define STAN_MATH_FWD_CONSTRAINT_UNIT_VECTOR_CONSTRAIN_HPP #include #include @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include #include diff --git a/stan/math/fwd/fun.hpp b/stan/math/fwd/fun.hpp index cd4f25d8e11..6457ea3b6cf 100644 --- a/stan/math/fwd/fun.hpp +++ b/stan/math/fwd/fun.hpp @@ -120,7 +120,7 @@ #include #include #include -#include +#include #include #include diff --git a/stan/math/mix.hpp b/stan/math/mix.hpp index deb3cbba522..d65900c6cd3 100644 --- a/stan/math/mix.hpp +++ b/stan/math/mix.hpp @@ -13,8 +13,10 @@ #ifdef STAN_OPENCL #include +#include #endif +#include #include #include #include diff --git a/stan/math/opencl/prim/lb_constrain.hpp b/stan/math/opencl/prim/constraint/lb_constrain.hpp similarity index 94% rename from stan/math/opencl/prim/lb_constrain.hpp rename to stan/math/opencl/prim/constraint/lb_constrain.hpp index 0ef7e77b16d..e94f6ead13f 100644 --- a/stan/math/opencl/prim/lb_constrain.hpp +++ b/stan/math/opencl/prim/constraint/lb_constrain.hpp @@ -1,5 +1,5 @@ -#ifndef STAN_MATH_OPENCL_PRIM_LB_CONSTRAIN_HPP -#define STAN_MATH_OPENCL_PRIM_LB_CONSTRAIN_HPP +#ifndef STAN_MATH_OPENCL_PRIM_CONSTRAINT_LB_CONSTRAIN_HPP +#define STAN_MATH_OPENCL_PRIM_CONSTRAINT_LB_CONSTRAIN_HPP #ifdef STAN_OPENCL #include diff --git a/stan/math/opencl/prim/lub_constrain.hpp b/stan/math/opencl/prim/constraint/lub_constrain.hpp similarity index 96% rename from stan/math/opencl/prim/lub_constrain.hpp rename to stan/math/opencl/prim/constraint/lub_constrain.hpp index 212e89537fe..a5fa4c6e2ea 100644 --- a/stan/math/opencl/prim/lub_constrain.hpp +++ b/stan/math/opencl/prim/constraint/lub_constrain.hpp @@ -1,5 +1,5 @@ -#ifndef STAN_MATH_OPENCL_PRIM_LUB_CONSTRAIN_HPP -#define STAN_MATH_OPENCL_PRIM_LUB_CONSTRAIN_HPP +#ifndef STAN_MATH_OPENCL_PRIM_CONSTRAINT_LUB_CONSTRAIN_HPP +#define STAN_MATH_OPENCL_PRIM_CONSTRAINT_LUB_CONSTRAIN_HPP #ifdef STAN_OPENCL #include diff --git a/stan/math/opencl/prim/offset_multiplier_constrain.hpp b/stan/math/opencl/prim/constraint/offset_multiplier_constrain.hpp similarity index 96% rename from stan/math/opencl/prim/offset_multiplier_constrain.hpp rename to stan/math/opencl/prim/constraint/offset_multiplier_constrain.hpp index 67c4b6457bc..481287f6457 100644 --- a/stan/math/opencl/prim/offset_multiplier_constrain.hpp +++ b/stan/math/opencl/prim/constraint/offset_multiplier_constrain.hpp @@ -1,5 +1,5 @@ -#ifndef STAN_MATH_OPENCL_PRIM_OFFSET_MULTIPLIER_CONSTRAIN_HPP -#define STAN_MATH_OPENCL_PRIM_OFFSET_MULTIPLIER_CONSTRAIN_HPP +#ifndef STAN_MATH_OPENCL_PRIM_CONSTRAINT_OFFSET_MULTIPLIER_CONSTRAIN_HPP +#define STAN_MATH_OPENCL_PRIM_CONSTRAINT_OFFSET_MULTIPLIER_CONSTRAIN_HPP #ifdef STAN_OPENCL #include diff --git a/stan/math/opencl/prim/ub_constrain.hpp b/stan/math/opencl/prim/constraint/ub_constrain.hpp similarity index 94% rename from stan/math/opencl/prim/ub_constrain.hpp rename to stan/math/opencl/prim/constraint/ub_constrain.hpp index eebb3e927c2..fd158ee93c8 100644 --- a/stan/math/opencl/prim/ub_constrain.hpp +++ b/stan/math/opencl/prim/constraint/ub_constrain.hpp @@ -1,5 +1,5 @@ -#ifndef STAN_MATH_OPENCL_PRIM_UB_CONSTRAIN_HPP -#define STAN_MATH_OPENCL_PRIM_UB_CONSTRAIN_HPP +#ifndef STAN_MATH_OPENCL_PRIM_CONSTRAINT_UB_CONSTRAIN_HPP +#define STAN_MATH_OPENCL_PRIM_CONSTRAINT_UB_CONSTRAIN_HPP #ifdef STAN_OPENCL #include diff --git a/stan/math/opencl/prim/unit_vector_constrain.hpp b/stan/math/opencl/prim/constraint/unit_vector_constrain.hpp similarity index 92% rename from stan/math/opencl/prim/unit_vector_constrain.hpp rename to stan/math/opencl/prim/constraint/unit_vector_constrain.hpp index e1f0b283061..a5a4c8c10bc 100644 --- a/stan/math/opencl/prim/unit_vector_constrain.hpp +++ b/stan/math/opencl/prim/constraint/unit_vector_constrain.hpp @@ -1,5 +1,5 @@ -#ifndef STAN_MATH_OPENCL_UNIT_VECTOR_CONSTRAIN_BLOCK_HPP -#define STAN_MATH_OPENCL_UNIT_VECTOR_CONSTRAIN_BLOCK_HPP +#ifndef STAN_MATH_OPENCL_PRIM_CONSTRAINT_UNIT_VECTOR_CONSTRAIN_BLOCK_HPP +#define STAN_MATH_OPENCL_PRIM_CONSTRAINT_UNIT_VECTOR_CONSTRAIN_BLOCK_HPP #ifdef STAN_OPENCL #include diff --git a/stan/math/opencl/prim_constraint.cpp b/stan/math/opencl/prim_constraint.cpp new file mode 100644 index 00000000000..9c38de83393 --- /dev/null +++ b/stan/math/opencl/prim_constraint.cpp @@ -0,0 +1,111 @@ +#ifndef STAN_MATH_OPENCL_PRIM_CONSTRAINT_HPP +#define STAN_MATH_OPENCL_PRIM_CONSTRAINT_HPP +#ifdef STAN_OPENCL + +/** + * \defgroup opencl OpenCL + * Stan's OpenCL backend allows for computation to be executed in parallel + * on a GPU or in multithreaded CPUs. It is meant to easily conform with Eigen + * such that you can create and read from a `matrix_cl` by doing + * + *```cpp + * Eigen::MatrixXd A_eig = Eigen::MatrixXd::Random(10, 10); + * matrix_cl A(A_eig); + * matrix_cl B = to_matrix_cl(A_eig); + * matrix_cl C = cholesky_decompose(A * B); + * // Read back to eigen matrix. + * Eigen::MatrixXd C_eig = from_matrix_cl(C); + * + * // Also for vectors and raw pointers of pointers + * std::vector A_vec(10, 0); + * matrix_cl B_var(A_vec, 10, 1); + * + * vari** A_vari= // fill + * matrix_cl B_vari(A_vari, 10, 1); + * + *``` + * + * Execution is performed in async and Kernel operations are compounded and + * compiled Just In Time. This allows for a low amount of overhead when passing + * data to and from the device and executing computations. + * + * For more details see the paper on Arvix. + * https://arxiv.org/pdf/1907.01063.pdf + */ + +/** + * \ingroup opencl + * \defgroup error_checks_opencl Error Checks + */ + +/** + * \ingroup opencl + * \defgroup kernel_executor_opencl Kernel Executor + * The kernel executor allows OpenCL kernels to be executed in async. GPUs + * have the capability to perform reads, writes, and computation at the same + * time. In order to maximize the throughput to the device the Kernel + * Executor assigns matrices read and write events. Write events are blocking + * in that no further operations can be completed until the write event + * is finished. However, read events can happen in async together. + * Take the following for example + * + *```cpp + * matrix_cl A = from_eigen_cl(A_eig); + * matrix_cl B = from_eigen_cl(B_eig); + * matrix_cl C = A * B; + * matrix_cl D = A + B; + * matrix_cl E = C + D; + *``` + * In the above, When `A` and `B` are created from the Eigen matrices `A_eig` + *and `B_eig`. they are both assigned write events to their write event stack. + * `C` and `D` depend on `A` and `B` while `E` depends on + * `C` and `D`. When executing `C`'s operation, `A` and `B` are assigned + * events to their read event stack while `C` is assigned an event to it's write + *event stack. Once `A` and `B` have finished their write event the kernel to + *compute `C` can begin. The excution to create `D` also waits for the write + *events of `A` and `B`, but does not have to wait for the execution of `C` to + *finish. Executing `E` requires waiting for for the write events of both `C` + *and `D`. + * + */ + +/** + * \ingroup opencl + * \defgroup opencl_kernels Custom OpenCL kernels + */ + +/** + * \ingroup opencl + * \defgroup prim_fun_opencl OpenCL overloads of stan/math/prim functions + */ +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +#endif +#endif diff --git a/stan/math/opencl/rev/lb_constrain.hpp b/stan/math/opencl/rev/constraint/lb_constrain.hpp similarity index 96% rename from stan/math/opencl/rev/lb_constrain.hpp rename to stan/math/opencl/rev/constraint/lb_constrain.hpp index e796073586c..012d81a8bde 100644 --- a/stan/math/opencl/rev/lb_constrain.hpp +++ b/stan/math/opencl/rev/constraint/lb_constrain.hpp @@ -1,5 +1,5 @@ -#ifndef STAN_MATH_OPENCL_REV_LB_CONSTRAIN_HPP -#define STAN_MATH_OPENCL_REV_LB_CONSTRAIN_HPP +#ifndef STAN_MATH_OPENCL_REV_CONSTRAINT_LB_CONSTRAIN_HPP +#define STAN_MATH_OPENCL_REV_CONSTRAINT_LB_CONSTRAIN_HPP #ifdef STAN_OPENCL #include diff --git a/stan/math/opencl/rev/lub_constrain.hpp b/stan/math/opencl/rev/constraint/lub_constrain.hpp similarity index 97% rename from stan/math/opencl/rev/lub_constrain.hpp rename to stan/math/opencl/rev/constraint/lub_constrain.hpp index 21ded0b24e2..9fae858693d 100644 --- a/stan/math/opencl/rev/lub_constrain.hpp +++ b/stan/math/opencl/rev/constraint/lub_constrain.hpp @@ -1,5 +1,5 @@ -#ifndef STAN_MATH_OPENCL_REV_LUB_CONSTRAIN_HPP -#define STAN_MATH_OPENCL_REV_LUB_CONSTRAIN_HPP +#ifndef STAN_MATH_OPENCL_REV_CONSTRAINT_LUB_CONSTRAIN_HPP +#define STAN_MATH_OPENCL_REV_CONSTRAINT_LUB_CONSTRAIN_HPP #ifdef STAN_OPENCL #include diff --git a/stan/math/opencl/rev/offset_multiplier_constrain.hpp b/stan/math/opencl/rev/constraint/offset_multiplier_constrain.hpp similarity index 96% rename from stan/math/opencl/rev/offset_multiplier_constrain.hpp rename to stan/math/opencl/rev/constraint/offset_multiplier_constrain.hpp index ca6f6fe3ecc..c75eecc0571 100644 --- a/stan/math/opencl/rev/offset_multiplier_constrain.hpp +++ b/stan/math/opencl/rev/constraint/offset_multiplier_constrain.hpp @@ -1,5 +1,5 @@ -#ifndef STAN_MATH_OPENCL_REV_OFFSET_MULTIPLIER_CONSTRAIN_HPP -#define STAN_MATH_OPENCL_REV_OFFSET_MULTIPLIER_CONSTRAIN_HPP +#ifndef STAN_MATH_OPENCL_REV_CONSTRAINT_OFFSET_MULTIPLIER_CONSTRAIN_HPP +#define STAN_MATH_OPENCL_REV_CONSTRAINT_OFFSET_MULTIPLIER_CONSTRAIN_HPP #ifdef STAN_OPENCL #include diff --git a/stan/math/opencl/rev/ub_constrain.hpp b/stan/math/opencl/rev/constraint/ub_constrain.hpp similarity index 96% rename from stan/math/opencl/rev/ub_constrain.hpp rename to stan/math/opencl/rev/constraint/ub_constrain.hpp index ef87c2ba07e..c8748447593 100644 --- a/stan/math/opencl/rev/ub_constrain.hpp +++ b/stan/math/opencl/rev/constraint/ub_constrain.hpp @@ -1,5 +1,5 @@ -#ifndef STAN_MATH_OPENCL_REV_UB_CONSTRAIN_HPP -#define STAN_MATH_OPENCL_REV_UB_CONSTRAIN_HPP +#ifndef STAN_MATH_OPENCL_REV_CONSTRAINT_UB_CONSTRAIN_HPP +#define STAN_MATH_OPENCL_REV_CONSTRAINT_UB_CONSTRAIN_HPP #ifdef STAN_OPENCL #include diff --git a/stan/math/opencl/rev/unit_vector_constrain.hpp b/stan/math/opencl/rev/constraint/unit_vector_constrain.hpp similarity index 93% rename from stan/math/opencl/rev/unit_vector_constrain.hpp rename to stan/math/opencl/rev/constraint/unit_vector_constrain.hpp index e2fa6a63462..968005880fa 100644 --- a/stan/math/opencl/rev/unit_vector_constrain.hpp +++ b/stan/math/opencl/rev/constraint/unit_vector_constrain.hpp @@ -1,5 +1,5 @@ -#ifndef STAN_MATH_OPENCL_REV_UNIT_VECTOR_CONSTRAIN_HPP -#define STAN_MATH_OPENCL_REV_UNIT_VECTOR_CONSTRAIN_HPP +#ifndef STAN_MATH_OPENCL_REV_CONSTRAINT_UNIT_VECTOR_CONSTRAIN_HPP +#define STAN_MATH_OPENCL_REV_CONSTRAINT_UNIT_VECTOR_CONSTRAIN_HPP #ifdef STAN_OPENCL #include diff --git a/stan/math/opencl/rev_constraint.cpp b/stan/math/opencl/rev_constraint.cpp new file mode 100644 index 00000000000..20a9660322c --- /dev/null +++ b/stan/math/opencl/rev_constraint.cpp @@ -0,0 +1,111 @@ +#ifndef STAN_MATH_OPENCL_PRIM_CONSTRAINT_HPP +#define STAN_MATH_OPENCL_PRIM_CONSTRAINT_HPP +#ifdef STAN_OPENCL + +/** + * \defgroup opencl OpenCL + * Stan's OpenCL backend allows for computation to be executed in parallel + * on a GPU or in multithreaded CPUs. It is meant to easily conform with Eigen + * such that you can create and read from a `matrix_cl` by doing + * + *```cpp + * Eigen::MatrixXd A_eig = Eigen::MatrixXd::Random(10, 10); + * matrix_cl A(A_eig); + * matrix_cl B = to_matrix_cl(A_eig); + * matrix_cl C = cholesky_decompose(A * B); + * // Read back to eigen matrix. + * Eigen::MatrixXd C_eig = from_matrix_cl(C); + * + * // Also for vectors and raw pointers of pointers + * std::vector A_vec(10, 0); + * matrix_cl B_var(A_vec, 10, 1); + * + * vari** A_vari= // fill + * matrix_cl B_vari(A_vari, 10, 1); + * + *``` + * + * Execution is performed in async and Kernel operations are compounded and + * compiled Just In Time. This allows for a low amount of overhead when passing + * data to and from the device and executing computations. + * + * For more details see the paper on Arvix. + * https://arxiv.org/pdf/1907.01063.pdf + */ + +/** + * \ingroup opencl + * \defgroup error_checks_opencl Error Checks + */ + +/** + * \ingroup opencl + * \defgroup kernel_executor_opencl Kernel Executor + * The kernel executor allows OpenCL kernels to be executed in async. GPUs + * have the capability to perform reads, writes, and computation at the same + * time. In order to maximize the throughput to the device the Kernel + * Executor assigns matrices read and write events. Write events are blocking + * in that no further operations can be completed until the write event + * is finished. However, read events can happen in async together. + * Take the following for example + * + *```cpp + * matrix_cl A = from_eigen_cl(A_eig); + * matrix_cl B = from_eigen_cl(B_eig); + * matrix_cl C = A * B; + * matrix_cl D = A + B; + * matrix_cl E = C + D; + *``` + * In the above, When `A` and `B` are created from the Eigen matrices `A_eig` + *and `B_eig`. they are both assigned write events to their write event stack. + * `C` and `D` depend on `A` and `B` while `E` depends on + * `C` and `D`. When executing `C`'s operation, `A` and `B` are assigned + * events to their read event stack while `C` is assigned an event to it's write + *event stack. Once `A` and `B` have finished their write event the kernel to + *compute `C` can begin. The excution to create `D` also waits for the write + *events of `A` and `B`, but does not have to wait for the execution of `C` to + *finish. Executing `E` requires waiting for for the write events of both `C` + *and `D`. + * + */ + +/** + * \ingroup opencl + * \defgroup opencl_kernels Custom OpenCL kernels + */ + +/** + * \ingroup opencl + * \defgroup prim_fun_opencl OpenCL overloads of stan/math/prim functions + */ +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +#endif +#endif diff --git a/stan/math/prim.hpp b/stan/math/prim.hpp index 30b66815356..208818ae116 100644 --- a/stan/math/prim.hpp +++ b/stan/math/prim.hpp @@ -5,8 +5,10 @@ #ifdef STAN_OPENCL #include +#include #endif +#include #include #include #include diff --git a/stan/math/prim/constraint.hpp b/stan/math/prim/constraint.hpp new file mode 100644 index 00000000000..9a252202811 --- /dev/null +++ b/stan/math/prim/constraint.hpp @@ -0,0 +1,42 @@ +#ifndef STAN_MATH_PRIM_CONSTRAINT_HPP +#define STAN_MATH_PRIM_CONSTRAINT_HPP +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif \ No newline at end of file diff --git a/stan/math/prim/fun/cholesky_corr_constrain.hpp b/stan/math/prim/constraint/cholesky_corr_constrain.hpp similarity index 96% rename from stan/math/prim/fun/cholesky_corr_constrain.hpp rename to stan/math/prim/constraint/cholesky_corr_constrain.hpp index c949b85554d..b7909de4d0f 100644 --- a/stan/math/prim/fun/cholesky_corr_constrain.hpp +++ b/stan/math/prim/constraint/cholesky_corr_constrain.hpp @@ -1,12 +1,12 @@ -#ifndef STAN_MATH_PRIM_FUN_CHOLESKY_CORR_CONSTRAIN_HPP -#define STAN_MATH_PRIM_FUN_CHOLESKY_CORR_CONSTRAIN_HPP +#ifndef STAN_MATH_PRIM_CONSTRAINT_CHOLESKY_CORR_CONSTRAIN_HPP +#define STAN_MATH_PRIM_CONSTRAINT_CHOLESKY_CORR_CONSTRAIN_HPP #include #include #include #include #include -#include +#include #include namespace stan { diff --git a/stan/math/prim/fun/cholesky_corr_free.hpp b/stan/math/prim/constraint/cholesky_corr_free.hpp similarity index 89% rename from stan/math/prim/fun/cholesky_corr_free.hpp rename to stan/math/prim/constraint/cholesky_corr_free.hpp index f5746eaceeb..4245e495bdc 100644 --- a/stan/math/prim/fun/cholesky_corr_free.hpp +++ b/stan/math/prim/constraint/cholesky_corr_free.hpp @@ -1,9 +1,9 @@ -#ifndef STAN_MATH_PRIM_FUN_CHOLESKY_CORR_FREE_HPP -#define STAN_MATH_PRIM_FUN_CHOLESKY_CORR_FREE_HPP +#ifndef STAN_MATH_PRIM_CONSTRAINT_CHOLESKY_CORR_FREE_HPP +#define STAN_MATH_PRIM_CONSTRAINT_CHOLESKY_CORR_FREE_HPP #include #include -#include +#include #include #include diff --git a/stan/math/prim/fun/cholesky_factor_constrain.hpp b/stan/math/prim/constraint/cholesky_factor_constrain.hpp similarity index 97% rename from stan/math/prim/fun/cholesky_factor_constrain.hpp rename to stan/math/prim/constraint/cholesky_factor_constrain.hpp index ef8addb9ae1..31ef9731079 100644 --- a/stan/math/prim/fun/cholesky_factor_constrain.hpp +++ b/stan/math/prim/constraint/cholesky_factor_constrain.hpp @@ -1,5 +1,5 @@ -#ifndef STAN_MATH_PRIM_FUN_CHOLESKY_FACTOR_CONSTRAIN_HPP -#define STAN_MATH_PRIM_FUN_CHOLESKY_FACTOR_CONSTRAIN_HPP +#ifndef STAN_MATH_PRIM_CONSTRAINT_CHOLESKY_FACTOR_CONSTRAIN_HPP +#define STAN_MATH_PRIM_CONSTRAINT_CHOLESKY_FACTOR_CONSTRAIN_HPP #include #include diff --git a/stan/math/prim/fun/cholesky_factor_free.hpp b/stan/math/prim/constraint/cholesky_factor_free.hpp similarity index 94% rename from stan/math/prim/fun/cholesky_factor_free.hpp rename to stan/math/prim/constraint/cholesky_factor_free.hpp index 0cc4185a3fc..9077f7b8829 100644 --- a/stan/math/prim/fun/cholesky_factor_free.hpp +++ b/stan/math/prim/constraint/cholesky_factor_free.hpp @@ -1,5 +1,5 @@ -#ifndef STAN_MATH_PRIM_FUN_CHOLESKY_FACTOR_FREE_HPP -#define STAN_MATH_PRIM_FUN_CHOLESKY_FACTOR_FREE_HPP +#ifndef STAN_MATH_PRIM_CONSTRAINT_CHOLESKY_FACTOR_FREE_HPP +#define STAN_MATH_PRIM_CONSTRAINT_CHOLESKY_FACTOR_FREE_HPP #include #include diff --git a/stan/math/prim/fun/corr_constrain.hpp b/stan/math/prim/constraint/corr_constrain.hpp similarity index 95% rename from stan/math/prim/fun/corr_constrain.hpp rename to stan/math/prim/constraint/corr_constrain.hpp index 277846b6ffc..fcbad5125ce 100644 --- a/stan/math/prim/fun/corr_constrain.hpp +++ b/stan/math/prim/constraint/corr_constrain.hpp @@ -1,5 +1,5 @@ -#ifndef STAN_MATH_PRIM_FUN_CORR_CONSTRAIN_HPP -#define STAN_MATH_PRIM_FUN_CORR_CONSTRAIN_HPP +#ifndef STAN_MATH_PRIM_CONSTRAINT_CORR_CONSTRAIN_HPP +#define STAN_MATH_PRIM_CONSTRAINT_CORR_CONSTRAIN_HPP #include #include diff --git a/stan/math/prim/fun/corr_free.hpp b/stan/math/prim/constraint/corr_free.hpp similarity index 89% rename from stan/math/prim/fun/corr_free.hpp rename to stan/math/prim/constraint/corr_free.hpp index a5b4065d0e3..b76d7f96a2b 100644 --- a/stan/math/prim/fun/corr_free.hpp +++ b/stan/math/prim/constraint/corr_free.hpp @@ -1,5 +1,5 @@ -#ifndef STAN_MATH_PRIM_FUN_CORR_FREE_HPP -#define STAN_MATH_PRIM_FUN_CORR_FREE_HPP +#ifndef STAN_MATH_PRIM_CONSTRAINT_CORR_FREE_HPP +#define STAN_MATH_PRIM_CONSTRAINT_CORR_FREE_HPP #include #include diff --git a/stan/math/prim/fun/corr_matrix_constrain.hpp b/stan/math/prim/constraint/corr_matrix_constrain.hpp similarity index 97% rename from stan/math/prim/fun/corr_matrix_constrain.hpp rename to stan/math/prim/constraint/corr_matrix_constrain.hpp index cbe8fc6cc25..b556adcb988 100644 --- a/stan/math/prim/fun/corr_matrix_constrain.hpp +++ b/stan/math/prim/constraint/corr_matrix_constrain.hpp @@ -1,10 +1,10 @@ -#ifndef STAN_MATH_PRIM_FUN_CORR_MATRIX_CONSTRAIN_HPP -#define STAN_MATH_PRIM_FUN_CORR_MATRIX_CONSTRAIN_HPP +#ifndef STAN_MATH_PRIM_CONSTRAINT_CORR_MATRIX_CONSTRAIN_HPP +#define STAN_MATH_PRIM_CONSTRAINT_CORR_MATRIX_CONSTRAIN_HPP #include #include #include -#include +#include #include #include diff --git a/stan/math/prim/fun/corr_matrix_free.hpp b/stan/math/prim/constraint/corr_matrix_free.hpp similarity index 95% rename from stan/math/prim/fun/corr_matrix_free.hpp rename to stan/math/prim/constraint/corr_matrix_free.hpp index 3a0242ab257..81c0630dd50 100644 --- a/stan/math/prim/fun/corr_matrix_free.hpp +++ b/stan/math/prim/constraint/corr_matrix_free.hpp @@ -1,5 +1,5 @@ -#ifndef STAN_MATH_PRIM_FUN_CORR_MATRIX_FREE_HPP -#define STAN_MATH_PRIM_FUN_CORR_MATRIX_FREE_HPP +#ifndef STAN_MATH_PRIM_CONSTRAINT_CORR_MATRIX_FREE_HPP +#define STAN_MATH_PRIM_CONSTRAINT_CORR_MATRIX_FREE_HPP #include #include diff --git a/stan/math/prim/fun/cov_matrix_constrain.hpp b/stan/math/prim/constraint/cov_matrix_constrain.hpp similarity index 98% rename from stan/math/prim/fun/cov_matrix_constrain.hpp rename to stan/math/prim/constraint/cov_matrix_constrain.hpp index 6b761b10000..46083c3aeb2 100644 --- a/stan/math/prim/fun/cov_matrix_constrain.hpp +++ b/stan/math/prim/constraint/cov_matrix_constrain.hpp @@ -1,5 +1,5 @@ -#ifndef STAN_MATH_PRIM_FUN_COV_MATRIX_CONSTRAIN_HPP -#define STAN_MATH_PRIM_FUN_COV_MATRIX_CONSTRAIN_HPP +#ifndef STAN_MATH_PRIM_CONSTRAINT_COV_MATRIX_CONSTRAIN_HPP +#define STAN_MATH_PRIM_CONSTRAINT_COV_MATRIX_CONSTRAIN_HPP #include #include diff --git a/stan/math/prim/fun/cov_matrix_constrain_lkj.hpp b/stan/math/prim/constraint/cov_matrix_constrain_lkj.hpp similarity index 95% rename from stan/math/prim/fun/cov_matrix_constrain_lkj.hpp rename to stan/math/prim/constraint/cov_matrix_constrain_lkj.hpp index a74bbc0844d..c5605cdd43d 100644 --- a/stan/math/prim/fun/cov_matrix_constrain_lkj.hpp +++ b/stan/math/prim/constraint/cov_matrix_constrain_lkj.hpp @@ -1,9 +1,9 @@ -#ifndef STAN_MATH_PRIM_FUN_COV_MATRIX_CONSTRAIN_LKJ_HPP -#define STAN_MATH_PRIM_FUN_COV_MATRIX_CONSTRAIN_LKJ_HPP +#ifndef STAN_MATH_PRIM_CONSTRAINT_COV_MATRIX_CONSTRAIN_LKJ_HPP +#define STAN_MATH_PRIM_CONSTRAINT_COV_MATRIX_CONSTRAIN_LKJ_HPP #include -#include -#include +#include +#include #include #include diff --git a/stan/math/prim/fun/cov_matrix_free.hpp b/stan/math/prim/constraint/cov_matrix_free.hpp similarity index 95% rename from stan/math/prim/fun/cov_matrix_free.hpp rename to stan/math/prim/constraint/cov_matrix_free.hpp index a507655bf28..1a5ad30c4e5 100644 --- a/stan/math/prim/fun/cov_matrix_free.hpp +++ b/stan/math/prim/constraint/cov_matrix_free.hpp @@ -1,5 +1,5 @@ -#ifndef STAN_MATH_PRIM_FUN_COV_MATRIX_FREE_HPP -#define STAN_MATH_PRIM_FUN_COV_MATRIX_FREE_HPP +#ifndef STAN_MATH_PRIM_CONSTRAINT_COV_MATRIX_FREE_HPP +#define STAN_MATH_PRIM_CONSTRAINT_COV_MATRIX_FREE_HPP #include #include diff --git a/stan/math/prim/fun/cov_matrix_free_lkj.hpp b/stan/math/prim/constraint/cov_matrix_free_lkj.hpp similarity index 95% rename from stan/math/prim/fun/cov_matrix_free_lkj.hpp rename to stan/math/prim/constraint/cov_matrix_free_lkj.hpp index 81c16068813..b0d6c94f7a8 100644 --- a/stan/math/prim/fun/cov_matrix_free_lkj.hpp +++ b/stan/math/prim/constraint/cov_matrix_free_lkj.hpp @@ -1,5 +1,5 @@ -#ifndef STAN_MATH_PRIM_FUN_COV_MATRIX_FREE_LKJ_HPP -#define STAN_MATH_PRIM_FUN_COV_MATRIX_FREE_LKJ_HPP +#ifndef STAN_MATH_PRIM_CONSTRAINT_COV_MATRIX_FREE_LKJ_HPP +#define STAN_MATH_PRIM_CONSTRAINT_COV_MATRIX_FREE_LKJ_HPP #include #include diff --git a/stan/math/prim/fun/identity_constrain.hpp b/stan/math/prim/constraint/identity_constrain.hpp similarity index 87% rename from stan/math/prim/fun/identity_constrain.hpp rename to stan/math/prim/constraint/identity_constrain.hpp index 86b1e294388..00590438700 100644 --- a/stan/math/prim/fun/identity_constrain.hpp +++ b/stan/math/prim/constraint/identity_constrain.hpp @@ -1,5 +1,5 @@ -#ifndef STAN_MATH_PRIM_FUN_IDENTITY_CONSTRAIN_HPP -#define STAN_MATH_PRIM_FUN_IDENTITY_CONSTRAIN_HPP +#ifndef STAN_MATH_PRIM_CONSTRAINT_IDENTITY_CONSTRAIN_HPP +#define STAN_MATH_PRIM_CONSTRAINT_IDENTITY_CONSTRAIN_HPP #include diff --git a/stan/math/prim/fun/identity_free.hpp b/stan/math/prim/constraint/identity_free.hpp similarity index 86% rename from stan/math/prim/fun/identity_free.hpp rename to stan/math/prim/constraint/identity_free.hpp index 0652ac11e24..ef5925c2355 100644 --- a/stan/math/prim/fun/identity_free.hpp +++ b/stan/math/prim/constraint/identity_free.hpp @@ -1,5 +1,5 @@ -#ifndef STAN_MATH_PRIM_FUN_IDENTITY_FREE_HPP -#define STAN_MATH_PRIM_FUN_IDENTITY_FREE_HPP +#ifndef STAN_MATH_PRIM_CONSTRAINT_IDENTITY_FREE_HPP +#define STAN_MATH_PRIM_CONSTRAINT_IDENTITY_FREE_HPP #include diff --git a/stan/math/prim/fun/lb_constrain.hpp b/stan/math/prim/constraint/lb_constrain.hpp similarity index 97% rename from stan/math/prim/fun/lb_constrain.hpp rename to stan/math/prim/constraint/lb_constrain.hpp index f31da80cfbf..3df5ce62107 100644 --- a/stan/math/prim/fun/lb_constrain.hpp +++ b/stan/math/prim/constraint/lb_constrain.hpp @@ -1,11 +1,11 @@ -#ifndef STAN_MATH_PRIM_FUN_LB_CONSTRAIN_HPP -#define STAN_MATH_PRIM_FUN_LB_CONSTRAIN_HPP +#ifndef STAN_MATH_PRIM_CONSTRAINT_LB_CONSTRAIN_HPP +#define STAN_MATH_PRIM_CONSTRAINT_LB_CONSTRAIN_HPP #include #include #include -#include -#include +#include +#include #include #include #include diff --git a/stan/math/prim/fun/lb_free.hpp b/stan/math/prim/constraint/lb_free.hpp similarity index 96% rename from stan/math/prim/fun/lb_free.hpp rename to stan/math/prim/constraint/lb_free.hpp index 9e1ee605ebf..f5e80d700e6 100644 --- a/stan/math/prim/fun/lb_free.hpp +++ b/stan/math/prim/constraint/lb_free.hpp @@ -1,10 +1,10 @@ -#ifndef STAN_MATH_PRIM_FUN_LB_FREE_HPP -#define STAN_MATH_PRIM_FUN_LB_FREE_HPP +#ifndef STAN_MATH_PRIM_CONSTRAINT_LB_FREE_HPP +#define STAN_MATH_PRIM_CONSTRAINT_LB_FREE_HPP #include #include #include -#include +#include #include #include #include diff --git a/stan/math/prim/fun/lub_constrain.hpp b/stan/math/prim/constraint/lub_constrain.hpp similarity index 98% rename from stan/math/prim/fun/lub_constrain.hpp rename to stan/math/prim/constraint/lub_constrain.hpp index a3e91883f51..ea186fa240f 100644 --- a/stan/math/prim/fun/lub_constrain.hpp +++ b/stan/math/prim/constraint/lub_constrain.hpp @@ -1,21 +1,21 @@ -#ifndef STAN_MATH_PRIM_FUN_LUB_CONSTRAIN_HPP -#define STAN_MATH_PRIM_FUN_LUB_CONSTRAIN_HPP +#ifndef STAN_MATH_PRIM_CONSTRAINT_LUB_CONSTRAIN_HPP +#define STAN_MATH_PRIM_CONSTRAINT_LUB_CONSTRAIN_HPP +#include +#include +#include #include #include #include #include #include #include -#include #include #include #include -#include #include #include #include -#include #include namespace stan { diff --git a/stan/math/prim/fun/lub_free.hpp b/stan/math/prim/constraint/lub_free.hpp similarity index 96% rename from stan/math/prim/fun/lub_free.hpp rename to stan/math/prim/constraint/lub_free.hpp index c4876cbcd6d..23afee1c60d 100644 --- a/stan/math/prim/fun/lub_free.hpp +++ b/stan/math/prim/constraint/lub_free.hpp @@ -1,13 +1,13 @@ -#ifndef STAN_MATH_PRIM_FUN_LUB_FREE_HPP -#define STAN_MATH_PRIM_FUN_LUB_FREE_HPP +#ifndef STAN_MATH_PRIM_CONSTRAINT_LUB_FREE_HPP +#define STAN_MATH_PRIM_CONSTRAINT_LUB_FREE_HPP #include #include #include #include #include -#include -#include +#include +#include #include namespace stan { diff --git a/stan/math/prim/fun/offset_multiplier_constrain.hpp b/stan/math/prim/constraint/offset_multiplier_constrain.hpp similarity index 98% rename from stan/math/prim/fun/offset_multiplier_constrain.hpp rename to stan/math/prim/constraint/offset_multiplier_constrain.hpp index 85a58ce4771..a226ae2e15f 100644 --- a/stan/math/prim/fun/offset_multiplier_constrain.hpp +++ b/stan/math/prim/constraint/offset_multiplier_constrain.hpp @@ -1,10 +1,10 @@ -#ifndef STAN_MATH_PRIM_FUN_OFFSET_MULTIPLIER_CONSTRAIN_HPP -#define STAN_MATH_PRIM_FUN_OFFSET_MULTIPLIER_CONSTRAIN_HPP +#ifndef STAN_MATH_PRIM_CONSTRAINT_OFFSET_MULTIPLIER_CONSTRAIN_HPP +#define STAN_MATH_PRIM_CONSTRAINT_OFFSET_MULTIPLIER_CONSTRAIN_HPP #include #include #include -#include +#include #include #include #include diff --git a/stan/math/prim/fun/offset_multiplier_free.hpp b/stan/math/prim/constraint/offset_multiplier_free.hpp similarity index 96% rename from stan/math/prim/fun/offset_multiplier_free.hpp rename to stan/math/prim/constraint/offset_multiplier_free.hpp index e0fe927330e..becf0e0d6b5 100644 --- a/stan/math/prim/fun/offset_multiplier_free.hpp +++ b/stan/math/prim/constraint/offset_multiplier_free.hpp @@ -1,9 +1,9 @@ -#ifndef STAN_MATH_PRIM_FUN_OFFSET_MULTIPLIER_FREE_HPP -#define STAN_MATH_PRIM_FUN_OFFSET_MULTIPLIER_FREE_HPP +#ifndef STAN_MATH_PRIM_CONSTRAINT_OFFSET_MULTIPLIER_FREE_HPP +#define STAN_MATH_PRIM_CONSTRAINT_OFFSET_MULTIPLIER_FREE_HPP #include #include -#include +#include #include #include #include diff --git a/stan/math/prim/fun/ordered_constrain.hpp b/stan/math/prim/constraint/ordered_constrain.hpp similarity index 97% rename from stan/math/prim/fun/ordered_constrain.hpp rename to stan/math/prim/constraint/ordered_constrain.hpp index ac0c18ca74d..91a75c2f1fd 100644 --- a/stan/math/prim/fun/ordered_constrain.hpp +++ b/stan/math/prim/constraint/ordered_constrain.hpp @@ -1,5 +1,5 @@ -#ifndef STAN_MATH_PRIM_FUN_ORDERED_CONSTRAIN_HPP -#define STAN_MATH_PRIM_FUN_ORDERED_CONSTRAIN_HPP +#ifndef STAN_MATH_PRIM_CONSTRAINT_ORDERED_CONSTRAIN_HPP +#define STAN_MATH_PRIM_CONSTRAINT_ORDERED_CONSTRAIN_HPP #include #include diff --git a/stan/math/prim/fun/ordered_free.hpp b/stan/math/prim/constraint/ordered_free.hpp similarity index 94% rename from stan/math/prim/fun/ordered_free.hpp rename to stan/math/prim/constraint/ordered_free.hpp index 4764bceb6a8..b8fbc46624c 100644 --- a/stan/math/prim/fun/ordered_free.hpp +++ b/stan/math/prim/constraint/ordered_free.hpp @@ -1,5 +1,5 @@ -#ifndef STAN_MATH_PRIM_FUN_ORDERED_FREE_HPP -#define STAN_MATH_PRIM_FUN_ORDERED_FREE_HPP +#ifndef STAN_MATH_PRIM_CONSTRAINT_ORDERED_FREE_HPP +#define STAN_MATH_PRIM_CONSTRAINT_ORDERED_FREE_HPP #include #include diff --git a/stan/math/prim/fun/positive_constrain.hpp b/stan/math/prim/constraint/positive_constrain.hpp similarity index 96% rename from stan/math/prim/fun/positive_constrain.hpp rename to stan/math/prim/constraint/positive_constrain.hpp index b6d46129c42..dc52cfb57f0 100644 --- a/stan/math/prim/fun/positive_constrain.hpp +++ b/stan/math/prim/constraint/positive_constrain.hpp @@ -1,5 +1,5 @@ -#ifndef STAN_MATH_PRIM_FUN_POSITIVE_CONSTRAIN_HPP -#define STAN_MATH_PRIM_FUN_POSITIVE_CONSTRAIN_HPP +#ifndef STAN_MATH_PRIM_CONSTRAINT_POSITIVE_CONSTRAIN_HPP +#define STAN_MATH_PRIM_CONSTRAINT_POSITIVE_CONSTRAIN_HPP #include #include diff --git a/stan/math/prim/fun/positive_free.hpp b/stan/math/prim/constraint/positive_free.hpp similarity index 89% rename from stan/math/prim/fun/positive_free.hpp rename to stan/math/prim/constraint/positive_free.hpp index af18b5e0119..4317fdfa70c 100644 --- a/stan/math/prim/fun/positive_free.hpp +++ b/stan/math/prim/constraint/positive_free.hpp @@ -1,5 +1,5 @@ -#ifndef STAN_MATH_PRIM_FUN_POSITIVE_FREE_HPP -#define STAN_MATH_PRIM_FUN_POSITIVE_FREE_HPP +#ifndef STAN_MATH_PRIM_CONSTRAINT_POSITIVE_FREE_HPP +#define STAN_MATH_PRIM_CONSTRAINT_POSITIVE_FREE_HPP #include #include diff --git a/stan/math/prim/fun/positive_ordered_constrain.hpp b/stan/math/prim/constraint/positive_ordered_constrain.hpp similarity index 96% rename from stan/math/prim/fun/positive_ordered_constrain.hpp rename to stan/math/prim/constraint/positive_ordered_constrain.hpp index f3f0adf1fcf..30ab958209f 100644 --- a/stan/math/prim/fun/positive_ordered_constrain.hpp +++ b/stan/math/prim/constraint/positive_ordered_constrain.hpp @@ -1,5 +1,5 @@ -#ifndef STAN_MATH_PRIM_FUN_POSITIVE_ORDERED_CONSTRAIN_HPP -#define STAN_MATH_PRIM_FUN_POSITIVE_ORDERED_CONSTRAIN_HPP +#ifndef STAN_MATH_PRIM_CONSTRAINT_POSITIVE_ORDERED_CONSTRAIN_HPP +#define STAN_MATH_PRIM_CONSTRAINT_POSITIVE_ORDERED_CONSTRAIN_HPP #include #include diff --git a/stan/math/prim/fun/positive_ordered_free.hpp b/stan/math/prim/constraint/positive_ordered_free.hpp similarity index 93% rename from stan/math/prim/fun/positive_ordered_free.hpp rename to stan/math/prim/constraint/positive_ordered_free.hpp index c627f03ec5c..408b0922650 100644 --- a/stan/math/prim/fun/positive_ordered_free.hpp +++ b/stan/math/prim/constraint/positive_ordered_free.hpp @@ -1,5 +1,5 @@ -#ifndef STAN_MATH_PRIM_FUN_POSITIVE_ORDERED_FREE_HPP -#define STAN_MATH_PRIM_FUN_POSITIVE_ORDERED_FREE_HPP +#ifndef STAN_MATH_PRIM_CONSTRAINT_POSITIVE_ORDERED_FREE_HPP +#define STAN_MATH_PRIM_CONSTRAINT_POSITIVE_ORDERED_FREE_HPP #include #include diff --git a/stan/math/prim/fun/prob_constrain.hpp b/stan/math/prim/constraint/prob_constrain.hpp similarity index 95% rename from stan/math/prim/fun/prob_constrain.hpp rename to stan/math/prim/constraint/prob_constrain.hpp index 0ed4ee605aa..d05193c8648 100644 --- a/stan/math/prim/fun/prob_constrain.hpp +++ b/stan/math/prim/constraint/prob_constrain.hpp @@ -1,5 +1,5 @@ -#ifndef STAN_MATH_PRIM_FUN_PROB_CONSTRAIN_HPP -#define STAN_MATH_PRIM_FUN_PROB_CONSTRAIN_HPP +#ifndef STAN_MATH_PRIM_CONSTRAINT_PROB_CONSTRAIN_HPP +#define STAN_MATH_PRIM_CONSTRAINT_PROB_CONSTRAIN_HPP #include #include diff --git a/stan/math/prim/fun/prob_free.hpp b/stan/math/prim/constraint/prob_free.hpp similarity index 89% rename from stan/math/prim/fun/prob_free.hpp rename to stan/math/prim/constraint/prob_free.hpp index debefb5efb5..0f980ab87cd 100644 --- a/stan/math/prim/fun/prob_free.hpp +++ b/stan/math/prim/constraint/prob_free.hpp @@ -1,5 +1,5 @@ -#ifndef STAN_MATH_PRIM_FUN_PROB_FREE_HPP -#define STAN_MATH_PRIM_FUN_PROB_FREE_HPP +#ifndef STAN_MATH_PRIM_CONSTRAINT_PROB_FREE_HPP +#define STAN_MATH_PRIM_CONSTRAINT_PROB_FREE_HPP #include #include diff --git a/stan/math/prim/fun/simplex_constrain.hpp b/stan/math/prim/constraint/simplex_constrain.hpp similarity index 97% rename from stan/math/prim/fun/simplex_constrain.hpp rename to stan/math/prim/constraint/simplex_constrain.hpp index cd10e93d587..b92c65779ee 100644 --- a/stan/math/prim/fun/simplex_constrain.hpp +++ b/stan/math/prim/constraint/simplex_constrain.hpp @@ -1,5 +1,5 @@ -#ifndef STAN_MATH_PRIM_FUN_SIMPLEX_CONSTRAIN_HPP -#define STAN_MATH_PRIM_FUN_SIMPLEX_CONSTRAIN_HPP +#ifndef STAN_MATH_PRIM_CONSTRAINT_SIMPLEX_CONSTRAIN_HPP +#define STAN_MATH_PRIM_CONSTRAINT_SIMPLEX_CONSTRAIN_HPP #include #include diff --git a/stan/math/prim/fun/simplex_free.hpp b/stan/math/prim/constraint/simplex_free.hpp similarity index 95% rename from stan/math/prim/fun/simplex_free.hpp rename to stan/math/prim/constraint/simplex_free.hpp index 39487a0cae0..f3bb6195b7c 100644 --- a/stan/math/prim/fun/simplex_free.hpp +++ b/stan/math/prim/constraint/simplex_free.hpp @@ -1,5 +1,5 @@ -#ifndef STAN_MATH_PRIM_FUN_SIMPLEX_FREE_HPP -#define STAN_MATH_PRIM_FUN_SIMPLEX_FREE_HPP +#ifndef STAN_MATH_PRIM_CONSTRAINT_SIMPLEX_FREE_HPP +#define STAN_MATH_PRIM_CONSTRAINT_SIMPLEX_FREE_HPP #include #include diff --git a/stan/math/prim/fun/stochastic_column_constrain.hpp b/stan/math/prim/constraint/stochastic_column_constrain.hpp similarity index 95% rename from stan/math/prim/fun/stochastic_column_constrain.hpp rename to stan/math/prim/constraint/stochastic_column_constrain.hpp index 8ed66883579..42c4f87d3b8 100644 --- a/stan/math/prim/fun/stochastic_column_constrain.hpp +++ b/stan/math/prim/constraint/stochastic_column_constrain.hpp @@ -1,5 +1,5 @@ -#ifndef STAN_MATH_PRIM_FUN_SIMPLEX_COLUMN_CONSTRAIN_HPP -#define STAN_MATH_PRIM_FUN_SIMPLEX_COLUMN_CONSTRAIN_HPP +#ifndef STAN_MATH_PRIM_CONSTRAINT_SIMPLEX_COLUMN_CONSTRAIN_HPP +#define STAN_MATH_PRIM_CONSTRAINT_SIMPLEX_COLUMN_CONSTRAIN_HPP #include #include @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include namespace stan { diff --git a/stan/math/prim/fun/stochastic_column_free.hpp b/stan/math/prim/constraint/stochastic_column_free.hpp similarity index 88% rename from stan/math/prim/fun/stochastic_column_free.hpp rename to stan/math/prim/constraint/stochastic_column_free.hpp index b7a69fced25..fa4d2a43449 100644 --- a/stan/math/prim/fun/stochastic_column_free.hpp +++ b/stan/math/prim/constraint/stochastic_column_free.hpp @@ -1,9 +1,9 @@ -#ifndef STAN_MATH_PRIM_FUN_STOCHASTIC_COLUMN_FREE_HPP -#define STAN_MATH_PRIM_FUN_STOCHASTIC_COLUMN_FREE_HPP +#ifndef STAN_MATH_PRIM_CONSTRAINT_STOCHASTIC_COLUMN_FREE_HPP +#define STAN_MATH_PRIM_CONSTRAINT_STOCHASTIC_COLUMN_FREE_HPP #include #include -#include +#include namespace stan { namespace math { diff --git a/stan/math/prim/fun/stochastic_row_constrain.hpp b/stan/math/prim/constraint/stochastic_row_constrain.hpp similarity index 96% rename from stan/math/prim/fun/stochastic_row_constrain.hpp rename to stan/math/prim/constraint/stochastic_row_constrain.hpp index 7ea9306a933..d0f183f273a 100644 --- a/stan/math/prim/fun/stochastic_row_constrain.hpp +++ b/stan/math/prim/constraint/stochastic_row_constrain.hpp @@ -1,5 +1,5 @@ -#ifndef STAN_MATH_PRIM_FUN_STOCHASTIC_ROW_CONSTRAIN_HPP -#define STAN_MATH_PRIM_FUN_STOCHASTIC_ROW_CONSTRAIN_HPP +#ifndef STAN_MATH_PRIM_CONSTRAINT_STOCHASTIC_ROW_CONSTRAIN_HPP +#define STAN_MATH_PRIM_CONSTRAINT_STOCHASTIC_ROW_CONSTRAIN_HPP #include #include @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include namespace stan { diff --git a/stan/math/prim/fun/stochastic_row_free.hpp b/stan/math/prim/constraint/stochastic_row_free.hpp similarity index 89% rename from stan/math/prim/fun/stochastic_row_free.hpp rename to stan/math/prim/constraint/stochastic_row_free.hpp index 7fa255b9949..82ad3e3ea92 100644 --- a/stan/math/prim/fun/stochastic_row_free.hpp +++ b/stan/math/prim/constraint/stochastic_row_free.hpp @@ -1,9 +1,9 @@ -#ifndef STAN_MATH_PRIM_FUN_STOCHASTIC_ROW_FREE_HPP -#define STAN_MATH_PRIM_FUN_STOCHASTIC_ROW_FREE_HPP +#ifndef STAN_MATH_PRIM_CONSTRAINT_STOCHASTIC_ROW_FREE_HPP +#define STAN_MATH_PRIM_CONSTRAINT_STOCHASTIC_ROW_FREE_HPP #include #include -#include +#include namespace stan { namespace math { diff --git a/stan/math/prim/fun/ub_constrain.hpp b/stan/math/prim/constraint/ub_constrain.hpp similarity index 97% rename from stan/math/prim/fun/ub_constrain.hpp rename to stan/math/prim/constraint/ub_constrain.hpp index f753f744b52..2c523e9ff47 100644 --- a/stan/math/prim/fun/ub_constrain.hpp +++ b/stan/math/prim/constraint/ub_constrain.hpp @@ -1,12 +1,12 @@ -#ifndef STAN_MATH_PRIM_FUN_UB_CONSTRAIN_HPP -#define STAN_MATH_PRIM_FUN_UB_CONSTRAIN_HPP +#ifndef STAN_MATH_PRIM_CONSTRAINT_UB_CONSTRAIN_HPP +#define STAN_MATH_PRIM_CONSTRAINT_UB_CONSTRAIN_HPP #include #include #include #include -#include -#include +#include +#include #include #include #include diff --git a/stan/math/prim/fun/ub_free.hpp b/stan/math/prim/constraint/ub_free.hpp similarity index 96% rename from stan/math/prim/fun/ub_free.hpp rename to stan/math/prim/constraint/ub_free.hpp index 4c58f475a7d..05a3acce775 100644 --- a/stan/math/prim/fun/ub_free.hpp +++ b/stan/math/prim/constraint/ub_free.hpp @@ -1,10 +1,10 @@ -#ifndef STAN_MATH_PRIM_FUN_UB_FREE_HPP -#define STAN_MATH_PRIM_FUN_UB_FREE_HPP +#ifndef STAN_MATH_PRIM_CONSTRAINT_UB_FREE_HPP +#define STAN_MATH_PRIM_CONSTRAINT_UB_FREE_HPP #include #include #include -#include +#include #include #include diff --git a/stan/math/prim/fun/unit_vector_constrain.hpp b/stan/math/prim/constraint/unit_vector_constrain.hpp similarity index 97% rename from stan/math/prim/fun/unit_vector_constrain.hpp rename to stan/math/prim/constraint/unit_vector_constrain.hpp index 7239c765f56..19ccfae39a3 100644 --- a/stan/math/prim/fun/unit_vector_constrain.hpp +++ b/stan/math/prim/constraint/unit_vector_constrain.hpp @@ -1,5 +1,5 @@ -#ifndef STAN_MATH_PRIM_FUN_UNIT_VECTOR_CONSTRAIN_HPP -#define STAN_MATH_PRIM_FUN_UNIT_VECTOR_CONSTRAIN_HPP +#ifndef STAN_MATH_PRIM_CONSTRAINT_UNIT_VECTOR_CONSTRAIN_HPP +#define STAN_MATH_PRIM_CONSTRAINT_UNIT_VECTOR_CONSTRAIN_HPP #include #include diff --git a/stan/math/prim/fun/unit_vector_free.hpp b/stan/math/prim/constraint/unit_vector_free.hpp similarity index 92% rename from stan/math/prim/fun/unit_vector_free.hpp rename to stan/math/prim/constraint/unit_vector_free.hpp index 870e30e6b35..9f7d39e61ac 100644 --- a/stan/math/prim/fun/unit_vector_free.hpp +++ b/stan/math/prim/constraint/unit_vector_free.hpp @@ -1,5 +1,5 @@ -#ifndef STAN_MATH_PRIM_FUN_UNIT_VECTOR_FREE_HPP -#define STAN_MATH_PRIM_FUN_UNIT_VECTOR_FREE_HPP +#ifndef STAN_MATH_PRIM_CONSTRAINT_UNIT_VECTOR_FREE_HPP +#define STAN_MATH_PRIM_CONSTRAINT_UNIT_VECTOR_FREE_HPP #include #include diff --git a/stan/math/prim/fun.hpp b/stan/math/prim/fun.hpp index 80ee52d4fe7..8a82bb97925 100644 --- a/stan/math/prim/fun.hpp +++ b/stan/math/prim/fun.hpp @@ -38,11 +38,7 @@ #include #include #include -#include -#include #include -#include -#include #include #include #include @@ -52,17 +48,9 @@ #include #include #include -#include -#include -#include -#include #include #include #include -#include -#include -#include -#include #include #include #include @@ -139,8 +127,6 @@ #include #include #include -#include -#include #include #include #include @@ -169,8 +155,6 @@ #include #include #include -#include -#include #include #include #include @@ -213,8 +197,6 @@ #include #include #include -#include -#include #include #include #include @@ -245,8 +227,6 @@ #include #include #include -#include -#include #include #include #include @@ -255,22 +235,14 @@ #include #include #include -#include -#include #include #include #include #include #include #include -#include -#include -#include -#include #include #include -#include -#include #include #include #include @@ -315,8 +287,6 @@ #include #include #include -#include -#include #include #include #include @@ -334,10 +304,6 @@ #include #include #include -#include -#include -#include -#include #include #include #include @@ -369,12 +335,8 @@ #include #include #include -#include -#include #include #include -#include -#include #include #include #include diff --git a/stan/math/rev.hpp b/stan/math/rev.hpp index 91d374eb12d..e89df411728 100644 --- a/stan/math/rev.hpp +++ b/stan/math/rev.hpp @@ -5,8 +5,10 @@ #ifdef STAN_OPENCL #include +#include #endif +#include #include #include #include diff --git a/stan/math/rev/constraint.hpp b/stan/math/rev/constraint.hpp new file mode 100644 index 00000000000..9bebfdf9553 --- /dev/null +++ b/stan/math/rev/constraint.hpp @@ -0,0 +1,26 @@ +#ifndef STAN_MATH_REV_CONSTRAINT_HPP +#define STAN_MATH_REV_CONSTRAINT_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#endif diff --git a/stan/math/rev/fun/cholesky_corr_constrain.hpp b/stan/math/rev/constraint/cholesky_corr_constrain.hpp similarity index 96% rename from stan/math/rev/fun/cholesky_corr_constrain.hpp rename to stan/math/rev/constraint/cholesky_corr_constrain.hpp index f65c32c4770..e61fcbc5cbd 100644 --- a/stan/math/rev/fun/cholesky_corr_constrain.hpp +++ b/stan/math/rev/constraint/cholesky_corr_constrain.hpp @@ -1,5 +1,5 @@ -#ifndef STAN_MATH_REV_FUN_CHOLESKY_CORR_CONSTRAIN_HPP -#define STAN_MATH_REV_FUN_CHOLESKY_CORR_CONSTRAIN_HPP +#ifndef STAN_MATH_REV_CONSTRAINT_CHOLESKY_CORR_CONSTRAIN_HPP +#define STAN_MATH_REV_CONSTRAINT_CHOLESKY_CORR_CONSTRAIN_HPP #include #include @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include namespace stan { diff --git a/stan/math/rev/fun/cholesky_factor_constrain.hpp b/stan/math/rev/constraint/cholesky_factor_constrain.hpp similarity index 96% rename from stan/math/rev/fun/cholesky_factor_constrain.hpp rename to stan/math/rev/constraint/cholesky_factor_constrain.hpp index 3cc96382180..17d18d7ee0e 100644 --- a/stan/math/rev/fun/cholesky_factor_constrain.hpp +++ b/stan/math/rev/constraint/cholesky_factor_constrain.hpp @@ -1,5 +1,5 @@ -#ifndef STAN_MATH_REV_FUN_CHOLESKY_FACTOR_CONSTRAIN_HPP -#define STAN_MATH_REV_FUN_CHOLESKY_FACTOR_CONSTRAIN_HPP +#ifndef STAN_MATH_REV_CONSTRAINT_CHOLESKY_FACTOR_CONSTRAIN_HPP +#define STAN_MATH_REV_CONSTRAINT_CHOLESKY_FACTOR_CONSTRAIN_HPP #include #include diff --git a/stan/math/rev/fun/corr_matrix_constrain.hpp b/stan/math/rev/constraint/corr_matrix_constrain.hpp similarity index 94% rename from stan/math/rev/fun/corr_matrix_constrain.hpp rename to stan/math/rev/constraint/corr_matrix_constrain.hpp index f28d7ed5e01..c3d1b8d2f7d 100644 --- a/stan/math/rev/fun/corr_matrix_constrain.hpp +++ b/stan/math/rev/constraint/corr_matrix_constrain.hpp @@ -1,11 +1,11 @@ -#ifndef STAN_MATH_REV_FUN_CORR_MATRIX_CONSTRAIN_HPP -#define STAN_MATH_REV_FUN_CORR_MATRIX_CONSTRAIN_HPP +#ifndef STAN_MATH_REV_CONSTRAINT_CORR_MATRIX_CONSTRAIN_HPP +#define STAN_MATH_REV_CONSTRAINT_CORR_MATRIX_CONSTRAIN_HPP #include #include #include #include -#include +#include #include #include diff --git a/stan/math/rev/fun/cov_matrix_constrain.hpp b/stan/math/rev/constraint/cov_matrix_constrain.hpp similarity index 97% rename from stan/math/rev/fun/cov_matrix_constrain.hpp rename to stan/math/rev/constraint/cov_matrix_constrain.hpp index f0e6eca08f5..ccf4ac496ba 100644 --- a/stan/math/rev/fun/cov_matrix_constrain.hpp +++ b/stan/math/rev/constraint/cov_matrix_constrain.hpp @@ -1,5 +1,5 @@ -#ifndef STAN_MATH_REV_FUN_COV_MATRIX_CONSTRAIN_HPP -#define STAN_MATH_REV_FUN_COV_MATRIX_CONSTRAIN_HPP +#ifndef STAN_MATH_REV_CONSTRAINT_COV_MATRIX_CONSTRAIN_HPP +#define STAN_MATH_REV_CONSTRAINT_COV_MATRIX_CONSTRAIN_HPP #include #include diff --git a/stan/math/rev/fun/cov_matrix_constrain_lkj.hpp b/stan/math/rev/constraint/cov_matrix_constrain_lkj.hpp similarity index 92% rename from stan/math/rev/fun/cov_matrix_constrain_lkj.hpp rename to stan/math/rev/constraint/cov_matrix_constrain_lkj.hpp index 29ef3a2b0fe..1e8d8ea3e8c 100644 --- a/stan/math/rev/fun/cov_matrix_constrain_lkj.hpp +++ b/stan/math/rev/constraint/cov_matrix_constrain_lkj.hpp @@ -1,10 +1,10 @@ -#ifndef STAN_MATH_REV_FUN_COV_MATRIX_CONSTRAIN_LKJ_HPP -#define STAN_MATH_REV_FUN_COV_MATRIX_CONSTRAIN_LKJ_HPP +#ifndef STAN_MATH_REV_CONSTRAINT_COV_MATRIX_CONSTRAIN_LKJ_HPP +#define STAN_MATH_REV_CONSTRAINT_COV_MATRIX_CONSTRAIN_LKJ_HPP #include #include -#include -#include +#include +#include #include #include diff --git a/stan/math/rev/fun/identity_constrain.hpp b/stan/math/rev/constraint/identity_constrain.hpp similarity index 87% rename from stan/math/rev/fun/identity_constrain.hpp rename to stan/math/rev/constraint/identity_constrain.hpp index 821aa441996..6d6bbff205c 100644 --- a/stan/math/rev/fun/identity_constrain.hpp +++ b/stan/math/rev/constraint/identity_constrain.hpp @@ -1,9 +1,9 @@ -#ifndef STAN_MATH_REV_FUN_IDENTITY_CONSTRAIN_HPP -#define STAN_MATH_REV_FUN_IDENTITY_CONSTRAIN_HPP +#ifndef STAN_MATH_REV_CONSTRAINT_IDENTITY_CONSTRAIN_HPP +#define STAN_MATH_REV_CONSTRAINT_IDENTITY_CONSTRAIN_HPP #include #include -#include +#include #include namespace stan { namespace math { diff --git a/stan/math/rev/fun/identity_free.hpp b/stan/math/rev/constraint/identity_free.hpp similarity index 80% rename from stan/math/rev/fun/identity_free.hpp rename to stan/math/rev/constraint/identity_free.hpp index 09fa323466c..596d52e6cdf 100644 --- a/stan/math/rev/fun/identity_free.hpp +++ b/stan/math/rev/constraint/identity_free.hpp @@ -1,8 +1,8 @@ -#ifndef STAN_MATH_REV_FUN_IDENTITY_CONSTRAIN_HPP -#define STAN_MATH_REV_FUN_IDENTITY_CONSTRAIN_HPP +#ifndef STAN_MATH_REV_CONSTRAINT_IDENTITY_CONSTRAIN_HPP +#define STAN_MATH_REV_CONSTRAINT_IDENTITY_CONSTRAIN_HPP #include -#include +#include #include namespace stan { diff --git a/stan/math/rev/fun/lb_constrain.hpp b/stan/math/rev/constraint/lb_constrain.hpp similarity index 98% rename from stan/math/rev/fun/lb_constrain.hpp rename to stan/math/rev/constraint/lb_constrain.hpp index 0bdad75a716..8f8da96afce 100644 --- a/stan/math/rev/fun/lb_constrain.hpp +++ b/stan/math/rev/constraint/lb_constrain.hpp @@ -1,15 +1,15 @@ -#ifndef STAN_MATH_REV_FUN_LB_CONSTRAIN_HPP -#define STAN_MATH_REV_FUN_LB_CONSTRAIN_HPP +#ifndef STAN_MATH_REV_CONSTRAINT_LB_CONSTRAIN_HPP +#define STAN_MATH_REV_CONSTRAINT_LB_CONSTRAIN_HPP #include #include #include #include -#include +#include #include #include -#include -#include +#include +#include #include #include #include diff --git a/stan/math/rev/fun/lub_constrain.hpp b/stan/math/rev/constraint/lub_constrain.hpp similarity index 99% rename from stan/math/rev/fun/lub_constrain.hpp rename to stan/math/rev/constraint/lub_constrain.hpp index ac54a675b8b..36715e4de95 100644 --- a/stan/math/rev/fun/lub_constrain.hpp +++ b/stan/math/rev/constraint/lub_constrain.hpp @@ -1,11 +1,11 @@ -#ifndef STAN_MATH_REV_FUN_LUB_CONSTRAIN_HPP -#define STAN_MATH_REV_FUN_LUB_CONSTRAIN_HPP +#ifndef STAN_MATH_REV_CONSTRAINT_LUB_CONSTRAIN_HPP +#define STAN_MATH_REV_CONSTRAINT_LUB_CONSTRAIN_HPP #include #include -#include -#include -#include +#include +#include +#include #include namespace stan { diff --git a/stan/math/rev/fun/ordered_constrain.hpp b/stan/math/rev/constraint/ordered_constrain.hpp similarity index 95% rename from stan/math/rev/fun/ordered_constrain.hpp rename to stan/math/rev/constraint/ordered_constrain.hpp index 3f10ab70e75..98b10919875 100644 --- a/stan/math/rev/fun/ordered_constrain.hpp +++ b/stan/math/rev/constraint/ordered_constrain.hpp @@ -1,5 +1,5 @@ -#ifndef STAN_MATH_REV_FUN_ORDERED_CONSTRAIN_HPP -#define STAN_MATH_REV_FUN_ORDERED_CONSTRAIN_HPP +#ifndef STAN_MATH_REV_CONSTRAINT_ORDERED_CONSTRAIN_HPP +#define STAN_MATH_REV_CONSTRAINT_ORDERED_CONSTRAIN_HPP #include #include diff --git a/stan/math/rev/fun/positive_ordered_constrain.hpp b/stan/math/rev/constraint/positive_ordered_constrain.hpp similarity index 92% rename from stan/math/rev/fun/positive_ordered_constrain.hpp rename to stan/math/rev/constraint/positive_ordered_constrain.hpp index 7c39d83a667..d5c6b02f9e9 100644 --- a/stan/math/rev/fun/positive_ordered_constrain.hpp +++ b/stan/math/rev/constraint/positive_ordered_constrain.hpp @@ -1,5 +1,5 @@ -#ifndef STAN_MATH_REV_FUN_POSITIVE_ORDERED_CONSTRAIN_HPP -#define STAN_MATH_REV_FUN_POSITIVE_ORDERED_CONSTRAIN_HPP +#ifndef STAN_MATH_REV_CONSTRAINT_POSITIVE_ORDERED_CONSTRAIN_HPP +#define STAN_MATH_REV_CONSTRAINT_POSITIVE_ORDERED_CONSTRAIN_HPP #include #include diff --git a/stan/math/rev/fun/simplex_constrain.hpp b/stan/math/rev/constraint/simplex_constrain.hpp similarity index 97% rename from stan/math/rev/fun/simplex_constrain.hpp rename to stan/math/rev/constraint/simplex_constrain.hpp index c7dd57788b8..e81cc53557d 100644 --- a/stan/math/rev/fun/simplex_constrain.hpp +++ b/stan/math/rev/constraint/simplex_constrain.hpp @@ -1,5 +1,5 @@ -#ifndef STAN_MATH_REV_FUN_SIMPLEX_CONSTRAIN_HPP -#define STAN_MATH_REV_FUN_SIMPLEX_CONSTRAIN_HPP +#ifndef STAN_MATH_REV_CONSTRAINT_SIMPLEX_CONSTRAIN_HPP +#define STAN_MATH_REV_CONSTRAINT_SIMPLEX_CONSTRAIN_HPP #include #include diff --git a/stan/math/rev/fun/stochastic_column_constrain.hpp b/stan/math/rev/constraint/stochastic_column_constrain.hpp similarity index 97% rename from stan/math/rev/fun/stochastic_column_constrain.hpp rename to stan/math/rev/constraint/stochastic_column_constrain.hpp index 3838e0d0f77..02970513ff2 100644 --- a/stan/math/rev/fun/stochastic_column_constrain.hpp +++ b/stan/math/rev/constraint/stochastic_column_constrain.hpp @@ -1,5 +1,5 @@ -#ifndef STAN_MATH_REV_FUN_STOCHASTIC_COLUMN_CONSTRAIN_HPP -#define STAN_MATH_REV_FUN_STOCHASTIC_COLUMN_CONSTRAIN_HPP +#ifndef STAN_MATH_REV_CONSTRAINT_STOCHASTIC_COLUMN_CONSTRAIN_HPP +#define STAN_MATH_REV_CONSTRAINT_STOCHASTIC_COLUMN_CONSTRAIN_HPP #include #include diff --git a/stan/math/rev/fun/stochastic_row_constrain.hpp b/stan/math/rev/constraint/stochastic_row_constrain.hpp similarity index 97% rename from stan/math/rev/fun/stochastic_row_constrain.hpp rename to stan/math/rev/constraint/stochastic_row_constrain.hpp index 98f6781a1c3..654681107a7 100644 --- a/stan/math/rev/fun/stochastic_row_constrain.hpp +++ b/stan/math/rev/constraint/stochastic_row_constrain.hpp @@ -1,5 +1,5 @@ -#ifndef STAN_MATH_REV_FUN_STOCHASTIC_ROW_CONSTRAIN_HPP -#define STAN_MATH_REV_FUN_STOCHASTIC_ROW_CONSTRAIN_HPP +#ifndef STAN_MATH_REV_CONSTRAINT_STOCHASTIC_ROW_CONSTRAIN_HPP +#define STAN_MATH_REV_CONSTRAINT_STOCHASTIC_ROW_CONSTRAIN_HPP #include #include diff --git a/stan/math/rev/fun/ub_constrain.hpp b/stan/math/rev/constraint/ub_constrain.hpp similarity index 98% rename from stan/math/rev/fun/ub_constrain.hpp rename to stan/math/rev/constraint/ub_constrain.hpp index 9057330c691..f31f9bc21f3 100644 --- a/stan/math/rev/fun/ub_constrain.hpp +++ b/stan/math/rev/constraint/ub_constrain.hpp @@ -1,10 +1,10 @@ -#ifndef STAN_MATH_REV_FUN_UB_CONSTRAIN_HPP -#define STAN_MATH_REV_FUN_UB_CONSTRAIN_HPP +#ifndef STAN_MATH_REV_CONSTRAINT_UB_CONSTRAIN_HPP +#define STAN_MATH_REV_CONSTRAINT_UB_CONSTRAIN_HPP #include #include #include -#include +#include #include namespace stan { diff --git a/stan/math/rev/fun/unit_vector_constrain.hpp b/stan/math/rev/constraint/unit_vector_constrain.hpp similarity index 95% rename from stan/math/rev/fun/unit_vector_constrain.hpp rename to stan/math/rev/constraint/unit_vector_constrain.hpp index 6bc7536d326..86193c28e7e 100644 --- a/stan/math/rev/fun/unit_vector_constrain.hpp +++ b/stan/math/rev/constraint/unit_vector_constrain.hpp @@ -1,5 +1,5 @@ -#ifndef STAN_MATH_REV_FUN_UNIT_VECTOR_CONSTRAIN_HPP -#define STAN_MATH_REV_FUN_UNIT_VECTOR_CONSTRAIN_HPP +#ifndef STAN_MATH_REV_CONSTRAINT_UNIT_VECTOR_CONSTRAIN_HPP +#define STAN_MATH_REV_CONSTRAINT_UNIT_VECTOR_CONSTRAIN_HPP #include #include diff --git a/stan/math/rev/fun.hpp b/stan/math/rev/fun.hpp index 08f0f044a6d..28b9e1d35cb 100644 --- a/stan/math/rev/fun.hpp +++ b/stan/math/rev/fun.hpp @@ -28,18 +28,13 @@ #include #include #include -#include -#include #include #include #include #include #include #include -#include -#include #include -#include #include #include #include @@ -79,8 +74,6 @@ #include #include #include -#include -#include #include #include #include @@ -98,7 +91,6 @@ #include #include #include -#include #include #include #include @@ -124,7 +116,6 @@ #include #include #include -#include #include #include #include @@ -139,10 +130,8 @@ #include #include #include -#include #include #include -#include #include #include #include @@ -160,11 +149,8 @@ #include #include #include -#include #include #include -#include -#include #include #include #include @@ -191,12 +177,11 @@ #include #include #include -#include -#include #include #include #include +#include #include #include #include diff --git a/test/unit/math/mix/fun/cholesky_corr_constrain_test.cpp b/test/unit/math/mix/constraint/cholesky_corr_constrain_test.cpp similarity index 100% rename from test/unit/math/mix/fun/cholesky_corr_constrain_test.cpp rename to test/unit/math/mix/constraint/cholesky_corr_constrain_test.cpp diff --git a/test/unit/math/mix/fun/cholesky_factor_constrain_test.cpp b/test/unit/math/mix/constraint/cholesky_factor_constrain_test.cpp similarity index 100% rename from test/unit/math/mix/fun/cholesky_factor_constrain_test.cpp rename to test/unit/math/mix/constraint/cholesky_factor_constrain_test.cpp diff --git a/test/unit/math/mix/fun/corr_constrain_test.cpp b/test/unit/math/mix/constraint/corr_constrain_test.cpp similarity index 100% rename from test/unit/math/mix/fun/corr_constrain_test.cpp rename to test/unit/math/mix/constraint/corr_constrain_test.cpp diff --git a/test/unit/math/mix/fun/corr_matrix_constrain_test.cpp b/test/unit/math/mix/constraint/corr_matrix_constrain_test.cpp similarity index 100% rename from test/unit/math/mix/fun/corr_matrix_constrain_test.cpp rename to test/unit/math/mix/constraint/corr_matrix_constrain_test.cpp diff --git a/test/unit/math/mix/fun/cov_matrix_constrain_lkj_test.cpp b/test/unit/math/mix/constraint/cov_matrix_constrain_lkj_test.cpp similarity index 100% rename from test/unit/math/mix/fun/cov_matrix_constrain_lkj_test.cpp rename to test/unit/math/mix/constraint/cov_matrix_constrain_lkj_test.cpp diff --git a/test/unit/math/mix/fun/cov_matrix_constrain_test.cpp b/test/unit/math/mix/constraint/cov_matrix_constrain_test.cpp similarity index 100% rename from test/unit/math/mix/fun/cov_matrix_constrain_test.cpp rename to test/unit/math/mix/constraint/cov_matrix_constrain_test.cpp diff --git a/test/unit/math/mix/fun/identity_constrain_test.cpp b/test/unit/math/mix/constraint/identity_constrain_test.cpp similarity index 100% rename from test/unit/math/mix/fun/identity_constrain_test.cpp rename to test/unit/math/mix/constraint/identity_constrain_test.cpp diff --git a/test/unit/math/mix/fun/lb_constrain_matvar_test.cpp b/test/unit/math/mix/constraint/lb_constrain_matvar_test.cpp similarity index 100% rename from test/unit/math/mix/fun/lb_constrain_matvar_test.cpp rename to test/unit/math/mix/constraint/lb_constrain_matvar_test.cpp diff --git a/test/unit/math/mix/fun/lb_constrain_test.cpp b/test/unit/math/mix/constraint/lb_constrain_test.cpp similarity index 100% rename from test/unit/math/mix/fun/lb_constrain_test.cpp rename to test/unit/math/mix/constraint/lb_constrain_test.cpp diff --git a/test/unit/math/mix/fun/lub_constrain_1_test.cpp b/test/unit/math/mix/constraint/lub_constrain_1_test.cpp similarity index 91% rename from test/unit/math/mix/fun/lub_constrain_1_test.cpp rename to test/unit/math/mix/constraint/lub_constrain_1_test.cpp index 04c7466dd87..d76175a441c 100644 --- a/test/unit/math/mix/fun/lub_constrain_1_test.cpp +++ b/test/unit/math/mix/constraint/lub_constrain_1_test.cpp @@ -1,5 +1,5 @@ #include -#include +#include TEST(mathMixMatFun, lub_constrain_scalars) { double x1 = 0.7; diff --git a/test/unit/math/mix/fun/lub_constrain_2_test.cpp b/test/unit/math/mix/constraint/lub_constrain_2_test.cpp similarity index 95% rename from test/unit/math/mix/fun/lub_constrain_2_test.cpp rename to test/unit/math/mix/constraint/lub_constrain_2_test.cpp index 22fa33e28d1..bdd88ef0a6c 100644 --- a/test/unit/math/mix/fun/lub_constrain_2_test.cpp +++ b/test/unit/math/mix/constraint/lub_constrain_2_test.cpp @@ -1,5 +1,5 @@ #include -#include +#include TEST(mathMixMatFun, lub_constrain_vector_scalar_scalar) { Eigen::MatrixXd x1(1, 1); diff --git a/test/unit/math/mix/fun/lub_constrain_3_test.cpp b/test/unit/math/mix/constraint/lub_constrain_3_test.cpp similarity index 96% rename from test/unit/math/mix/fun/lub_constrain_3_test.cpp rename to test/unit/math/mix/constraint/lub_constrain_3_test.cpp index e2fca238fde..d3dd04ed10f 100644 --- a/test/unit/math/mix/fun/lub_constrain_3_test.cpp +++ b/test/unit/math/mix/constraint/lub_constrain_3_test.cpp @@ -1,5 +1,5 @@ #include -#include +#include TEST(mathMixMatFun, lub_constrain_vector_scalar_vector) { Eigen::MatrixXd x1(2, 2); diff --git a/test/unit/math/mix/fun/lub_constrain_4_test.cpp b/test/unit/math/mix/constraint/lub_constrain_4_test.cpp similarity index 94% rename from test/unit/math/mix/fun/lub_constrain_4_test.cpp rename to test/unit/math/mix/constraint/lub_constrain_4_test.cpp index 077e6bfda98..30b9322aab7 100644 --- a/test/unit/math/mix/fun/lub_constrain_4_test.cpp +++ b/test/unit/math/mix/constraint/lub_constrain_4_test.cpp @@ -1,5 +1,5 @@ #include -#include +#include // real[], real[], real[] // real[], real, real[] diff --git a/test/unit/math/mix/fun/lub_constrain_5_test.cpp b/test/unit/math/mix/constraint/lub_constrain_5_test.cpp similarity index 96% rename from test/unit/math/mix/fun/lub_constrain_5_test.cpp rename to test/unit/math/mix/constraint/lub_constrain_5_test.cpp index b1934ddbf04..f8fcf301904 100644 --- a/test/unit/math/mix/fun/lub_constrain_5_test.cpp +++ b/test/unit/math/mix/constraint/lub_constrain_5_test.cpp @@ -1,5 +1,5 @@ #include -#include +#include // array matrix[], array matrix[], array matrix[] // array matrix[], array matrix[], matrix[] diff --git a/test/unit/math/mix/fun/lub_constrain_6_test.cpp b/test/unit/math/mix/constraint/lub_constrain_6_test.cpp similarity index 96% rename from test/unit/math/mix/fun/lub_constrain_6_test.cpp rename to test/unit/math/mix/constraint/lub_constrain_6_test.cpp index 504bb67095b..00d91f7bceb 100644 --- a/test/unit/math/mix/fun/lub_constrain_6_test.cpp +++ b/test/unit/math/mix/constraint/lub_constrain_6_test.cpp @@ -1,5 +1,5 @@ #include -#include +#include // array matrix[], array matrix[], array matrix[] // array matrix[], array matrix[], matrix[] diff --git a/test/unit/math/mix/fun/lub_constrain_7_test.cpp b/test/unit/math/mix/constraint/lub_constrain_7_test.cpp similarity index 96% rename from test/unit/math/mix/fun/lub_constrain_7_test.cpp rename to test/unit/math/mix/constraint/lub_constrain_7_test.cpp index 8c097445b3d..e75009d2dee 100644 --- a/test/unit/math/mix/fun/lub_constrain_7_test.cpp +++ b/test/unit/math/mix/constraint/lub_constrain_7_test.cpp @@ -1,5 +1,5 @@ #include -#include +#include // array matrix[], array matrix[], array matrix[] // array matrix[], array matrix[], matrix[] diff --git a/test/unit/math/mix/fun/lub_constrain_8_test.cpp b/test/unit/math/mix/constraint/lub_constrain_8_test.cpp similarity index 96% rename from test/unit/math/mix/fun/lub_constrain_8_test.cpp rename to test/unit/math/mix/constraint/lub_constrain_8_test.cpp index 3e18bfa2602..4811f56d4a0 100644 --- a/test/unit/math/mix/fun/lub_constrain_8_test.cpp +++ b/test/unit/math/mix/constraint/lub_constrain_8_test.cpp @@ -1,5 +1,5 @@ #include -#include +#include // array matrix[], array matrix[], array matrix[] // array matrix[], array matrix[], matrix[] diff --git a/test/unit/math/mix/fun/lub_constrain_helpers.hpp b/test/unit/math/mix/constraint/lub_constrain_helpers.hpp similarity index 100% rename from test/unit/math/mix/fun/lub_constrain_helpers.hpp rename to test/unit/math/mix/constraint/lub_constrain_helpers.hpp diff --git a/test/unit/math/mix/fun/lub_constrain_matvar_test.cpp b/test/unit/math/mix/constraint/lub_constrain_matvar_test.cpp similarity index 100% rename from test/unit/math/mix/fun/lub_constrain_matvar_test.cpp rename to test/unit/math/mix/constraint/lub_constrain_matvar_test.cpp diff --git a/test/unit/math/mix/fun/offset_multiplier_constrain_1_matvar_test.cpp b/test/unit/math/mix/constraint/offset_multiplier_constrain_1_matvar_test.cpp similarity index 92% rename from test/unit/math/mix/fun/offset_multiplier_constrain_1_matvar_test.cpp rename to test/unit/math/mix/constraint/offset_multiplier_constrain_1_matvar_test.cpp index c3e123c5de5..ebb66b4e3b1 100644 --- a/test/unit/math/mix/fun/offset_multiplier_constrain_1_matvar_test.cpp +++ b/test/unit/math/mix/constraint/offset_multiplier_constrain_1_matvar_test.cpp @@ -1,5 +1,5 @@ #include -#include +#include TEST(mathMixMatFun, offset_multiplier_constrain_matvar_scalars) { double x1 = 0.7; diff --git a/test/unit/math/mix/fun/offset_multiplier_constrain_1_test.cpp b/test/unit/math/mix/constraint/offset_multiplier_constrain_1_test.cpp similarity index 92% rename from test/unit/math/mix/fun/offset_multiplier_constrain_1_test.cpp rename to test/unit/math/mix/constraint/offset_multiplier_constrain_1_test.cpp index 5a22a26ca6f..c0aca029305 100644 --- a/test/unit/math/mix/fun/offset_multiplier_constrain_1_test.cpp +++ b/test/unit/math/mix/constraint/offset_multiplier_constrain_1_test.cpp @@ -1,5 +1,5 @@ #include -#include +#include TEST(mathMixMatFun, offset_multiplier_constrain_scalars) { double x1 = 0.7; diff --git a/test/unit/math/mix/fun/offset_multiplier_constrain_2_matvar_test.cpp b/test/unit/math/mix/constraint/offset_multiplier_constrain_2_matvar_test.cpp similarity index 91% rename from test/unit/math/mix/fun/offset_multiplier_constrain_2_matvar_test.cpp rename to test/unit/math/mix/constraint/offset_multiplier_constrain_2_matvar_test.cpp index 7f0232eef66..38d0712c69c 100644 --- a/test/unit/math/mix/fun/offset_multiplier_constrain_2_matvar_test.cpp +++ b/test/unit/math/mix/constraint/offset_multiplier_constrain_2_matvar_test.cpp @@ -1,5 +1,5 @@ #include -#include +#include TEST(mathMixMatFun, offset_multiplier_constrain_matvar_vector_scalar_vector) { Eigen::MatrixXd x1(2, 2); diff --git a/test/unit/math/mix/fun/offset_multiplier_constrain_2_test.cpp b/test/unit/math/mix/constraint/offset_multiplier_constrain_2_test.cpp similarity index 91% rename from test/unit/math/mix/fun/offset_multiplier_constrain_2_test.cpp rename to test/unit/math/mix/constraint/offset_multiplier_constrain_2_test.cpp index c62a0747501..5a47fa2b6d0 100644 --- a/test/unit/math/mix/fun/offset_multiplier_constrain_2_test.cpp +++ b/test/unit/math/mix/constraint/offset_multiplier_constrain_2_test.cpp @@ -1,5 +1,5 @@ #include -#include +#include TEST(mathMixMatFun, offset_multiplier_constrain_vector_scalar_vector) { Eigen::MatrixXd x1(2, 2); diff --git a/test/unit/math/mix/fun/offset_multiplier_constrain_3_matvar_test.cpp b/test/unit/math/mix/constraint/offset_multiplier_constrain_3_matvar_test.cpp similarity index 94% rename from test/unit/math/mix/fun/offset_multiplier_constrain_3_matvar_test.cpp rename to test/unit/math/mix/constraint/offset_multiplier_constrain_3_matvar_test.cpp index 764c84c0a1b..a48cc636521 100644 --- a/test/unit/math/mix/fun/offset_multiplier_constrain_3_matvar_test.cpp +++ b/test/unit/math/mix/constraint/offset_multiplier_constrain_3_matvar_test.cpp @@ -1,5 +1,5 @@ #include -#include +#include // array[] matrix, matrix, array[] matrix // array[] matrix, matrix, matrix diff --git a/test/unit/math/mix/fun/offset_multiplier_constrain_3_test.cpp b/test/unit/math/mix/constraint/offset_multiplier_constrain_3_test.cpp similarity index 94% rename from test/unit/math/mix/fun/offset_multiplier_constrain_3_test.cpp rename to test/unit/math/mix/constraint/offset_multiplier_constrain_3_test.cpp index 28089aacc8a..0bbb27ebee9 100644 --- a/test/unit/math/mix/fun/offset_multiplier_constrain_3_test.cpp +++ b/test/unit/math/mix/constraint/offset_multiplier_constrain_3_test.cpp @@ -1,5 +1,5 @@ #include -#include +#include // array[] matrix, matrix, array[] matrix // array[] matrix, matrix, matrix diff --git a/test/unit/math/mix/fun/offset_multiplier_constrain_4_matvar_test.cpp b/test/unit/math/mix/constraint/offset_multiplier_constrain_4_matvar_test.cpp similarity index 88% rename from test/unit/math/mix/fun/offset_multiplier_constrain_4_matvar_test.cpp rename to test/unit/math/mix/constraint/offset_multiplier_constrain_4_matvar_test.cpp index 79c0c36867e..0b2d6506959 100644 --- a/test/unit/math/mix/fun/offset_multiplier_constrain_4_matvar_test.cpp +++ b/test/unit/math/mix/constraint/offset_multiplier_constrain_4_matvar_test.cpp @@ -1,5 +1,5 @@ #include -#include +#include // real[], real[], real[] // real[], real, real[] diff --git a/test/unit/math/mix/fun/offset_multiplier_constrain_4_test.cpp b/test/unit/math/mix/constraint/offset_multiplier_constrain_4_test.cpp similarity index 88% rename from test/unit/math/mix/fun/offset_multiplier_constrain_4_test.cpp rename to test/unit/math/mix/constraint/offset_multiplier_constrain_4_test.cpp index fb37442f6f0..ec20c584407 100644 --- a/test/unit/math/mix/fun/offset_multiplier_constrain_4_test.cpp +++ b/test/unit/math/mix/constraint/offset_multiplier_constrain_4_test.cpp @@ -1,5 +1,5 @@ #include -#include +#include // real[], real[], real[] // real[], real, real[] diff --git a/test/unit/math/mix/fun/offset_multiplier_constrain_5_matvar_test.cpp b/test/unit/math/mix/constraint/offset_multiplier_constrain_5_matvar_test.cpp similarity index 90% rename from test/unit/math/mix/fun/offset_multiplier_constrain_5_matvar_test.cpp rename to test/unit/math/mix/constraint/offset_multiplier_constrain_5_matvar_test.cpp index e47b579f2ed..f9191a79757 100644 --- a/test/unit/math/mix/fun/offset_multiplier_constrain_5_matvar_test.cpp +++ b/test/unit/math/mix/constraint/offset_multiplier_constrain_5_matvar_test.cpp @@ -1,5 +1,5 @@ #include -#include +#include // array[] matrix, array[] matrix, real // array[] matrix, real, array[] matrix diff --git a/test/unit/math/mix/fun/offset_multiplier_constrain_5_test.cpp b/test/unit/math/mix/constraint/offset_multiplier_constrain_5_test.cpp similarity index 90% rename from test/unit/math/mix/fun/offset_multiplier_constrain_5_test.cpp rename to test/unit/math/mix/constraint/offset_multiplier_constrain_5_test.cpp index 610a2f9de11..6663ec2e3cf 100644 --- a/test/unit/math/mix/fun/offset_multiplier_constrain_5_test.cpp +++ b/test/unit/math/mix/constraint/offset_multiplier_constrain_5_test.cpp @@ -1,5 +1,5 @@ #include -#include +#include // array[] matrix, array[] matrix, real // array[] matrix, real, array[] matrix diff --git a/test/unit/math/mix/fun/offset_multiplier_constrain_6_matvar_test.cpp b/test/unit/math/mix/constraint/offset_multiplier_constrain_6_matvar_test.cpp similarity index 91% rename from test/unit/math/mix/fun/offset_multiplier_constrain_6_matvar_test.cpp rename to test/unit/math/mix/constraint/offset_multiplier_constrain_6_matvar_test.cpp index b65f76bb0c7..a4d86a774dd 100644 --- a/test/unit/math/mix/fun/offset_multiplier_constrain_6_matvar_test.cpp +++ b/test/unit/math/mix/constraint/offset_multiplier_constrain_6_matvar_test.cpp @@ -1,5 +1,5 @@ #include -#include +#include // array[] matrix, matrix, real // array[] matrix, real, matrix diff --git a/test/unit/math/mix/fun/offset_multiplier_constrain_6_test.cpp b/test/unit/math/mix/constraint/offset_multiplier_constrain_6_test.cpp similarity index 91% rename from test/unit/math/mix/fun/offset_multiplier_constrain_6_test.cpp rename to test/unit/math/mix/constraint/offset_multiplier_constrain_6_test.cpp index 190d01f0c81..3dd21630ce9 100644 --- a/test/unit/math/mix/fun/offset_multiplier_constrain_6_test.cpp +++ b/test/unit/math/mix/constraint/offset_multiplier_constrain_6_test.cpp @@ -1,5 +1,5 @@ #include -#include +#include // array[] matrix, matrix, real // array[] matrix, real, matrix diff --git a/test/unit/math/mix/fun/offset_multiplier_constrain_7_test.cpp b/test/unit/math/mix/constraint/offset_multiplier_constrain_7_test.cpp similarity index 100% rename from test/unit/math/mix/fun/offset_multiplier_constrain_7_test.cpp rename to test/unit/math/mix/constraint/offset_multiplier_constrain_7_test.cpp diff --git a/test/unit/math/mix/fun/offset_multiplier_constrain_helpers.hpp b/test/unit/math/mix/constraint/offset_multiplier_constrain_helpers.hpp similarity index 100% rename from test/unit/math/mix/fun/offset_multiplier_constrain_helpers.hpp rename to test/unit/math/mix/constraint/offset_multiplier_constrain_helpers.hpp diff --git a/test/unit/math/mix/fun/offset_multiplier_constrain_matvar_helpers.hpp b/test/unit/math/mix/constraint/offset_multiplier_constrain_matvar_helpers.hpp similarity index 100% rename from test/unit/math/mix/fun/offset_multiplier_constrain_matvar_helpers.hpp rename to test/unit/math/mix/constraint/offset_multiplier_constrain_matvar_helpers.hpp diff --git a/test/unit/math/mix/fun/ordered_constrain_test.cpp b/test/unit/math/mix/constraint/ordered_constrain_test.cpp similarity index 100% rename from test/unit/math/mix/fun/ordered_constrain_test.cpp rename to test/unit/math/mix/constraint/ordered_constrain_test.cpp diff --git a/test/unit/math/mix/fun/positive_ordered_constrain_test.cpp b/test/unit/math/mix/constraint/positive_ordered_constrain_test.cpp similarity index 100% rename from test/unit/math/mix/fun/positive_ordered_constrain_test.cpp rename to test/unit/math/mix/constraint/positive_ordered_constrain_test.cpp diff --git a/test/unit/math/mix/fun/simplex_constrain_test.cpp b/test/unit/math/mix/constraint/simplex_constrain_test.cpp similarity index 100% rename from test/unit/math/mix/fun/simplex_constrain_test.cpp rename to test/unit/math/mix/constraint/simplex_constrain_test.cpp diff --git a/test/unit/math/mix/fun/stochastic_column_constrain_test.cpp b/test/unit/math/mix/constraint/stochastic_column_constrain_test.cpp similarity index 100% rename from test/unit/math/mix/fun/stochastic_column_constrain_test.cpp rename to test/unit/math/mix/constraint/stochastic_column_constrain_test.cpp diff --git a/test/unit/math/mix/fun/stochastic_row_constrain_test.cpp b/test/unit/math/mix/constraint/stochastic_row_constrain_test.cpp similarity index 100% rename from test/unit/math/mix/fun/stochastic_row_constrain_test.cpp rename to test/unit/math/mix/constraint/stochastic_row_constrain_test.cpp diff --git a/test/unit/math/mix/fun/unit_vector_constrain_test.cpp b/test/unit/math/mix/constraint/unit_vector_constrain_test.cpp similarity index 100% rename from test/unit/math/mix/fun/unit_vector_constrain_test.cpp rename to test/unit/math/mix/constraint/unit_vector_constrain_test.cpp diff --git a/test/unit/math/opencl/rev/lb_constrain_test.cpp b/test/unit/math/opencl/rev/constraint/lb_constrain_test.cpp similarity index 100% rename from test/unit/math/opencl/rev/lb_constrain_test.cpp rename to test/unit/math/opencl/rev/constraint/lb_constrain_test.cpp diff --git a/test/unit/math/opencl/rev/lub_constrain_test.cpp b/test/unit/math/opencl/rev/constraint/lub_constrain_test.cpp similarity index 100% rename from test/unit/math/opencl/rev/lub_constrain_test.cpp rename to test/unit/math/opencl/rev/constraint/lub_constrain_test.cpp diff --git a/test/unit/math/opencl/rev/offset_multiplier_constrain_test.cpp b/test/unit/math/opencl/rev/constraint/offset_multiplier_constrain_test.cpp similarity index 100% rename from test/unit/math/opencl/rev/offset_multiplier_constrain_test.cpp rename to test/unit/math/opencl/rev/constraint/offset_multiplier_constrain_test.cpp diff --git a/test/unit/math/opencl/rev/ub_constrain_test.cpp b/test/unit/math/opencl/rev/constraint/ub_constrain_test.cpp similarity index 100% rename from test/unit/math/opencl/rev/ub_constrain_test.cpp rename to test/unit/math/opencl/rev/constraint/ub_constrain_test.cpp diff --git a/test/unit/math/opencl/rev/unit_vector_constrain_test.cpp b/test/unit/math/opencl/rev/constraint/unit_vector_constrain_test.cpp similarity index 100% rename from test/unit/math/opencl/rev/unit_vector_constrain_test.cpp rename to test/unit/math/opencl/rev/constraint/unit_vector_constrain_test.cpp diff --git a/test/unit/math/prim/fun/cholesky_corr_transform_test.cpp b/test/unit/math/prim/constraint/cholesky_corr_transform_test.cpp similarity index 100% rename from test/unit/math/prim/fun/cholesky_corr_transform_test.cpp rename to test/unit/math/prim/constraint/cholesky_corr_transform_test.cpp diff --git a/test/unit/math/prim/fun/cholesky_factor_transform_test.cpp b/test/unit/math/prim/constraint/cholesky_factor_transform_test.cpp similarity index 100% rename from test/unit/math/prim/fun/cholesky_factor_transform_test.cpp rename to test/unit/math/prim/constraint/cholesky_factor_transform_test.cpp diff --git a/test/unit/math/prim/fun/corr_transform_test.cpp b/test/unit/math/prim/constraint/corr_transform_test.cpp similarity index 100% rename from test/unit/math/prim/fun/corr_transform_test.cpp rename to test/unit/math/prim/constraint/corr_transform_test.cpp diff --git a/test/unit/math/prim/fun/cov_matrix_transform_test.cpp b/test/unit/math/prim/constraint/cov_matrix_transform_test.cpp similarity index 100% rename from test/unit/math/prim/fun/cov_matrix_transform_test.cpp rename to test/unit/math/prim/constraint/cov_matrix_transform_test.cpp diff --git a/test/unit/math/prim/fun/identity_transform_test.cpp b/test/unit/math/prim/constraint/identity_transform_test.cpp similarity index 100% rename from test/unit/math/prim/fun/identity_transform_test.cpp rename to test/unit/math/prim/constraint/identity_transform_test.cpp diff --git a/test/unit/math/prim/fun/lb_transform_test.cpp b/test/unit/math/prim/constraint/lb_transform_test.cpp similarity index 100% rename from test/unit/math/prim/fun/lb_transform_test.cpp rename to test/unit/math/prim/constraint/lb_transform_test.cpp diff --git a/test/unit/math/prim/fun/lub_transform_test.cpp b/test/unit/math/prim/constraint/lub_transform_test.cpp similarity index 100% rename from test/unit/math/prim/fun/lub_transform_test.cpp rename to test/unit/math/prim/constraint/lub_transform_test.cpp diff --git a/test/unit/math/prim/fun/offset_multiplier_matrix_transform_test.cpp b/test/unit/math/prim/constraint/offset_multiplier_matrix_transform_test.cpp similarity index 100% rename from test/unit/math/prim/fun/offset_multiplier_matrix_transform_test.cpp rename to test/unit/math/prim/constraint/offset_multiplier_matrix_transform_test.cpp diff --git a/test/unit/math/prim/fun/offset_multiplier_transform_test.cpp b/test/unit/math/prim/constraint/offset_multiplier_transform_test.cpp similarity index 100% rename from test/unit/math/prim/fun/offset_multiplier_transform_test.cpp rename to test/unit/math/prim/constraint/offset_multiplier_transform_test.cpp diff --git a/test/unit/math/prim/fun/ordered_transform_test.cpp b/test/unit/math/prim/constraint/ordered_transform_test.cpp similarity index 100% rename from test/unit/math/prim/fun/ordered_transform_test.cpp rename to test/unit/math/prim/constraint/ordered_transform_test.cpp diff --git a/test/unit/math/prim/fun/prob_transform_test.cpp b/test/unit/math/prim/constraint/prob_transform_test.cpp similarity index 100% rename from test/unit/math/prim/fun/prob_transform_test.cpp rename to test/unit/math/prim/constraint/prob_transform_test.cpp diff --git a/test/unit/math/prim/fun/simplex_transform_test.cpp b/test/unit/math/prim/constraint/simplex_transform_test.cpp similarity index 100% rename from test/unit/math/prim/fun/simplex_transform_test.cpp rename to test/unit/math/prim/constraint/simplex_transform_test.cpp diff --git a/test/unit/math/prim/fun/stochastic_column_constrain_test.cpp b/test/unit/math/prim/constraint/stochastic_column_constrain_test.cpp similarity index 100% rename from test/unit/math/prim/fun/stochastic_column_constrain_test.cpp rename to test/unit/math/prim/constraint/stochastic_column_constrain_test.cpp diff --git a/test/unit/math/prim/fun/stochastic_row_constrain_test.cpp b/test/unit/math/prim/constraint/stochastic_row_constrain_test.cpp similarity index 100% rename from test/unit/math/prim/fun/stochastic_row_constrain_test.cpp rename to test/unit/math/prim/constraint/stochastic_row_constrain_test.cpp diff --git a/test/unit/math/prim/fun/ub_transform_test.cpp b/test/unit/math/prim/constraint/ub_transform_test.cpp similarity index 100% rename from test/unit/math/prim/fun/ub_transform_test.cpp rename to test/unit/math/prim/constraint/ub_transform_test.cpp diff --git a/test/unit/math/prim/fun/unit_vector_transform_test.cpp b/test/unit/math/prim/constraint/unit_vector_transform_test.cpp similarity index 100% rename from test/unit/math/prim/fun/unit_vector_transform_test.cpp rename to test/unit/math/prim/constraint/unit_vector_transform_test.cpp From c9c98378c1691288c9c4ed0bdacaf01d8f98a3bc Mon Sep 17 00:00:00 2001 From: Sean Pinkney Date: Sun, 24 Mar 2024 18:21:23 -0400 Subject: [PATCH 33/52] fix forward --- stan/math/mix.hpp | 1 + stan/math/opencl/{prim_constraint.cpp => prim_constraint.hpp} | 0 stan/math/opencl/{rev_constraint.cpp => rev_constraint.hpp} | 0 3 files changed, 1 insertion(+) rename stan/math/opencl/{prim_constraint.cpp => prim_constraint.hpp} (100%) rename stan/math/opencl/{rev_constraint.cpp => rev_constraint.hpp} (100%) diff --git a/stan/math/mix.hpp b/stan/math/mix.hpp index d65900c6cd3..bb7ff7c0b1f 100644 --- a/stan/math/mix.hpp +++ b/stan/math/mix.hpp @@ -5,6 +5,7 @@ #include #include +#include #include #include #include diff --git a/stan/math/opencl/prim_constraint.cpp b/stan/math/opencl/prim_constraint.hpp similarity index 100% rename from stan/math/opencl/prim_constraint.cpp rename to stan/math/opencl/prim_constraint.hpp diff --git a/stan/math/opencl/rev_constraint.cpp b/stan/math/opencl/rev_constraint.hpp similarity index 100% rename from stan/math/opencl/rev_constraint.cpp rename to stan/math/opencl/rev_constraint.hpp From 2f1c952b7235ad44f2d1ff7c22e2f919d3dc1f71 Mon Sep 17 00:00:00 2001 From: Sean Pinkney Date: Sun, 24 Mar 2024 18:26:35 -0400 Subject: [PATCH 34/52] fix opencl headers --- stan/math/opencl/prim.hpp | 5 ----- stan/math/opencl/rev.hpp | 5 ----- 2 files changed, 10 deletions(-) diff --git a/stan/math/opencl/prim.hpp b/stan/math/opencl/prim.hpp index f0875a4268c..8e8730f537f 100644 --- a/stan/math/opencl/prim.hpp +++ b/stan/math/opencl/prim.hpp @@ -172,7 +172,6 @@ #include #include #include -#include #include #include #include @@ -184,7 +183,6 @@ #include #include #include -#include #include #include #include @@ -201,7 +199,6 @@ #include #include #include -#include #include #include #include @@ -266,12 +263,10 @@ #include #include #include -#include #include #include #include #include -#include #include #include #include diff --git a/stan/math/opencl/rev.hpp b/stan/math/opencl/rev.hpp index f48de0b806f..4dddb45691b 100644 --- a/stan/math/opencl/rev.hpp +++ b/stan/math/opencl/rev.hpp @@ -58,7 +58,6 @@ #include #include #include -#include #include #include #include @@ -77,14 +76,12 @@ #include #include #include -#include #include #include #include #include #include #include -#include #include #include #include @@ -117,8 +114,6 @@ #include #include #include -#include -#include #include #include From ae5d6403557f10a22cbcb2ffab1345cae46d3eaf Mon Sep 17 00:00:00 2001 From: Sean Pinkney Date: Sun, 24 Mar 2024 18:36:51 -0400 Subject: [PATCH 35/52] add new line --- stan/math/fwd/constraint.hpp | 2 +- stan/math/prim/constraint.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/stan/math/fwd/constraint.hpp b/stan/math/fwd/constraint.hpp index 87a396055b4..c0d7912cc83 100644 --- a/stan/math/fwd/constraint.hpp +++ b/stan/math/fwd/constraint.hpp @@ -6,4 +6,4 @@ #include -#endif \ No newline at end of file +#endif diff --git a/stan/math/prim/constraint.hpp b/stan/math/prim/constraint.hpp index 9a252202811..9193ea3ddad 100644 --- a/stan/math/prim/constraint.hpp +++ b/stan/math/prim/constraint.hpp @@ -39,4 +39,4 @@ #include #include -#endif \ No newline at end of file +#endif From b445511a7ca0a14ff4a195553d0eda159f7531b9 Mon Sep 17 00:00:00 2001 From: Sean Pinkney Date: Mon, 25 Mar 2024 05:09:32 -0400 Subject: [PATCH 36/52] update opencl headers --- stan/math/opencl/prim.hpp | 2 + stan/math/opencl/prim_constraint.hpp | 99 ------------------------- stan/math/opencl/rev.hpp | 2 + stan/math/opencl/rev_constraint.hpp | 103 +-------------------------- 4 files changed, 6 insertions(+), 200 deletions(-) diff --git a/stan/math/opencl/prim.hpp b/stan/math/opencl/prim.hpp index 8e8730f537f..4c5b193a7da 100644 --- a/stan/math/opencl/prim.hpp +++ b/stan/math/opencl/prim.hpp @@ -99,6 +99,8 @@ #include #include +#include + #include #include #include diff --git a/stan/math/opencl/prim_constraint.hpp b/stan/math/opencl/prim_constraint.hpp index 9c38de83393..b092eafc275 100644 --- a/stan/math/opencl/prim_constraint.hpp +++ b/stan/math/opencl/prim_constraint.hpp @@ -2,110 +2,11 @@ #define STAN_MATH_OPENCL_PRIM_CONSTRAINT_HPP #ifdef STAN_OPENCL -/** - * \defgroup opencl OpenCL - * Stan's OpenCL backend allows for computation to be executed in parallel - * on a GPU or in multithreaded CPUs. It is meant to easily conform with Eigen - * such that you can create and read from a `matrix_cl` by doing - * - *```cpp - * Eigen::MatrixXd A_eig = Eigen::MatrixXd::Random(10, 10); - * matrix_cl A(A_eig); - * matrix_cl B = to_matrix_cl(A_eig); - * matrix_cl C = cholesky_decompose(A * B); - * // Read back to eigen matrix. - * Eigen::MatrixXd C_eig = from_matrix_cl(C); - * - * // Also for vectors and raw pointers of pointers - * std::vector A_vec(10, 0); - * matrix_cl B_var(A_vec, 10, 1); - * - * vari** A_vari= // fill - * matrix_cl B_vari(A_vari, 10, 1); - * - *``` - * - * Execution is performed in async and Kernel operations are compounded and - * compiled Just In Time. This allows for a low amount of overhead when passing - * data to and from the device and executing computations. - * - * For more details see the paper on Arvix. - * https://arxiv.org/pdf/1907.01063.pdf - */ - -/** - * \ingroup opencl - * \defgroup error_checks_opencl Error Checks - */ - -/** - * \ingroup opencl - * \defgroup kernel_executor_opencl Kernel Executor - * The kernel executor allows OpenCL kernels to be executed in async. GPUs - * have the capability to perform reads, writes, and computation at the same - * time. In order to maximize the throughput to the device the Kernel - * Executor assigns matrices read and write events. Write events are blocking - * in that no further operations can be completed until the write event - * is finished. However, read events can happen in async together. - * Take the following for example - * - *```cpp - * matrix_cl A = from_eigen_cl(A_eig); - * matrix_cl B = from_eigen_cl(B_eig); - * matrix_cl C = A * B; - * matrix_cl D = A + B; - * matrix_cl E = C + D; - *``` - * In the above, When `A` and `B` are created from the Eigen matrices `A_eig` - *and `B_eig`. they are both assigned write events to their write event stack. - * `C` and `D` depend on `A` and `B` while `E` depends on - * `C` and `D`. When executing `C`'s operation, `A` and `B` are assigned - * events to their read event stack while `C` is assigned an event to it's write - *event stack. Once `A` and `B` have finished their write event the kernel to - *compute `C` can begin. The excution to create `D` also waits for the write - *events of `A` and `B`, but does not have to wait for the execution of `C` to - *finish. Executing `E` requires waiting for for the write events of both `C` - *and `D`. - * - */ - -/** - * \ingroup opencl - * \defgroup opencl_kernels Custom OpenCL kernels - */ - -/** - * \ingroup opencl - * \defgroup prim_fun_opencl OpenCL overloads of stan/math/prim functions - */ -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include #include #include #include #include -#include - #endif #endif diff --git a/stan/math/opencl/rev.hpp b/stan/math/opencl/rev.hpp index 4dddb45691b..37c5b716230 100644 --- a/stan/math/opencl/rev.hpp +++ b/stan/math/opencl/rev.hpp @@ -3,6 +3,8 @@ #ifdef STAN_OPENCL #include +#include + #include #include #include diff --git a/stan/math/opencl/rev_constraint.hpp b/stan/math/opencl/rev_constraint.hpp index 20a9660322c..2b42eee74cb 100644 --- a/stan/math/opencl/rev_constraint.hpp +++ b/stan/math/opencl/rev_constraint.hpp @@ -1,111 +1,12 @@ -#ifndef STAN_MATH_OPENCL_PRIM_CONSTRAINT_HPP -#define STAN_MATH_OPENCL_PRIM_CONSTRAINT_HPP +#ifndef STAN_MATH_OPENCL_REV_CONSTRAINT_HPP +#define STAN_MATH_OPENCL_REV_CONSTRAINT_HPP #ifdef STAN_OPENCL -/** - * \defgroup opencl OpenCL - * Stan's OpenCL backend allows for computation to be executed in parallel - * on a GPU or in multithreaded CPUs. It is meant to easily conform with Eigen - * such that you can create and read from a `matrix_cl` by doing - * - *```cpp - * Eigen::MatrixXd A_eig = Eigen::MatrixXd::Random(10, 10); - * matrix_cl A(A_eig); - * matrix_cl B = to_matrix_cl(A_eig); - * matrix_cl C = cholesky_decompose(A * B); - * // Read back to eigen matrix. - * Eigen::MatrixXd C_eig = from_matrix_cl(C); - * - * // Also for vectors and raw pointers of pointers - * std::vector A_vec(10, 0); - * matrix_cl B_var(A_vec, 10, 1); - * - * vari** A_vari= // fill - * matrix_cl B_vari(A_vari, 10, 1); - * - *``` - * - * Execution is performed in async and Kernel operations are compounded and - * compiled Just In Time. This allows for a low amount of overhead when passing - * data to and from the device and executing computations. - * - * For more details see the paper on Arvix. - * https://arxiv.org/pdf/1907.01063.pdf - */ - -/** - * \ingroup opencl - * \defgroup error_checks_opencl Error Checks - */ - -/** - * \ingroup opencl - * \defgroup kernel_executor_opencl Kernel Executor - * The kernel executor allows OpenCL kernels to be executed in async. GPUs - * have the capability to perform reads, writes, and computation at the same - * time. In order to maximize the throughput to the device the Kernel - * Executor assigns matrices read and write events. Write events are blocking - * in that no further operations can be completed until the write event - * is finished. However, read events can happen in async together. - * Take the following for example - * - *```cpp - * matrix_cl A = from_eigen_cl(A_eig); - * matrix_cl B = from_eigen_cl(B_eig); - * matrix_cl C = A * B; - * matrix_cl D = A + B; - * matrix_cl E = C + D; - *``` - * In the above, When `A` and `B` are created from the Eigen matrices `A_eig` - *and `B_eig`. they are both assigned write events to their write event stack. - * `C` and `D` depend on `A` and `B` while `E` depends on - * `C` and `D`. When executing `C`'s operation, `A` and `B` are assigned - * events to their read event stack while `C` is assigned an event to it's write - *event stack. Once `A` and `B` have finished their write event the kernel to - *compute `C` can begin. The excution to create `D` also waits for the write - *events of `A` and `B`, but does not have to wait for the execution of `C` to - *finish. Executing `E` requires waiting for for the write events of both `C` - *and `D`. - * - */ - -/** - * \ingroup opencl - * \defgroup opencl_kernels Custom OpenCL kernels - */ - -/** - * \ingroup opencl - * \defgroup prim_fun_opencl OpenCL overloads of stan/math/prim functions - */ -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include #include #include #include #include -#include - #endif #endif From d2bf89c798a8dba86ea834c17ab3093ba386e27b Mon Sep 17 00:00:00 2001 From: Sean Pinkney Date: Mon, 25 Mar 2024 05:56:25 -0400 Subject: [PATCH 37/52] include apply functor in wiener_5_lpdf --- stan/math/prim/prob/wiener5_lpdf.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/stan/math/prim/prob/wiener5_lpdf.hpp b/stan/math/prim/prob/wiener5_lpdf.hpp index 0414b59f60c..9a1081006c7 100644 --- a/stan/math/prim/prob/wiener5_lpdf.hpp +++ b/stan/math/prim/prob/wiener5_lpdf.hpp @@ -2,6 +2,7 @@ #define STAN_MATH_PRIM_PROB_WIENER5_LPDF_HPP #include +#include namespace stan { namespace math { From 38b69a520e62b355844f50765fd11f8149001dc9 Mon Sep 17 00:00:00 2001 From: Sean Pinkney Date: Mon, 25 Mar 2024 09:13:28 -0400 Subject: [PATCH 38/52] update runTests.py --- runTests.py | 8 ++++++++ test/unit/math/mix/constraint/lub_constrain_helpers.hpp | 4 ++-- .../constraint/offset_multiplier_constrain_helpers.hpp | 4 ++-- .../offset_multiplier_constrain_matvar_helpers.hpp | 4 ++-- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/runTests.py b/runTests.py index 4bce225109b..e6adc86b84f 100755 --- a/runTests.py +++ b/runTests.py @@ -23,9 +23,12 @@ allowed_paths_with_jumbo = [ "test/unit/math/prim/", + "test/unit/math/prim/constraint", "test/unit/math/", "test/unit/math/rev/", + "test/unit/math/rev/constraint", "test/unit/math/fwd/", + "test/unit/math/fwd/constraint", "test/unit/math/mix/", "test/unit/math/mix/fun/", "test/unit/math/opencl/", @@ -33,18 +36,21 @@ ] jumbo_folders = [ + "test/unit/math/prim/constraint", "test/unit/math/prim/core", "test/unit/math/prim/err", "test/unit/math/prim/fun", "test/unit/math/prim/functor", "test/unit/math/prim/meta", "test/unit/math/prim/prob", + "test/unit/math/rev/constraint", "test/unit/math/rev/core", "test/unit/math/rev/err", "test/unit/math/rev/fun", "test/unit/math/rev/functor", "test/unit/math/rev/meta", "test/unit/math/rev/prob", + "test/unit/math/fwd/constraint", "test/unit/math/fwd/core", "test/unit/math/fwd/fun", "test/unit/math/fwd/functor", @@ -58,7 +64,9 @@ "test/unit/math/opencl/device_functions", "test/unit/math/opencl/kernel_generator", "test/unit/math/opencl/prim", + "test/unit/math/opencl/prim/constraint", "test/unit/math/opencl/rev", + "test/unit/math/opencl/rev/constraint", ] diff --git a/test/unit/math/mix/constraint/lub_constrain_helpers.hpp b/test/unit/math/mix/constraint/lub_constrain_helpers.hpp index c12c99fcc9e..52c2c7a85dc 100644 --- a/test/unit/math/mix/constraint/lub_constrain_helpers.hpp +++ b/test/unit/math/mix/constraint/lub_constrain_helpers.hpp @@ -1,5 +1,5 @@ -#ifndef STAN_TEST_UNIT_MATH_MIX_FUN_LUB_CONSTRAIN_HELPERS_HPP -#define STAN_TEST_UNIT_MATH_MIX_FUN_LUB_CONSTRAIN_HELPERS_HPP +#ifndef STAN_TEST_UNIT_MATH_MIX_CONSTRAINT_LUB_CONSTRAIN_HELPERS_HPP +#define STAN_TEST_UNIT_MATH_MIX_CONSTRAINT_LUB_CONSTRAIN_HELPERS_HPP namespace lub_constrain_tests { template diff --git a/test/unit/math/mix/constraint/offset_multiplier_constrain_helpers.hpp b/test/unit/math/mix/constraint/offset_multiplier_constrain_helpers.hpp index 7d28a595dda..1bce7e2a985 100644 --- a/test/unit/math/mix/constraint/offset_multiplier_constrain_helpers.hpp +++ b/test/unit/math/mix/constraint/offset_multiplier_constrain_helpers.hpp @@ -1,5 +1,5 @@ -#ifndef STAN_TEST_UNIT_MATH_MIX_FUN_offset_multiplier_CONSTRAIN_HELPERS_HPP -#define STAN_TEST_UNIT_MATH_MIX_FUN_offset_multiplier_CONSTRAIN_HELPERS_HPP +#ifndef STAN_TEST_UNIT_MATH_MIX_CONSTRAINT_OFFSET_MULTIPLIER_CONSTRAIN_HELPERS_HPP +#define STAN_TEST_UNIT_MATH_MIX_CONSTRAINT_OFFSET_MULTIPLIER_CONSTRAIN_HELPERS_HPP namespace offset_multiplier_constrain_tests { template diff --git a/test/unit/math/mix/constraint/offset_multiplier_constrain_matvar_helpers.hpp b/test/unit/math/mix/constraint/offset_multiplier_constrain_matvar_helpers.hpp index ecb5a50da82..f9c48bc7907 100644 --- a/test/unit/math/mix/constraint/offset_multiplier_constrain_matvar_helpers.hpp +++ b/test/unit/math/mix/constraint/offset_multiplier_constrain_matvar_helpers.hpp @@ -1,5 +1,5 @@ -#ifndef STAN_TEST_UNIT_MATH_MIX_FUN_OFFSET_MULTIPLIER_MAT_CONSTRAIN_HELPERS_HPP -#define STAN_TEST_UNIT_MATH_MIX_FUN_OFFSET_MULTIPLIER_MAT_CONSTRAIN_HELPERS_HPP +#ifndef STAN_TEST_UNIT_MATH_MIX_CONSTRAINT_OFFSET_MULTIPLIER_MAT_CONSTRAIN_HELPERS_HPP +#define STAN_TEST_UNIT_MATH_MIX_CONSTRAINT_OFFSET_MULTIPLIER_MAT_CONSTRAIN_HELPERS_HPP namespace offset_multiplier_constrain_tests { template From a7dfdb384cf8f5bc682898e2e558ee95618276bb Mon Sep 17 00:00:00 2001 From: Sean Pinkney Date: Mon, 25 Mar 2024 09:36:36 -0400 Subject: [PATCH 39/52] fix lint error --- .../mix/constraint/offset_multiplier_constrain_helpers.hpp | 4 ++-- .../constraint/offset_multiplier_constrain_matvar_helpers.hpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/unit/math/mix/constraint/offset_multiplier_constrain_helpers.hpp b/test/unit/math/mix/constraint/offset_multiplier_constrain_helpers.hpp index 1bce7e2a985..92f063e207c 100644 --- a/test/unit/math/mix/constraint/offset_multiplier_constrain_helpers.hpp +++ b/test/unit/math/mix/constraint/offset_multiplier_constrain_helpers.hpp @@ -1,5 +1,5 @@ -#ifndef STAN_TEST_UNIT_MATH_MIX_CONSTRAINT_OFFSET_MULTIPLIER_CONSTRAIN_HELPERS_HPP -#define STAN_TEST_UNIT_MATH_MIX_CONSTRAINT_OFFSET_MULTIPLIER_CONSTRAIN_HELPERS_HPP +#ifndef STAN_TEST_UNIT_MATH_MIX_OFFSET_MULTIPLIER_CONSTRAIN_HELPERS_HPP +#define STAN_TEST_UNIT_MATH_MIX_OFFSET_MULTIPLIER_CONSTRAIN_HELPERS_HPP namespace offset_multiplier_constrain_tests { template diff --git a/test/unit/math/mix/constraint/offset_multiplier_constrain_matvar_helpers.hpp b/test/unit/math/mix/constraint/offset_multiplier_constrain_matvar_helpers.hpp index f9c48bc7907..fc299d5dfb5 100644 --- a/test/unit/math/mix/constraint/offset_multiplier_constrain_matvar_helpers.hpp +++ b/test/unit/math/mix/constraint/offset_multiplier_constrain_matvar_helpers.hpp @@ -1,5 +1,5 @@ -#ifndef STAN_TEST_UNIT_MATH_MIX_CONSTRAINT_OFFSET_MULTIPLIER_MAT_CONSTRAIN_HELPERS_HPP -#define STAN_TEST_UNIT_MATH_MIX_CONSTRAINT_OFFSET_MULTIPLIER_MAT_CONSTRAIN_HELPERS_HPP +#ifndef STAN_TEST_UNIT_MATH_MIX_OFFSET_MULTIPLIER_MAT_CONSTRAIN_HELPERS_HPP +#define STAN_TEST_UNIT_MATH_MIX_OFFSET_MULTIPLIER_MAT_CONSTRAIN_HELPERS_HPP namespace offset_multiplier_constrain_tests { template From 7551da01468b51f51570a45ae8826fe6e00df777 Mon Sep 17 00:00:00 2001 From: Sean Pinkney Date: Mon, 25 Mar 2024 18:22:21 -0400 Subject: [PATCH 40/52] update --- stan/math/prim/constraint.hpp | 3 +++ stan/math/rev/constraint.hpp | 2 ++ 2 files changed, 5 insertions(+) diff --git a/stan/math/prim/constraint.hpp b/stan/math/prim/constraint.hpp index 9193ea3ddad..169fd8f2e31 100644 --- a/stan/math/prim/constraint.hpp +++ b/stan/math/prim/constraint.hpp @@ -1,5 +1,8 @@ #ifndef STAN_MATH_PRIM_CONSTRAINT_HPP #define STAN_MATH_PRIM_CONSTRAINT_HPP + +#include + #include #include #include diff --git a/stan/math/rev/constraint.hpp b/stan/math/rev/constraint.hpp index 9bebfdf9553..3ab4a6f72c7 100644 --- a/stan/math/rev/constraint.hpp +++ b/stan/math/rev/constraint.hpp @@ -1,6 +1,8 @@ #ifndef STAN_MATH_REV_CONSTRAINT_HPP #define STAN_MATH_REV_CONSTRAINT_HPP +#include + #include #include #include From e64496297cf25716b34a4b208fc4a61b1bb78378 Mon Sep 17 00:00:00 2001 From: Sean Pinkney Date: Tue, 26 Mar 2024 09:05:40 -0400 Subject: [PATCH 41/52] include log1p_exp in prim lub_constrain --- stan/math/prim/constraint/lub_constrain.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/stan/math/prim/constraint/lub_constrain.hpp b/stan/math/prim/constraint/lub_constrain.hpp index ea186fa240f..23b3369a5e7 100644 --- a/stan/math/prim/constraint/lub_constrain.hpp +++ b/stan/math/prim/constraint/lub_constrain.hpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include From 0707438eb37653e0a2a248579111f3d4d9a418f6 Mon Sep 17 00:00:00 2001 From: Steve Bronder Date: Tue, 2 Apr 2024 12:33:08 -0400 Subject: [PATCH 42/52] only allow the move operator for arena matrix types if the input type is the same type as what will be stored in the matrix --- stan/math/rev/core/arena_matrix.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/stan/math/rev/core/arena_matrix.hpp b/stan/math/rev/core/arena_matrix.hpp index 54c061e7880..d20bb9a5c52 100644 --- a/stan/math/rev/core/arena_matrix.hpp +++ b/stan/math/rev/core/arena_matrix.hpp @@ -105,7 +105,8 @@ class arena_matrix> template * = nullptr, require_not_arena_matrix_t* = nullptr, require_t>* = nullptr, - require_plain_type_t* = nullptr> + require_plain_type_t* = nullptr, + require_same_t* = nullptr> arena_matrix(T&& other) // NOLINT : Base::Map([](auto&& x) { using base_map_t = @@ -126,7 +127,8 @@ class arena_matrix> template * = nullptr, require_not_arena_matrix_t* = nullptr, require_t>* = nullptr, - require_plain_type_t* = nullptr> + require_plain_type_t* = nullptr, + require_same_t* = nullptr> arena_matrix& operator=(T&& other) { auto other_ptr = make_chainable_ptr(std::move(other)); new (this) From a604fa447bba49b120e3b7c0fd1006dd2d2f0485 Mon Sep 17 00:00:00 2001 From: Steve Bronder Date: Thu, 18 Apr 2024 12:51:07 -0400 Subject: [PATCH 43/52] update header includes for var_test --- test/unit/math/rev/core/var_test.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/test/unit/math/rev/core/var_test.cpp b/test/unit/math/rev/core/var_test.cpp index 1bfbc207170..a2ca9a36d64 100644 --- a/test/unit/math/rev/core/var_test.cpp +++ b/test/unit/math/rev/core/var_test.cpp @@ -3,7 +3,6 @@ #include #include #include -#include #include #include #include From 6a71cfb9d04f8d3797e324d68305d4af885464db Mon Sep 17 00:00:00 2001 From: Steve Bronder Date: Thu, 18 Apr 2024 13:20:13 -0400 Subject: [PATCH 44/52] ad require_not_arena_matrix_t --- stan/math/prim/meta/is_arena_matrix.hpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/stan/math/prim/meta/is_arena_matrix.hpp b/stan/math/prim/meta/is_arena_matrix.hpp index f9553a5b016..00e71b6abe4 100644 --- a/stan/math/prim/meta/is_arena_matrix.hpp +++ b/stan/math/prim/meta/is_arena_matrix.hpp @@ -23,5 +23,17 @@ template using require_arena_matrix_t = require_t>>; /*! @} */ +/*! \ingroup require_eigen_types */ +/*! \defgroup arena_matrix_types arena_matrix */ +/*! \addtogroup arena_matrix_types */ +/*! @{ */ + +/*! \brief Require type does not satisfy @ref is_arena_matrix */ +/*! @tparam T the type to check */ +template +using require_not_arena_matrix_t = require_t>>; +/*! @} */ + + } // namespace stan #endif From a2124c1a25f2d9adbaf844a53c6d1aaea85075e9 Mon Sep 17 00:00:00 2001 From: Stan Jenkins Date: Thu, 18 Apr 2024 13:21:17 -0400 Subject: [PATCH 45/52] [Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1 --- stan/math/prim/meta/is_arena_matrix.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/stan/math/prim/meta/is_arena_matrix.hpp b/stan/math/prim/meta/is_arena_matrix.hpp index 00e71b6abe4..3f895bed183 100644 --- a/stan/math/prim/meta/is_arena_matrix.hpp +++ b/stan/math/prim/meta/is_arena_matrix.hpp @@ -34,6 +34,5 @@ template using require_not_arena_matrix_t = require_t>>; /*! @} */ - } // namespace stan #endif From a035f62189ca05074c253915940ae476d5afb236 Mon Sep 17 00:00:00 2001 From: Steve Bronder Date: Thu, 18 Apr 2024 13:34:16 -0400 Subject: [PATCH 46/52] remove wiener_log function --- stan/math/prim/prob.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/stan/math/prim/prob.hpp b/stan/math/prim/prob.hpp index 15a76213d74..f1b4efa5b6f 100644 --- a/stan/math/prim/prob.hpp +++ b/stan/math/prim/prob.hpp @@ -306,7 +306,6 @@ #include #include #include -#include #include #include #include From 1e906d968f910fdee807dad9df4abc656c7a3a85 Mon Sep 17 00:00:00 2001 From: Steve Bronder Date: Thu, 18 Apr 2024 14:35:29 -0400 Subject: [PATCH 47/52] fix definition of require_not_arena_matrix_t --- stan/math/prim/meta/is_arena_matrix.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stan/math/prim/meta/is_arena_matrix.hpp b/stan/math/prim/meta/is_arena_matrix.hpp index 00e71b6abe4..9e9503ba0e5 100644 --- a/stan/math/prim/meta/is_arena_matrix.hpp +++ b/stan/math/prim/meta/is_arena_matrix.hpp @@ -31,7 +31,7 @@ using require_arena_matrix_t = require_t>>; /*! \brief Require type does not satisfy @ref is_arena_matrix */ /*! @tparam T the type to check */ template -using require_not_arena_matrix_t = require_t>>; +using require_not_arena_matrix_t = require_t>::value>>; /*! @} */ From de7d11e7030d74d7eddbe9ebfc9a3366359a047a Mon Sep 17 00:00:00 2001 From: Steve Bronder Date: Thu, 18 Apr 2024 14:36:34 -0400 Subject: [PATCH 48/52] fix definition of require_not_arena_matrix_t --- stan/math/prim/meta/is_arena_matrix.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stan/math/prim/meta/is_arena_matrix.hpp b/stan/math/prim/meta/is_arena_matrix.hpp index 9e9503ba0e5..00e71b6abe4 100644 --- a/stan/math/prim/meta/is_arena_matrix.hpp +++ b/stan/math/prim/meta/is_arena_matrix.hpp @@ -31,7 +31,7 @@ using require_arena_matrix_t = require_t>>; /*! \brief Require type does not satisfy @ref is_arena_matrix */ /*! @tparam T the type to check */ template -using require_not_arena_matrix_t = require_t>::value>>; +using require_not_arena_matrix_t = require_t>>; /*! @} */ From eee02d8a7b7f27a57260859fc1202f2d108f35d2 Mon Sep 17 00:00:00 2001 From: Steve Bronder Date: Thu, 18 Apr 2024 14:38:02 -0400 Subject: [PATCH 49/52] merge --- stan/math/prim/meta/is_arena_matrix.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stan/math/prim/meta/is_arena_matrix.hpp b/stan/math/prim/meta/is_arena_matrix.hpp index 3f895bed183..90438d8971d 100644 --- a/stan/math/prim/meta/is_arena_matrix.hpp +++ b/stan/math/prim/meta/is_arena_matrix.hpp @@ -31,7 +31,7 @@ using require_arena_matrix_t = require_t>>; /*! \brief Require type does not satisfy @ref is_arena_matrix */ /*! @tparam T the type to check */ template -using require_not_arena_matrix_t = require_t>>; +using require_not_arena_matrix_t = require_t>::value>>; /*! @} */ } // namespace stan From c5f983ace671c90df4cd213fbb364b97f57994c1 Mon Sep 17 00:00:00 2001 From: Stan Jenkins Date: Thu, 18 Apr 2024 14:39:02 -0400 Subject: [PATCH 50/52] [Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1 --- stan/math/prim/meta/is_arena_matrix.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stan/math/prim/meta/is_arena_matrix.hpp b/stan/math/prim/meta/is_arena_matrix.hpp index 90438d8971d..bd2acfe4c38 100644 --- a/stan/math/prim/meta/is_arena_matrix.hpp +++ b/stan/math/prim/meta/is_arena_matrix.hpp @@ -31,7 +31,8 @@ using require_arena_matrix_t = require_t>>; /*! \brief Require type does not satisfy @ref is_arena_matrix */ /*! @tparam T the type to check */ template -using require_not_arena_matrix_t = require_t>::value>>; +using require_not_arena_matrix_t + = require_t>::value>>; /*! @} */ } // namespace stan From 00314f3ac86779c43793c626b2f974e782fc28b4 Mon Sep 17 00:00:00 2001 From: Steve Bronder Date: Thu, 18 Apr 2024 14:41:36 -0400 Subject: [PATCH 51/52] fix test that used _log function --- test/unit/math/mix/prob/multi_student_t_cholesky_test.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/test/unit/math/mix/prob/multi_student_t_cholesky_test.cpp b/test/unit/math/mix/prob/multi_student_t_cholesky_test.cpp index 6aff088995a..010440f3ee1 100644 --- a/test/unit/math/mix/prob/multi_student_t_cholesky_test.cpp +++ b/test/unit/math/mix/prob/multi_student_t_cholesky_test.cpp @@ -76,7 +76,6 @@ TEST(ProbDistributionsMultiStudentTCholesky, fvar_var) { using Eigen::Dynamic; using Eigen::Matrix; using stan::math::fvar; - using stan::math::multi_student_t_log; using stan::math::var; using std::vector; Matrix, Dynamic, 1> y(3, 1); From 91ea4c12b78e834922ecb8093da1f361952d706d Mon Sep 17 00:00:00 2001 From: Steve Bronder Date: Mon, 29 Apr 2024 13:55:46 -0400 Subject: [PATCH 52/52] fix docs --- .../contributor_help_pages/common_pitfalls.md | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/doxygen/contributor_help_pages/common_pitfalls.md b/doxygen/contributor_help_pages/common_pitfalls.md index 371faa07017..3ce9e15569f 100644 --- a/doxygen/contributor_help_pages/common_pitfalls.md +++ b/doxygen/contributor_help_pages/common_pitfalls.md @@ -177,7 +177,7 @@ We can see in the above that the standard style of a move (the constructor takin But in Stan, particularly for reverse mode, we need to keep memory around even if it's only temporary for when we call the gradient calculations in the reverse pass. And since memory for reverse mode is stored in our arena allocator no copying happens in the first place. -Functions for Stan math's reverse mode autodiff should use [_perfect forwarding_](https://drewcampbell92.medium.com/understanding-move-semantics-and-perfect-forwarding-part-3-65575d523ff8) arguments. This arguments are a template parameter with `&&` next to them. +Functions for Stan Math's reverse mode autodiff should use [_perfect forwarding_](https://drewcampbell92.medium.com/understanding-move-semantics-and-perfect-forwarding-part-3-65575d523ff8) arguments. Perfect forwarding arguments use a template parameter wit no attributes such as `const` and `volatile` and have a double ampersand `&&` next to them. ```c++ template @@ -186,7 +186,8 @@ Functions for Stan math's reverse mode autodiff should use [_perfect forwarding_ } ``` -A perfect forwarding argument of a function accepts any reference type as it's input argument. +The `std::forward` in the in the code above tells the compiler that if `T` is deduced to be an rvalue reference (such as `Eigen::MatrixXd&&`), then it should be moved to `my_other_function`, where there it can possibly use another objects move constructor to reuse memory. +A perfect forwarding argument of a function accepts any reference type as its input argument. The above signature is equivalent to writing out several functions with different reference types ```c++ @@ -202,10 +203,12 @@ The above signature is equivalent to writing out several functions with differen auto my_function(Eigen::MatrixXd&& x) { return my_other_function(std::move(x)); } + // Accepts a const rvalue reference + auto my_function(const Eigen::MatrixXd&& x) { + return my_other_function(std::move(x)); + } ``` -The `std::forward` in the in the code above tells the compiler that if `T` is deduced to be an rvalue reference (such as `Eigen::MatrixXd&&`), then it should be moved to `my_other_function`, where there it can possibly use another objects move constructor to reuse memory. - In Stan, perfect forwarding is used in reverse mode functions which can accept an Eigen matrix type. ```c++ @@ -257,7 +260,7 @@ That expression will be evaluated into new memory allocated in the arena allocat return ret; ``` -The rest of this code follows the standard format for the rest of Stan math's reverse mode that accepts Eigen types as input. +The rest of this code follows the standard format for the rest of Stan Math's reverse mode that accepts Eigen types as input. The `reverse_pass_callback` function accepts a lambda as input and places the lambda in Stan's callback stack to be called later when `grad()` is called by the user. Since `arena_matrix` types only store a pointer to memory allocated elsewhere they are copied into the lambda. The body of the lambda holds the gradient calculation needed for the reverse mode pass. @@ -279,9 +282,9 @@ The general rules to follow for passing values to a function are: The use of auto with the Stan Math library should be used with care, like in [Eigen](https://eigen.tuxfamily.org/dox/TopicPitfalls.html). Along with the cautions mentioned in the Eigen docs, there are also memory considerations when using reverse mode automatic differentiation. -When returning from a function in the Stan math library with an Eigen matrix output with a scalar `var` type, the actual returned type will often be an `arena_matrix>`. +When returning from a function in the Stan Math library with an Eigen matrix output with a scalar `var` type, the actual returned type will often be an `arena_matrix>`. The `arena_matrix` class is an Eigen matrix where the underlying array of memory is located in Stan's memory arena. -The `arena_matrix` that is returned by Stan functions is normally the same one resting in the callback used to calculate gradients in the reverse pass. +The `arena_matrix` that is returned by Math functions is normally the same one resting in the callback used to calculate gradients in the reverse pass. Directly changing the elements of this matrix would also change the memory the reverse pass callback sees which would result in incorrect calculations. The simple solution to this is that when you use a math library function that returns a matrix and then want to assign to any of the individual elements of the matrix, assign to an actual Eigen matrix type instead of using auto. @@ -367,8 +370,8 @@ grad(); Now `res` is `innocent_return` and we've changed one of the elements of `innocent_return`, but that is also going to change the element of `res` which is being used in our reverse pass callback! -Care must be taken by end users of Stan math by using `auto` with caution. -When a user wishes to manipulate the coefficients of a matrix that is a return from a function in Stan math, they should assign the matrix to a plain Eigen type. +Care must be taken by end users of Stan Math by using `auto` with caution. +When a user wishes to manipulate the coefficients of a matrix that is a return from a function in Stan Math, they should assign the matrix to a plain Eigen type. ```c++ Eigen::Matrix x = Eigen::Matrix::Random(5);