Description
The Stan math library has several functions for checking that two containers have the same size.
check_matching_dims
check_matching_sizes
check_consistent_sizes
check_consistent_sizes_mvt
But these are limited. The first one only operates on matrices. The other three check only the outermost dimension.
Sometimes it's necessary to validate that all dimensions match. For example
std::vector<Eigen::VectorXd> a(2, Eigen::VectorXd::Constant(2, 1.0));
std::vector<Eigen::VectorXd> b(N, Eigen::VectorXd::Constant(K, 2.0));
stan::math::check_consistent_sizes("vectorized_add", "A", a, "B", b);
stan::math::apply_scalar_binary(a, b, [=](double x, double y) { return x + y; });
N=2,K=2: ok
N=3,K=2: throws exception "A has size = 2, but B has size 3; and they must be the same size." (as expected)
N=2,K=3: aborted: assertion failed (very bad)
I need something that can check arbitrary deep dimensions for stan-dev/stanc3#552
Current Version:
v3.2.0
Description
The Stan math library has several functions for checking that two containers have the same size.
check_matching_dimscheck_matching_sizescheck_consistent_sizescheck_consistent_sizes_mvtBut these are limited. The first one only operates on matrices. The other three check only the outermost dimension.
Sometimes it's necessary to validate that all dimensions match. For example
N=2,K=2: okN=3,K=2: throws exception"A has size = 2, but B has size 3; and they must be the same size."(as expected)N=2,K=3: aborted: assertion failed (very bad)I need something that can check arbitrary deep dimensions for stan-dev/stanc3#552
Current Version:
v3.2.0