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
1 change: 0 additions & 1 deletion stan/math/prim/meta.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@
#include <stan/math/prim/meta/ad_promotable.hpp>
#include <stan/math/prim/meta/append_return_type.hpp>
#include <stan/math/prim/meta/base_type.hpp>
#include <stan/math/prim/meta/common_container_type.hpp>
#include <stan/math/prim/meta/contains_std_vector.hpp>
#include <stan/math/prim/meta/contains_tuple.hpp>
#include <stan/math/prim/meta/error_index.hpp>
Expand Down
77 changes: 0 additions & 77 deletions stan/math/prim/meta/common_container_type.hpp

This file was deleted.

5 changes: 4 additions & 1 deletion stan/math/prim/meta/is_vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,10 @@ using require_eigen_row_vector_t
* member with a value of false.
*/
template <typename T>
struct is_row_vector : internal::is_row_vector_impl<T> {};
struct is_row_vector : internal::is_row_vector_impl<std::decay_t<T>> {};

template <typename T>
inline constexpr bool is_row_vector_v = is_row_vector<T>::value;

/*! \ingroup require_eigens_types */
/*! \defgroup row_vector_types row_vector */
Expand Down
21 changes: 11 additions & 10 deletions stan/math/prim/prob/student_t_qf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <stan/math/prim/fun/sqrt.hpp>
#include <stan/math/prim/fun/inv_inc_beta.hpp>
#include <stan/math/prim/fun/max_size.hpp>
#include <stan/math/prim/fun/to_ref.hpp>

namespace stan {
namespace math {
Expand Down Expand Up @@ -70,20 +71,20 @@ template <typename T_p, typename T_nu, typename T_mu, typename T_sigma,
require_any_vector_t<T_p, T_nu, T_mu, T_sigma>* = nullptr>
inline auto student_t_qf(const T_p& p, const T_nu& nu, const T_mu& mu,
const T_sigma& sigma) {
using T_container = common_container_t<T_p, T_nu, T_mu, T_sigma>;
using ret_scalar = return_type_t<T_p, T_nu, T_mu, T_sigma>;
static constexpr const char* function = "student_t_qf";
const size_t max_size_all = max_size(p, nu, mu, sigma);
T_container result(max_size_all);
Eigen::Matrix<ret_scalar, -1, 1> result(max_size_all);

ref_type_t<T_p> p_ref = p;
ref_type_t<T_nu> nu_ref = nu;
ref_type_t<T_mu> mu_ref = mu;
ref_type_t<T_sigma> sigma_ref = sigma;
decltype(auto) p_ref = to_ref(p);
decltype(auto) nu_ref = to_ref(nu);
decltype(auto) mu_ref = to_ref(mu);
decltype(auto) sigma_ref = to_ref(sigma);

scalar_seq_view<ref_type_t<T_p>> p_vec(p_ref);
scalar_seq_view<ref_type_t<T_nu>> nu_vec(nu_ref);
scalar_seq_view<ref_type_t<T_mu>> mu_vec(mu_ref);
scalar_seq_view<ref_type_t<T_sigma>> sigma_vec(sigma_ref);
scalar_seq_view<decltype(p_ref)> p_vec(p_ref);
scalar_seq_view<decltype(nu_ref)> nu_vec(nu_ref);
scalar_seq_view<decltype(mu_ref)> mu_vec(mu_ref);
scalar_seq_view<decltype(sigma_ref)> sigma_vec(sigma_ref);

for (size_t i = 0; i < max_size_all; ++i) {
result[i] = student_t_qf(p_vec[i], nu_vec[i], mu_vec[i], sigma_vec[i]);
Expand Down
9 changes: 3 additions & 6 deletions test/unit/math/mix/prob/student_t_qf_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,11 @@ TEST_F(AgradRev, mathMixProb_student_t_qf) {
stan::test::expect_ad(f, 0.8, 0.5, 0.1);
stan::test::expect_ad(f, 0.1, 3, 3);

Eigen::VectorXd p(3);
p << 0.3, 0.8, 0.1;
Eigen::VectorXd p{{0.3, 0.8, 0.1}};

Eigen::VectorXd nu(3);
nu << 0.5, 0.5, 3;
Eigen::VectorXd nu{{0.5, 0.5, 3}};

Eigen::VectorXd sigma(3);
sigma << 3, 0.1, 3;
Eigen::VectorXd sigma{{3, 0.1, 3}};

stan::test::expect_ad(f, p, nu, sigma);
}
11 changes: 4 additions & 7 deletions test/unit/math/prim/prob/student_t_qf_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
TEST(MathFunctions, student_t_qf_vals) {
using stan::math::student_t_qf;

Eigen::VectorXd p(5);
p << 0.1, 0.2, 0.5, 0.8, 0.9;
Eigen::VectorXd p{{0.1, 0.2, 0.5, 0.8, 0.9}};

Eigen::VectorXd res = student_t_qf(p, 4, 2, 3);

Expand All @@ -21,11 +20,9 @@ TEST(MathFunctions, student_t_qf_vals) {
TEST(MathFunctions, student_t_qf_vec) {
using stan::math::student_t_qf;

Eigen::VectorXd p(5);
p << 0.1, 0.2, 0.5, 0.8, 0.9;
Eigen::VectorXd p{{0.1, 0.2, 0.5, 0.8, 0.9}};

Eigen::VectorXd nu(5);
nu << 4, 4, 3, 3, 3;
Eigen::VectorXd nu{{4, 4, 3, 3, 3}};

Eigen::VectorXd res(5);
for (int i = 0; i < 5; ++i) {
Expand All @@ -37,7 +34,7 @@ TEST(MathFunctions, student_t_qf_vec) {
Eigen::RowVectorXd nu_rowvec = nu.transpose();
Eigen::RowVectorXd res_rowvec = res.transpose();

EXPECT_MATRIX_FLOAT_EQ(res_rowvec, student_t_qf(p_rowvec, nu_rowvec, 2, 3));
EXPECT_MATRIX_FLOAT_EQ(res, student_t_qf(p_rowvec, nu_rowvec, 2, 3));
}

TEST(MathFunctions, student_t_qf_inf) {
Expand Down
Loading