|
2 | 2 | #define STAN_MATH_MIX_FUNCTOR_LAPLACE_MARGINAL_DENSITY_HPP |
3 | 3 | #include <stan/math/prim/fun/Eigen.hpp> |
4 | 4 | #include <stan/math/mix/functor/laplace_likelihood.hpp> |
5 | | -#include <test/unit/pretty_print_types.hpp> |
6 | 5 | #include <stan/math/rev/meta.hpp> |
7 | 6 | #include <stan/math/rev/core.hpp> |
8 | 7 | #include <stan/math/rev/fun.hpp> |
@@ -315,7 +314,9 @@ inline void set_zero_adjoint(Output&& output) { |
315 | 314 | static_assert( |
316 | 315 | sizeof(std::decay_t<output_i_t>*) == 0, |
317 | 316 | "INTERNAL ERROR:(laplace_marginal_lpdf) set_zero_adjoints was " |
318 | | - "not able to deduce the actions needed for the given type."); |
| 317 | + "not able to deduce the actions needed for the given type. " |
| 318 | + "This is an internal error, please report it: " |
| 319 | + "https://github.com/stan-dev/math/issues"); |
319 | 320 | } |
320 | 321 | }, |
321 | 322 | std::forward<Output>(output)); |
@@ -360,7 +361,9 @@ inline void collect_adjoints(Output& output, Input&& input) { |
360 | 361 | static_assert( |
361 | 362 | sizeof(std::decay_t<output_i_t>*) == 0, |
362 | 363 | "INTERNAL ERROR:(laplace_marginal_lpdf) set_zero_adjoints was " |
363 | | - "not able to deduce the actions needed for the given type."); |
| 364 | + "not able to deduce the actions needed for the given type. " |
| 365 | + "This is an internal error, please report it: " |
| 366 | + "https://github.com/stan-dev/math/issues"); |
364 | 367 | } |
365 | 368 | }, |
366 | 369 | std::forward<Output>(output), std::forward<Input>(input)); |
@@ -497,7 +500,7 @@ inline auto laplace_marginal_density_est(LLFun&& ll_fun, LLTupleArgs&& ll_args, |
497 | 500 | }; |
498 | 501 | auto ll_args_vals = value_of(ll_args); |
499 | 502 | const Eigen::Index theta_size = theta_0.size(); |
500 | | - std::decay_t<ThetaVec> theta = theta_0; |
| 503 | + Eigen::VectorXd theta = std::forward<ThetaVec>(theta_0); |
501 | 504 | double objective_old = std::numeric_limits<double>::lowest(); |
502 | 505 | double objective_new = std::numeric_limits<double>::lowest() + 1; |
503 | 506 | Eigen::VectorXd a_prev = Eigen::VectorXd::Zero(theta_size); |
@@ -814,7 +817,9 @@ inline void collect_adjoints(Output&& output, Input&& input) { |
814 | 817 | static_assert( |
815 | 818 | sizeof(std::decay_t<output_i_t>*) == 0, |
816 | 819 | "INTERNAL ERROR:(laplace_marginal_lpdf) set_zero_adjoints was " |
817 | | - "not able to deduce the actions needed for the given type."); |
| 820 | + "not able to deduce the actions needed for the given type. " |
| 821 | + "This is an internal error, please report it: " |
| 822 | + "https://github.com/stan-dev/math/issues"); |
818 | 823 | } |
819 | 824 | }, |
820 | 825 | std::forward<Output>(output), std::forward<Input>(input)); |
@@ -864,7 +869,9 @@ inline void copy_compute_s2(Output&& output, Input&& input) { |
864 | 869 | static_assert( |
865 | 870 | sizeof(std::decay_t<output_i_t>*) == 0, |
866 | 871 | "INTERNAL ERROR:(laplace_marginal_lpdf) set_zero_adjoints was " |
867 | | - "not able to deduce the actions needed for the given type."); |
| 872 | + "not able to deduce the actions needed for the given type. " |
| 873 | + "This is an internal error, please report it: " |
| 874 | + "https://github.com/stan-dev/math/issues"); |
868 | 875 | } |
869 | 876 | }, |
870 | 877 | std::forward<Output>(output), std::forward<Input>(input)); |
@@ -921,11 +928,11 @@ template <typename Output, typename Input> |
921 | 928 | inline void collect_adjoints(Output&& output, const vari* ret, Input&& input) { |
922 | 929 | if constexpr (is_tuple_v<Output>) { |
923 | 930 | static_assert(sizeof(std::decay_t<Output>*) == 0, |
924 | | - "INTERNAL ERROR:(laplace_marginal_lpdf)" |
| 931 | + "INTERNAL ERROR:(laplace_marginal_lpdf) " |
925 | 932 | "Accumulate Adjoints called on a tuple, but tuples cannot be " |
926 | | - "on the reverse mode stack!" |
927 | | - "This is an internal error, please report it to the stan " |
928 | | - "github as an issue."); |
| 933 | + "on the reverse mode stack! " |
| 934 | + "This is an internal error, please report it: " |
| 935 | + "https://github.com/stan-dev/math/issues"); |
929 | 936 | } else if constexpr (is_std_vector_v<Output>) { |
930 | 937 | if constexpr (!is_var_v<value_type_t<Output>>) { |
931 | 938 | const auto output_size = output.size(); |
@@ -1032,7 +1039,7 @@ inline auto laplace_marginal_density(const LLFun& ll_fun, LLTupleArgs&& ll_args, |
1032 | 1039 | // Solver 3 |
1033 | 1040 | arena_t<Eigen::MatrixXd> LU_solve_covariance; |
1034 | 1041 | // Solver 1, 2, 3 |
1035 | | - arena_t<promote_scalar_t<double, std::decay_t<ThetaVec>>> s2( |
| 1042 | + arena_t<promote_scalar_t<double, plain_type_t<std::decay_t<ThetaVec>>>> s2( |
1036 | 1043 | theta_0.size()); |
1037 | 1044 | // Make one hard copy here |
1038 | 1045 | using laplace_likelihood::internal::conditional_copy_and_promote; |
|
0 commit comments