Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion stan/math/prim/err/check_cholesky_factor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <stan/math/prim/fun/to_ref.hpp>
#include <stan/math/prim/fun/value_of_rec.hpp>
#include <stan/math/prim/err/check_positive.hpp>
#include <stan/math/prim/err/check_nonnegative.hpp>
#include <stan/math/prim/err/check_less_or_equal.hpp>
#include <stan/math/prim/err/check_lower_triangular.hpp>
#include <stan/math/prim/err/make_iter_name.hpp>
Expand Down Expand Up @@ -34,7 +35,7 @@ inline void check_cholesky_factor(const char* function, const char* name,
const Mat& y) {
check_less_or_equal(function, "columns and rows of Cholesky factor", y.cols(),
y.rows());
check_positive(function, "columns of Cholesky factor", y.cols());
check_nonnegative(function, "columns of Cholesky factor", y.cols());
auto&& y_ref = to_ref(value_of_rec(y));
check_lower_triangular(function, name, y_ref);
check_positive(function, name, y_ref.diagonal());
Expand Down
13 changes: 13 additions & 0 deletions test/unit/math/prim/prob/lkj_corr_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@
#include <boost/random/mersenne_twister.hpp>
#include <boost/math/distributions.hpp>

TEST(ProbDistributionsLkjCorr, testZero) {
boost::random::mt19937 rng;
unsigned int K = 0;
Eigen::MatrixXd Sigma(K, K);
Sigma.setZero();
Sigma.diagonal().setOnes();
double eta = stan::math::uniform_rng(0, 2, rng);
double f = stan::math::do_lkj_constant(eta, K);
EXPECT_FLOAT_EQ(0, stan::math::lkj_corr_cholesky_lpdf(Sigma, eta));
eta = 1.0;
EXPECT_FLOAT_EQ(0, stan::math::lkj_corr_cholesky_lpdf(Sigma, eta));
}

TEST(ProbDistributionsLkjCorr, testIdentity) {
boost::random::mt19937 rng;
unsigned int K = 4;
Expand Down
Loading