All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
check_range.hpp
Go to the documentation of this file.
#ifndef STAN_MATH_PRIM_MAT_ERR_CHECK_RANGE_HPP
#define STAN_MATH_PRIM_MAT_ERR_CHECK_RANGE_HPP
#include <stan/math/prim/scal/err/out_of_range.hpp>
#include <stan/math/prim/mat/meta/index_type.hpp>
#include <stan/math/prim/scal/meta/error_index.hpp>
#include <sstream>
#include <string>
namespace stan {
namespace math {
inline bool check_range(const char* function,
const char* name,
const int max,
const int index,
const int nested_level,
const char* error_msg) {
if ((index >= stan::error_index::value)
&& (index < max + stan::error_index::value))
return true;
std::stringstream msg;
msg << "; index position = " << nested_level;
std::string msg_str(msg.str());
out_of_range(function, max, index, msg_str.c_str(), error_msg);
return false;
}
inline bool check_range(const char* function,
const char* name,
const int max,
const int index,
const char* error_msg) {
if ((index >= stan::error_index::value)
&& (index < max + stan::error_index::value))
return true;
out_of_range(function, max, index, error_msg);
return false;
}
inline bool check_range(const char* function,
const char* name,
const int max,
const int index) {
if ((index >= stan::error_index::value)
&& (index < max + stan::error_index::value))
return true;
out_of_range(function, max, index);
return false;
}
}
}
#endif
out_of_range.hpp
stan::math::check_range
bool check_range(const char *function, const char *name, const int max, const int index, const int nested_level, const char *error_msg)
Return true if specified index is within range.
Definition: check_range.hpp:29
index_type.hpp
stan::error_index::value
Definition: error_index.hpp:7
stan::math::out_of_range
void out_of_range(const char *function, const int max, const int index, const char *msg1="", const char *msg2="")
Throw an out_of_range exception with a consistently formatted message.
Definition: out_of_range.hpp:30
stan::math::max
int max(const std::vector< int > &x)
Returns the maximum coefficient in the specified column vector.
Definition: max.hpp:21
error_index.hpp

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