1#ifndef STAN_MATH_PRIM_ERR_ELEMENTWISE_ERROR_CHECKER_HPP
2#define STAN_MATH_PRIM_ERR_ELEMENTWISE_ERROR_CHECKER_HPP
42 template <
typename T,
typename = require_stan_scalar_t<T>>
53 template <
typename T,
typename = require_not_stan_scalar_t<T>,
66inline void pipe_in(std::stringstream& ss) {}
76template <
typename Arg0,
typename... Args>
77inline void pipe_in(std::stringstream& ss, Arg0 arg0,
const Args... args) {
87template <
typename... Args>
91 throw std::domain_error(ss.str());
114template <
typename F,
typename T,
typename... Indexings,
117 const char* name,
const T& x,
const char* must_be,
118 const Indexings&... indexings) {
122 indexings...,
" is ", x,
123 ", but must be ", must_be,
"!");
145template <
typename F,
typename T,
typename... Indexings,
147 std::enable_if_t<(Eigen::internal::traits<T>::Flags
148 & Eigen::LinearAccessBit)
149 || T::IsVectorAtCompileTime>* =
nullptr>
151 const char* name,
const T& x,
const char* must_be,
152 const Indexings&... indexings) {
153 for (
size_t i = 0; i < x.size(); i++) {
160 "] is ", scal,
", but must be ", must_be,
"!");
161 }
else if (Eigen::internal::traits<T>::Flags & Eigen::RowMajorBit) {
163 function,
": ", name, indexings...,
"[",
166 ", but must be ", must_be,
"!");
169 function,
": ", name, indexings...,
"[",
172 ", but must be ", must_be,
"!");
197template <
typename F,
typename T,
typename... Indexings,
199 std::enable_if_t<!(Eigen::internal::traits<T>::Flags
200 & Eigen::LinearAccessBit)
201 && !T::IsVectorAtCompileTime
202 && !(Eigen::internal::traits<T>::Flags
203 & Eigen::RowMajorBit)>* =
nullptr>
205 const char* name,
const T& x,
const char* must_be,
206 const Indexings&... indexings) {
207 for (
size_t i = 0; i < x.rows(); i++) {
208 for (
size_t j = 0; j < x.cols(); j++) {
240template <
typename F,
typename T,
typename... Indexings,
241 require_eigen_t<T>* =
nullptr,
243 !(Eigen::internal::traits<T>::Flags & Eigen::LinearAccessBit)
244 && !T::IsVectorAtCompileTime
245 &&
static_cast<bool>(Eigen::internal::traits<T>::Flags
246 & Eigen::RowMajorBit)>* =
nullptr>
248 const char* name,
const T& x,
const char* must_be,
249 const Indexings&... indexings) {
250 for (
size_t j = 0; j < x.cols(); j++) {
251 for (
size_t i = 0; i < x.rows(); i++) {
283template <
typename F,
typename T,
typename... Indexings,
284 require_std_vector_t<T>* =
nullptr>
286 const char* name,
const T& x,
const char* must_be,
287 const Indexings&... indexings) {
288 for (
size_t j = 0; j < x.size(); j++) {
312template <
typename F,
typename T,
typename... Indexings,
313 require_var_matrix_t<T>* =
nullptr>
315 const char* name,
const T& x,
const char* must_be,
316 const Indexings&... indexings) {
332template <
typename F,
typename T>
bool is(const T &x)
Check all the scalars inside the container.
bool is(const T &x)
Check the scalar.
Apply an error check to a container, signal failure with false.
require_t< is_eigen< std::decay_t< T > > > require_eigen_t
Require type satisfies is_eigen.
require_t< is_stan_scalar< std::decay_t< T > > > require_stan_scalar_t
Require type satisfies is_stan_scalar.
T get(const T &x, size_t n)
Returns the provided element.
int64_t size(const T &m)
Returns the size (number of the elements) of a matrix_cl or var_value<matrix_cl<T>>.
void pipe_in(std::stringstream &ss)
No-op.
void elementwise_throw_domain_error(const Args... args)
Throws domain error with concatenation of arguments for the error message.
double value_of_rec(const fvar< T > &v)
Return the value of the specified variable.
void elementwise_check(const F &is_good, const char *function, const char *name, const T &x, const char *must_be, const Indexings &... indexings)
Check that the predicate holds for the value of x.
bool elementwise_is(const F &is_good, const T &x)
Check that the predicate holds for the value of x, working elementwise on containers.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
If the input type T is an eigen matrix with 1 column or 1 row at compile time this has a static membe...