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
4 changes: 2 additions & 2 deletions stan/math/mix/functor/laplace_marginal_density_estimator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ inline constexpr auto tuple_to_laplace_options(Options&& ops) {
}
auto defaults = laplace_options_default{};
return laplace_options_user_supplied{
value_of(std::get<0>(std::forward<Ops>(ops))),
value_of(std::get<0>(std::forward<Options>(ops))),
std::get<1>(ops),
std::get<2>(ops),
defaults.hessian_block_size,
Expand All @@ -163,7 +163,7 @@ inline constexpr auto tuple_to_laplace_options(Options&& ops) {
(std::get<5>(ops) > 0) ? true : false,
};
} else {
return std::forward<Ops>(ops);
return std::forward<Options>(ops);
}
}

Expand Down
36 changes: 36 additions & 0 deletions test/unit/math/laplace/tuple_to_laplace_options_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include <test/unit/math/test_ad.hpp>
#include <test/unit/math/laplace/laplace_utility.hpp>

TEST(laplace_utils, tuple_to_laplace_options) {
using stan::math::laplace_options_user_supplied;
using stan::math::internal::tuple_to_laplace_options;

auto ops = std::make_tuple(Eigen::VectorXd::Zero(3), 1e-6, 100, 1, 2, 0);
auto laplace_opts = tuple_to_laplace_options(ops);
EXPECT_EQ(laplace_opts.hessian_block_size, 1);
EXPECT_EQ(laplace_opts.solver, 1);
EXPECT_EQ(laplace_opts.tolerance, 1e-6);
EXPECT_EQ(laplace_opts.max_num_steps, 100);
EXPECT_EQ(laplace_opts.line_search.max_iterations, 2);
EXPECT_EQ(laplace_opts.allow_fallthrough, false);
EXPECT_EQ(laplace_opts.theta_0, Eigen::VectorXd::Zero(3));
static_assert(
std::is_same_v<decltype(laplace_opts), laplace_options_user_supplied>);
}

TEST(laplace_utils, tuple_to_laplace_options_move) {
using stan::math::laplace_options_user_supplied;
using stan::math::internal::tuple_to_laplace_options;

auto ops = std::make_tuple(Eigen::VectorXd::Zero(3), 1e-6, 100, 1, 2, 1);
auto laplace_opts = tuple_to_laplace_options(std::move(ops));
EXPECT_EQ(laplace_opts.hessian_block_size, 1);
EXPECT_EQ(laplace_opts.solver, 1);
EXPECT_EQ(laplace_opts.tolerance, 1e-6);
EXPECT_EQ(laplace_opts.max_num_steps, 100);
EXPECT_EQ(laplace_opts.line_search.max_iterations, 2);
EXPECT_EQ(laplace_opts.allow_fallthrough, true);
EXPECT_EQ(laplace_opts.theta_0, Eigen::VectorXd::Zero(3));
static_assert(
std::is_same_v<decltype(laplace_opts), laplace_options_user_supplied>);
}
Loading