Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
767bdc5
feat: add map-like helpers map, mapN, row_map, row_mapN, col_map, col…
Jul 17, 2026
518aaf5
tests: add unit tests for map-like helpers
Jul 17, 2026
4fed436
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot Jul 17, 2026
8459b1c
refactor: minor refactoring in assign_matrix_row/col
Jul 19, 2026
ca611e9
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot Jul 19, 2026
ef70860
ci: retrigger Jenkins after auto-formatting
Jul 20, 2026
5d27bf1
remove assign_(row/col) and generalize the check_consistent_size(...)
SteveBronder Jul 22, 2026
716f5d5
Merge commit '20bf73474b5f5c38ed54e30d207b1b9e0bf8769e' into HEAD
yashikno Jul 22, 2026
05b7c8d
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot Jul 22, 2026
eba6918
generalize the check_matching_dims(...) of map.hpp
SteveBronder Jul 22, 2026
189b971
add tuple arguments to mapN helpers
SteveBronder Jul 22, 2026
819a8d9
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot Jul 22, 2026
4dc1c00
fix tuple map Eigen expression lifetime
SteveBronder Jul 23, 2026
73cd3f8
Merge commit '5b59600d557d911b159f06f75dc4c0f31c498d14' into HEAD
yashikno Jul 23, 2026
db518e2
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot Jul 23, 2026
8927f56
refactor: add trailing shared args
Jul 29, 2026
adc33cb
fix: apply review requests regarding API, style, and checks
Aug 10, 2026
67caf1a
feat: add new template
Aug 10, 2026
3549bb9
tests: add new tests for signiture
Aug 10, 2026
b44c91a
Merge commit 'cc6ba8bcf31996d581d67c887653009df3b9d7dd' into HEAD
yashikno Aug 10, 2026
b8b9396
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot Aug 10, 2026
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
30 changes: 30 additions & 0 deletions stan/math/prim/err/check_consistent_sizes.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#ifndef STAN_MATH_PRIM_ERR_CHECK_CONSISTENT_SIZES_HPP
#define STAN_MATH_PRIM_ERR_CHECK_CONSISTENT_SIZES_HPP

#include <stan/math/prim/err/check_matching_sizes.hpp>
#include <stan/math/prim/err/invalid_argument.hpp>
#include <stan/math/prim/fun/size.hpp>
#include <stan/math/prim/meta/is_container.hpp>
#include <stan/math/prim/meta/require_generics.hpp>
#include <algorithm>
#include <sstream>
Expand Down Expand Up @@ -66,6 +68,34 @@ inline void check_consistent_sizes(const char* function, const char* name1,
}
}

/**
* Check that the unnamed container inputs have the same size. Inputs are
* labeled `arg1`, `arg2`, and so on in error messages.
*
* @tparam T type of the first input
* @tparam Types types of the remaining inputs
* @param function function name (for error messages)
* @param x first input
* @param xs remaining inputs
* @throw `invalid_argument` if sizes are inconsistent
*/
template <typename T, typename... Types,
require_all_container_t<T, Types...>* = nullptr>
inline void check_consistent_sizes(const char* function, T&& x, Types&&... xs) {
std::size_t arg_idx = 2;
(
[&](const auto& y) {
if (x.size() != y.size()) {
[&]() STAN_COLD_PATH {
const std::string name = "arg" + std::to_string(arg_idx);
check_matching_sizes(function, "arg1", x, name.c_str(), y);
}();
}
++arg_idx;
}(xs),
...);
}

} // namespace math
} // namespace stan
#endif
29 changes: 29 additions & 0 deletions stan/math/prim/err/check_matching_dims.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,35 @@ inline void check_matching_dims(const char* function, const char* name1,
check_matching_dims(function, name1, y1, name2, y2);
}

/**
* Check that the unnamed Eigen inputs have the same dimensions. Inputs are
* labeled `arg1`, `arg2`, and so on in error messages.
*
* @tparam T type of the first input
* @tparam Types types of the remaining inputs
* @param function function name (for error messages)
* @param x first input
* @param xs remaining inputs
* @throw `invalid_argument` if dimensions do not match
*/
template <typename T, typename... Types,
require_all_eigen_t<T, Types...>* = nullptr>
inline void check_matching_dims(const char* function, const T& x,
const Types&... xs) {
std::size_t arg_idx = 2;
(
[&](const auto& y) {
if (x.rows() != y.rows() || x.cols() != y.cols()) {
[&]() STAN_COLD_PATH {
const std::string name = "arg" + std::to_string(arg_idx);
check_matching_dims(function, "arg1", x, name.c_str(), y);
}();
}
++arg_idx;
}(xs),
...);
}

} // namespace math
} // namespace stan
#endif
1 change: 1 addition & 0 deletions stan/math/prim/functor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <stan/math/prim/functor/ode_ckrk.hpp>
#include <stan/math/prim/functor/ode_rk45.hpp>
#include <stan/math/prim/functor/ode_store_sensitivities.hpp>
#include <stan/math/prim/functor/map.hpp>
#include <stan/math/prim/functor/map_if.hpp>
#include <stan/math/prim/functor/map_rect.hpp>
#include <stan/math/prim/functor/map_rect_combine.hpp>
Expand Down
Loading