All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Groups
check_consistent_size.hpp
Go to the documentation of this file.
#ifndef STAN_MATH_PRIM_SCAL_ERR_CHECK_CONSISTENT_SIZE_HPP
#define STAN_MATH_PRIM_SCAL_ERR_CHECK_CONSISTENT_SIZE_HPP
#include <stan/math/prim/scal/err/invalid_argument.hpp>
#include <stan/math/prim/scal/meta/size_of.hpp>
#include <sstream>
#include <string>
namespace stan {
namespace math {
template <typename T>
inline bool check_consistent_size(const char* function,
const char* name,
const T& x,
size_t expected_size) {
if (!is_vector<T>::value)
return true;
if (is_vector<T>::value && expected_size == stan::size_of(x))
return true;
std::stringstream msg;
msg << ", expecting dimension = "
<< expected_size
<< "; a function was called with arguments of different "
<< "scalar, array, vector, or matrix types, and they were not "
<< "consistently sized; all arguments must be scalars or "
<< "multidimensional values of the same shape.";
std::string msg_str(msg.str());
invalid_argument(function, name, stan::size_of(x),
"has dimension = ",
msg_str.c_str());
return false;
}
}
}
#endif
invalid_argument.hpp
size_of.hpp
stan::is_vector
Definition: is_vector.hpp:10
stan::math::check_consistent_size
bool check_consistent_size(const char *function, const char *name, const T &x, size_t expected_size)
Return true if the dimension of x is consistent, which is defined to be expected_size if x is a vecto...
Definition: check_consistent_size.hpp:29
stan::size_of
size_t size_of(const T &x)
Definition: size_of.hpp:27
stan::math::invalid_argument
void invalid_argument(const char *function, const char *name, const T &y, const char *msg1, const char *msg2)
Throw an invalid_argument exception with a consistently formatted message.
Definition: invalid_argument.hpp:31

[ Stan Home Page ] © 2011–2015, Stan Development Team.